| 1 | /* Copyright (C) 2004-2008 MySQL AB & MySQL Finland AB & TCX DataKonsult AB |
| 2 | Copyright (C) 2008-2009 Sun Microsystems, Inc. |
| 3 | Copyright (c) 2009, 2021, MariaDB Corporation Ab |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; version 2 of the License. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ |
| 17 | |
| 18 | |
| 19 | #define MYSQL_SERVERcxx . . $ `storage/maria/ha_maria.cc:19:9`! 1 |
| 20 | #include <my_global.h>cxx . . $ `<file>/include/my_global.h`/ |
| 21 | #include <m_ctype.h>cxx . . $ `<file>/include/m_ctype.h`/ |
| 22 | #include <my_dir.h>cxx . . $ `<file>/include/my_dir.h`/ |
| 23 | #include <myisampack.h>cxx . . $ `<file>/include/myisampack.h`/ |
| 24 | #include <my_bit.h>cxx . . $ `<file>/include/my_bit.h`/ |
| 25 | #include "ha_maria.h"cxx . . $ `<file>/storage/maria/ha_maria.h`/ |
| 26 | #include "trnman_public.h"cxx . . $ `<file>/storage/maria/trnman_public.h`/ |
| 27 | #include "trnman.h"cxx . . $ `<file>/storage/maria/trnman.h`/ |
| 28 | |
| 29 | C_MODE_STARTcxx . . $ `include/my_global.h:75:9`! |
| 30 | #include "maria_def.h"cxx . . $ `<file>/storage/maria/maria_def.h`/ |
| 31 | #include "ma_rt_index.h"cxx . . $ `<file>/storage/maria/ma_rt_index.h`/ |
| 32 | #include "ma_blockrec.h"cxx . . $ `<file>/storage/maria/ma_blockrec.h`/ |
| 33 | #include "ma_checkpoint.h"cxx . . $ `<file>/storage/maria/ma_checkpoint.h`/ |
| 34 | #include "ma_recovery.h"cxx . . $ `<file>/storage/maria/ma_recovery.h`/ |
| 35 | C_MODE_ENDcxx . . $ `include/my_global.h:76:9`! |
| 36 | #include "ma_trnman.h"cxx . . $ `<file>/storage/maria/ma_trnman.h`/ |
| 37 | #include "ma_loghandler.h"cxx . . $ `<file>/storage/maria/ma_loghandler.h`/ |
| 38 | |
| 39 | //#include "sql_priv.h" |
| 40 | #include "protocol.h"cxx . . $ `<file>/sql/protocol.h`/ |
| 41 | #include "sql_class.h"cxx . . $ `<file>/sql/sql_class.h`/ |
| 42 | #include "key.h"cxx . . $ `<file>/sql/key.h`/ |
| 43 | #include "log.h"cxx . . $ `<file>/sql/log.h`/ |
| 44 | #include "sql_parse.h"cxx . . $ `<file>/sql/sql_parse.h`/ |
| 45 | #include "mysql/service_print_check_msg.h"cxx . . $ `<file>/include/mysql/service_print_check_msg.h`/ |
| 46 | #include "debug.h"cxx . . $ `<file>/sql/debug.h`/ |
| 47 | |
| 48 | /* |
| 49 | Note that in future versions, only *transactional* Maria tables can |
| 50 | rollback, so this flag should be up or down conditionally. |
| 51 | */ |
| 52 | #ifdef ARIA_HAS_TRANSACTIONS |
| 53 | #define TRANSACTION_STATE |
| 54 | #else |
| 55 | #define TRANSACTION_STATEcxx . . $ `storage/maria/ha_maria.cc:55:9`! HA_NO_TRANSACTIONScxx . . $ `sql/handler.h:124:9`! |
| 56 | #endif |
| 57 | |
| 58 | #define THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`! (TRN*) thd_get_ha_data(thd, maria_hton) |
| 59 | |
| 60 | ulong pagecache_division_limitcxx . . $ pagecache_division_limit., pagecache_age_thresholdcxx . . $ pagecache_age_threshold., pagecache_file_hash_sizecxx . . $ pagecache_file_hash_size.; |
| 61 | ulonglongcxx . . $ ulonglong# pagecache_buffer_sizecxx . . $ pagecache_buffer_size.; |
| 62 | const char *zerofill_error_msgcxx . . $ zerofill_error_msg.= |
| 63 | "Table is probably from another system and must be zerofilled or repaired ('REPAIR TABLE table_name') to be usable on this system"; |
| 64 | |
| 65 | /** |
| 66 | As the auto-repair is initiated when opened from the SQL layer |
| 67 | (open_unireg_entry(), check_and_repair()), it does not happen when Maria's |
| 68 | Recovery internally opens the table to apply log records to it, which is |
| 69 | good. It would happen only after Recovery, if the table is still |
| 70 | corrupted. |
| 71 | */ |
| 72 | ulonglongcxx . . $ ulonglong# maria_recover_optionscxx . . $ maria_recover_options.= HA_RECOVER_NONEcxx . . $ `storage/maria/ha_maria.h:25:9`!; |
| 73 | handlertoncxx . . $ handlerton# *maria_htoncxx . . $ maria_hton.; |
| 74 | |
| 75 | /* bits in maria_recover_options */ |
| 76 | const char *maria_recover_namescxx . . $ maria_recover_names.[]= |
| 77 | { |
| 78 | /* |
| 79 | Compared to MyISAM, "default" was renamed to "normal" as it collided with |
| 80 | SET var=default which sets to the var's default i.e. what happens when the |
| 81 | var is not set i.e. HA_RECOVER_NONE. |
| 82 | OFF flag is ignored. |
| 83 | */ |
| 84 | "NORMAL", "BACKUP", "FORCE", "QUICK", "OFF", NullScxx . . $ `include/my_global.h:844:9`! |
| 85 | }; |
| 86 | TYPELIBcxx . . $ TYPELIB# maria_recover_typelibcxx . . $ maria_recover_typelib.= CREATE_TYPELIB_FORcxx . . $ `include/typelib.h:37:9`!(maria_recover_names); |
| 87 | |
| 88 | const char *maria_stats_method_namescxx . . $ maria_stats_method_names.[]= |
| 89 | { |
| 90 | "nulls_unequal", "nulls_equal", |
| 91 | "nulls_ignored", NullScxx . . $ `include/my_global.h:844:9`! |
| 92 | }; |
| 93 | TYPELIBcxx . . $ TYPELIB# maria_stats_method_typelibcxx . . $ maria_stats_method_typelib.= CREATE_TYPELIB_FORcxx . . $ `include/typelib.h:37:9`!(maria_stats_method_names); |
| 94 | |
| 95 | /* transactions log purge mode */ |
| 96 | const char *maria_translog_purge_type_namescxx . . $ maria_translog_purge_type_names.[]= |
| 97 | { |
| 98 | "immediate", "external", "at_flush", NullScxx . . $ `include/my_global.h:844:9`! |
| 99 | }; |
| 100 | TYPELIBcxx . . $ TYPELIB# maria_translog_purge_type_typelibcxx . . $ maria_translog_purge_type_typelib.= CREATE_TYPELIB_FORcxx . . $ `include/typelib.h:37:9`!(maria_translog_purge_type_names); |
| 101 | |
| 102 | /* transactional log directory sync */ |
| 103 | const char *maria_sync_log_dir_namescxx . . $ maria_sync_log_dir_names.[]= |
| 104 | { |
| 105 | "NEVER", "NEWFILE", "ALWAYS", NullScxx . . $ `include/my_global.h:844:9`! |
| 106 | }; |
| 107 | TYPELIBcxx . . $ TYPELIB# maria_sync_log_dir_typelibcxx . . $ maria_sync_log_dir_typelib.= CREATE_TYPELIB_FORcxx . . $ `include/typelib.h:37:9`!(maria_sync_log_dir_names); |
| 108 | |
| 109 | /* transactional log group commit */ |
| 110 | const char *maria_group_commit_namescxx . . $ maria_group_commit_names.[]= |
| 111 | { |
| 112 | "none", "hard", "soft", NullScxx . . $ `include/my_global.h:844:9`! |
| 113 | }; |
| 114 | TYPELIBcxx . . $ TYPELIB# maria_group_commit_typelibcxx . . $ maria_group_commit_typelib.= CREATE_TYPELIB_FORcxx . . $ `include/typelib.h:37:9`!(maria_group_commit_names); |
| 115 | |
| 116 | /** Interval between background checkpoints in seconds */ |
| 117 | static ulong checkpoint_intervalcxx . . $ checkpoint_interval.; |
| 118 | static void update_checkpoint_intervalcxx . . $ update_checkpoint_interval(2e543e8da16c42d1).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd, |
| 119 | struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *var, |
| 120 | void *var_ptr, const void *save); |
| 121 | static void update_maria_group_commitcxx . . $ update_maria_group_commit(2e543e8da16c42d1).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd, |
| 122 | struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *var, |
| 123 | void *var_ptr, const void *save); |
| 124 | static void update_maria_group_commit_intervalcxx . . $ update_maria_group_commit_interval(2e543e8da16c42d1).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd, |
| 125 | struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *var, |
| 126 | void *var_ptr, const void *save); |
| 127 | /** After that many consecutive recovery failures, remove logs */ |
| 128 | static ulong force_start_after_recovery_failurescxx . . $ force_start_after_recovery_failures.; |
| 129 | static void update_log_file_sizecxx . . $ update_log_file_size(2e543e8da16c42d1).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd, |
| 130 | struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *var, |
| 131 | void *var_ptr, const void *save); |
| 132 | |
| 133 | /* The 4096 is there because of MariaDB privilege tables */ |
| 134 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(block_size, maria_block_size, |
| 135 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`! | PLUGIN_VAR_READONLYcxx . . $ `include/mysql/plugin.h:253:9`!, |
| 136 | "Block size to be used for Aria index pages", 0, 0, |
| 137 | MARIA_KEY_BLOCK_LENGTHcxx . . $ `storage/maria/maria_def.h:69:9`!, 4096, |
| 138 | MARIA_MAX_KEY_BLOCK_LENGTHcxx . . $ `storage/maria/maria_def.h:71:9`!, MARIA_MIN_KEY_BLOCK_LENGTHcxx . . $ `storage/maria/maria_def.h:70:9`!); |
| 139 | |
| 140 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(checkpoint_interval, checkpoint_interval, |
| 141 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 142 | "Interval between tries to do an automatic checkpoints. In seconds; 0 means" |
| 143 | " 'no automatic checkpoints' which makes sense only for testing", |
| 144 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, update_checkpoint_interval, 30, 0, UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`!, 1); |
| 145 | |
| 146 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(checkpoint_log_activity, maria_checkpoint_min_log_activity, |
| 147 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 148 | "Number of bytes that the transaction log has to grow between checkpoints before a new " |
| 149 | "checkpoint is written to the log", |
| 150 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 1024*1024, 0, UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`!, 1); |
| 151 | |
| 152 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(force_start_after_recovery_failures, |
| 153 | force_start_after_recovery_failures, |
| 154 | /* |
| 155 | Read-only because setting it on the fly has no useful effect, |
| 156 | should be set on command-line. |
| 157 | */ |
| 158 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`! | PLUGIN_VAR_READONLYcxx . . $ `include/mysql/plugin.h:253:9`!, |
| 159 | "Number of consecutive log recovery failures after which logs will be" |
| 160 | " automatically deleted to cure the problem; 0 (the default) disables" |
| 161 | " the feature", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0, 0, UINT_MAX8cxx . . $ `include/my_global.h:785:9`!, 1); |
| 162 | |
| 163 | static MYSQL_SYSVAR_BOOLcxx . . $ `include/mysql/plugin.h:391:9`!(page_checksum, maria_page_checksums, 0, |
| 164 | "Maintain page checksums (can be overridden per table " |
| 165 | "with PAGE_CHECKSUM clause in CREATE TABLE)", 0, 0, 1); |
| 166 | |
| 167 | /* It is only command line argument */ |
| 168 | static MYSQL_SYSVAR_CONST_STRcxx . . $ `include/mysql/plugin.h:401:9`!(log_dir_path, maria_data_root, |
| 169 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`! | PLUGIN_VAR_READONLYcxx . . $ `include/mysql/plugin.h:253:9`!, |
| 170 | "Path to the directory where to store transactional log", |
| 171 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mysql_real_data_home); |
| 172 | |
| 173 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(log_file_size, log_file_size, |
| 174 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 175 | "Limit for transaction log size", |
| 176 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, update_log_file_size, TRANSLOG_FILE_SIZEcxx . . $ `storage/maria/ma_loghandler.h:24:9`!, |
| 177 | TRANSLOG_MIN_FILE_SIZEcxx . . $ `storage/maria/ma_loghandler.h:26:9`!, 0xffffffffL, TRANSLOG_PAGE_SIZEcxx . . $ `storage/maria/ma_loghandler.h:54:9`!); |
| 178 | |
| 179 | static MYSQL_SYSVAR_ENUMcxx . . $ `include/mysql/plugin.h:453:9`!(group_commit, maria_group_commit, |
| 180 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 181 | "Specifies Aria group commit mode. " |
| 182 | "Possible values are \"none\" (no group commit), " |
| 183 | "\"hard\" (with waiting to actual commit), " |
| 184 | "\"soft\" (no wait for commit (DANGEROUS!!!))", |
| 185 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, update_maria_group_commit, |
| 186 | TRANSLOG_GCOMMIT_NONE, &maria_group_commit_typelib); |
| 187 | |
| 188 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(group_commit_interval, maria_group_commit_interval, |
| 189 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 190 | "Interval between commits in microseconds (1/1000000 sec)." |
| 191 | " 0 stands for no waiting" |
| 192 | " for other threads to come and do a commit in \"hard\" mode and no" |
| 193 | " sync()/commit at all in \"soft\" mode. Option has only an effect" |
| 194 | " if aria_group_commit is used", |
| 195 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, update_maria_group_commit_interval, 0, 0, UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`!, 1); |
| 196 | |
| 197 | static MYSQL_SYSVAR_ENUMcxx . . $ `include/mysql/plugin.h:453:9`!(log_purge_type, log_purge_type, |
| 198 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 199 | "Specifies how Aria transactional log will be purged", |
| 200 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, TRANSLOG_PURGE_IMMIDIATE, |
| 201 | &maria_translog_purge_type_typelib); |
| 202 | |
| 203 | static MYSQL_SYSVAR_ULONGLONGcxx . . $ `include/mysql/plugin.h:431:9`!(max_sort_file_size, |
| 204 | maria_max_temp_length, PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 205 | "Don't use the fast sort index method to created index if the " |
| 206 | "temporary file would get bigger than this", |
| 207 | 0, 0, MAX_FILE_SIZEcxx . . $ `include/my_base.h:701:9`! & ~((ulonglong) (1*MBcxx . . $ `storage/maria/ma_loghandler.h:19:9`!-1)), |
| 208 | 0, MAX_FILE_SIZEcxx . . $ `include/my_base.h:701:9`!, 1*MBcxx . . $ `storage/maria/ma_loghandler.h:19:9`!); |
| 209 | |
| 210 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(pagecache_age_threshold, |
| 211 | pagecache_age_threshold, PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 212 | "This characterizes the number of hits a hot block has to be untouched " |
| 213 | "until it is considered aged enough to be downgraded to a warm block. " |
| 214 | "This specifies the percentage ratio of that number of hits to the " |
| 215 | "total number of blocks in the page cache", 0, 0, |
| 216 | 300, 100, ~ (ulong) 0L, 100); |
| 217 | |
| 218 | static MYSQL_SYSVAR_ULONGLONGcxx . . $ `include/mysql/plugin.h:431:9`!(pagecache_buffer_size, pagecache_buffer_size, |
| 219 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`! | PLUGIN_VAR_READONLYcxx . . $ `include/mysql/plugin.h:253:9`!, |
| 220 | "The size of the buffer used for index blocks for Aria tables. " |
| 221 | "Increase this to get better index handling (for all reads and " |
| 222 | "multiple writes) to as much as you can afford", 0, 0, |
| 223 | KEY_CACHE_SIZEcxx . . $ `include/my_global.h:684:9`!, 8192*16L, ~(ulonglong) 0, 1); |
| 224 | |
| 225 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(pagecache_division_limit, pagecache_division_limit, |
| 226 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 227 | "The minimum percentage of warm blocks in key cache", 0, 0, |
| 228 | 100, 1, 100, 1); |
| 229 | |
| 230 | static MYSQL_SYSVAR_ULONGcxx . . $ `include/mysql/plugin.h:421:9`!(pagecache_file_hash_size, pagecache_file_hash_size, |
| 231 | PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`! | PLUGIN_VAR_READONLYcxx . . $ `include/mysql/plugin.h:253:9`!, |
| 232 | "Number of hash buckets for open and changed files. If you have a lot of Aria " |
| 233 | "files open you should increase this for faster flush of changes. A good " |
| 234 | "value is probably 1/10 of number of possible open Aria files", 0,0, |
| 235 | 512, 128, 16384, 1); |
| 236 | |
| 237 | static MYSQL_SYSVAR_SETcxx . . $ `include/mysql/plugin.h:458:9`!(recover_options, maria_recover_options, PLUGIN_VAR_OPCMDARGcxx . . $ `include/mysql/plugin.h:258:9`!, |
| 238 | "Specifies how corrupted tables should be automatically repaired", |
| 239 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, HA_RECOVER_BACKUPcxx . . $ `storage/maria/ha_maria.h:27:9`!|HA_RECOVER_QUICKcxx . . $ `storage/maria/ha_maria.h:29:9`!, &maria_recover_typelib); |
| 240 | |
| 241 | static MYSQL_THDVAR_ULONGcxx . . $ `include/mysql/plugin.h:493:9`!(repair_threads, PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 242 | "Number of threads to use when repairing Aria tables. The value of 1 " |
| 243 | "disables parallel repair", |
| 244 | 0, 0, 1, 1, 128, 1); |
| 245 | |
| 246 | static MYSQL_THDVAR_ULONGLONGcxx . . $ `include/mysql/plugin.h:503:9`!(sort_buffer_size, PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 247 | "The buffer that is allocated when sorting the index when doing a " |
| 248 | "REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE", |
| 249 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 250 | SORT_BUFFER_INITcxx . . $ `storage/maria/maria_def.h:1622:9`!, MARIA_MIN_SORT_MEMORYcxx . . $ `storage/maria/maria_def.h:349:9`!, SIZE_T_MAXcxx . . $ `include/my_global.h:797:9`!/16, 1); |
| 251 | |
| 252 | static MYSQL_THDVAR_ENUMcxx . . $ `include/mysql/plugin.h:508:9`!(stats_method, PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 253 | "Specifies how Aria index statistics collection code should treat " |
| 254 | "NULLs", 0, 0, 0, &maria_stats_method_typelib); |
| 255 | |
| 256 | static MYSQL_SYSVAR_ENUMcxx . . $ `include/mysql/plugin.h:453:9`!(sync_log_dir, sync_log_dir, PLUGIN_VAR_RQCMDARGcxx . . $ `include/mysql/plugin.h:257:9`!, |
| 257 | "Controls syncing directory after log file growth and new file " |
| 258 | "creation", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, TRANSLOG_SYNC_DIR_NEWFILE, |
| 259 | &maria_sync_log_dir_typelib); |
| 260 | |
| 261 | #ifdef USE_ARIA_FOR_TMP_TABLEScxx . . $ `/build/tmp.NxIY9EeyJN/package/build/include/my_config.h:502:9`! |
| 262 | #define USE_ARIA_FOR_TMP_TABLES_VALcxx . . $ `storage/maria/ha_maria.cc:262:9`! 1 |
| 263 | #else |
| 264 | #define USE_ARIA_FOR_TMP_TABLES_VAL 0 |
| 265 | #endif |
| 266 | my_boolcxx . . $ my_bool# use_maria_for_temp_tablescxx . . $ use_maria_for_temp_tables.= USE_ARIA_FOR_TMP_TABLES_VALcxx . . $ `storage/maria/ha_maria.cc:262:9`!; |
| 267 | |
| 268 | static MYSQL_SYSVAR_BOOLcxx . . $ `include/mysql/plugin.h:391:9`!(used_for_temp_tables, |
| 269 | use_maria_for_temp_tables, PLUGIN_VAR_READONLYcxx . . $ `include/mysql/plugin.h:253:9`! | PLUGIN_VAR_NOCMDOPTcxx . . $ `include/mysql/plugin.h:255:9`!, |
| 270 | "Whether temporary tables should be MyISAM or Aria", 0, 0, |
| 271 | 1); |
| 272 | |
| 273 | static MYSQL_SYSVAR_BOOLcxx . . $ `include/mysql/plugin.h:391:9`!(encrypt_tables, maria_encrypt_tables, |
| 274 | PLUGIN_VAR_OPCMDARGcxx . . $ `include/mysql/plugin.h:258:9`!, |
| 275 | "Encrypt tables (only for tables with ROW_FORMAT=PAGE (default) " |
| 276 | "and not FIXED/DYNAMIC)", |
| 277 | 0, 0, 0); |
| 278 | |
| 279 | #if defined HAVE_PSI_INTERFACEcxx . . $ `include/my_global.h:90:9`! && !defined EMBEDDED_LIBRARY |
| 280 | |
| 281 | static PSI_mutex_info all_aria_mutexescxx . . $ all_aria_mutexes.[]= |
| 282 | { |
| 283 | { &key_THR_LOCK_maria, "THR_LOCK_maria", PSI_FLAG_GLOBALcxx . . $ `include/mysql/psi/psi_base.h:58:9`!}, |
| 284 | { &key_LOCK_soft_sync, "LOCK_soft_sync", PSI_FLAG_GLOBALcxx . . $ `include/mysql/psi/psi_base.h:58:9`!}, |
| 285 | { &key_LOCK_trn_list, "LOCK_trn_list", PSI_FLAG_GLOBALcxx . . $ `include/mysql/psi/psi_base.h:58:9`!}, |
| 286 | { &key_SHARE_BITMAP_lock, "SHARE::bitmap::bitmap_lock", 0}, |
| 287 | { &key_SORT_INFO_mutex, "SORT_INFO::mutex", 0}, |
| 288 | { &key_TRANSLOG_BUFFER_mutex, "TRANSLOG_BUFFER::mutex", 0}, |
| 289 | { &key_TRANSLOG_DESCRIPTOR_dirty_buffer_mask_lock, "TRANSLOG_DESCRIPTOR::dirty_buffer_mask_lock", 0}, |
| 290 | { &key_TRANSLOG_DESCRIPTOR_sent_to_disk_lock, "TRANSLOG_DESCRIPTOR::sent_to_disk_lock", 0}, |
| 291 | { &key_TRANSLOG_DESCRIPTOR_log_flush_lock, "TRANSLOG_DESCRIPTOR::log_flush_lock", 0}, |
| 292 | { &key_TRANSLOG_DESCRIPTOR_file_header_lock, "TRANSLOG_DESCRIPTOR::file_header_lock", 0}, |
| 293 | { &key_TRANSLOG_DESCRIPTOR_unfinished_files_lock, "TRANSLOG_DESCRIPTOR::unfinished_files_lock", 0}, |
| 294 | { &key_TRANSLOG_DESCRIPTOR_purger_lock, "TRANSLOG_DESCRIPTOR::purger_lock", 0}, |
| 295 | { &key_SHARE_intern_lock, "SHARE::intern_lock", 0}, |
| 296 | { &key_SHARE_key_del_lock, "SHARE::key_del_lock", 0}, |
| 297 | { &key_SHARE_close_lock, "SHARE::close_lock", 0}, |
| 298 | { &key_SERVICE_THREAD_CONTROL_lock, "SERVICE_THREAD_CONTROL::LOCK_control", 0}, |
| 299 | { &key_TRN_state_lock, "TRN::state_lock", 0}, |
| 300 | { &key_PAGECACHE_cache_lock, "PAGECACHE::cache_lock", 0} |
| 301 | }; |
| 302 | |
| 303 | static PSI_cond_info all_aria_condscxx . . $ all_aria_conds.[]= |
| 304 | { |
| 305 | { &key_COND_soft_sync, "COND_soft_sync", PSI_FLAG_GLOBALcxx . . $ `include/mysql/psi/psi_base.h:58:9`!}, |
| 306 | { &key_SHARE_key_del_cond, "SHARE::key_del_cond", 0}, |
| 307 | { &key_SERVICE_THREAD_CONTROL_cond, "SERVICE_THREAD_CONTROL::COND_control", 0}, |
| 308 | { &key_SORT_INFO_cond, "SORT_INFO::cond", 0}, |
| 309 | { &key_SHARE_BITMAP_cond, "BITMAP::bitmap_cond", 0}, |
| 310 | { &key_TRANSLOG_BUFFER_waiting_filling_buffer, "TRANSLOG_BUFFER::waiting_filling_buffer", 0}, |
| 311 | { &key_TRANSLOG_BUFFER_prev_sent_to_disk_cond, "TRANSLOG_BUFFER::prev_sent_to_disk_cond", 0}, |
| 312 | { &key_TRANSLOG_DESCRIPTOR_log_flush_cond, "TRANSLOG_DESCRIPTOR::log_flush_cond", 0}, |
| 313 | { &key_TRANSLOG_DESCRIPTOR_new_goal_cond, "TRANSLOG_DESCRIPTOR::new_goal_cond", 0} |
| 314 | }; |
| 315 | |
| 316 | static PSI_rwlock_info all_aria_rwlockscxx . . $ all_aria_rwlocks.[]= |
| 317 | { |
| 318 | { &key_KEYINFO_root_lock, "KEYINFO::root_lock", 0}, |
| 319 | { &key_SHARE_mmap_lock, "SHARE::mmap_lock", 0}, |
| 320 | { &key_TRANSLOG_DESCRIPTOR_open_files_lock, "TRANSLOG_DESCRIPTOR::open_files_lock", 0} |
| 321 | }; |
| 322 | |
| 323 | static PSI_thread_info all_aria_threadscxx . . $ all_aria_threads.[]= |
| 324 | { |
| 325 | { &key_thread_checkpoint, "checkpoint_bg", PSI_FLAG_GLOBALcxx . . $ `include/mysql/psi/psi_base.h:58:9`!}, |
| 326 | { &key_thread_soft_sync, "soft_sync_bg", PSI_FLAG_GLOBALcxx . . $ `include/mysql/psi/psi_base.h:58:9`!}, |
| 327 | { &key_thread_find_all_keys, "find_all_keys", 0} |
| 328 | }; |
| 329 | |
| 330 | static PSI_file_info all_aria_filescxx . . $ all_aria_files.[]= |
| 331 | { |
| 332 | { &key_file_translog, "translog", 0}, |
| 333 | { &key_file_kfile, "MAI", 0}, |
| 334 | { &key_file_dfile, "MAD", 0}, |
| 335 | { &key_file_control, "control", PSI_FLAG_GLOBALcxx . . $ `include/mysql/psi/psi_base.h:58:9`!} |
| 336 | }; |
| 337 | |
| 338 | # ifdef HAVE_PSI_STAGE_INTERFACEcxx . . $ `include/mysql/psi/psi.h:469:9`! |
| 339 | static PSI_stage_info *all_aria_stagescxx . . $ all_aria_stages.[]= |
| 340 | { |
| 341 | & stage_waiting_for_a_resource |
| 342 | }; |
| 343 | # endif /* HAVE_PSI_STAGE_INTERFACE */ |
| 344 | |
| 345 | static void init_aria_psi_keyscxx . . $ init_aria_psi_keys(49f6e7a06ebc5aa8).(void) |
| 346 | { |
| 347 | const char* category= "aria"; |
| 348 | int count; |
| 349 | |
| 350 | count= array_elementscxx . . $ `include/my_global.h:472:9`!(all_aria_mutexes); |
| 351 | mysql_mutex_registercxx . . $ `include/mysql/psi/mysql_thread.h:308:9`!(category, all_aria_mutexes, count); |
| 352 | |
| 353 | count= array_elementscxx . . $ `include/my_global.h:472:9`!(all_aria_rwlocks); |
| 354 | mysql_rwlock_registercxx . . $ `include/mysql/psi/mysql_thread.h:399:9`!(category, all_aria_rwlocks, count); |
| 355 | |
| 356 | count= array_elementscxx . . $ `include/my_global.h:472:9`!(all_aria_conds); |
| 357 | mysql_cond_registercxx . . $ `include/mysql/psi/mysql_thread.h:549:9`!(category, all_aria_conds, count); |
| 358 | |
| 359 | count= array_elementscxx . . $ `include/my_global.h:472:9`!(all_aria_threads); |
| 360 | mysql_thread_registercxx . . $ `include/mysql/psi/mysql_thread.h:619:9`!(category, all_aria_threads, count); |
| 361 | |
| 362 | count= array_elementscxx . . $ `include/my_global.h:472:9`!(all_aria_files); |
| 363 | mysql_file_registercxx . . $ `include/mysql/psi/mysql_file.h:65:9`!(category, all_aria_files, count); |
| 364 | # ifdef HAVE_PSI_STAGE_INTERFACEcxx . . $ `include/mysql/psi/psi.h:469:9`! |
| 365 | count= array_elementscxx . . $ `include/my_global.h:472:9`!(all_aria_stages); |
| 366 | mysql_stage_registercxx . . $ `include/mysql/psi/mysql_stage.h:48:9`!(category, all_aria_stages, count); |
| 367 | # endif /* HAVE_PSI_STAGE_INTERFACE */ |
| 368 | } |
| 369 | #else |
| 370 | #define init_aria_psi_keys() /* no-op */ |
| 371 | #endif /* HAVE_PSI_INTERFACE */ |
| 372 | |
| 373 | const LEX_CSTRINGcxx . . $ LEX_CSTRING# MA_CHECK_INFOcxx . . $ MA_CHECK_INFO.= { STRING_WITH_LENcxx . . $ `include/m_string.h:206:9`!("info") }; |
| 374 | const LEX_CSTRINGcxx . . $ LEX_CSTRING# MA_CHECK_WARNINGcxx . . $ MA_CHECK_WARNING.= { STRING_WITH_LENcxx . . $ `include/m_string.h:206:9`!("warning") }; |
| 375 | const LEX_CSTRINGcxx . . $ LEX_CSTRING# MA_CHECK_ERRORcxx . . $ MA_CHECK_ERROR.= { STRING_WITH_LENcxx . . $ `include/m_string.h:206:9`!("error") }; |
| 376 | |
| 377 | /***************************************************************************** |
| 378 | ** MARIA tables |
| 379 | *****************************************************************************/ |
| 380 | |
| 381 | static handlercxx . . $ handler# *maria_create_handlercxx . . $ maria_create_handler(2b6d627a0912fa60).(handlertoncxx . . $ handlerton# *hton, |
| 382 | TABLE_SHAREcxx . . $ TABLE_SHARE# * table, |
| 383 | MEM_ROOTcxx . . $ MEM_ROOT# *mem_root) |
| 384 | { |
| 385 | return new (mem_root) ha_mariacxx . . $ ha_maria#(hton, table); |
| 386 | } |
| 387 | |
| 388 | |
| 389 | static void _ma_check_printcxx . . $ _ma_check_print(acbf0771603a8c68).(HA_CHECKcxx . . $ HA_CHECK# *param, const LEX_CSTRINGcxx . . $ LEX_CSTRING# *msg_type, |
| 390 | const char *msgbuf) |
| 391 | { |
| 392 | if (msg_type == &MA_CHECK_INFOcxx . . $ MA_CHECK_INFO.) |
| 393 | sql_print_informationcxx . . $ sql_print_information(326aeb464d16410c).("%s.%s: %s", param->db_namecxx . . $ st_handler_check_param#db_name., param->table_namecxx . . $ st_handler_check_param#table_name., |
| 394 | msgbuf); |
| 395 | else if (msg_type == &MA_CHECK_WARNINGcxx . . $ MA_CHECK_WARNING.) |
| 396 | sql_print_warningcxx . . $ sql_print_warning(326aeb464d16410c).("%s.%s: %s", param->db_namecxx . . $ st_handler_check_param#db_name., param->table_namecxx . . $ st_handler_check_param#table_name., |
| 397 | msgbuf); |
| 398 | else |
| 399 | sql_print_errorcxx . . $ sql_print_error(326aeb464d16410c).("%s.%s: %s", param->db_namecxx . . $ st_handler_check_param#db_name., param->table_namecxx . . $ st_handler_check_param#table_name., msgbuf); |
| 400 | } |
| 401 | |
| 402 | |
| 403 | // collect errors printed by maria_check routines |
| 404 | ATTRIBUTE_FORMATcxx . . $ `include/my_attribute.h:57:10`!(printf, 3, 0) |
| 405 | static void _ma_check_print_msgcxx . . $ _ma_check_print_msg(2bd9d81b8d9cf012).(HA_CHECKcxx . . $ HA_CHECK# *param, const LEX_CSTRINGcxx . . $ LEX_CSTRING# *msg_type, |
| 406 | const char *fmt, va_list args) |
| 407 | { |
| 408 | THDcxx . . $ THD# *thd= (THDcxx . . $ THD# *) param->thdcxx . . $ st_handler_check_param#thd.; |
| 409 | size_t msg_length __attribute__((unused)); |
| 410 | char msgbuf[MYSQL_ERRMSG_SIZEcxx . . $ `include/mysql_com.h:435:9`!]; |
| 411 | |
| 412 | if (param->testflagcxx . . $ st_handler_check_param#testflag. & T_SUPPRESS_ERR_HANDLINGcxx . . $ `include/my_check_opt.h:70:9`!) |
| 413 | return; |
| 414 | |
| 415 | msg_length= my_vsnprintf(msgbuf, sizeof(msgbuf), fmt, args); |
| 416 | msgbuf[sizeof(msgbuf) - 1]= 0; // healthy paranoia |
| 417 | |
| 418 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!(msg_type->str, ("message: %s", msgbuf)); |
| 419 | |
| 420 | if (!thd->vio_okcxx . . $ THD#vio_ok(50ce9a9e25b4a850).()) |
| 421 | { |
| 422 | _ma_check_printcxx . . $ _ma_check_print(acbf0771603a8c68).(param, msg_type, msgbuf); |
| 423 | return; |
| 424 | } |
| 425 | |
| 426 | if (param->testflagcxx . . $ st_handler_check_param#testflag. & |
| 427 | (T_CREATE_MISSING_KEYScxx . . $ `include/my_check_opt.h:35:9`! | T_SAFE_REPAIRcxx . . $ `include/my_check_opt.h:52:9`! | T_AUTO_REPAIRcxx . . $ `include/my_check_opt.h:30:9`!)) |
| 428 | { |
| 429 | myfcxx . . $ myf# flag= 0; |
| 430 | if (msg_type == &MA_CHECK_INFOcxx . . $ MA_CHECK_INFO.) |
| 431 | flag= ME_NOTEcxx . . $ `include/my_sys.h:108:9`!; |
| 432 | else if (msg_type == &MA_CHECK_WARNINGcxx . . $ MA_CHECK_WARNING.) |
| 433 | flag= ME_WARNINGcxx . . $ `include/my_sys.h:109:9`!; |
| 434 | my_message(ER_NOT_KEYFILEcxx . . $ `build/include/mysqld_error.h:39:9`!, msgbuf, MYFcxx . . $ `include/my_global.h:986:9`!(flag)); |
| 435 | if (thd->variablescxx . . $ THD#variables..log_warningscxx . . $ system_variables#log_warnings. > 2) |
| 436 | _ma_check_printcxx . . $ _ma_check_print(acbf0771603a8c68).(param, msg_type, msgbuf); |
| 437 | return; |
| 438 | } |
| 439 | print_check_msg(thd, param->db_namecxx . . $ st_handler_check_param#db_name., param->table_namecxx . . $ st_handler_check_param#table_name., |
| 440 | param->op_namecxx . . $ st_handler_check_param#op_name., msg_type->str, msgbuf, 0); |
| 441 | if (thd->variablescxx . . $ THD#variables..log_warningscxx . . $ system_variables#log_warnings. > 2) |
| 442 | _ma_check_printcxx . . $ _ma_check_print(acbf0771603a8c68).(param, msg_type, msgbuf); |
| 443 | return; |
| 444 | } |
| 445 | |
| 446 | |
| 447 | /* |
| 448 | Convert TABLE object to Maria key and column definition |
| 449 | |
| 450 | SYNOPSIS |
| 451 | table2maria() |
| 452 | table_arg in TABLE object. |
| 453 | keydef_out out Maria key definition. |
| 454 | recinfo_out out Maria column definition. |
| 455 | records_out out Number of fields. |
| 456 | |
| 457 | DESCRIPTION |
| 458 | This function will allocate and initialize Maria key and column |
| 459 | definition for further use in ma_create or for a check for underlying |
| 460 | table conformance in merge engine. |
| 461 | |
| 462 | The caller needs to free *recinfo_out after use. Since *recinfo_out |
| 463 | and *keydef_out are allocated with a my_multi_malloc, *keydef_out |
| 464 | is freed automatically when *recinfo_out is freed. |
| 465 | |
| 466 | RETURN VALUE |
| 467 | 0 OK |
| 468 | # error code |
| 469 | */ |
| 470 | |
| 471 | static int table2mariacxx . . $ table2maria(f59b83681afcea70).(TABLEcxx . . $ TABLE# *table_arg, data_file_typecxx . . $ data_file_type# row_type, |
| 472 | MARIA_KEYDEF **keydef_out, |
| 473 | MARIA_COLUMNDEF **recinfo_out, uint *records_out, |
| 474 | MARIA_CREATE_INFO *create_info) |
| 475 | { |
| 476 | uint i, j, recpos, minpos, fieldpos, temp_length, length; |
| 477 | enum ha_base_keytypecxx . . $ ha_base_keytype# type= HA_KEYTYPE_BINARYcxx . . $ HA_KEYTYPE_BINARY.; |
| 478 | ucharcxx . . $ uchar# *record; |
| 479 | KEYcxx . . $ KEY# *pos; |
| 480 | MARIA_KEYDEF *keydef; |
| 481 | MARIA_COLUMNDEF *recinfo, *recinfo_pos; |
| 482 | HA_KEYSEG *keyseg; |
| 483 | TABLE_SHAREcxx . . $ TABLE_SHARE# *share= table_arg->scxx . . $ TABLE#s.; |
| 484 | uint options= share->db_options_in_usecxx . . $ TABLE_SHARE#db_options_in_use.; |
| 485 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("table2maria"); |
| 486 | |
| 487 | if (row_type == BLOCK_RECORDcxx . . $ BLOCK_RECORD.) |
| 488 | options|= HA_OPTION_PACK_RECORDcxx . . $ `include/my_base.h:344:9`!; |
| 489 | |
| 490 | if (!(my_multi_malloc(PSI_INSTRUMENT_MEcxx . . $ `include/mysql/psi/psi_base.h:48:9`!, MYFcxx . . $ `include/my_global.h:986:9`!(MY_WMEcxx . . $ `include/my_sys.h:57:9`!), |
| 491 | recinfo_out, (share->fieldscxx . . $ TABLE_SHARE#fields. * 2 + 2) * sizeof(MARIA_COLUMNDEF), |
| 492 | keydef_out, share->keyscxx . . $ TABLE_SHARE#keys. * sizeof(MARIA_KEYDEF), |
| 493 | &keyseg, (share->key_partscxx . . $ TABLE_SHARE#key_parts. + share->keyscxx . . $ TABLE_SHARE#keys.) * sizeof(HA_KEYSEG), |
| 494 | NullScxx . . $ `include/my_global.h:844:9`!))) |
| 495 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ERR_OUT_OF_MEMcxx . . $ `include/my_base.h:473:9`!); /* purecov: inspected */ |
| 496 | keydef= *keydef_out; |
| 497 | recinfo= *recinfo_out; |
| 498 | pos= table_arg->key_infocxx . . $ TABLE#key_info.; |
| 499 | for (i= 0; i < share->keyscxx . . $ TABLE_SHARE#keys.; i++, pos++) |
| 500 | { |
| 501 | keydef[i].flag= (uint16cxx . . $ uint16#) (pos->flagscxx . . $ st_key#flags. & (HA_NOSAMEcxx . . $ `include/my_base.h:285:9`! | HA_FULLTEXT_legacycxx . . $ `include/my_base.h:292:9`! | |
| 502 | HA_SPATIAL_legacycxx . . $ `include/my_base.h:294:9`!)); |
| 503 | keydef[i].key_alg= pos->algorithmcxx . . $ st_key#algorithm. == HA_KEY_ALG_UNDEFcxx . . $ HA_KEY_ALG_UNDEF. ? HA_KEY_ALG_BTREEcxx . . $ HA_KEY_ALG_BTREE. |
| 504 | : pos->algorithmcxx . . $ st_key#algorithm.; |
| 505 | keydef[i].block_length= pos->block_sizecxx . . $ st_key#block_size.; |
| 506 | keydef[i].seg= keyseg; |
| 507 | keydef[i].keysegs= pos->user_defined_key_partscxx . . $ st_key#user_defined_key_parts.; |
| 508 | for (j= 0; j < pos->user_defined_key_partscxx . . $ st_key#user_defined_key_parts.; j++) |
| 509 | { |
| 510 | Fieldcxx . . $ Field# *field= pos->key_partcxx . . $ st_key#key_part.[j].fieldcxx . . $ st_key_part_info#field.; |
| 511 | |
| 512 | if (!table_arg->fieldcxx . . $ TABLE#field.[field->field_indexcxx . . $ Field#field_index.]->stored_in_dbcxx . . $ Field#stored_in_db(50ce9a9e25b4a850).()) |
| 513 | { |
| 514 | my_free(*recinfo_out); |
| 515 | if (table_arg->scxx . . $ TABLE#s.->long_unique_tablecxx . . $ TABLE_SHARE#long_unique_table.) |
| 516 | { |
| 517 | my_error(ER_TOO_LONG_KEYcxx . . $ `build/include/mysqld_error.h:76:9`!, MYFcxx . . $ `include/my_global.h:986:9`!(0), table_arg->filecxx . . $ TABLE#file.->max_key_lengthcxx . . $ handler#max_key_length(ddd8539a2fcdd4ce).()); |
| 518 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ERR_INDEX_COL_TOO_LONGcxx . . $ `include/my_base.h:537:9`!); |
| 519 | } |
| 520 | my_error(ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMNcxx . . $ `build/include/mysqld_error.h:895:9`!, MYFcxx . . $ `include/my_global.h:986:9`!(0)); |
| 521 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ERR_UNSUPPORTEDcxx . . $ `include/my_base.h:483:9`!); |
| 522 | } |
| 523 | |
| 524 | type= field->key_typecxx . . $ Field#key_type(3b5d0f34b06b85e8).(); |
| 525 | keydef[i].seg[j].flag= pos->key_partcxx . . $ st_key#key_part.[j].key_part_flagcxx . . $ st_key_part_info#key_part_flag.; |
| 526 | |
| 527 | if (options & HA_OPTION_PACK_KEYScxx . . $ `include/my_base.h:345:9`! || |
| 528 | (pos->flagscxx . . $ st_key#flags. & (HA_PACK_KEYcxx . . $ `include/my_base.h:286:9`! | HA_BINARY_PACK_KEYcxx . . $ `include/my_base.h:290:9`! | |
| 529 | HA_SPACE_PACK_USEDcxx . . $ `include/my_base.h:287:9`!))) |
| 530 | { |
| 531 | if (pos->key_partcxx . . $ st_key#key_part.[j].lengthcxx . . $ st_key_part_info#length. > 8 && |
| 532 | (type == HA_KEYTYPE_TEXTcxx . . $ HA_KEYTYPE_TEXT. || |
| 533 | type == HA_KEYTYPE_NUMcxx . . $ HA_KEYTYPE_NUM. || |
| 534 | (type == HA_KEYTYPE_BINARYcxx . . $ HA_KEYTYPE_BINARY. && !field->zero_packcxx . . $ Field#zero_pack(50ce9a9e25b4a850).()))) |
| 535 | { |
| 536 | /* No blobs here */ |
| 537 | if (j == 0) |
| 538 | keydef[i].flag|= HA_PACK_KEYcxx . . $ `include/my_base.h:286:9`!; |
| 539 | if (!(field->flagscxx . . $ Field#flags. & ZEROFILL_FLAGcxx . . $ `include/mysql_com.h:148:9`!) && |
| 540 | (field->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_STRING || |
| 541 | field->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_VAR_STRING || |
| 542 | ((int) (pos->key_partcxx . . $ st_key#key_part.[j].lengthcxx . . $ st_key_part_info#length. - field->decimalscxx . . $ Field#decimals(72085aa11f4b6e09).())) >= 4)) |
| 543 | keydef[i].seg[j].flag|= HA_SPACE_PACKcxx . . $ `include/my_base.h:331:9`!; |
| 544 | } |
| 545 | else if (j == 0 && (!(pos->flagscxx . . $ st_key#flags. & HA_NOSAMEcxx . . $ `include/my_base.h:285:9`!) || pos->key_lengthcxx . . $ st_key#key_length. > 16)) |
| 546 | keydef[i].flag|= HA_BINARY_PACK_KEYcxx . . $ `include/my_base.h:290:9`!; |
| 547 | } |
| 548 | keydef[i].seg[j].type= (int) type; |
| 549 | keydef[i].seg[j].start= pos->key_partcxx . . $ st_key#key_part.[j].offsetcxx . . $ st_key_part_info#offset.; |
| 550 | keydef[i].seg[j].length= pos->key_partcxx . . $ st_key#key_part.[j].lengthcxx . . $ st_key_part_info#length.; |
| 551 | keydef[i].seg[j].bit_start= keydef[i].seg[j].bit_length= 0; |
| 552 | keydef[i].seg[j].bit_pos= 0; |
| 553 | keydef[i].seg[j].language= field->charsetcxx . . $ Field#charset(2209ea2d1c8c1ec1).()->numbercxx . . $ charset_info_st#number.; |
| 554 | |
| 555 | if (field->null_ptrcxx . . $ Field#null_ptr.) |
| 556 | { |
| 557 | keydef[i].seg[j].null_bit= field->null_bitcxx . . $ Field#null_bit.; |
| 558 | keydef[i].seg[j].null_pos= (uint) (field->null_ptrcxx . . $ Field#null_ptr.- |
| 559 | (ucharcxx . . $ uchar#*) table_arg->recordcxx . . $ TABLE#record.[0]); |
| 560 | } |
| 561 | else |
| 562 | { |
| 563 | keydef[i].seg[j].null_bit= 0; |
| 564 | keydef[i].seg[j].null_pos= 0; |
| 565 | } |
| 566 | if (field->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_BLOB || |
| 567 | field->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_GEOMETRY) |
| 568 | { |
| 569 | keydef[i].seg[j].flag|= HA_BLOB_PARTcxx . . $ `include/my_base.h:335:9`!; |
| 570 | /* save number of bytes used to pack length */ |
| 571 | keydef[i].seg[j].bit_start= (uint) (field->pack_lengthcxx . . $ Field#pack_length(ddd8539a2fcdd4ce).() - |
| 572 | portable_sizeof_char_ptrcxx . . $ `include/my_compare.h:252:9`!); |
| 573 | } |
| 574 | else if (field->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_BIT) |
| 575 | { |
| 576 | keydef[i].seg[j].bit_length= ((Field_bitcxx . . $ Field_bit# *) field)->bit_lencxx . . $ Field_bit#bit_len.; |
| 577 | keydef[i].seg[j].bit_start= ((Field_bitcxx . . $ Field_bit# *) field)->bit_ofscxx . . $ Field_bit#bit_ofs.; |
| 578 | keydef[i].seg[j].bit_pos= (uint) (((Field_bitcxx . . $ Field_bit# *) field)->bit_ptrcxx . . $ Field_bit#bit_ptr. - |
| 579 | (ucharcxx . . $ uchar#*) table_arg->recordcxx . . $ TABLE#record.[0]); |
| 580 | } |
| 581 | } |
| 582 | keyseg+= pos->user_defined_key_partscxx . . $ st_key#user_defined_key_parts.; |
| 583 | } |
| 584 | if (table_arg->found_next_number_fieldcxx . . $ TABLE#found_next_number_field.) |
| 585 | keydef[share->next_number_indexcxx . . $ TABLE_SHARE#next_number_index.].flag|= HA_AUTO_KEYcxx . . $ `include/my_base.h:289:9`!; |
| 586 | record= table_arg->recordcxx . . $ TABLE#record.[0]; |
| 587 | recpos= 0; |
| 588 | recinfo_pos= recinfo; |
| 589 | create_info->null_bytes= table_arg->scxx . . $ TABLE#s.->null_bytescxx . . $ TABLE_SHARE#null_bytes.; |
| 590 | |
| 591 | while (recpos < (uint) share->stored_rec_lengthcxx . . $ TABLE_SHARE#stored_rec_length.) |
| 592 | { |
| 593 | Fieldcxx . . $ Field# **field, *found= 0; |
| 594 | minpos= share->stored_rec_lengthcxx . . $ TABLE_SHARE#stored_rec_length.; |
| 595 | length= 0; |
| 596 | |
| 597 | for (field= table_arg->fieldcxx . . $ TABLE#field.; *field; field++) |
| 598 | { |
| 599 | if ((fieldpos= (*field)->offsetcxx . . $ Field#offset(7b29846448713708).(record)) >= recpos && |
| 600 | fieldpos < minpos) |
| 601 | { |
| 602 | /* skip null fields */ |
| 603 | if (!(temp_length= (*field)->pack_length_in_reccxx . . $ Field#pack_length_in_rec(ddd8539a2fcdd4ce).())) |
| 604 | continue; /* Skip null-fields */ |
| 605 | if (! found || fieldpos < minpos || |
| 606 | (fieldpos == minpos && temp_length < length)) |
| 607 | { |
| 608 | minpos= fieldpos; |
| 609 | found= *field; |
| 610 | length= temp_length; |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("loop", ("found: %p recpos: %d minpos: %d length: %d", |
| 615 | found, recpos, minpos, length)); |
| 616 | if (!found) |
| 617 | break; |
| 618 | |
| 619 | if (found->flagscxx . . $ Field#flags. & BLOB_FLAGcxx . . $ `include/mysql_com.h:146:9`!) |
| 620 | recinfo_pos->type= FIELD_BLOBcxx . . $ FIELD_BLOB.; |
| 621 | else if (found->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_TIMESTAMP) |
| 622 | recinfo_pos->type= FIELD_NORMALcxx . . $ FIELD_NORMAL.; |
| 623 | else if (found->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_VARCHAR) |
| 624 | recinfo_pos->type= FIELD_VARCHARcxx . . $ FIELD_VARCHAR.; |
| 625 | else if (!(options & HA_OPTION_PACK_RECORDcxx . . $ `include/my_base.h:344:9`!) || |
| 626 | (found->zero_packcxx . . $ Field#zero_pack(50ce9a9e25b4a850).() && (found->flagscxx . . $ Field#flags. & PRI_KEY_FLAGcxx . . $ `include/mysql_com.h:143:9`!))) |
| 627 | recinfo_pos->type= FIELD_NORMALcxx . . $ FIELD_NORMAL.; |
| 628 | else if (found->zero_packcxx . . $ Field#zero_pack(50ce9a9e25b4a850).()) |
| 629 | recinfo_pos->type= FIELD_SKIP_ZEROcxx . . $ FIELD_SKIP_ZERO.; |
| 630 | else |
| 631 | recinfo_pos->type= ((length <= 3 || |
| 632 | (found->flagscxx . . $ Field#flags. & ZEROFILL_FLAGcxx . . $ `include/mysql_com.h:148:9`!)) ? |
| 633 | FIELD_NORMALcxx . . $ FIELD_NORMAL. : |
| 634 | found->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_STRING || |
| 635 | found->typecxx . . $ Field#type(475fe4fba976c6ac).() == MYSQL_TYPE_VAR_STRING ? |
| 636 | FIELD_SKIP_ENDSPACEcxx . . $ FIELD_SKIP_ENDSPACE. : |
| 637 | FIELD_SKIP_PRESPACEcxx . . $ FIELD_SKIP_PRESPACE.); |
| 638 | if (found->null_ptrcxx . . $ Field#null_ptr.) |
| 639 | { |
| 640 | recinfo_pos->null_bit= found->null_bitcxx . . $ Field#null_bit.; |
| 641 | recinfo_pos->null_pos= (uint) (found->null_ptrcxx . . $ Field#null_ptr. - |
| 642 | (ucharcxx . . $ uchar#*) table_arg->recordcxx . . $ TABLE#record.[0]); |
| 643 | } |
| 644 | else |
| 645 | { |
| 646 | recinfo_pos->null_bit= 0; |
| 647 | recinfo_pos->null_pos= 0; |
| 648 | } |
| 649 | (recinfo_pos++)->length= (uint16cxx . . $ uint16#) length; |
| 650 | recpos= minpos + length; |
| 651 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("loop", ("length: %d type: %d", |
| 652 | recinfo_pos[-1].length,recinfo_pos[-1].type)); |
| 653 | } |
| 654 | *records_out= (uint) (recinfo_pos - recinfo); |
| 655 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 656 | } |
| 657 | |
| 658 | |
| 659 | /* |
| 660 | Check for underlying table conformance |
| 661 | |
| 662 | SYNOPSIS |
| 663 | maria_check_definition() |
| 664 | t1_keyinfo in First table key definition |
| 665 | t1_recinfo in First table record definition |
| 666 | t1_keys in Number of keys in first table |
| 667 | t1_recs in Number of records in first table |
| 668 | t2_keyinfo in Second table key definition |
| 669 | t2_recinfo in Second table record definition |
| 670 | t2_keys in Number of keys in second table |
| 671 | t2_recs in Number of records in second table |
| 672 | strict in Strict check switch |
| 673 | |
| 674 | DESCRIPTION |
| 675 | This function compares two Maria definitions. By intention it was done |
| 676 | to compare merge table definition against underlying table definition. |
| 677 | It may also be used to compare dot-frm and MAI definitions of Maria |
| 678 | table as well to compare different Maria table definitions. |
| 679 | |
| 680 | For merge table it is not required that number of keys in merge table |
| 681 | must exactly match number of keys in underlying table. When calling this |
| 682 | function for underlying table conformance check, 'strict' flag must be |
| 683 | set to false, and converted merge definition must be passed as t1_*. |
| 684 | |
| 685 | Otherwise 'strict' flag must be set to 1 and it is not required to pass |
| 686 | converted dot-frm definition as t1_*. |
| 687 | |
| 688 | RETURN VALUE |
| 689 | 0 - Equal definitions. |
| 690 | 1 - Different definitions. |
| 691 | |
| 692 | TODO |
| 693 | - compare FULLTEXT keys; |
| 694 | - compare SPATIAL keys; |
| 695 | - compare FIELD_SKIP_ZERO which is converted to FIELD_NORMAL correctly |
| 696 | (should be correctly detected in table2maria). |
| 697 | |
| 698 | FIXME: |
| 699 | maria_check_definition() is never used! CHECK TABLE does not detect the |
| 700 | corruption! Do maria_check_definition() like check_definition() is done |
| 701 | by MyISAM (related to MDEV-25803). |
| 702 | */ |
| 703 | |
| 704 | int maria_check_definitioncxx . . $ maria_check_definition(4de612088f330f3).(MARIA_KEYDEF *t1_keyinfo, |
| 705 | MARIA_COLUMNDEF *t1_recinfo, |
| 706 | uint t1_keys, uint t1_recs, |
| 707 | MARIA_KEYDEF *t2_keyinfo, |
| 708 | MARIA_COLUMNDEF *t2_recinfo, |
| 709 | uint t2_keys, uint t2_recs, bool strict) |
| 710 | { |
| 711 | uint i, j; |
| 712 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("maria_check_definition"); |
| 713 | if ((strict ? t1_keys != t2_keys : t1_keys > t2_keys)) |
| 714 | { |
| 715 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("Number of keys differs: t1_keys=%u, t2_keys=%u", |
| 716 | t1_keys, t2_keys)); |
| 717 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); |
| 718 | } |
| 719 | if (t1_recs != t2_recs) |
| 720 | { |
| 721 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("Number of recs differs: t1_recs=%u, t2_recs=%u", |
| 722 | t1_recs, t2_recs)); |
| 723 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); |
| 724 | } |
| 725 | for (i= 0; i < t1_keys; i++) |
| 726 | { |
| 727 | HA_KEYSEG *t1_keysegs= t1_keyinfo[i].seg; |
| 728 | HA_KEYSEG *t2_keysegs= t2_keyinfo[i].seg; |
| 729 | if ((t1_keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXTcxx . . $ HA_KEY_ALG_FULLTEXT. && |
| 730 | t2_keyinfo[i].key_alg == HA_KEY_ALG_FULLTEXTcxx . . $ HA_KEY_ALG_FULLTEXT.) || |
| 731 | (t1_keyinfo[i].key_alg == HA_KEY_ALG_RTREEcxx . . $ HA_KEY_ALG_RTREE. && |
| 732 | t2_keyinfo[i].key_alg == HA_KEY_ALG_RTREEcxx . . $ HA_KEY_ALG_RTREE.)) |
| 733 | continue; |
| 734 | if (t1_keyinfo[i].keysegs != t2_keyinfo[i].keysegs || |
| 735 | t1_keyinfo[i].key_alg != t2_keyinfo[i].key_alg) |
| 736 | { |
| 737 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("Key %d has different definition", i)); |
| 738 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("t1_keysegs=%d, t1_key_alg=%d", |
| 739 | t1_keyinfo[i].keysegs, t1_keyinfo[i].key_alg)); |
| 740 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("t2_keysegs=%d, t2_key_alg=%d", |
| 741 | t2_keyinfo[i].keysegs, t2_keyinfo[i].key_alg)); |
| 742 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); |
| 743 | } |
| 744 | for (j= t1_keyinfo[i].keysegs; j--;) |
| 745 | { |
| 746 | uint8cxx . . $ uint8# t1_keysegs_j__type= t1_keysegs[j].type; |
| 747 | /* |
| 748 | Table migration from 4.1 to 5.1. In 5.1 a *TEXT key part is |
| 749 | always HA_KEYTYPE_VARTEXT2. In 4.1 we had only the equivalent of |
| 750 | HA_KEYTYPE_VARTEXT1. Since we treat both the same on MyISAM |
| 751 | level, we can ignore a mismatch between these types. |
| 752 | */ |
| 753 | if ((t1_keysegs[j].flag & HA_BLOB_PARTcxx . . $ `include/my_base.h:335:9`!) && |
| 754 | (t2_keysegs[j].flag & HA_BLOB_PARTcxx . . $ `include/my_base.h:335:9`!)) |
| 755 | { |
| 756 | if ((t1_keysegs_j__type == HA_KEYTYPE_VARTEXT2cxx . . $ HA_KEYTYPE_VARTEXT2.) && |
| 757 | (t2_keysegs[j].type == HA_KEYTYPE_VARTEXT1cxx . . $ HA_KEYTYPE_VARTEXT1.)) |
| 758 | t1_keysegs_j__type= HA_KEYTYPE_VARTEXT1cxx . . $ HA_KEYTYPE_VARTEXT1.; /* purecov: tested */ |
| 759 | else if ((t1_keysegs_j__type == HA_KEYTYPE_VARBINARY2cxx . . $ HA_KEYTYPE_VARBINARY2.) && |
| 760 | (t2_keysegs[j].type == HA_KEYTYPE_VARBINARY1cxx . . $ HA_KEYTYPE_VARBINARY1.)) |
| 761 | t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1cxx . . $ HA_KEYTYPE_VARBINARY1.; /* purecov: inspected */ |
| 762 | } |
| 763 | |
| 764 | if (t1_keysegs_j__type != t2_keysegs[j].type || |
| 765 | t1_keysegs[j].language != t2_keysegs[j].language || |
| 766 | t1_keysegs[j].null_bit != t2_keysegs[j].null_bit || |
| 767 | t1_keysegs[j].length != t2_keysegs[j].length) |
| 768 | { |
| 769 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("Key segment %d (key %d) has different " |
| 770 | "definition", j, i)); |
| 771 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("t1_type=%d, t1_language=%d, t1_null_bit=%d, " |
| 772 | "t1_length=%d", |
| 773 | t1_keysegs[j].type, t1_keysegs[j].language, |
| 774 | t1_keysegs[j].null_bit, t1_keysegs[j].length)); |
| 775 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("t2_type=%d, t2_language=%d, t2_null_bit=%d, " |
| 776 | "t2_length=%d", |
| 777 | t2_keysegs[j].type, t2_keysegs[j].language, |
| 778 | t2_keysegs[j].null_bit, t2_keysegs[j].length)); |
| 779 | |
| 780 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); |
| 781 | } |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | for (i= 0; i < t1_recs; i++) |
| 786 | { |
| 787 | MARIA_COLUMNDEF *t1_rec= &t1_recinfo[i]; |
| 788 | MARIA_COLUMNDEF *t2_rec= &t2_recinfo[i]; |
| 789 | /* |
| 790 | FIELD_SKIP_ZERO can be changed to FIELD_NORMAL in maria_create, |
| 791 | see NOTE1 in ma_create.c |
| 792 | */ |
| 793 | if ((t1_rec->type != t2_rec->type && |
| 794 | !(t1_rec->type == (int) FIELD_SKIP_ZEROcxx . . $ FIELD_SKIP_ZERO. && |
| 795 | t1_rec->length == 1 && |
| 796 | t2_rec->type == (int) FIELD_NORMALcxx . . $ FIELD_NORMAL.)) || |
| 797 | t1_rec->length != t2_rec->length || |
| 798 | t1_rec->null_bit != t2_rec->null_bit) |
| 799 | { |
| 800 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("Field %d has different definition", i)); |
| 801 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("t1_type=%d, t1_length=%d, t1_null_bit=%d", |
| 802 | t1_rec->type, t1_rec->length, t1_rec->null_bit)); |
| 803 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("error", ("t2_type=%d, t2_length=%d, t2_null_bit=%d", |
| 804 | t2_rec->type, t2_rec->length, t2_rec->null_bit)); |
| 805 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); |
| 806 | } |
| 807 | } |
| 808 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 809 | } |
| 810 | |
| 811 | |
| 812 | extern "C" { |
| 813 | |
| 814 | int _ma_killed_ptr(HA_CHECKcxx . . $ HA_CHECK# *param) |
| 815 | { |
| 816 | if (!param->thdcxx . . $ st_handler_check_param#thd. || likelycxx . . $ `include/my_global.h:360:9`!(thd_killedcxx . . $ `include/mysql/service_kill_statement.h:53:9`!((THD*)param->thd)) == 0) |
| 817 | return 0; |
| 818 | my_errnocxx . . $ `include/my_pthread.h:720:9`!= HA_ERR_ABORTED_BY_USERcxx . . $ `include/my_base.h:546:9`!; |
| 819 | return 1; |
| 820 | } |
| 821 | |
| 822 | |
| 823 | /* |
| 824 | Report progress to mysqld |
| 825 | |
| 826 | This is a bit more complex than what a normal progress report |
| 827 | function normally is. |
| 828 | |
| 829 | The reason is that this is called by enable_index/repair which |
| 830 | is one stage in ALTER TABLE and we can't use the external |
| 831 | stage/max_stage for this. |
| 832 | |
| 833 | thd_progress_init/thd_progress_next_stage is to be called by |
| 834 | high level commands like CHECK TABLE or REPAIR TABLE, not |
| 835 | by sub commands like enable_index(). |
| 836 | |
| 837 | In ma_check.c it's easier to work with stages than with a total |
| 838 | progress, so we use internal stage/max_stage here to keep the |
| 839 | code simple. |
| 840 | */ |
| 841 | |
| 842 | void _ma_report_progress(HA_CHECKcxx . . $ HA_CHECK# *param, ulonglongcxx . . $ ulonglong# progress, |
| 843 | ulonglongcxx . . $ ulonglong# max_progress) |
| 844 | { |
| 845 | if (param->thdcxx . . $ st_handler_check_param#thd.) |
| 846 | thd_progress_report((THDcxx . . $ THD#*)param->thdcxx . . $ st_handler_check_param#thd., |
| 847 | progress + max_progress * param->stagecxx . . $ st_handler_check_param#stage., |
| 848 | max_progress * param->max_stagecxx . . $ st_handler_check_param#max_stage.); |
| 849 | } |
| 850 | |
| 851 | |
| 852 | void _ma_check_print_error(HA_CHECKcxx . . $ HA_CHECK# *param, const char *fmt, ...) |
| 853 | { |
| 854 | va_list args; |
| 855 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_ma_check_print_error"); |
| 856 | param->error_printedcxx . . $ st_handler_check_param#error_printed.++; |
| 857 | param->out_flagcxx . . $ st_handler_check_param#out_flag. |= O_DATA_LOSTcxx . . $ `include/myisamchk.h:37:9`!; |
| 858 | if (param->testflagcxx . . $ st_handler_check_param#testflag. & T_SUPPRESS_ERR_HANDLINGcxx . . $ `include/my_check_opt.h:70:9`!) |
| 859 | DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!; |
| 860 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, fmt); |
| 861 | _ma_check_print_msgcxx . . $ _ma_check_print_msg(2bd9d81b8d9cf012).(param, &MA_CHECK_ERRORcxx . . $ MA_CHECK_ERROR., fmt, args); |
| 862 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args); |
| 863 | DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!; |
| 864 | } |
| 865 | |
| 866 | |
| 867 | void _ma_check_print_info(HA_CHECKcxx . . $ HA_CHECK# *param, const char *fmt, ...) |
| 868 | { |
| 869 | va_list args; |
| 870 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_ma_check_print_info"); |
| 871 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, fmt); |
| 872 | _ma_check_print_msgcxx . . $ _ma_check_print_msg(2bd9d81b8d9cf012).(param, &MA_CHECK_INFOcxx . . $ MA_CHECK_INFO., fmt, args); |
| 873 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args); |
| 874 | DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!; |
| 875 | } |
| 876 | |
| 877 | |
| 878 | void _ma_check_print_warning(HA_CHECKcxx . . $ HA_CHECK# *param, const char *fmt, ...) |
| 879 | { |
| 880 | va_list args; |
| 881 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("_ma_check_print_warning"); |
| 882 | param->warning_printedcxx . . $ st_handler_check_param#warning_printed.++; |
| 883 | param->out_flagcxx . . $ st_handler_check_param#out_flag. |= O_DATA_LOSTcxx . . $ `include/myisamchk.h:37:9`!; |
| 884 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, fmt); |
| 885 | _ma_check_print_msgcxx . . $ _ma_check_print_msg(2bd9d81b8d9cf012).(param, &MA_CHECK_WARNINGcxx . . $ MA_CHECK_WARNING., fmt, args); |
| 886 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args); |
| 887 | DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!; |
| 888 | } |
| 889 | |
| 890 | /* |
| 891 | Create a transaction object |
| 892 | |
| 893 | SYNOPSIS |
| 894 | info Maria handler |
| 895 | |
| 896 | RETURN |
| 897 | 0 ok |
| 898 | # Error number (HA_ERR_OUT_OF_MEM) |
| 899 | */ |
| 900 | |
| 901 | static int maria_create_trn_for_mysql(MARIA_HA *info) |
| 902 | { |
| 903 | THDcxx . . $ THD# *thd= ((TABLEcxx . . $ TABLE#*) info->external_refcxx . . $ st_maria_handler#external_ref.)->in_usecxx . . $ TABLE#in_use.; |
| 904 | TRN *trn= THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`!; |
| 905 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("maria_create_trn_for_mysql"); |
| 906 | |
| 907 | if (!trn) /* no transaction yet - open it now */ |
| 908 | { |
| 909 | trn= trnman_new_trn(& thd->transactioncxx . . $ THD#transaction.->wtcxx . . $ THD#st_transactions#wt.); |
| 910 | if (unlikelycxx . . $ `include/my_global.h:361:9`!(!trn)) |
| 911 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ERR_OUT_OF_MEMcxx . . $ `include/my_base.h:473:9`!); |
| 912 | thd_set_ha_data(thd, maria_htoncxx . . $ maria_hton., trn); |
| 913 | if (thd->variablescxx . . $ THD#variables..option_bitscxx . . $ system_variables#option_bits. & (OPTION_NOT_AUTOCOMMITcxx . . $ `sql/sql_priv.h:68:9`! | OPTION_BEGINcxx . . $ `sql/sql_priv.h:69:9`!)) |
| 914 | trans_register_hacxx . . $ trans_register_ha(e122d80d5a4cafbd).(thd, TRUEcxx . . $ `include/my_global.h:476:9`!, maria_htoncxx . . $ maria_hton., trn->tridcxx . . $ st_ma_transaction#trid.); |
| 915 | } |
| 916 | _ma_set_trn_for_tablecxx . . $ _ma_set_trn_for_table(de0e2855de83418e).(info, trn); |
| 917 | if (!trnman_increment_locked_tables(trn)) |
| 918 | { |
| 919 | trans_register_hacxx . . $ trans_register_ha(e122d80d5a4cafbd).(thd, FALSEcxx . . $ `include/my_global.h:477:9`!, maria_htoncxx . . $ maria_hton., trn->tridcxx . . $ st_ma_transaction#trid.); |
| 920 | trnman_new_statement(trn); |
| 921 | } |
| 922 | #ifdef EXTRA_DEBUG |
| 923 | if (info->lock_type == F_WRLCK && |
| 924 | ! (trnman_get_flags(trn) & TRN_STATE_INFO_LOGGED)) |
| 925 | { |
| 926 | trnman_set_flags(trn, trnman_get_flags(trn) | TRN_STATE_INFO_LOGGED | |
| 927 | TRN_STATE_TABLES_CAN_CHANGE); |
| 928 | (void) translog_log_debug_info(trn, LOGREC_DEBUG_INFO_QUERY, |
| 929 | (uchar*) thd->query(), |
| 930 | thd->query_length()); |
| 931 | } |
| 932 | else |
| 933 | { |
| 934 | DBUG_PRINT("info", ("lock_type: %d trnman_flags: %u", |
| 935 | info->lock_type, trnman_get_flags(trn))); |
| 936 | } |
| 937 | |
| 938 | #endif |
| 939 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 940 | } |
| 941 | |
| 942 | my_boolcxx . . $ my_bool# ma_killed_in_mariadb(MARIA_HA *info) |
| 943 | { |
| 944 | return (((TABLEcxx . . $ TABLE#*) (info->external_refcxx . . $ st_maria_handler#external_ref.))->in_usecxx . . $ TABLE#in_use.->killedcxx . . $ THD#killed. != 0); |
| 945 | } |
| 946 | |
| 947 | void maria_debug_crash_here(const char *keyword) |
| 948 | { |
| 949 | #ifndef DBUG_OFFcxx . . $ `<built-in>:485:9`! |
| 950 | debug_crash_here(keyword); |
| 951 | #endif /* DBUG_OFF */ |
| 952 | } |
| 953 | |
| 954 | } /* extern "C" */ |
| 955 | |
| 956 | /** |
| 957 | Transactional table doing bulk insert with one single UNDO |
| 958 | (UNDO_BULK_INSERT) and with repair. |
| 959 | */ |
| 960 | #define BULK_INSERT_SINGLE_UNDO_AND_REPAIRcxx . . $ `storage/maria/ha_maria.cc:960:9`! 1 |
| 961 | /** |
| 962 | Transactional table doing bulk insert with one single UNDO |
| 963 | (UNDO_BULK_INSERT) and without repair. |
| 964 | */ |
| 965 | #define BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIRcxx . . $ `storage/maria/ha_maria.cc:965:9`! 2 |
| 966 | /** |
| 967 | None of BULK_INSERT_SINGLE_UNDO_AND_REPAIR and |
| 968 | BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR. |
| 969 | */ |
| 970 | #define BULK_INSERT_NONEcxx . . $ `storage/maria/ha_maria.cc:970:9`! 0 |
| 971 | |
| 972 | ha_mariacxx . . $ ha_maria#::ha_mariacxx . . $ ha_maria#ha_maria(4ed6374a37a121ca).(handlertoncxx . . $ handlerton# *hton, TABLE_SHAREcxx . . $ TABLE_SHARE# *table_arg): |
| 973 | handlercxx . . $ handler#handler(4ed6374a37a121ca).(hton, table_arg), filecxx . . $ ha_maria#file.(0), |
| 974 | int_table_flagscxx . . $ ha_maria#int_table_flags.(HA_NULL_IN_KEYcxx . . $ `sql/handler.h:148:9`! | HA_CAN_FULLTEXTcxx . . $ `sql/handler.h:188:9`! | HA_CAN_SQL_HANDLERcxx . . $ `sql/handler.h:189:9`! | |
| 975 | HA_BINLOG_ROW_CAPABLEcxx . . $ `sql/handler.h:206:9`! | HA_BINLOG_STMT_CAPABLEcxx . . $ `sql/handler.h:207:9`! | |
| 976 | HA_DUPLICATE_POScxx . . $ `sql/handler.h:149:9`! | HA_CAN_INDEX_BLOBScxx . . $ `sql/handler.h:151:9`! | HA_AUTO_PART_KEYcxx . . $ `sql/handler.h:152:9`! | |
| 977 | HA_FILE_BASEDcxx . . $ `sql/handler.h:194:9`! | HA_CAN_GEOMETRYcxx . . $ `sql/handler.h:136:9`! | TRANSACTION_STATEcxx . . $ `storage/maria/ha_maria.cc:55:9`! | |
| 978 | HA_CAN_BIT_FIELDcxx . . $ `sql/handler.h:195:9`! | HA_CAN_RTREEKEYScxx . . $ `sql/handler.h:180:9`! | HA_CAN_REPAIRcxx . . $ `sql/handler.h:238:9`! | |
| 979 | HA_CAN_VIRTUAL_COLUMNScxx . . $ `sql/handler.h:242:9`! | HA_CAN_EXPORTcxx . . $ `sql/handler.h:299:9`! | |
| 980 | HA_HAS_RECORDScxx . . $ `sql/handler.h:199:9`! | HA_STATS_RECORDS_IS_EXACTcxx . . $ `sql/handler.h:160:9`! | |
| 981 | HA_CAN_TABLES_WITHOUT_ROLLBACKcxx . . $ `sql/handler.h:318:9`!), |
| 982 | can_enable_indexescxx . . $ ha_maria#can_enable_indexes.(0), bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo.(BULK_INSERT_NONEcxx . . $ `storage/maria/ha_maria.cc:970:9`!) |
| 983 | {} |
| 984 | |
| 985 | |
| 986 | handlercxx . . $ handler# *ha_mariacxx . . $ ha_maria#::clonecxx . . $ ha_maria#clone(5728aa33ab292386).(const char *name __attribute__((unused)), |
| 987 | MEM_ROOTcxx . . $ MEM_ROOT# *mem_root) |
| 988 | { |
| 989 | ha_mariacxx . . $ ha_maria# *new_handler= |
| 990 | static_cast <ha_mariacxx . . $ ha_maria# *>(handlercxx . . $ handler#::clonecxx . . $ handler#clone(5728aa33ab292386).(filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->open_file_name.strcxx . . $ st_mysql_lex_string#str., |
| 991 | mem_root)); |
| 992 | if (new_handler) |
| 993 | { |
| 994 | new_handler->filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.= filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.; |
| 995 | /* maria_create_trn_for_mysql() is never called for clone() tables */ |
| 996 | new_handler->filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.= filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.; |
| 997 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(new_handler->file->trn_prev == 0 && |
| 998 | new_handler->file->trn_next == 0); |
| 999 | } |
| 1000 | return new_handler; |
| 1001 | } |
| 1002 | |
| 1003 | |
| 1004 | static const char *ha_maria_extscxx . . $ ha_maria_exts.[]= |
| 1005 | { |
| 1006 | MARIA_NAME_IEXTcxx . . $ `storage/maria/maria_def.h:64:9`!, |
| 1007 | MARIA_NAME_DEXTcxx . . $ `storage/maria/maria_def.h:65:9`!, |
| 1008 | NullScxx . . $ `include/my_global.h:844:9`! |
| 1009 | }; |
| 1010 | |
| 1011 | |
| 1012 | ulong ha_mariacxx . . $ ha_maria#::index_flagscxx . . $ ha_maria#index_flags(ac3be7eff3a46d11).(uint inx, uint part, bool all_parts) const |
| 1013 | { |
| 1014 | ulong flags; |
| 1015 | if (table_sharecxx . . $ handler#table_share.->key_infocxx . . $ TABLE_SHARE#key_info.[inx].algorithmcxx . . $ st_key#algorithm. == HA_KEY_ALG_FULLTEXTcxx . . $ HA_KEY_ALG_FULLTEXT. || |
| 1016 | table_sharecxx . . $ handler#table_share.->key_infocxx . . $ TABLE_SHARE#key_info.[inx].algorithmcxx . . $ st_key#algorithm. == HA_KEY_ALG_UNIQUE_HASHcxx . . $ HA_KEY_ALG_UNIQUE_HASH.) |
| 1017 | flags= 0; |
| 1018 | else |
| 1019 | if (table_sharecxx . . $ handler#table_share.->key_infocxx . . $ TABLE_SHARE#key_info.[inx].algorithmcxx . . $ st_key#algorithm. == HA_KEY_ALG_RTREEcxx . . $ HA_KEY_ALG_RTREE.) |
| 1020 | { |
| 1021 | /* All GIS scans are non-ROR scans. We also disable IndexConditionPushdown */ |
| 1022 | flags= HA_READ_NEXTcxx . . $ `sql/handler.h:394:9`! | HA_READ_PREVcxx . . $ `sql/handler.h:395:9`! | HA_READ_RANGEcxx . . $ `sql/handler.h:397:9`! | |
| 1023 | HA_READ_ORDERcxx . . $ `sql/handler.h:396:9`! | HA_KEYREAD_ONLYcxx . . $ `sql/handler.h:399:9`! | HA_KEY_SCAN_NOT_RORcxx . . $ `sql/handler.h:405:9`!; |
| 1024 | } |
| 1025 | else |
| 1026 | { |
| 1027 | flags= (HA_READ_NEXTcxx . . $ `sql/handler.h:394:9`! | HA_READ_PREVcxx . . $ `sql/handler.h:395:9`! | HA_READ_RANGEcxx . . $ `sql/handler.h:397:9`! | |
| 1028 | HA_READ_ORDERcxx . . $ `sql/handler.h:396:9`! | HA_KEYREAD_ONLYcxx . . $ `sql/handler.h:399:9`! | HA_DO_INDEX_COND_PUSHDOWNcxx . . $ `sql/handler.h:406:9`! | |
| 1029 | HA_DO_RANGE_FILTER_PUSHDOWNcxx . . $ `sql/handler.h:413:9`!); |
| 1030 | } |
| 1031 | return flags; |
| 1032 | } |
| 1033 | |
| 1034 | |
| 1035 | /* |
| 1036 | Update costs that are unique for this TABLE instance |
| 1037 | */ |
| 1038 | |
| 1039 | void ha_mariacxx . . $ ha_maria#::update_optimizer_costscxx . . $ ha_maria#update_optimizer_costs(de7659b82b708318).(OPTIMIZER_COSTScxx . . $ OPTIMIZER_COSTS# *costs) |
| 1040 | { |
| 1041 | /* |
| 1042 | Default costs for Aria with BLOCK_FORMAT is the same as MariaDB default |
| 1043 | costs. |
| 1044 | */ |
| 1045 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->data_file_type != BLOCK_RECORDcxx . . $ BLOCK_RECORD.) |
| 1046 | { |
| 1047 | /* |
| 1048 | MyISAM format row lookup costs are slow as the row data is on a not |
| 1049 | cached file. Costs taken from ha_myisam.cc |
| 1050 | */ |
| 1051 | costs->row_next_find_costcxx . . $ OPTIMIZER_COSTS#row_next_find_cost.= 0.000063539; |
| 1052 | costs->row_lookup_costcxx . . $ OPTIMIZER_COSTS#row_lookup_cost.= 0.001014818; |
| 1053 | } |
| 1054 | } |
| 1055 | |
| 1056 | |
| 1057 | IO_AND_CPU_COSTcxx . . $ IO_AND_CPU_COST# ha_mariacxx . . $ ha_maria#::rnd_pos_timecxx . . $ ha_maria#rnd_pos_time(e3fb9b078e5ff6d3).(ha_rowscxx . . $ ha_rows# rows) |
| 1058 | { |
| 1059 | IO_AND_CPU_COSTcxx . . $ IO_AND_CPU_COST# cost= handlercxx . . $ handler#::rnd_pos_timecxx . . $ handler#rnd_pos_time(e3fb9b078e5ff6d3).(rows); |
| 1060 | /* file may be 0 if this is an internal temporary file that is not yet opened */ |
| 1061 | if (filecxx . . $ ha_maria#file. && filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->data_file_type != BLOCK_RECORDcxx . . $ BLOCK_RECORD.) |
| 1062 | { |
| 1063 | /* |
| 1064 | Row data is not cached. costs.row_lookup_cost includes the cost of |
| 1065 | the reading the row from system (probably cached by the OS). |
| 1066 | */ |
| 1067 | cost.iocxx . . $ IO_AND_CPU_COST#io.= 0; |
| 1068 | } |
| 1069 | return cost; |
| 1070 | } |
| 1071 | |
| 1072 | |
| 1073 | /* |
| 1074 | We need to be able to store at least 2 keys on an index page as the |
| 1075 | splitting algorithms depends on this. (With only one key on a page |
| 1076 | we also can't use any compression, which may make the index file much |
| 1077 | larger) |
| 1078 | We use MARIA_MAX_KEY_LENGTH to limit the key size as we don't want to use |
| 1079 | too much stack when searching in the b_tree. |
| 1080 | |
| 1081 | We also need to reserve place for a record pointer (8) and 3 bytes |
| 1082 | per key segment to store the length of the segment + possible null bytes. |
| 1083 | These extra bytes are required here so that maria_create() will surely |
| 1084 | accept any keys created which the returned key data storage length. |
| 1085 | */ |
| 1086 | |
| 1087 | uint ha_mariacxx . . $ ha_maria#::max_supported_key_lengthcxx . . $ ha_maria#max_supported_key_length(ddd8539a2fcdd4ce).() const |
| 1088 | { |
| 1089 | return maria_max_key_length(); |
| 1090 | } |
| 1091 | |
| 1092 | /* Name is here without an extension */ |
| 1093 | |
| 1094 | int ha_mariacxx . . $ ha_maria#::opencxx . . $ ha_maria#open(ac5e327aedb29b06).(const char *name, int mode, uint test_if_locked) |
| 1095 | { |
| 1096 | uint i; |
| 1097 | |
| 1098 | #ifdef NOT_USED |
| 1099 | /* |
| 1100 | If the user wants to have memory mapped data files, add an |
| 1101 | open_flag. Do not memory map temporary tables because they are |
| 1102 | expected to be inserted and thus extended a lot. Memory mapping is |
| 1103 | efficient for files that keep their size, but very inefficient for |
| 1104 | growing files. Using an open_flag instead of calling ma_extra(... |
| 1105 | HA_EXTRA_MMAP ...) after maxs_open() has the advantage that the |
| 1106 | mapping is not repeated for every open, but just done on the initial |
| 1107 | open, when the MyISAM share is created. Every time the server |
| 1108 | requires to open a new instance of a table it calls this method. We |
| 1109 | will always supply HA_OPEN_MMAP for a permanent table. However, the |
| 1110 | Maria storage engine will ignore this flag if this is a secondary |
| 1111 | open of a table that is in use by other threads already (if the |
| 1112 | Maria share exists already). |
| 1113 | */ |
| 1114 | if (!(test_if_locked & HA_OPEN_TMP_TABLE) && opt_maria_use_mmap) |
| 1115 | test_if_locked|= HA_OPEN_MMAP; |
| 1116 | #endif |
| 1117 | |
| 1118 | if (maria_recover_optionscxx . . $ maria_recover_options. & HA_RECOVER_ANYcxx . . $ `storage/maria/maria_def.h:256:9`!) |
| 1119 | { |
| 1120 | /* user asked to trigger a repair if table was not properly closed */ |
| 1121 | test_if_locked|= HA_OPEN_ABORT_IF_CRASHEDcxx . . $ `include/my_base.h:41:9`!; |
| 1122 | } |
| 1123 | |
| 1124 | if (aria_readonly) |
| 1125 | test_if_locked|= HA_OPEN_IGNORE_MOVED_STATEcxx . . $ `storage/maria/maria_def.h:352:9`!; |
| 1126 | |
| 1127 | if (!(filecxx . . $ ha_maria#file.= maria_open(name, mode, test_if_locked | HA_OPEN_FROM_SQL_LAYERcxx . . $ `include/my_base.h:43:9`!, |
| 1128 | s3_open_argscxx . . $ ha_maria#s3_open_args(636d4fed7dd18516).()))) |
| 1129 | { |
| 1130 | if (my_errnocxx . . $ `include/my_pthread.h:720:9`! == HA_ERR_OLD_FILEcxx . . $ `include/my_base.h:477:9`!) |
| 1131 | { |
| 1132 | push_warningcxx . . $ push_warning(e5388ac74f886b26).(current_thdcxx . . $ `sql/mysqld.h:916:9`!, Sql_conditioncxx . . $ Sql_condition#::WARN_LEVEL_NOTEcxx . . $ Sql_state_errno_level#WARN_LEVEL_NOTE., |
| 1133 | ER_CRASHED_ON_USAGEcxx . . $ `build/include/mysqld_error.h:199:9`!, |
| 1134 | zerofill_error_msgcxx . . $ zerofill_error_msg.); |
| 1135 | } |
| 1136 | return (my_errnocxx . . $ `include/my_pthread.h:720:9`! ? my_errnocxx . . $ `include/my_pthread.h:720:9`! : -1); |
| 1137 | } |
| 1138 | if (aria_readonly) |
| 1139 | filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->options|= HA_OPTION_READ_ONLY_DATAcxx . . $ `include/my_base.h:376:9`!; |
| 1140 | |
| 1141 | filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->chst_invalidator= query_cache_invalidate_by_MyISAM_filename_refcxx . . $ `sql/sql_cache.h:584:9`!; |
| 1142 | /* Set external_ref, mainly for temporary tables */ |
| 1143 | filecxx . . $ ha_maria#file.->external_refcxx . . $ st_maria_handler#external_ref.= (void*) tablecxx . . $ handler#table.; // For ma_killed() |
| 1144 | |
| 1145 | if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKEDcxx . . $ `include/my_base.h:38:9`! | HA_OPEN_TMP_TABLEcxx . . $ `include/my_base.h:39:9`!)) |
| 1146 | maria_extra(filecxx . . $ ha_maria#file., HA_EXTRA_NO_WAIT_LOCKcxx . . $ HA_EXTRA_NO_WAIT_LOCK., 0); |
| 1147 | |
| 1148 | infocxx . . $ ha_maria#info(4c679297bf94b9eb).(HA_STATUS_NO_LOCKcxx . . $ `include/my_base.h:421:9`! | HA_STATUS_VARIABLEcxx . . $ `include/my_base.h:436:9`! | HA_STATUS_CONSTcxx . . $ `include/my_base.h:430:9`!); |
| 1149 | if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKEDcxx . . $ `include/my_base.h:37:9`!)) |
| 1150 | maria_extra(filecxx . . $ ha_maria#file., HA_EXTRA_WAIT_LOCKcxx . . $ HA_EXTRA_WAIT_LOCK., 0); |
| 1151 | if ((data_file_typecxx . . $ ha_maria#data_file_type.= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->data_file_type) != STATIC_RECORDcxx . . $ STATIC_RECORD.) |
| 1152 | int_table_flagscxx . . $ ha_maria#int_table_flags. |= HA_REC_NOT_IN_SEQcxx . . $ `sql/handler.h:135:9`!; |
| 1153 | if (!filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->base.born_transactional) |
| 1154 | { |
| 1155 | /* |
| 1156 | INSERT DELAYED cannot work with transactional tables (because it cannot |
| 1157 | stand up to "when client gets ok the data is safe on disk": the record |
| 1158 | may not even be inserted). In the future, we could enable it back (as a |
| 1159 | client doing INSERT DELAYED knows the specificities; but we then should |
| 1160 | make sure to regularly commit in the delayed_insert thread). |
| 1161 | */ |
| 1162 | int_table_flagscxx . . $ ha_maria#int_table_flags.|= HA_CAN_INSERT_DELAYEDcxx . . $ `sql/handler.h:165:9`! | HA_NO_TRANSACTIONScxx . . $ `sql/handler.h:124:9`!; |
| 1163 | } |
| 1164 | else |
| 1165 | int_table_flagscxx . . $ ha_maria#int_table_flags.|= HA_CRASH_SAFEcxx . . $ `sql/handler.h:366:9`!; |
| 1166 | |
| 1167 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->options & (HA_OPTION_CHECKSUMcxx . . $ `include/my_base.h:349:9`! | HA_OPTION_COMPRESS_RECORDcxx . . $ `include/my_base.h:346:9`!)) |
| 1168 | int_table_flagscxx . . $ ha_maria#int_table_flags. |= HA_HAS_NEW_CHECKSUMcxx . . $ `sql/handler.h:241:9`!; |
| 1169 | |
| 1170 | /* |
| 1171 | We can only do online backup on transactional tables with checksum. |
| 1172 | Checksums are needed to avoid half writes. |
| 1173 | */ |
| 1174 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->options & HA_OPTION_PAGE_CHECKSUMcxx . . $ `include/my_base.h:355:9`! && |
| 1175 | filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->base.born_transactional) |
| 1176 | int_table_flagscxx . . $ ha_maria#int_table_flags. |= HA_CAN_ONLINE_BACKUPScxx . . $ `sql/handler.h:362:9`!; |
| 1177 | |
| 1178 | /* |
| 1179 | For static size rows, tell MariaDB that we will access all bytes |
| 1180 | in the record when writing it. This signals MariaDB to initialize |
| 1181 | the full row to ensure we don't get any errors from valgrind and |
| 1182 | that all bytes in the row is properly reset. |
| 1183 | */ |
| 1184 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->data_file_type == STATIC_RECORDcxx . . $ STATIC_RECORD. && |
| 1185 | (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->has_varchar_fields || filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->has_null_fields)) |
| 1186 | int_table_flagscxx . . $ ha_maria#int_table_flags.|= HA_RECORD_MUST_BE_CLEAN_ON_WRITEcxx . . $ `sql/handler.h:245:9`!; |
| 1187 | |
| 1188 | for (i= 0; i < tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->keyscxx . . $ TABLE_SHARE#keys.; i++) |
| 1189 | { |
| 1190 | plugin_refcxx . . $ plugin_ref# parser= tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info.[i].parsercxx . . $ st_key#$anonymous_type_0#parser.; |
| 1191 | if (tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info.[i].flagscxx . . $ st_key#flags. & HA_USES_PARSERcxx . . $ `include/my_base.h:298:9`!) |
| 1192 | filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->keyinfo[i].parser= |
| 1193 | (struct st_mysql_ftparser *)plugin_declcxx . . $ `sql/sql_plugin.h:136:9`!(parser)->infocxx . . $ st_maria_plugin#info.; |
| 1194 | tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info.[i].block_sizecxx . . $ st_key#block_size.= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->keyinfo[i].block_length; |
| 1195 | tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->key_infocxx . . $ TABLE_SHARE#key_info.[i].block_sizecxx . . $ st_key#block_size.= tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info.[i].block_sizecxx . . $ st_key#block_size.; |
| 1196 | } |
| 1197 | my_errnocxx . . $ `include/my_pthread.h:720:9`!= 0; |
| 1198 | |
| 1199 | /* Count statistics of usage for newly open normal files */ |
| 1200 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->reopen == 1 && ! (test_if_locked & HA_OPEN_TMP_TABLEcxx . . $ `include/my_base.h:39:9`!)) |
| 1201 | { |
| 1202 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->delay_key_write) |
| 1203 | feature_files_opened_with_delayed_keyscxx . . $ feature_files_opened_with_delayed_keys.++; |
| 1204 | } |
| 1205 | |
| 1206 | return my_errnocxx . . $ `include/my_pthread.h:720:9`!; |
| 1207 | } |
| 1208 | |
| 1209 | |
| 1210 | int ha_mariacxx . . $ ha_maria#::closecxx . . $ ha_maria#close(b126dc7c1de90089).(void) |
| 1211 | { |
| 1212 | MARIA_HA *tmp= filecxx . . $ ha_maria#file.; |
| 1213 | if (!tmp) |
| 1214 | return 0; |
| 1215 | /* Ensure we have no open transactions */ |
| 1216 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(file->trn == 0 || file->trn == &dummy_transaction_object); |
| 1217 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(file->trn_next == 0 && file->trn_prev == 0); |
| 1218 | filecxx . . $ ha_maria#file.= 0; |
| 1219 | return maria_close(tmp); |
| 1220 | } |
| 1221 | |
| 1222 | |
| 1223 | int ha_mariacxx . . $ ha_maria#::write_rowcxx . . $ ha_maria#write_row(b84ccf4e0bb14b06).(const ucharcxx . . $ uchar# * buf) |
| 1224 | { |
| 1225 | /* |
| 1226 | If we have an auto_increment column and we are writing a changed row |
| 1227 | or a new row, then update the auto_increment value in the record. |
| 1228 | */ |
| 1229 | if (tablecxx . . $ handler#table.->next_number_fieldcxx . . $ TABLE#next_number_field. && buf == tablecxx . . $ handler#table.->recordcxx . . $ TABLE#record.[0]) |
| 1230 | { |
| 1231 | int error; |
| 1232 | if ((error= update_auto_incrementcxx . . $ handler#update_auto_increment(b126dc7c1de90089).())) |
| 1233 | return error; |
| 1234 | } |
| 1235 | return maria_write(filecxx . . $ ha_maria#file., buf); |
| 1236 | } |
| 1237 | |
| 1238 | |
| 1239 | int ha_mariacxx . . $ ha_maria#::checkcxx . . $ ha_maria#check(95babc367ae08d43).(THDcxx . . $ THD# * thd, HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# * check_opt) |
| 1240 | { |
| 1241 | int error, fatal_error; |
| 1242 | HA_CHECKcxx . . $ HA_CHECK# *param= thd->alloccxx . . $ Query_arena#alloc(4856804ddd09b9b2).<HA_CHECKcxx . . $ HA_CHECK#>(1); |
| 1243 | MARIA_SHARE *share= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.; |
| 1244 | const char *old_proc_info; |
| 1245 | TRN *old_trn= filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.; |
| 1246 | |
| 1247 | if (!filecxx . . $ ha_maria#file. || !param) return HA_ADMIN_INTERNAL_ERRORcxx . . $ `sql/handler.h:65:9`!; |
| 1248 | |
| 1249 | unmap_file(filecxx . . $ ha_maria#file.); |
| 1250 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 1251 | maria_chk_init(param); |
| 1252 | param->thdcxx . . $ st_handler_check_param#thd.= thd; |
| 1253 | param->op_namecxx . . $ st_handler_check_param#op_name.= "check"; |
| 1254 | param->db_namecxx . . $ st_handler_check_param#db_name.= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->dbcxx . . $ TABLE_SHARE#db..str; |
| 1255 | param->table_namecxx . . $ st_handler_check_param#table_name.= tablecxx . . $ handler#table.->aliascxx . . $ TABLE#alias..c_ptrcxx . . $ Binary_string#c_ptr(41208ce6ca65dd58).(); |
| 1256 | param->testflagcxx . . $ st_handler_check_param#testflag.= check_opt->flagscxx . . $ st_ha_check_opt#flags. | T_CHECKcxx . . $ `include/my_check_opt.h:33:9`! | T_SILENTcxx . . $ `include/my_check_opt.h:53:9`!; |
| 1257 | param->stats_methodcxx . . $ st_handler_check_param#stats_method.= (enum_handler_stats_methodcxx . . $ enum_handler_stats_method#)THDVARcxx . . $ `include/mysql/plugin.h:529:9`!(thd,stats_method); |
| 1258 | |
| 1259 | if (!(tablecxx . . $ handler#table.->db_statcxx . . $ TABLE#db_stat. & HA_READ_ONLYcxx . . $ `sql/handler.h:492:9`!)) |
| 1260 | param->testflagcxx . . $ st_handler_check_param#testflag. |= T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`!; |
| 1261 | param->using_global_keycachecxx . . $ st_handler_check_param#using_global_keycache.= 1; |
| 1262 | |
| 1263 | if (!maria_is_crashedcxx . . $ `storage/maria/maria_def.h:1181:9`!(file) && |
| 1264 | (((param->testflagcxx . . $ st_handler_check_param#testflag. & T_CHECK_ONLY_CHANGEDcxx . . $ `include/my_check_opt.h:34:9`!) && |
| 1265 | !(share->state.changed & (STATE_CHANGEDcxx . . $ `storage/maria/maria_def.h:1088:9`! | STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`! | |
| 1266 | STATE_IN_REPAIRcxx . . $ `storage/maria/maria_def.h:1098:9`!)) && |
| 1267 | share->state.open_count == 0) || |
| 1268 | ((param->testflagcxx . . $ st_handler_check_param#testflag. & T_FASTcxx . . $ `include/my_check_opt.h:39:9`!) && (share->state.open_count == |
| 1269 | (uint) (share->global_changed ? 1 : |
| 1270 | 0))))) |
| 1271 | return HA_ADMIN_ALREADY_DONEcxx . . $ `sql/handler.h:60:9`!; |
| 1272 | |
| 1273 | maria_chk_init_for_check(param, filecxx . . $ ha_maria#file.); |
| 1274 | param->max_allowed_lsncxx . . $ st_handler_check_param#max_allowed_lsn.= translog_get_horizon(); |
| 1275 | |
| 1276 | if ((filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.changed & (STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`! | STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!)) == |
| 1277 | STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!) |
| 1278 | { |
| 1279 | _ma_check_print_error(param, "%s", zerofill_error_msgcxx . . $ zerofill_error_msg.); |
| 1280 | return HA_ADMIN_CORRUPTcxx . . $ `sql/handler.h:64:9`!; |
| 1281 | } |
| 1282 | |
| 1283 | old_proc_info= thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Checking status"); |
| 1284 | thd_progress_init(thd, 3); |
| 1285 | error= maria_chk_status(param, filecxx . . $ ha_maria#file.); // Not fatal |
| 1286 | /* maria_chk_size() will flush the page cache for this file */ |
| 1287 | if (maria_chk_size(param, filecxx . . $ ha_maria#file.)) |
| 1288 | error= 1; |
| 1289 | if (!error) |
| 1290 | error|= maria_chk_del(param, filecxx . . $ ha_maria#file., param->testflagcxx . . $ st_handler_check_param#testflag.); |
| 1291 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Checking keys"); |
| 1292 | thd_progress_next_stage(thd); |
| 1293 | if (!error) |
| 1294 | error= maria_chk_key(param, filecxx . . $ ha_maria#file.); |
| 1295 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Checking data"); |
| 1296 | thd_progress_next_stage(thd); |
| 1297 | if (!error) |
| 1298 | { |
| 1299 | if ((!(param->testflagcxx . . $ st_handler_check_param#testflag. & T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!) && |
| 1300 | ((share->options & |
| 1301 | (HA_OPTION_PACK_RECORDcxx . . $ `include/my_base.h:344:9`! | HA_OPTION_COMPRESS_RECORDcxx . . $ `include/my_base.h:346:9`!)) || |
| 1302 | (param->testflagcxx . . $ st_handler_check_param#testflag. & (T_EXTENDcxx . . $ `include/my_check_opt.h:38:9`! | T_MEDIUMcxx . . $ `include/my_check_opt.h:44:9`!)))) || maria_is_crashedcxx . . $ `storage/maria/maria_def.h:1181:9`!(file)) |
| 1303 | { |
| 1304 | ulonglongcxx . . $ ulonglong# old_testflag= param->testflagcxx . . $ st_handler_check_param#testflag.; |
| 1305 | param->testflagcxx . . $ st_handler_check_param#testflag. |= T_MEDIUMcxx . . $ `include/my_check_opt.h:44:9`!; |
| 1306 | |
| 1307 | /* BLOCK_RECORD does not need a cache as it is using the page cache */ |
| 1308 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->data_file_type != BLOCK_RECORDcxx . . $ BLOCK_RECORD.) |
| 1309 | error= init_io_cache(¶m->read_cachecxx . . $ st_handler_check_param#read_cache., filecxx . . $ ha_maria#file.->dfilecxx . . $ st_maria_handler#dfile..file, |
| 1310 | my_default_record_cache_size, READ_CACHE, |
| 1311 | share->pack.header_length, 1, MYFcxx . . $ `include/my_global.h:986:9`!(MY_WMEcxx . . $ `include/my_sys.h:57:9`!)); |
| 1312 | if (!error) |
| 1313 | error= maria_chk_data_link(param, filecxx . . $ ha_maria#file., |
| 1314 | MY_TESTcxx . . $ `include/my_global.h:467:9`!(param->testflag & T_EXTENDcxx . . $ `include/my_check_opt.h:38:9`!)); |
| 1315 | |
| 1316 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->data_file_type != BLOCK_RECORDcxx . . $ BLOCK_RECORD.) |
| 1317 | end_io_cache(¶m->read_cachecxx . . $ st_handler_check_param#read_cache.); |
| 1318 | param->testflagcxx . . $ st_handler_check_param#testflag.= old_testflag; |
| 1319 | } |
| 1320 | } |
| 1321 | fatal_error= error; |
| 1322 | if (param->error_printedcxx . . $ st_handler_check_param#error_printed. && |
| 1323 | param->error_printedcxx . . $ st_handler_check_param#error_printed. == (param->skip_lsn_error_countcxx . . $ st_handler_check_param#skip_lsn_error_count. + |
| 1324 | param->not_visible_rows_foundcxx . . $ st_handler_check_param#not_visible_rows_found.) && |
| 1325 | !(share->state.changed & (STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`! | STATE_IN_REPAIRcxx . . $ `storage/maria/maria_def.h:1098:9`!))) |
| 1326 | { |
| 1327 | _ma_check_print_error(param, "%s", zerofill_error_msgcxx . . $ zerofill_error_msg.); |
| 1328 | /* This ensures that a future REPAIR TABLE will only do a zerofill */ |
| 1329 | filecxx . . $ ha_maria#file.->updatecxx . . $ st_maria_handler#update.|= STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!; |
| 1330 | share->state.changed|= STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!; |
| 1331 | fatal_error= 0; |
| 1332 | } |
| 1333 | if (!fatal_error) |
| 1334 | { |
| 1335 | if ((share->state.changed & (STATE_CHANGEDcxx . . $ `storage/maria/maria_def.h:1088:9`! | STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`! | |
| 1336 | STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`! | |
| 1337 | STATE_IN_REPAIRcxx . . $ `storage/maria/maria_def.h:1098:9`! | STATE_NOT_ANALYZEDcxx . . $ `storage/maria/maria_def.h:1091:9`!)) || |
| 1338 | (param->testflagcxx . . $ st_handler_check_param#testflag. & T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`!) || maria_is_crashedcxx . . $ `storage/maria/maria_def.h:1181:9`!(file)) |
| 1339 | { |
| 1340 | filecxx . . $ ha_maria#file.->updatecxx . . $ st_maria_handler#update. |= HA_STATE_CHANGEDcxx . . $ `include/my_base.h:617:9`! | HA_STATE_ROW_CHANGEDcxx . . $ `include/my_base.h:627:9`!; |
| 1341 | mysql_mutex_lockcxx . . $ `include/mysql/psi/mysql_thread.h:360:11`!(&share->intern_lock); |
| 1342 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", ("Resetting crashed state")); |
| 1343 | share->state.changed&= ~(STATE_CHANGEDcxx . . $ `storage/maria/maria_def.h:1088:9`! | STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`! | |
| 1344 | STATE_IN_REPAIRcxx . . $ `storage/maria/maria_def.h:1098:9`!); |
| 1345 | share->crash_error= 0; |
| 1346 | if (!(tablecxx . . $ handler#table.->db_statcxx . . $ TABLE#db_stat. & HA_READ_ONLYcxx . . $ `sql/handler.h:492:9`!)) |
| 1347 | { |
| 1348 | int tmp; |
| 1349 | if ((tmp= maria_update_state_info(param, filecxx . . $ ha_maria#file., |
| 1350 | UPDATE_TIMEcxx . . $ `storage/maria/maria_def.h:1613:9`! | UPDATE_OPEN_COUNTcxx . . $ `storage/maria/maria_def.h:1617:9`! | |
| 1351 | UPDATE_STATcxx . . $ `storage/maria/maria_def.h:1614:9`!))) |
| 1352 | error= tmp; |
| 1353 | } |
| 1354 | mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&share->intern_lock); |
| 1355 | infocxx . . $ ha_maria#info(4c679297bf94b9eb).(HA_STATUS_NO_LOCKcxx . . $ `include/my_base.h:421:9`! | HA_STATUS_TIMEcxx . . $ `include/my_base.h:423:9`! | HA_STATUS_VARIABLEcxx . . $ `include/my_base.h:436:9`! | |
| 1356 | HA_STATUS_CONSTcxx . . $ `include/my_base.h:430:9`!); |
| 1357 | |
| 1358 | /* |
| 1359 | Write a 'table is ok' message to error log if table is ok and |
| 1360 | we have written to error log that table was getting checked |
| 1361 | */ |
| 1362 | if (!error && !(tablecxx . . $ handler#table.->db_statcxx . . $ TABLE#db_stat. & HA_READ_ONLYcxx . . $ `sql/handler.h:492:9`!) && |
| 1363 | !maria_is_crashedcxx . . $ `storage/maria/maria_def.h:1181:9`!(file) && thd->error_printed_to_logcxx . . $ THD#error_printed_to_log. && |
| 1364 | (param->warning_printedcxx . . $ st_handler_check_param#warning_printed. || param->error_printedcxx . . $ st_handler_check_param#error_printed. || |
| 1365 | param->note_printedcxx . . $ st_handler_check_param#note_printed.)) |
| 1366 | _ma_check_print_info(param, "Table is fixed"); |
| 1367 | } |
| 1368 | } |
| 1369 | else if (!maria_is_crashedcxx . . $ `storage/maria/maria_def.h:1181:9`!(file) && !thd->killedcxx . . $ THD#killed.) |
| 1370 | { |
| 1371 | maria_mark_crashedcxx . . $ `storage/maria/maria_def.h:1160:9`!(file); |
| 1372 | filecxx . . $ ha_maria#file.->updatecxx . . $ st_maria_handler#update. |= HA_STATE_CHANGEDcxx . . $ `include/my_base.h:617:9`! | HA_STATE_ROW_CHANGEDcxx . . $ `include/my_base.h:627:9`!; |
| 1373 | } |
| 1374 | |
| 1375 | /* Reset trn, that may have been set by repair */ |
| 1376 | if (old_trn && old_trn != filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.) |
| 1377 | { |
| 1378 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(old_trn->used_instances == 0); |
| 1379 | _ma_set_trn_for_tablecxx . . $ _ma_set_trn_for_table(de0e2855de83418e).(filecxx . . $ ha_maria#file., old_trn); |
| 1380 | } |
| 1381 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, old_proc_info); |
| 1382 | thd_progress_end(thd); |
| 1383 | return error ? HA_ADMIN_CORRUPTcxx . . $ `sql/handler.h:64:9`! : HA_ADMIN_OKcxx . . $ `sql/handler.h:61:9`!; |
| 1384 | } |
| 1385 | |
| 1386 | |
| 1387 | /* |
| 1388 | Analyze the key distribution in the table |
| 1389 | As the table may be only locked for read, we have to take into account that |
| 1390 | two threads may do an analyze at the same time! |
| 1391 | */ |
| 1392 | |
| 1393 | int ha_mariacxx . . $ ha_maria#::analyzecxx . . $ ha_maria#analyze(95babc367ae08d43).(THDcxx . . $ THD# *thd, HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# * check_opt) |
| 1394 | { |
| 1395 | int error= 0; |
| 1396 | HA_CHECKcxx . . $ HA_CHECK# *param= thd->alloccxx . . $ Query_arena#alloc(4856804ddd09b9b2).<HA_CHECKcxx . . $ HA_CHECK#>(1); |
| 1397 | MARIA_SHARE *share= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.; |
| 1398 | const char *old_proc_info; |
| 1399 | |
| 1400 | if (!param) |
| 1401 | return HA_ADMIN_INTERNAL_ERRORcxx . . $ `sql/handler.h:65:9`!; |
| 1402 | |
| 1403 | maria_chk_init(param); |
| 1404 | param->thdcxx . . $ st_handler_check_param#thd.= thd; |
| 1405 | param->op_namecxx . . $ st_handler_check_param#op_name.= "analyze"; |
| 1406 | param->db_namecxx . . $ st_handler_check_param#db_name.= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->dbcxx . . $ TABLE_SHARE#db..str; |
| 1407 | param->table_namecxx . . $ st_handler_check_param#table_name.= tablecxx . . $ handler#table.->aliascxx . . $ TABLE#alias..c_ptrcxx . . $ Binary_string#c_ptr(41208ce6ca65dd58).(); |
| 1408 | param->testflagcxx . . $ st_handler_check_param#testflag.= (T_FASTcxx . . $ `include/my_check_opt.h:39:9`! | T_CHECKcxx . . $ `include/my_check_opt.h:33:9`! | T_SILENTcxx . . $ `include/my_check_opt.h:53:9`! | T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`! | |
| 1409 | T_DONT_CHECK_CHECKSUMcxx . . $ `include/my_check_opt.h:37:9`!); |
| 1410 | param->using_global_keycachecxx . . $ st_handler_check_param#using_global_keycache.= 1; |
| 1411 | param->stats_methodcxx . . $ st_handler_check_param#stats_method.= (enum_handler_stats_methodcxx . . $ enum_handler_stats_method#)THDVARcxx . . $ `include/mysql/plugin.h:529:9`!(thd,stats_method); |
| 1412 | |
| 1413 | if (!(share->state.changed & STATE_NOT_ANALYZEDcxx . . $ `storage/maria/maria_def.h:1091:9`!)) |
| 1414 | return HA_ADMIN_ALREADY_DONEcxx . . $ `sql/handler.h:60:9`!; |
| 1415 | |
| 1416 | old_proc_info= thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Scanning"); |
| 1417 | thd_progress_init(thd, 1); |
| 1418 | error= maria_chk_key(param, filecxx . . $ ha_maria#file.); |
| 1419 | if (!error) |
| 1420 | { |
| 1421 | mysql_mutex_lockcxx . . $ `include/mysql/psi/mysql_thread.h:360:11`!(&share->intern_lock); |
| 1422 | error= maria_update_state_info(param, filecxx . . $ ha_maria#file., UPDATE_STATcxx . . $ `storage/maria/maria_def.h:1614:9`!); |
| 1423 | mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&share->intern_lock); |
| 1424 | } |
| 1425 | else if (!maria_is_crashedcxx . . $ `storage/maria/maria_def.h:1181:9`!(file) && !thd->killedcxx . . $ THD#killed.) |
| 1426 | maria_mark_crashedcxx . . $ `storage/maria/maria_def.h:1160:9`!(file); |
| 1427 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, old_proc_info); |
| 1428 | thd_progress_end(thd); |
| 1429 | return error ? HA_ADMIN_CORRUPTcxx . . $ `sql/handler.h:64:9`! : HA_ADMIN_OKcxx . . $ `sql/handler.h:61:9`!; |
| 1430 | } |
| 1431 | |
| 1432 | int ha_mariacxx . . $ ha_maria#::repaircxx . . $ ha_maria#repair(95babc367ae08d43).(THDcxx . . $ THD# * thd, HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# *check_opt) |
| 1433 | { |
| 1434 | int error; |
| 1435 | HA_CHECKcxx . . $ HA_CHECK# *param= thd->alloccxx . . $ Query_arena#alloc(4856804ddd09b9b2).<HA_CHECKcxx . . $ HA_CHECK#>(1); |
| 1436 | ha_rowscxx . . $ ha_rows# start_records; |
| 1437 | const char *old_proc_info; |
| 1438 | |
| 1439 | if (!filecxx . . $ ha_maria#file. || !param) |
| 1440 | return HA_ADMIN_INTERNAL_ERRORcxx . . $ `sql/handler.h:65:9`!; |
| 1441 | |
| 1442 | maria_chk_init(param); |
| 1443 | param->thdcxx . . $ st_handler_check_param#thd.= thd; |
| 1444 | param->op_namecxx . . $ st_handler_check_param#op_name.= "repair"; |
| 1445 | filecxx . . $ ha_maria#file.->error_countcxx . . $ st_maria_handler#error_count.=0; |
| 1446 | |
| 1447 | /* |
| 1448 | The following can only be true if the table was marked as STATE_MOVED |
| 1449 | during a CHECK TABLE and the table has not been used since then |
| 1450 | */ |
| 1451 | if ((filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.changed & STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!) && |
| 1452 | !(filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.changed & STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`!)) |
| 1453 | { |
| 1454 | param->db_namecxx . . $ st_handler_check_param#db_name.= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->dbcxx . . $ TABLE_SHARE#db..str; |
| 1455 | param->table_namecxx . . $ st_handler_check_param#table_name.= tablecxx . . $ handler#table.->aliascxx . . $ TABLE#alias..c_ptrcxx . . $ Binary_string#c_ptr(41208ce6ca65dd58).(); |
| 1456 | param->testflagcxx . . $ st_handler_check_param#testflag.= check_opt->flagscxx . . $ st_ha_check_opt#flags.; |
| 1457 | _ma_check_print_info(param, "Running zerofill on moved table"); |
| 1458 | return zerofillcxx . . $ ha_maria#zerofill(95babc367ae08d43).(thd, check_opt); |
| 1459 | } |
| 1460 | |
| 1461 | param->testflagcxx . . $ st_handler_check_param#testflag.= ((check_opt->flagscxx . . $ st_ha_check_opt#flags. & ~(T_EXTENDcxx . . $ `include/my_check_opt.h:38:9`!)) | |
| 1462 | T_SILENTcxx . . $ `include/my_check_opt.h:53:9`! | T_FORCE_CREATEcxx . . $ `include/my_check_opt.h:40:9`! | T_CALC_CHECKSUMcxx . . $ `include/my_check_opt.h:32:9`! | |
| 1463 | (check_opt->flagscxx . . $ st_ha_check_opt#flags. & T_EXTENDcxx . . $ `include/my_check_opt.h:38:9`! ? T_REPcxx . . $ `include/my_check_opt.h:48:9`! : T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`!)); |
| 1464 | param->orig_sort_buffer_lengthcxx . . $ st_handler_check_param#orig_sort_buffer_length.= THDVARcxx . . $ `include/mysql/plugin.h:529:9`!(thd, sort_buffer_size); |
| 1465 | param->backup_timecxx . . $ st_handler_check_param#backup_time.= check_opt->start_timecxx . . $ st_ha_check_opt#start_time.; |
| 1466 | start_records= filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records; |
| 1467 | old_proc_info= thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Checking table"); |
| 1468 | thd_progress_init(thd, 1); |
| 1469 | while ((error= repaircxx . . $ ha_maria#repair(1d30702b6c0e54c5).(thd, param, 0)) && param->retry_repaircxx . . $ st_handler_check_param#retry_repair.) |
| 1470 | { |
| 1471 | param->retry_repaircxx . . $ st_handler_check_param#retry_repair.= 0; |
| 1472 | filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records= start_records; |
| 1473 | if (test_all_bitscxx . . $ `include/my_global.h:471:9`!(param->testflag, |
| 1474 | (uint) (T_RETRY_WITHOUT_QUICKcxx . . $ `include/my_check_opt.h:51:9`! | T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!))) |
| 1475 | { |
| 1476 | param->testflagcxx . . $ st_handler_check_param#testflag.&= ~(T_RETRY_WITHOUT_QUICKcxx . . $ `include/my_check_opt.h:51:9`! | T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!); |
| 1477 | /* Ensure we don't loose any rows when retrying without quick */ |
| 1478 | param->testflagcxx . . $ st_handler_check_param#testflag.|= T_SAFE_REPAIRcxx . . $ `include/my_check_opt.h:52:9`!; |
| 1479 | if (thd->vio_okcxx . . $ THD#vio_ok(50ce9a9e25b4a850).()) |
| 1480 | _ma_check_print_info(param, "Retrying repair without quick"); |
| 1481 | else |
| 1482 | sql_print_informationcxx . . $ sql_print_information(326aeb464d16410c).("Retrying repair of: '%s' without quick", |
| 1483 | tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->pathcxx . . $ TABLE_SHARE#path..str); |
| 1484 | continue; |
| 1485 | } |
| 1486 | param->testflagcxx . . $ st_handler_check_param#testflag. &= ~T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!; |
| 1487 | if (param->testflagcxx . . $ st_handler_check_param#testflag. & T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`!) |
| 1488 | { |
| 1489 | param->testflagcxx . . $ st_handler_check_param#testflag.= (param->testflagcxx . . $ st_handler_check_param#testflag. & ~T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`!) | T_REPcxx . . $ `include/my_check_opt.h:48:9`!; |
| 1490 | if (thd->vio_okcxx . . $ THD#vio_ok(50ce9a9e25b4a850).()) |
| 1491 | _ma_check_print_info(param, "Retrying repair with keycache"); |
| 1492 | sql_print_informationcxx . . $ sql_print_information(326aeb464d16410c).("Retrying repair of: '%s' with keycache", |
| 1493 | tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->pathcxx . . $ TABLE_SHARE#path..str); |
| 1494 | continue; |
| 1495 | } |
| 1496 | break; |
| 1497 | } |
| 1498 | /* |
| 1499 | Commit is needed in the case of tables are locked to ensure that repair |
| 1500 | is registered in the recovery log |
| 1501 | */ |
| 1502 | if (implicit_commitcxx . . $ ha_maria#implicit_commit(a4bb9b94410fc259).(thd, TRUEcxx . . $ `include/my_global.h:476:9`!)) |
| 1503 | error= HA_ADMIN_COMMIT_ERRORcxx . . $ `sql/handler.h:92:9`!; |
| 1504 | |
| 1505 | if (!error && start_records != filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records && |
| 1506 | !(check_opt->flagscxx . . $ st_ha_check_opt#flags. & T_VERY_SILENTcxx . . $ `include/my_check_opt.h:60:9`!)) |
| 1507 | { |
| 1508 | char llbuff[22], llbuff2[22]; |
| 1509 | sql_print_informationcxx . . $ sql_print_information(326aeb464d16410c).("Found %s of %s rows when repairing '%s'", |
| 1510 | llstr(filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records, llbuff), |
| 1511 | llstr(start_records, llbuff2), |
| 1512 | tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->pathcxx . . $ TABLE_SHARE#path..str); |
| 1513 | } |
| 1514 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, old_proc_info); |
| 1515 | thd_progress_end(thd); |
| 1516 | return error; |
| 1517 | } |
| 1518 | |
| 1519 | int ha_mariacxx . . $ ha_maria#::zerofillcxx . . $ ha_maria#zerofill(95babc367ae08d43).(THDcxx . . $ THD# * thd, HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# *check_opt) |
| 1520 | { |
| 1521 | int error; |
| 1522 | HA_CHECKcxx . . $ HA_CHECK# *param= thd->alloccxx . . $ Query_arena#alloc(4856804ddd09b9b2).<HA_CHECKcxx . . $ HA_CHECK#>(1); |
| 1523 | TRN *old_trn; |
| 1524 | MARIA_SHARE *share= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.; |
| 1525 | |
| 1526 | if (!filecxx . . $ ha_maria#file. || !param) |
| 1527 | return HA_ADMIN_INTERNAL_ERRORcxx . . $ `sql/handler.h:65:9`!; |
| 1528 | |
| 1529 | unmap_file(filecxx . . $ ha_maria#file.); |
| 1530 | old_trn= filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.; |
| 1531 | maria_chk_init(param); |
| 1532 | param->thdcxx . . $ st_handler_check_param#thd.= thd; |
| 1533 | param->op_namecxx . . $ st_handler_check_param#op_name.= "zerofill"; |
| 1534 | param->testflagcxx . . $ st_handler_check_param#testflag.= check_opt->flagscxx . . $ st_ha_check_opt#flags. | T_SILENTcxx . . $ `include/my_check_opt.h:53:9`! | T_ZEROFILLcxx . . $ `include/my_check_opt.h:63:9`!; |
| 1535 | param->orig_sort_buffer_lengthcxx . . $ st_handler_check_param#orig_sort_buffer_length.= THDVARcxx . . $ `include/mysql/plugin.h:529:9`!(thd, sort_buffer_size); |
| 1536 | param->db_namecxx . . $ st_handler_check_param#db_name.= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->dbcxx . . $ TABLE_SHARE#db..str; |
| 1537 | param->table_namecxx . . $ st_handler_check_param#table_name.= tablecxx . . $ handler#table.->aliascxx . . $ TABLE#alias..c_ptrcxx . . $ Binary_string#c_ptr(41208ce6ca65dd58).(); |
| 1538 | |
| 1539 | error=maria_zerofill(param, filecxx . . $ ha_maria#file., share->open_file_name.strcxx . . $ st_mysql_lex_string#str.); |
| 1540 | |
| 1541 | /* Reset trn, that may have been set by repair */ |
| 1542 | if (old_trn && old_trn != filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.) |
| 1543 | _ma_set_trn_for_tablecxx . . $ _ma_set_trn_for_table(de0e2855de83418e).(filecxx . . $ ha_maria#file., old_trn); |
| 1544 | |
| 1545 | if (!error) |
| 1546 | { |
| 1547 | TrID create_trid= trnman_get_min_safe_trid(); |
| 1548 | mysql_mutex_lockcxx . . $ `include/mysql/psi/mysql_thread.h:360:11`!(&share->intern_lock); |
| 1549 | share->state.changed|= STATE_NOT_MOVABLEcxx . . $ `storage/maria/maria_def.h:1096:9`!; |
| 1550 | maria_update_state_info(param, filecxx . . $ ha_maria#file., UPDATE_TIMEcxx . . $ `storage/maria/maria_def.h:1613:9`! | UPDATE_OPEN_COUNTcxx . . $ `storage/maria/maria_def.h:1617:9`!); |
| 1551 | _ma_update_state_lsns_sub(share, LSN_IMPOSSIBLEcxx . . $ `storage/maria/ma_loghandler_lsn.h:92:9`!, create_trid, |
| 1552 | TRUEcxx . . $ `include/my_global.h:476:9`!, TRUEcxx . . $ `include/my_global.h:476:9`!); |
| 1553 | mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&share->intern_lock); |
| 1554 | } |
| 1555 | return error; |
| 1556 | } |
| 1557 | |
| 1558 | int ha_mariacxx . . $ ha_maria#::optimizecxx . . $ ha_maria#optimize(95babc367ae08d43).(THDcxx . . $ THD# * thd, HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# *check_opt) |
| 1559 | { |
| 1560 | int error; |
| 1561 | HA_CHECKcxx . . $ HA_CHECK# *param= thd->alloccxx . . $ Query_arena#alloc(4856804ddd09b9b2).<HA_CHECKcxx . . $ HA_CHECK#>(1); |
| 1562 | |
| 1563 | if (!filecxx . . $ ha_maria#file. || !param) |
| 1564 | return HA_ADMIN_INTERNAL_ERRORcxx . . $ `sql/handler.h:65:9`!; |
| 1565 | |
| 1566 | maria_chk_init(param); |
| 1567 | param->thdcxx . . $ st_handler_check_param#thd.= thd; |
| 1568 | param->op_namecxx . . $ st_handler_check_param#op_name.= "optimize"; |
| 1569 | param->testflagcxx . . $ st_handler_check_param#testflag.= (check_opt->flagscxx . . $ st_ha_check_opt#flags. | T_SILENTcxx . . $ `include/my_check_opt.h:53:9`! | T_FORCE_CREATEcxx . . $ `include/my_check_opt.h:40:9`! | |
| 1570 | T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`! | T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`! | T_SORT_INDEXcxx . . $ `include/my_check_opt.h:54:9`!); |
| 1571 | param->orig_sort_buffer_lengthcxx . . $ st_handler_check_param#orig_sort_buffer_length.= THDVARcxx . . $ `include/mysql/plugin.h:529:9`!(thd, sort_buffer_size); |
| 1572 | thd_progress_init(thd, 1); |
| 1573 | if ((error= repaircxx . . $ ha_maria#repair(1d30702b6c0e54c5).(thd, param, 1)) && param->retry_repaircxx . . $ st_handler_check_param#retry_repair.) |
| 1574 | { |
| 1575 | sql_print_warningcxx . . $ sql_print_warning(326aeb464d16410c).("Warning: Optimize table got errno %d on %s.%s, retrying", |
| 1576 | my_errnocxx . . $ `include/my_pthread.h:720:9`!, param->db_namecxx . . $ st_handler_check_param#db_name., param->table_namecxx . . $ st_handler_check_param#table_name.); |
| 1577 | param->testflagcxx . . $ st_handler_check_param#testflag. &= ~T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`!; |
| 1578 | error= repaircxx . . $ ha_maria#repair(1d30702b6c0e54c5).(thd, param, 0); |
| 1579 | } |
| 1580 | thd_progress_end(thd); |
| 1581 | return error; |
| 1582 | } |
| 1583 | |
| 1584 | /* |
| 1585 | Set current_thd() for parallel worker thread |
| 1586 | */ |
| 1587 | |
| 1588 | C_MODE_STARTcxx . . $ `include/my_global.h:75:9`! |
| 1589 | void maria_setup_thd_for_repair_thread(void *arg) |
| 1590 | { |
| 1591 | THDcxx . . $ THD# *thd= (THDcxx . . $ THD#*) arg; |
| 1592 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(thd->shared_thd); |
| 1593 | set_current_thdcxx . . $ set_current_thd(4b9aaf75000f3009).(thd); |
| 1594 | } |
| 1595 | C_MODE_ENDcxx . . $ `include/my_global.h:76:9`! |
| 1596 | |
| 1597 | |
| 1598 | int ha_mariacxx . . $ ha_maria#::repaircxx . . $ ha_maria#repair(1d30702b6c0e54c5).(THDcxx . . $ THD# *thd, HA_CHECKcxx . . $ HA_CHECK# *param, bool do_optimize) |
| 1599 | { |
| 1600 | int error= 0; |
| 1601 | ulonglongcxx . . $ ulonglong# local_testflag= param->testflagcxx . . $ st_handler_check_param#testflag.; |
| 1602 | bool optimize_done= !do_optimize, statistics_done= 0, full_repair_done= 0; |
| 1603 | const char *old_proc_info= thd->proc_infocxx . . $ THD#proc_info.; |
| 1604 | char fixed_name[FN_REFLENcxx . . $ `include/my_global.h:603:9`!]; |
| 1605 | MARIA_SHARE *share= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.; |
| 1606 | ha_rowscxx . . $ ha_rows# rows= filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records; |
| 1607 | TRN *old_trn= filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.; |
| 1608 | my_boolcxx . . $ my_bool# locking= 0; |
| 1609 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::repair"); |
| 1610 | |
| 1611 | /* |
| 1612 | Normally this method is entered with a properly opened table. If the |
| 1613 | repair fails, it can be repeated with more elaborate options. Under |
| 1614 | special circumstances it can happen that a repair fails so that it |
| 1615 | closed the data file and cannot re-open it. In this case file->dfile |
| 1616 | is set to -1. We must not try another repair without an open data |
| 1617 | file. (Bug #25289) |
| 1618 | */ |
| 1619 | if (filecxx . . $ ha_maria#file.->dfilecxx . . $ st_maria_handler#dfile..file == -1) |
| 1620 | { |
| 1621 | sql_print_informationcxx . . $ sql_print_information(326aeb464d16410c).("Retrying repair of: '%s' failed. " |
| 1622 | "Please try REPAIR EXTENDED or aria_chk", |
| 1623 | tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->pathcxx . . $ TABLE_SHARE#path..str); |
| 1624 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ADMIN_FAILEDcxx . . $ `sql/handler.h:63:9`!); |
| 1625 | } |
| 1626 | |
| 1627 | /* |
| 1628 | If transactions was not enabled for a transactional table then |
| 1629 | file->s->status is not up to date. This is needed for repair_by_sort |
| 1630 | to work |
| 1631 | */ |
| 1632 | if (share->base.born_transactional && !share->now_transactional) |
| 1633 | _ma_copy_nontrans_state_information(filecxx . . $ ha_maria#file.); |
| 1634 | |
| 1635 | param->db_namecxx . . $ st_handler_check_param#db_name.= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->dbcxx . . $ TABLE_SHARE#db..str; |
| 1636 | param->table_namecxx . . $ st_handler_check_param#table_name.= tablecxx . . $ handler#table.->aliascxx . . $ TABLE#alias..c_ptrcxx . . $ Binary_string#c_ptr(41208ce6ca65dd58).(); |
| 1637 | param->tmpfile_createflagcxx . . $ st_handler_check_param#tmpfile_createflag.= O_RDWRcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:45:9`! | O_TRUNCcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:56:10`!; |
| 1638 | param->using_global_keycachecxx . . $ st_handler_check_param#using_global_keycache.= 1; |
| 1639 | param->thdcxx . . $ st_handler_check_param#thd.= thd; |
| 1640 | param->tmpdircxx . . $ st_handler_check_param#tmpdir.= &mysql_tmpdir_listcxx . . $ mysql_tmpdir_list.; |
| 1641 | param->out_flagcxx . . $ st_handler_check_param#out_flag.= 0; |
| 1642 | share->state.dupp_key= MI_MAX_KEYcxx . . $ `include/myisam.h:40:9`!; |
| 1643 | strmovcxx . . $ `include/m_string.h:70:9`!(fixed_name, share->open_file_name.str); |
| 1644 | unmap_file(filecxx . . $ ha_maria#file.); |
| 1645 | |
| 1646 | /* |
| 1647 | Don't lock tables if we have used LOCK TABLE or if we come from |
| 1648 | enable_index() |
| 1649 | */ |
| 1650 | if (!thd->locked_tables_modecxx . . $ Open_tables_state#locked_tables_mode. && ! (param->testflagcxx . . $ st_handler_check_param#testflag. & T_NO_LOCKScxx . . $ `include/my_check_opt.h:68:9`!)) |
| 1651 | { |
| 1652 | locking= 1; |
| 1653 | if (maria_lock_database(filecxx . . $ ha_maria#file., tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->tmp_tablecxx . . $ TABLE_SHARE#tmp_table. ? F_EXTRA_LCKcxx . . $ `storage/maria/maria_def.h:1073:9`! : F_WRLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:224:10`!)) |
| 1654 | { |
| 1655 | _ma_check_print_error(param, ER_THDcxx . . $ `sql/unireg.h:54:9`!(thd, ER_CANT_LOCKcxx . . $ `build/include/mysqld_error.h:20:9`!), my_errnocxx . . $ `include/my_pthread.h:720:9`!); |
| 1656 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ADMIN_FAILEDcxx . . $ `sql/handler.h:63:9`!); |
| 1657 | } |
| 1658 | } |
| 1659 | |
| 1660 | if (!do_optimize || |
| 1661 | (((share->data_file_type == BLOCK_RECORDcxx . . $ BLOCK_RECORD.) ? |
| 1662 | (share->state.changed & STATE_NOT_OPTIMIZED_ROWScxx . . $ `storage/maria/maria_def.h:1094:9`!) : |
| 1663 | (filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->del || |
| 1664 | share->state.split != filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records)) && |
| 1665 | (!(param->testflagcxx . . $ st_handler_check_param#testflag. & T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!) || |
| 1666 | (share->state.changed & (STATE_NOT_OPTIMIZED_KEYScxx . . $ `storage/maria/maria_def.h:1092:9`! | |
| 1667 | STATE_NOT_OPTIMIZED_ROWScxx . . $ `storage/maria/maria_def.h:1094:9`!))))) |
| 1668 | { |
| 1669 | ulonglongcxx . . $ ulonglong# key_map= ((local_testflag & T_CREATE_MISSING_KEYScxx . . $ `include/my_check_opt.h:35:9`!) ? |
| 1670 | maria_get_mask_all_keys_activecxx . . $ `storage/maria/maria_def.h:91:9`!(share->base.keys) : |
| 1671 | share->state.key_map); |
| 1672 | ulonglongcxx . . $ ulonglong# save_testflag= param->testflagcxx . . $ st_handler_check_param#testflag.; |
| 1673 | if (maria_test_if_sort_rep(filecxx . . $ ha_maria#file., filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records, key_map, 0) && |
| 1674 | (local_testflag & T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`!)) |
| 1675 | { |
| 1676 | local_testflag |= T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`!; |
| 1677 | param->testflagcxx . . $ st_handler_check_param#testflag. |= T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`!; // We get this for free |
| 1678 | statistics_done= 1; |
| 1679 | /* TODO: Remove BLOCK_RECORD test when parallel works with blocks */ |
| 1680 | if (THDVARcxx . . $ `include/mysql/plugin.h:529:9`!(thd,repair_threads) > 1 && |
| 1681 | share->data_file_type != BLOCK_RECORDcxx . . $ BLOCK_RECORD.) |
| 1682 | { |
| 1683 | char buf[40]; |
| 1684 | /* TODO: respect maria_repair_threads variable */ |
| 1685 | my_snprintf(buf, 40, "Repair with %d threads", my_count_bits(key_map)); |
| 1686 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, buf); |
| 1687 | param->testflagcxx . . $ st_handler_check_param#testflag.|= T_REP_PARALLELcxx . . $ `include/my_check_opt.h:50:9`!; |
| 1688 | /* |
| 1689 | Ensure that all threads are using the same THD. This is needed |
| 1690 | to get limit of tmp files to work |
| 1691 | */ |
| 1692 | param->init_repair_threadcxx . . $ st_handler_check_param#init_repair_thread.= maria_setup_thd_for_repair_thread; |
| 1693 | param->init_repair_thread_argcxx . . $ st_handler_check_param#init_repair_thread_arg.= tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use.; |
| 1694 | /* Mark that multiple threads are using the thd */ |
| 1695 | tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use.->shared_thdcxx . . $ THD#shared_thd.= 1; |
| 1696 | error= maria_repair_parallel(param, filecxx . . $ ha_maria#file., fixed_name, |
| 1697 | MY_TESTcxx . . $ `include/my_global.h:467:9`!(param->testflag & T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!)); |
| 1698 | tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use.->shared_thdcxx . . $ THD#shared_thd.= 0; |
| 1699 | /* to reset proc_info, as it was pointing to local buffer */ |
| 1700 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Repair done"); |
| 1701 | } |
| 1702 | else |
| 1703 | { |
| 1704 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Repair by sorting"); |
| 1705 | param->testflagcxx . . $ st_handler_check_param#testflag.|= T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`!; |
| 1706 | error= maria_repair_by_sort(param, filecxx . . $ ha_maria#file., fixed_name, |
| 1707 | MY_TESTcxx . . $ `include/my_global.h:467:9`!(param->testflag & T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!)); |
| 1708 | } |
| 1709 | if (error && filecxx . . $ ha_maria#file.->create_unique_index_by_sortcxx . . $ st_maria_handler#create_unique_index_by_sort. && |
| 1710 | share->state.dupp_key != MAX_KEYcxx . . $ `sql/sql_const.h:34:9`!) |
| 1711 | { |
| 1712 | my_errnocxx . . $ `include/my_pthread.h:720:9`!= HA_ERR_FOUND_DUPP_KEYcxx . . $ `include/my_base.h:467:9`!; |
| 1713 | maria_rrnd(filecxx . . $ ha_maria#file., tablecxx . . $ handler#table.->recordcxx . . $ TABLE#record.[0], filecxx . . $ ha_maria#file.->cur_rowcxx . . $ st_maria_handler#cur_row..lastpos); |
| 1714 | print_keydup_errorcxx . . $ print_keydup_error(7a9800894a494c43).(tablecxx . . $ handler#table., &tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info.[share->state.dupp_key], |
| 1715 | MYFcxx . . $ `include/my_global.h:986:9`!(0)); |
| 1716 | } |
| 1717 | } |
| 1718 | else |
| 1719 | { |
| 1720 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Repair with keycache"); |
| 1721 | param->testflagcxx . . $ st_handler_check_param#testflag. &= ~(T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`! | T_REP_PARALLELcxx . . $ `include/my_check_opt.h:50:9`!); |
| 1722 | error= maria_repair(param, filecxx . . $ ha_maria#file., fixed_name, |
| 1723 | MY_TESTcxx . . $ `include/my_global.h:467:9`!(param->testflag & T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!)); |
| 1724 | } |
| 1725 | param->testflagcxx . . $ st_handler_check_param#testflag.= save_testflag | (param->testflagcxx . . $ st_handler_check_param#testflag. & T_RETRY_WITHOUT_QUICKcxx . . $ `include/my_check_opt.h:51:9`!); |
| 1726 | optimize_done= 1; |
| 1727 | /* |
| 1728 | set full_repair_done if we re-wrote all rows and all keys |
| 1729 | (and thus removed all transid's from the table |
| 1730 | */ |
| 1731 | full_repair_done= !MY_TESTcxx . . $ `include/my_global.h:467:9`!(param->testflag & T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!); |
| 1732 | } |
| 1733 | if (!error) |
| 1734 | { |
| 1735 | if ((local_testflag & T_SORT_INDEXcxx . . $ `include/my_check_opt.h:54:9`!) && |
| 1736 | (share->state.changed & STATE_NOT_SORTED_PAGEScxx . . $ `storage/maria/maria_def.h:1093:9`!)) |
| 1737 | { |
| 1738 | optimize_done= 1; |
| 1739 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Sorting index"); |
| 1740 | error= maria_sort_index(param, filecxx . . $ ha_maria#file., fixed_name); |
| 1741 | } |
| 1742 | if (!error && !statistics_done && (local_testflag & T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`!)) |
| 1743 | { |
| 1744 | if (share->state.changed & STATE_NOT_ANALYZEDcxx . . $ `storage/maria/maria_def.h:1091:9`!) |
| 1745 | { |
| 1746 | optimize_done= 1; |
| 1747 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Analyzing"); |
| 1748 | error= maria_chk_key(param, filecxx . . $ ha_maria#file.); |
| 1749 | } |
| 1750 | else |
| 1751 | local_testflag &= ~T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`!; // Don't update statistics |
| 1752 | } |
| 1753 | } |
| 1754 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Saving state"); |
| 1755 | if (full_repair_done && !error && |
| 1756 | !(param->testflagcxx . . $ st_handler_check_param#testflag. & T_NO_CREATE_RENAME_LSNcxx . . $ `include/my_check_opt.h:66:9`!)) |
| 1757 | { |
| 1758 | /* Set trid (needed if the table was moved from another system) */ |
| 1759 | share->state.create_trid= trnman_get_min_safe_trid(); |
| 1760 | } |
| 1761 | |
| 1762 | /* |
| 1763 | Leaving not-zero value here leads to crash in the following |
| 1764 | maria_delete() particularly when we execute REPAIR TABLE partitioned_t;. |
| 1765 | */ |
| 1766 | filecxx . . $ ha_maria#file.->cur_rowcxx . . $ st_maria_handler#cur_row..trid= 0; |
| 1767 | |
| 1768 | mysql_mutex_lockcxx . . $ `include/mysql/psi/mysql_thread.h:360:11`!(&share->intern_lock); |
| 1769 | if (!error) |
| 1770 | { |
| 1771 | if ((share->state.changed & STATE_CHANGEDcxx . . $ `storage/maria/maria_def.h:1088:9`!) || maria_is_crashedcxx . . $ `storage/maria/maria_def.h:1181:9`!(file)) |
| 1772 | { |
| 1773 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", ("Resetting crashed state")); |
| 1774 | share->state.changed&= ~(STATE_CHANGEDcxx . . $ `storage/maria/maria_def.h:1088:9`! | STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`! | |
| 1775 | STATE_IN_REPAIRcxx . . $ `storage/maria/maria_def.h:1098:9`! | STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!); |
| 1776 | share->crash_error= 0; |
| 1777 | filecxx . . $ ha_maria#file.->updatecxx . . $ st_maria_handler#update. |= HA_STATE_CHANGEDcxx . . $ `include/my_base.h:617:9`! | HA_STATE_ROW_CHANGEDcxx . . $ `include/my_base.h:627:9`!; |
| 1778 | } |
| 1779 | /* |
| 1780 | repair updates share->state.state. Ensure that file->state is up to date |
| 1781 | */ |
| 1782 | if (filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state. != &share->state.state) |
| 1783 | *filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.= share->state.state; |
| 1784 | |
| 1785 | if (share->base.auto_key) |
| 1786 | _ma_update_auto_increment_key(param, filecxx . . $ ha_maria#file., 1); |
| 1787 | if (optimize_done) |
| 1788 | error= maria_update_state_info(param, filecxx . . $ ha_maria#file., |
| 1789 | UPDATE_TIMEcxx . . $ `storage/maria/maria_def.h:1613:9`! | UPDATE_OPEN_COUNTcxx . . $ `storage/maria/maria_def.h:1617:9`! | |
| 1790 | (local_testflag & |
| 1791 | T_STATISTICScxx . . $ `include/my_check_opt.h:56:9`! ? UPDATE_STATcxx . . $ `storage/maria/maria_def.h:1614:9`! : 0)); |
| 1792 | /* File is repaired; Mark the file as moved to this system */ |
| 1793 | (void) _ma_set_uuid(share, 0); |
| 1794 | |
| 1795 | infocxx . . $ ha_maria#info(4c679297bf94b9eb).(HA_STATUS_NO_LOCKcxx . . $ `include/my_base.h:421:9`! | HA_STATUS_TIMEcxx . . $ `include/my_base.h:423:9`! | HA_STATUS_VARIABLEcxx . . $ `include/my_base.h:436:9`! | |
| 1796 | HA_STATUS_CONSTcxx . . $ `include/my_base.h:430:9`!); |
| 1797 | if (rows != filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records && !(param->testflagcxx . . $ st_handler_check_param#testflag. & T_VERY_SILENTcxx . . $ `include/my_check_opt.h:60:9`!)) |
| 1798 | { |
| 1799 | char llbuff[22], llbuff2[22]; |
| 1800 | _ma_check_print_warning(param, "Number of rows changed from %s to %s", |
| 1801 | llstr(rows, llbuff), |
| 1802 | llstr(filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records, llbuff2)); |
| 1803 | /* |
| 1804 | ma_check_print_warning() may generate an error in case of creating keys |
| 1805 | for ALTER TABLE. In this case we should signal an error. |
| 1806 | */ |
| 1807 | error= thd->is_errorcxx . . $ THD#is_error(50ce9a9e25b4a850).(); |
| 1808 | } |
| 1809 | } |
| 1810 | else |
| 1811 | { |
| 1812 | maria_mark_crashed_on_repaircxx . . $ `storage/maria/maria_def.h:1169:9`!(file); |
| 1813 | filecxx . . $ ha_maria#file.->updatecxx . . $ st_maria_handler#update. |= HA_STATE_CHANGEDcxx . . $ `include/my_base.h:617:9`! | HA_STATE_ROW_CHANGEDcxx . . $ `include/my_base.h:627:9`!; |
| 1814 | maria_update_state_info(param, filecxx . . $ ha_maria#file., 0); |
| 1815 | } |
| 1816 | mysql_mutex_unlockcxx . . $ `include/mysql/psi/mysql_thread.h:391:11`!(&share->intern_lock); |
| 1817 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, old_proc_info); |
| 1818 | thd_progress_end(thd); // Mark done |
| 1819 | if (locking) |
| 1820 | maria_lock_database(filecxx . . $ ha_maria#file., F_UNLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:225:10`!); |
| 1821 | |
| 1822 | /* Reset trn, that may have been set by repair */ |
| 1823 | if (old_trn && old_trn != filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.) |
| 1824 | _ma_set_trn_for_tablecxx . . $ _ma_set_trn_for_table(de0e2855de83418e).(filecxx . . $ ha_maria#file., old_trn); |
| 1825 | error= error ? HA_ADMIN_FAILEDcxx . . $ `sql/handler.h:63:9`! : |
| 1826 | (optimize_done ? |
| 1827 | (write_log_record_for_repair(param, filecxx . . $ ha_maria#file.) ? HA_ADMIN_FAILEDcxx . . $ `sql/handler.h:63:9`! : |
| 1828 | HA_ADMIN_OKcxx . . $ `sql/handler.h:61:9`!) : HA_ADMIN_ALREADY_DONEcxx . . $ `sql/handler.h:60:9`!); |
| 1829 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error); |
| 1830 | } |
| 1831 | |
| 1832 | |
| 1833 | /* |
| 1834 | Assign table indexes to a specific key cache. |
| 1835 | */ |
| 1836 | |
| 1837 | int ha_mariacxx . . $ ha_maria#::assign_to_keycachecxx . . $ ha_maria#assign_to_keycache(95babc367ae08d43).(THDcxx . . $ THD# * thd, HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# *check_opt) |
| 1838 | { |
| 1839 | #if 0 && NOT_IMPLEMENTED |
| 1840 | PAGECACHE *new_pagecache= check_opt->pagecache; |
| 1841 | const char *errmsg= 0; |
| 1842 | int error= HA_ADMIN_OK; |
| 1843 | ulonglong map; |
| 1844 | TABLE_LIST *table_list= table->pos_in_table_list; |
| 1845 | DBUG_ENTER("ha_maria::assign_to_keycache"); |
| 1846 | |
| 1847 | table->keys_in_use_for_query.clear_all(); |
| 1848 | |
| 1849 | if (table_list->process_index_hints(table)) |
| 1850 | DBUG_RETURN(HA_ADMIN_FAILED); |
| 1851 | map= ~(ulonglong) 0; |
| 1852 | if (!table->keys_in_use_for_query.is_clear_all()) |
| 1853 | /* use all keys if there's no list specified by the user through hints */ |
| 1854 | map= table->keys_in_use_for_query.to_ulonglong(); |
| 1855 | |
| 1856 | if ((error= maria_assign_to_pagecache(file, map, new_pagecache))) |
| 1857 | { |
| 1858 | char buf[STRING_BUFFER_USUAL_SIZE]; |
| 1859 | my_snprintf(buf, sizeof(buf), |
| 1860 | "Failed to flush to index file (errno: %d)", error); |
| 1861 | errmsg= buf; |
| 1862 | error= HA_ADMIN_CORRUPT; |
| 1863 | } |
| 1864 | |
| 1865 | if (error != HA_ADMIN_OK) |
| 1866 | { |
| 1867 | /* Send error to user */ |
| 1868 | HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param); |
| 1869 | if (!param) |
| 1870 | return HA_ADMIN_INTERNAL_ERROR; |
| 1871 | |
| 1872 | maria_chk_init(param); |
| 1873 | param->thd= thd; |
| 1874 | param->op_name= "assign_to_keycache"; |
| 1875 | param->db_name= table->s->db.str; |
| 1876 | param->table_name= table->s->table_name.str; |
| 1877 | param->testflag= 0; |
| 1878 | _ma_check_print_error(param, errmsg); |
| 1879 | } |
| 1880 | DBUG_RETURN(error); |
| 1881 | #else |
| 1882 | return HA_ADMIN_NOT_IMPLEMENTEDcxx . . $ `sql/handler.h:62:9`!; |
| 1883 | #endif |
| 1884 | } |
| 1885 | |
| 1886 | |
| 1887 | /* |
| 1888 | Preload pages of the index file for a table into the key cache. |
| 1889 | */ |
| 1890 | |
| 1891 | int ha_mariacxx . . $ ha_maria#::preload_keyscxx . . $ ha_maria#preload_keys(95babc367ae08d43).(THDcxx . . $ THD# * thd, HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# *check_opt) |
| 1892 | { |
| 1893 | ulonglongcxx . . $ ulonglong# map; |
| 1894 | TABLE_LISTcxx . . $ TABLE_LIST# *table_list= tablecxx . . $ handler#table.->pos_in_table_listcxx . . $ TABLE#pos_in_table_list.; |
| 1895 | |
| 1896 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::preload_keys"); |
| 1897 | |
| 1898 | tablecxx . . $ handler#table.->keys_in_use_for_querycxx . . $ TABLE#keys_in_use_for_query..clear_allcxx . . $ Bitmap#clear_all(49f6e7a06ebc5aa8).(); |
| 1899 | |
| 1900 | if (table_list->process_index_hintscxx . . $ TABLE_LIST#process_index_hints(4b0aed1a3db11a8e).(tablecxx . . $ handler#table.)) |
| 1901 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ADMIN_FAILEDcxx . . $ `sql/handler.h:63:9`!); |
| 1902 | |
| 1903 | map= ~(ulonglongcxx . . $ ulonglong#) 0; |
| 1904 | /* Check validity of the index references */ |
| 1905 | if (!tablecxx . . $ handler#table.->keys_in_use_for_querycxx . . $ TABLE#keys_in_use_for_query..is_clear_allcxx . . $ Bitmap#is_clear_all(50ce9a9e25b4a850).()) |
| 1906 | /* use all keys if there's no list specified by the user through hints */ |
| 1907 | map= tablecxx . . $ handler#table.->keys_in_use_for_querycxx . . $ TABLE#keys_in_use_for_query..to_ulonglongcxx . . $ Bitmap#to_ulonglong(1c5fc1fd41a99ae7).(); |
| 1908 | |
| 1909 | maria_extra(filecxx . . $ ha_maria#file., HA_EXTRA_PRELOAD_BUFFER_SIZEcxx . . $ HA_EXTRA_PRELOAD_BUFFER_SIZE., |
| 1910 | (void*) &thd->variablescxx . . $ THD#variables..preload_buff_sizecxx . . $ system_variables#preload_buff_size.); |
| 1911 | |
| 1912 | int error; |
| 1913 | |
| 1914 | if ((error= maria_preload(filecxx . . $ ha_maria#file., map, table_list->ignore_leavescxx . . $ TABLE_LIST#ignore_leaves.))) |
| 1915 | { |
| 1916 | char buf[MYSQL_ERRMSG_SIZEcxx . . $ `include/mysql_com.h:435:9`!+20]; |
| 1917 | const char *errmsg; |
| 1918 | |
| 1919 | switch (error) { |
| 1920 | case HA_ERR_NON_UNIQUE_BLOCK_SIZEcxx . . $ `include/my_base.h:499:9`!: |
| 1921 | errmsg= "Indexes use different block sizes"; |
| 1922 | break; |
| 1923 | case HA_ERR_OUT_OF_MEMcxx . . $ `include/my_base.h:473:9`!: |
| 1924 | errmsg= "Failed to allocate buffer"; |
| 1925 | break; |
| 1926 | default: |
| 1927 | my_snprintf(buf, sizeof(buf), |
| 1928 | "Failed to read from index file (errno: %d)", my_errnocxx . . $ `include/my_pthread.h:720:9`!); |
| 1929 | errmsg= buf; |
| 1930 | } |
| 1931 | |
| 1932 | HA_CHECKcxx . . $ HA_CHECK# *param= thd->alloccxx . . $ Query_arena#alloc(4856804ddd09b9b2).<HA_CHECKcxx . . $ HA_CHECK#>(1); |
| 1933 | if (!param) |
| 1934 | return HA_ADMIN_INTERNAL_ERRORcxx . . $ `sql/handler.h:65:9`!; |
| 1935 | |
| 1936 | maria_chk_init(param); |
| 1937 | param->thdcxx . . $ st_handler_check_param#thd.= thd; |
| 1938 | param->op_namecxx . . $ st_handler_check_param#op_name.= "preload_keys"; |
| 1939 | param->db_namecxx . . $ st_handler_check_param#db_name.= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->dbcxx . . $ TABLE_SHARE#db..str; |
| 1940 | param->table_namecxx . . $ st_handler_check_param#table_name.= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->table_namecxx . . $ TABLE_SHARE#table_name..str; |
| 1941 | param->testflagcxx . . $ st_handler_check_param#testflag.= 0; |
| 1942 | _ma_check_print_error(param, "%s", errmsg); |
| 1943 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ADMIN_FAILEDcxx . . $ `sql/handler.h:63:9`!); |
| 1944 | } |
| 1945 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(HA_ADMIN_OKcxx . . $ `sql/handler.h:61:9`!); |
| 1946 | } |
| 1947 | |
| 1948 | |
| 1949 | /* |
| 1950 | Disable indexes, making it persistent if requested. |
| 1951 | |
| 1952 | SYNOPSIS |
| 1953 | disable_indexes() |
| 1954 | |
| 1955 | DESCRIPTION |
| 1956 | See handler::ha_disable_indexes() |
| 1957 | |
| 1958 | RETURN |
| 1959 | 0 ok |
| 1960 | HA_ERR_WRONG_COMMAND mode not implemented. |
| 1961 | */ |
| 1962 | |
| 1963 | int ha_mariacxx . . $ ha_maria#::disable_indexescxx . . $ ha_maria#disable_indexes(f5cd2bccb9a33102).(key_mapcxx . . $ key_map# map, bool persist) |
| 1964 | { |
| 1965 | int error; |
| 1966 | |
| 1967 | if (!persist) |
| 1968 | { |
| 1969 | /* call a storage engine function to switch the key map */ |
| 1970 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(map.is_clear_all()); |
| 1971 | error= maria_disable_indexes(filecxx . . $ ha_maria#file.); |
| 1972 | } |
| 1973 | else |
| 1974 | { |
| 1975 | /* auto-inc key cannot be disabled */ |
| 1976 | if (tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->next_number_indexcxx . . $ TABLE_SHARE#next_number_index. < MAX_KEYcxx . . $ `sql/sql_const.h:34:9`!) |
| 1977 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(map.is_set(table->s->next_number_index)); |
| 1978 | |
| 1979 | /* unique keys cannot be disabled either */ |
| 1980 | for (uint i=0; i < tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->keyscxx . . $ TABLE_SHARE#keys.; i++) |
| 1981 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(!(table->key_info[i].flags & HA_NOSAME) || map.is_set(i)); |
| 1982 | |
| 1983 | ulonglongcxx . . $ ulonglong# ullmap= map.to_ulonglongcxx . . $ Bitmap#to_ulonglong(1c5fc1fd41a99ae7).(); |
| 1984 | |
| 1985 | /* make sure auto-inc key is enabled even if it's > 64 */ |
| 1986 | if (map.lengthcxx . . $ Bitmap#length(ddd8539a2fcdd4ce).() > MARIA_KEYMAP_BITScxx . . $ `storage/maria/maria_def.h:89:9`! && |
| 1987 | tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->next_number_indexcxx . . $ TABLE_SHARE#next_number_index. < MAX_KEYcxx . . $ `sql/sql_const.h:34:9`!) |
| 1988 | maria_set_key_activecxx . . $ `storage/maria/maria_def.h:111:9`!(ullmap, table->s->next_number_index); |
| 1989 | |
| 1990 | maria_extra(filecxx . . $ ha_maria#file., HA_EXTRA_NO_KEYScxx . . $ HA_EXTRA_NO_KEYS., &ullmap); |
| 1991 | infocxx . . $ ha_maria#info(4c679297bf94b9eb).(HA_STATUS_CONSTcxx . . $ `include/my_base.h:430:9`!); // Read new key info |
| 1992 | error= 0; |
| 1993 | } |
| 1994 | return error; |
| 1995 | } |
| 1996 | |
| 1997 | |
| 1998 | /* |
| 1999 | Enable indexes, making it persistent if requested. |
| 2000 | |
| 2001 | SYNOPSIS |
| 2002 | enable_indexes() |
| 2003 | |
| 2004 | DESCRIPTION |
| 2005 | Enable indexes, which might have been disabled by disable_index() before. |
| 2006 | If persist=false, it works only if both data and indexes are empty, |
| 2007 | since the Aria repair would enable them persistently. |
| 2008 | To be sure in these cases, call handler::delete_all_rows() before. |
| 2009 | |
| 2010 | See also handler::ha_enable_indexes() |
| 2011 | |
| 2012 | RETURN |
| 2013 | 0 ok |
| 2014 | !=0 Error, among others: |
| 2015 | HA_ERR_CRASHED data or index is non-empty. Delete all rows and retry. |
| 2016 | HA_ERR_WRONG_COMMAND mode not implemented. |
| 2017 | */ |
| 2018 | |
| 2019 | int ha_mariacxx . . $ ha_maria#::enable_indexescxx . . $ ha_maria#enable_indexes(f5cd2bccb9a33102).(key_mapcxx . . $ key_map# map, bool persist) |
| 2020 | { |
| 2021 | int error; |
| 2022 | ha_rowscxx . . $ ha_rows# start_rows= filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records; |
| 2023 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", ("ha_maria::enable_indexes mode: %d", persist)); |
| 2024 | if (maria_is_all_keys_activecxx . . $ `storage/maria/maria_def.h:118:9`!(file->s->state.key_map, file->s->base.keys)) |
| 2025 | { |
| 2026 | /* All indexes are enabled already. */ |
| 2027 | return 0; |
| 2028 | } |
| 2029 | |
| 2030 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(map.is_prefix(table->s->keys)); |
| 2031 | if (!persist) |
| 2032 | { |
| 2033 | error= maria_enable_indexes(filecxx . . $ ha_maria#file.); |
| 2034 | /* |
| 2035 | Do not try to repair on error, |
| 2036 | as this could make the enabled state persistent, |
| 2037 | but mode==HA_KEY_SWITCH_ALL forbids it. |
| 2038 | */ |
| 2039 | } |
| 2040 | else |
| 2041 | { |
| 2042 | THDcxx . . $ THD# *thd= tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use.; |
| 2043 | HA_CHECKcxx . . $ HA_CHECK# *param= thd->alloccxx . . $ Query_arena#alloc(4856804ddd09b9b2).<HA_CHECKcxx . . $ HA_CHECK#>(1); |
| 2044 | if (!param) |
| 2045 | return HA_ADMIN_INTERNAL_ERRORcxx . . $ `sql/handler.h:65:9`!; |
| 2046 | |
| 2047 | const char *save_proc_info= thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, "Creating index"); |
| 2048 | |
| 2049 | maria_chk_init(param); |
| 2050 | param->op_namecxx . . $ st_handler_check_param#op_name.= "recreating_index"; |
| 2051 | param->testflagcxx . . $ st_handler_check_param#testflag.= (T_SILENTcxx . . $ `include/my_check_opt.h:53:9`! | T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`! | T_QUICKcxx . . $ `include/my_check_opt.h:46:9`! | |
| 2052 | T_CREATE_MISSING_KEYScxx . . $ `include/my_check_opt.h:35:9`! | T_SAFE_REPAIRcxx . . $ `include/my_check_opt.h:52:9`!); |
| 2053 | /* |
| 2054 | Don't lock and unlock table if it's locked. |
| 2055 | Normally table should be locked. This test is mostly for safety. |
| 2056 | */ |
| 2057 | if (likelycxx . . $ `include/my_global.h:360:9`!(file->lock_type != F_UNLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:225:10`!)) |
| 2058 | param->testflagcxx . . $ st_handler_check_param#testflag.|= T_NO_LOCKScxx . . $ `include/my_check_opt.h:68:9`!; |
| 2059 | |
| 2060 | if (filecxx . . $ ha_maria#file.->create_unique_index_by_sortcxx . . $ st_maria_handler#create_unique_index_by_sort.) |
| 2061 | param->testflagcxx . . $ st_handler_check_param#testflag.|= T_CREATE_UNIQUE_BY_SORTcxx . . $ `include/my_check_opt.h:69:9`!; |
| 2062 | |
| 2063 | if (bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo. == BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIRcxx . . $ `storage/maria/ha_maria.cc:965:9`!) |
| 2064 | { |
| 2065 | bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo.= BULK_INSERT_SINGLE_UNDO_AND_REPAIRcxx . . $ `storage/maria/ha_maria.cc:960:9`!; |
| 2066 | /* |
| 2067 | Don't bump create_rename_lsn, because UNDO_BULK_INSERT |
| 2068 | should not be skipped in case of crash during repair. |
| 2069 | */ |
| 2070 | param->testflagcxx . . $ st_handler_check_param#testflag.|= T_NO_CREATE_RENAME_LSNcxx . . $ `include/my_check_opt.h:66:9`!; |
| 2071 | } |
| 2072 | |
| 2073 | param->myf_rwcxx . . $ st_handler_check_param#myf_rw. &= ~MY_WAIT_IF_FULLcxx . . $ `include/my_sys.h:58:9`!; |
| 2074 | param->orig_sort_buffer_lengthcxx . . $ st_handler_check_param#orig_sort_buffer_length.= THDVARcxx . . $ `include/mysql/plugin.h:529:9`!(thd,sort_buffer_size); |
| 2075 | param->stats_methodcxx . . $ st_handler_check_param#stats_method.= (enum_handler_stats_methodcxx . . $ enum_handler_stats_method#)THDVARcxx . . $ `include/mysql/plugin.h:529:9`!(thd,stats_method); |
| 2076 | param->tmpdircxx . . $ st_handler_check_param#tmpdir.= &mysql_tmpdir_listcxx . . $ mysql_tmpdir_list.; |
| 2077 | |
| 2078 | /* |
| 2079 | Don't retry repair if we get duplicate key error if |
| 2080 | create_unique_index_by_sort is enabled |
| 2081 | This can be set when doing an ALTER TABLE and enabling unique keys |
| 2082 | */ |
| 2083 | if ((error= (repaircxx . . $ ha_maria#repair(1d30702b6c0e54c5).(thd, param, 0) != HA_ADMIN_OKcxx . . $ `sql/handler.h:61:9`!)) && param->retry_repaircxx . . $ st_handler_check_param#retry_repair. && |
| 2084 | !filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->internal_table && |
| 2085 | (my_errnocxx . . $ `include/my_pthread.h:720:9`! != HA_ERR_FOUND_DUPP_KEYcxx . . $ `include/my_base.h:467:9`! || |
| 2086 | !filecxx . . $ ha_maria#file.->create_unique_index_by_sortcxx . . $ st_maria_handler#create_unique_index_by_sort.)) |
| 2087 | { |
| 2088 | sql_print_warningcxx . . $ sql_print_warning(326aeb464d16410c).("Warning: Enabling keys got errno %d on %s, " |
| 2089 | "retrying", |
| 2090 | my_errnocxx . . $ `include/my_pthread.h:720:9`!, filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->open_file_name.strcxx . . $ st_mysql_lex_string#str.); |
| 2091 | /* Repairing by sort failed. Now try standard repair method. */ |
| 2092 | param->testflagcxx . . $ st_handler_check_param#testflag. &= ~T_REP_BY_SORTcxx . . $ `include/my_check_opt.h:49:9`!; |
| 2093 | filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records= start_rows; |
| 2094 | error= (repaircxx . . $ ha_maria#repair(1d30702b6c0e54c5).(thd, param, 0) != HA_ADMIN_OKcxx . . $ `sql/handler.h:61:9`!); |
| 2095 | /* |
| 2096 | If the standard repair succeeded, clear all error messages which |
| 2097 | might have been set by the first repair. They can still be seen |
| 2098 | with SHOW WARNINGS then. |
| 2099 | */ |
| 2100 | if (!error) |
| 2101 | thd->clear_errorcxx . . $ THD#clear_error(b45ddcbc8423892c).(); |
| 2102 | } |
| 2103 | infocxx . . $ ha_maria#info(4c679297bf94b9eb).(HA_STATUS_CONSTcxx . . $ `include/my_base.h:430:9`!); |
| 2104 | thd_proc_infocxx . . $ `include/mysql/service_progress_report.h:32:9`!(thd, save_proc_info); |
| 2105 | } |
| 2106 | DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("maria_flush_whole_log", |
| 2107 | { |
| 2108 | DBUG_PRINT("maria_flush_whole_log", ("now")); |
| 2109 | translog_flush(translog_get_horizon()); |
| 2110 | }); |
| 2111 | DBUG_EXECUTE_IFcxx . . $ `include/my_dbug.h:172:9`!("maria_crash_enable_index", |
| 2112 | { |
| 2113 | DBUG_PRINT("maria_crash_enable_index", ("now")); |
| 2114 | DBUG_SUICIDE(); |
| 2115 | }); |
| 2116 | return error; |
| 2117 | } |
| 2118 | |
| 2119 | |
| 2120 | /* |
| 2121 | Test if indexes are disabled. |
| 2122 | |
| 2123 | |
| 2124 | SYNOPSIS |
| 2125 | indexes_are_disabled() |
| 2126 | no parameters |
| 2127 | |
| 2128 | |
| 2129 | RETURN |
| 2130 | 0 indexes are not disabled |
| 2131 | 1 all indexes are disabled |
| 2132 | [2 non-unique indexes are disabled - NOT YET IMPLEMENTED] |
| 2133 | */ |
| 2134 | |
| 2135 | int ha_mariacxx . . $ ha_maria#::indexes_are_disabledcxx . . $ ha_maria#indexes_are_disabled(b126dc7c1de90089).(void) |
| 2136 | { |
| 2137 | return maria_indexes_are_disabled(filecxx . . $ ha_maria#file.); |
| 2138 | } |
| 2139 | |
| 2140 | |
| 2141 | /* |
| 2142 | prepare for a many-rows insert operation |
| 2143 | e.g. - disable indexes (if they can be recreated fast) or |
| 2144 | activate special bulk-insert optimizations |
| 2145 | |
| 2146 | SYNOPSIS |
| 2147 | start_bulk_insert(rows, flags) |
| 2148 | rows Rows to be inserted |
| 2149 | 0 if we don't know |
| 2150 | flags Flags to control index creation |
| 2151 | |
| 2152 | NOTICE |
| 2153 | Do not forget to call end_bulk_insert() later! |
| 2154 | */ |
| 2155 | |
| 2156 | void ha_mariacxx . . $ ha_maria#::start_bulk_insertcxx . . $ ha_maria#start_bulk_insert(b6e2c5f8c0be9008).(ha_rowscxx . . $ ha_rows# rows, uint flags) |
| 2157 | { |
| 2158 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::start_bulk_insert"); |
| 2159 | THDcxx . . $ THD# *thd= tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use.; |
| 2160 | MARIA_SHARE *share= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.; |
| 2161 | bool index_disabled= 0; |
| 2162 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", ("start_bulk_insert: rows %lu", (ulong) rows)); |
| 2163 | |
| 2164 | /* don't enable row cache if too few rows */ |
| 2165 | if ((!rows || rows > MARIA_MIN_ROWS_TO_USE_WRITE_CACHEcxx . . $ `storage/maria/maria_def.h:1260:9`!) && !has_long_uniquecxx . . $ handler#has_long_unique(c9857a73d68e59ba).()) |
| 2166 | { |
| 2167 | ulonglongcxx . . $ ulonglong# size= thd->variablescxx . . $ THD#variables..read_buff_sizecxx . . $ system_variables#read_buff_size., tmp; |
| 2168 | if (rows) |
| 2169 | { |
| 2170 | if (filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records) |
| 2171 | { |
| 2172 | MARIA_INFO maria_info; |
| 2173 | maria_status(filecxx . . $ ha_maria#file., &maria_info, HA_STATUS_NO_LOCKcxx . . $ `include/my_base.h:421:9`! |HA_STATUS_VARIABLEcxx . . $ `include/my_base.h:436:9`!); |
| 2174 | set_if_smallercxx . . $ `include/my_global.h:469:9`!(size, maria_info.mean_reclength * rows); |
| 2175 | } |
| 2176 | else if (tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->avg_row_lengthcxx . . $ TABLE_SHARE#avg_row_length.) |
| 2177 | set_if_smallercxx . . $ `include/my_global.h:469:9`!(size, (size_t) (table->s->avg_row_length * rows)); |
| 2178 | } |
| 2179 | tmp= (ulong) size; // Safe becasue of limits |
| 2180 | maria_extra(filecxx . . $ ha_maria#file., HA_EXTRA_WRITE_CACHEcxx . . $ HA_EXTRA_WRITE_CACHE., (void*) &tmp); |
| 2181 | } |
| 2182 | |
| 2183 | can_enable_indexescxx . . $ ha_maria#can_enable_indexes.= (maria_is_all_keys_activecxx . . $ `storage/maria/maria_def.h:118:9`!(share->state.key_map, |
| 2184 | share->base.keys)); |
| 2185 | bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo.= BULK_INSERT_NONEcxx . . $ `storage/maria/ha_maria.cc:970:9`!; |
| 2186 | |
| 2187 | if (!(specialflagcxx . . $ specialflag. & SPECIAL_SAFE_MODEcxx . . $ `sql/unireg.h:70:9`!)) |
| 2188 | { |
| 2189 | /* |
| 2190 | Only disable old index if the table was empty and we are inserting |
| 2191 | a lot of rows. |
| 2192 | We should not do this for only a few rows as this is slower and |
| 2193 | we don't want to update the key statistics based of only a few rows. |
| 2194 | Index file rebuild requires an exclusive lock, so if versioning is on |
| 2195 | don't do it (see how ha_maria::store_lock() tries to predict repair). |
| 2196 | We can repair index only if we have an exclusive (TL_WRITE) lock or |
| 2197 | if this is inside an ALTER TABLE, in which case lock_type == TL_UNLOCK. |
| 2198 | |
| 2199 | To see if table is empty, we shouldn't rely on the old record |
| 2200 | count from our transaction's start (if that old count is 0 but |
| 2201 | now there are records in the table, we would wrongly destroy |
| 2202 | them). So we need to look at share->state.state.records. As a |
| 2203 | safety net for now, we don't remove the test of |
| 2204 | file->state->records, because there is uncertainty on what will |
| 2205 | happen during repair if the two states disagree. |
| 2206 | |
| 2207 | We also have to check in case of transactional tables that the |
| 2208 | user has not used LOCK TABLE on the table twice. |
| 2209 | */ |
| 2210 | if ((filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records == 0) && |
| 2211 | (share->state.state.records == 0) && can_enable_indexescxx . . $ ha_maria#can_enable_indexes. && |
| 2212 | (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXEScxx . . $ `storage/maria/maria_def.h:1259:9`!) && |
| 2213 | (filecxx . . $ ha_maria#file.->lockcxx . . $ st_maria_handler#lock..type == TL_WRITE || filecxx . . $ ha_maria#file.->lockcxx . . $ st_maria_handler#lock..type == TL_UNLOCK) && |
| 2214 | (!share->have_versioning || !share->now_transactional || |
| 2215 | filecxx . . $ ha_maria#file.->used_tablescxx . . $ st_maria_handler#used_tables.->use_count == 1)) |
| 2216 | { |
| 2217 | /** |
| 2218 | @todo for a single-row INSERT SELECT, we will go into repair, which |
| 2219 | is more costly (flushes, syncs) than a row write. |
| 2220 | */ |
| 2221 | if (filecxx . . $ ha_maria#file.->open_flagscxx . . $ st_maria_handler#open_flags. & HA_OPEN_INTERNAL_TABLEcxx . . $ `include/my_base.h:47:9`!) |
| 2222 | { |
| 2223 | /* Internal table; If we get a duplicate something is very wrong */ |
| 2224 | filecxx . . $ ha_maria#file.->updatecxx . . $ st_maria_handler#update.|= HA_STATE_CHANGEDcxx . . $ `include/my_base.h:617:9`!; |
| 2225 | index_disabled= share->base.keys > 0; |
| 2226 | maria_clear_all_keys_activecxx . . $ `storage/maria/maria_def.h:122:9`!(file->s->state.key_map); |
| 2227 | } |
| 2228 | else |
| 2229 | { |
| 2230 | my_boolcxx . . $ my_bool# all_keys= MY_TESTcxx . . $ `include/my_global.h:467:9`!(flags & HA_CREATE_UNIQUE_INDEX_BY_SORTcxx . . $ `include/my_base.h:402:9`!); |
| 2231 | /* |
| 2232 | Deactivate all indexes that can be recreated fast. |
| 2233 | These include packed keys on which sorting will use more temporary |
| 2234 | space than the max allowed file length or for which the unpacked keys |
| 2235 | will take much more space than packed keys. |
| 2236 | Note that 'rows' may be zero for the case when we don't know how many |
| 2237 | rows we will put into the file. |
| 2238 | */ |
| 2239 | MARIA_SHARE *share= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.; |
| 2240 | MARIA_KEYDEF *key=share->keyinfo; |
| 2241 | uint i; |
| 2242 | |
| 2243 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(share->state.state.records == 0 && |
| 2244 | (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES)); |
| 2245 | for (i=0 ; i < share->base.keys ; i++,key++) |
| 2246 | { |
| 2247 | if (!(key->flag & HA_AUTO_KEYcxx . . $ `include/my_base.h:289:9`!) && share->base.auto_key != i+1 && |
| 2248 | ! maria_too_big_key_for_sort(key,rows) && |
| 2249 | (all_keys || !(key->flag & HA_NOSAMEcxx . . $ `include/my_base.h:285:9`!)) && |
| 2250 | tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info.[i].algorithmcxx . . $ st_key#algorithm. != HA_KEY_ALG_RTREEcxx . . $ HA_KEY_ALG_RTREE. && |
| 2251 | tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info.[i].algorithmcxx . . $ st_key#algorithm. != HA_KEY_ALG_LONG_HASHcxx . . $ HA_KEY_ALG_LONG_HASH.) |
| 2252 | { |
| 2253 | maria_clear_key_activecxx . . $ `storage/maria/maria_def.h:113:9`!(share->state.key_map, i); |
| 2254 | index_disabled= 1; |
| 2255 | filecxx . . $ ha_maria#file.->updatecxx . . $ st_maria_handler#update.|= HA_STATE_CHANGEDcxx . . $ `include/my_base.h:617:9`!; |
| 2256 | filecxx . . $ ha_maria#file.->create_unique_index_by_sortcxx . . $ st_maria_handler#create_unique_index_by_sort.= all_keys; |
| 2257 | } |
| 2258 | } |
| 2259 | } |
| 2260 | if (share->now_transactional) |
| 2261 | { |
| 2262 | bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo.= BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIRcxx . . $ `storage/maria/ha_maria.cc:965:9`!; |
| 2263 | write_log_record_for_bulk_insert(filecxx . . $ ha_maria#file.); |
| 2264 | /* |
| 2265 | Pages currently in the page cache have type PAGECACHE_LSN_PAGE, we |
| 2266 | are not allowed to overwrite them with PAGECACHE_PLAIN_PAGE, so |
| 2267 | throw them away. It is not losing data, because we just wrote and |
| 2268 | forced an UNDO which will for sure empty the table if we crash. The |
| 2269 | upcoming unique-key insertions however need a proper index, so we |
| 2270 | cannot leave the corrupted on-disk index file, thus we truncate it. |
| 2271 | |
| 2272 | The following call will log the truncate and update the lsn for the table |
| 2273 | to ensure that all redo's before this will be ignored. |
| 2274 | */ |
| 2275 | maria_delete_all_rows(filecxx . . $ ha_maria#file.); |
| 2276 | _ma_tmp_disable_logging_for_table(filecxx . . $ ha_maria#file., TRUEcxx . . $ `include/my_global.h:476:9`!); |
| 2277 | } |
| 2278 | } |
| 2279 | else if (!filecxx . . $ ha_maria#file.->bulk_insertcxx . . $ st_maria_handler#bulk_insert. && |
| 2280 | (!rows || rows >= MARIA_MIN_ROWS_TO_USE_BULK_INSERTcxx . . $ `storage/maria/maria_def.h:1258:9`!)) |
| 2281 | { |
| 2282 | maria_init_bulk_insert(filecxx . . $ ha_maria#file., |
| 2283 | (size_t) thd->variablescxx . . $ THD#variables..bulk_insert_buff_sizecxx . . $ system_variables#bulk_insert_buff_size., |
| 2284 | rows); |
| 2285 | } |
| 2286 | } |
| 2287 | can_enable_indexescxx . . $ ha_maria#can_enable_indexes.= index_disabled; |
| 2288 | DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!; |
| 2289 | } |
| 2290 | |
| 2291 | |
| 2292 | /* |
| 2293 | end special bulk-insert optimizations, |
| 2294 | which have been activated by start_bulk_insert(). |
| 2295 | |
| 2296 | SYNOPSIS |
| 2297 | end_bulk_insert() |
| 2298 | no arguments |
| 2299 | |
| 2300 | RETURN |
| 2301 | 0 OK |
| 2302 | != 0 Error |
| 2303 | */ |
| 2304 | |
| 2305 | int ha_mariacxx . . $ ha_maria#::end_bulk_insertcxx . . $ ha_maria#end_bulk_insert(b126dc7c1de90089).() |
| 2306 | { |
| 2307 | int first_error, first_errno= 0, error; |
| 2308 | my_boolcxx . . $ my_bool# abort= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->deleting, empty_table= 0; |
| 2309 | bool enable_persistently= true; |
| 2310 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::end_bulk_insert"); |
| 2311 | |
| 2312 | if ((first_error= maria_end_bulk_insert(filecxx . . $ ha_maria#file., abort))) |
| 2313 | { |
| 2314 | first_errno= my_errnocxx . . $ `include/my_pthread.h:720:9`!; |
| 2315 | abort= 1; |
| 2316 | } |
| 2317 | |
| 2318 | if ((error= maria_extra(filecxx . . $ ha_maria#file., HA_EXTRA_NO_CACHEcxx . . $ HA_EXTRA_NO_CACHE., 0))) |
| 2319 | { |
| 2320 | if (!first_error) |
| 2321 | { |
| 2322 | first_error= error; |
| 2323 | first_errno= my_errnocxx . . $ `include/my_pthread.h:720:9`!; |
| 2324 | } |
| 2325 | abort= 1; |
| 2326 | } |
| 2327 | |
| 2328 | if (bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo. != BULK_INSERT_NONEcxx . . $ `storage/maria/ha_maria.cc:970:9`!) |
| 2329 | { |
| 2330 | if (log_not_redoable_operationcxx . . $ handler#log_not_redoable_operation(c5f7da30cbc0f4e9).("BULK_INSERT")) |
| 2331 | { |
| 2332 | /* Got lock timeout. revert back to empty file and give error */ |
| 2333 | if (!first_error) |
| 2334 | { |
| 2335 | first_error= 1; |
| 2336 | first_errno= my_errnocxx . . $ `include/my_pthread.h:720:9`!; |
| 2337 | } |
| 2338 | enable_persistently= false; |
| 2339 | empty_table= 1; |
| 2340 | /* |
| 2341 | Ignore all changed pages, required by _ma_renable_logging_for_table() |
| 2342 | */ |
| 2343 | _ma_flush_table_files(filecxx . . $ ha_maria#file., MARIA_FLUSH_DATAcxx . . $ `storage/maria/maria_def.h:1705:9`!|MARIA_FLUSH_INDEXcxx . . $ `storage/maria/maria_def.h:1706:9`!, |
| 2344 | FLUSH_IGNORE_CHANGED, FLUSH_IGNORE_CHANGED); |
| 2345 | } |
| 2346 | } |
| 2347 | |
| 2348 | if (!abort && can_enable_indexescxx . . $ ha_maria#can_enable_indexes.) |
| 2349 | { |
| 2350 | if ((error= enable_indexescxx . . $ ha_maria#enable_indexes(f5cd2bccb9a33102).(key_mapcxx . . $ key_map#(tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->keyscxx . . $ TABLE_SHARE#keys.), enable_persistently))) |
| 2351 | { |
| 2352 | if (!first_error) |
| 2353 | { |
| 2354 | first_error= 1; |
| 2355 | first_errno= my_errnocxx . . $ `include/my_pthread.h:720:9`!; |
| 2356 | } |
| 2357 | } |
| 2358 | } |
| 2359 | if (bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo. != BULK_INSERT_NONEcxx . . $ `storage/maria/ha_maria.cc:970:9`!) |
| 2360 | { |
| 2361 | /* |
| 2362 | Table was transactional just before start_bulk_insert(). |
| 2363 | No need to flush pages if we did a repair (which already flushed). |
| 2364 | */ |
| 2365 | if ((error= _ma_reenable_logging_for_table(filecxx . . $ ha_maria#file., |
| 2366 | bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo. == |
| 2367 | BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIRcxx . . $ `storage/maria/ha_maria.cc:965:9`!)) && |
| 2368 | !empty_table) |
| 2369 | { |
| 2370 | if (!first_error) |
| 2371 | { |
| 2372 | first_error= 1; |
| 2373 | first_errno= my_errnocxx . . $ `include/my_pthread.h:720:9`!; |
| 2374 | } |
| 2375 | } |
| 2376 | bulk_insert_single_undocxx . . $ ha_maria#bulk_insert_single_undo.= BULK_INSERT_NONEcxx . . $ `storage/maria/ha_maria.cc:970:9`!; // Safety if called again |
| 2377 | } |
| 2378 | if (empty_table) |
| 2379 | maria_delete_all_rows(filecxx . . $ ha_maria#file.); |
| 2380 | |
| 2381 | can_enable_indexescxx . . $ ha_maria#can_enable_indexes.= 0; |
| 2382 | if (first_error) |
| 2383 | my_errnocxx . . $ `include/my_pthread.h:720:9`!= first_errno; |
| 2384 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(first_errno); |
| 2385 | } |
| 2386 | |
| 2387 | |
| 2388 | bool ha_mariacxx . . $ ha_maria#::check_and_repaircxx . . $ ha_maria#check_and_repair(ef3f197ce29d60f3).(THDcxx . . $ THD# *thd) |
| 2389 | { |
| 2390 | int error, crashed; |
| 2391 | HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# check_optcxx . . $ st_ha_check_opt#st_ha_check_opt(ced63f7c635d850d).; |
| 2392 | const CSET_STRINGcxx . . $ CSET_STRING# query_backup= thd->query_stringcxx . . $ Statement#query_string.; |
| 2393 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::check_and_repair"); |
| 2394 | |
| 2395 | check_opt.initcxx . . $ st_ha_check_opt#init(49f6e7a06ebc5aa8).(); |
| 2396 | check_opt.flagscxx . . $ st_ha_check_opt#flags.= T_MEDIUMcxx . . $ `include/my_check_opt.h:44:9`! | T_AUTO_REPAIRcxx . . $ `include/my_check_opt.h:30:9`!; |
| 2397 | |
| 2398 | error= 1; |
| 2399 | if (!aria_readonly && |
| 2400 | (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.changed & (STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`! | STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!)) == |
| 2401 | STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!) |
| 2402 | { |
| 2403 | /* Remove error about crashed table */ |
| 2404 | thd->get_stmt_dacxx . . $ THD#get_stmt_da(bbd3e063ae557713).()->clear_warning_infocxx . . $ Diagnostics_area#clear_warning_info(891dc3055356b409).(thd->query_idcxx . . $ THD#query_id.); |
| 2405 | push_warning_printfcxx . . $ push_warning_printf(aadc080f3f4146b5).(thd, Sql_conditioncxx . . $ Sql_condition#::WARN_LEVEL_NOTEcxx . . $ Sql_state_errno_level#WARN_LEVEL_NOTE., |
| 2406 | ER_CRASHED_ON_USAGEcxx . . $ `build/include/mysqld_error.h:199:9`!, |
| 2407 | "Zerofilling moved table %s", tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->pathcxx . . $ TABLE_SHARE#path..str); |
| 2408 | sql_print_informationcxx . . $ sql_print_information(326aeb464d16410c).("Zerofilling moved table: '%s'", |
| 2409 | tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->pathcxx . . $ TABLE_SHARE#path..str); |
| 2410 | if (!(error= zerofillcxx . . $ ha_maria#zerofill(95babc367ae08d43).(thd, &check_opt))) |
| 2411 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 2412 | } |
| 2413 | |
| 2414 | /* |
| 2415 | if we got this far - the table is crashed. |
| 2416 | but don't auto-repair if maria_recover_options is not set |
| 2417 | */ |
| 2418 | if (!maria_recover_optionscxx . . $ maria_recover_options.) |
| 2419 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error); |
| 2420 | |
| 2421 | error= 0; |
| 2422 | // Don't use quick if deleted rows |
| 2423 | if (!filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->del && (maria_recover_optionscxx . . $ maria_recover_options. & HA_RECOVER_QUICKcxx . . $ `storage/maria/ha_maria.h:29:9`!)) |
| 2424 | check_opt.flagscxx . . $ st_ha_check_opt#flags. |= T_QUICKcxx . . $ `include/my_check_opt.h:46:9`!; |
| 2425 | |
| 2426 | thd->set_querycxx . . $ THD#set_query(1f7c42adba354c49).((char*) tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->table_namecxx . . $ TABLE_SHARE#table_name..str, |
| 2427 | (uint) tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->table_namecxx . . $ TABLE_SHARE#table_name..length, system_charset_info); |
| 2428 | |
| 2429 | if (!(crashed= maria_is_crashedcxx . . $ `storage/maria/maria_def.h:1181:9`!(file))) |
| 2430 | { |
| 2431 | sql_print_warningcxx . . $ sql_print_warning(326aeb464d16410c).("Checking table: '%s'", tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->pathcxx . . $ TABLE_SHARE#path..str); |
| 2432 | crashed= checkcxx . . $ ha_maria#check(95babc367ae08d43).(thd, &check_opt); |
| 2433 | } |
| 2434 | |
| 2435 | if (crashed) |
| 2436 | { |
| 2437 | bool save_log_all_errors; |
| 2438 | sql_print_warningcxx . . $ sql_print_warning(326aeb464d16410c).("Recovering table: '%s'", tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->pathcxx . . $ TABLE_SHARE#path..str); |
| 2439 | save_log_all_errors= thd->log_all_errorscxx . . $ THD#log_all_errors.; |
| 2440 | thd->log_all_errorscxx . . $ THD#log_all_errors.|= (thd->variablescxx . . $ THD#variables..log_warningscxx . . $ system_variables#log_warnings. > 2); |
| 2441 | check_opt.flagscxx . . $ st_ha_check_opt#flags.= |
| 2442 | ((maria_recover_optionscxx . . $ maria_recover_options. & HA_RECOVER_BACKUPcxx . . $ `storage/maria/ha_maria.h:27:9`! ? T_BACKUP_DATAcxx . . $ `include/my_check_opt.h:31:9`! : 0) | |
| 2443 | (maria_recover_optionscxx . . $ maria_recover_options. & HA_RECOVER_FORCEcxx . . $ `storage/maria/ha_maria.h:28:9`! ? 0 : T_SAFE_REPAIRcxx . . $ `include/my_check_opt.h:52:9`!) | |
| 2444 | T_AUTO_REPAIRcxx . . $ `include/my_check_opt.h:30:9`!); |
| 2445 | if (repaircxx . . $ ha_maria#repair(95babc367ae08d43).(thd, &check_opt)) |
| 2446 | error= 1; |
| 2447 | thd->log_all_errorscxx . . $ THD#log_all_errors.= save_log_all_errors; |
| 2448 | } |
| 2449 | thd->set_querycxx . . $ THD#set_query(976648e04a042998).(query_backup); |
| 2450 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error); |
| 2451 | } |
| 2452 | |
| 2453 | |
| 2454 | bool ha_mariacxx . . $ ha_maria#::is_crashedcxx . . $ ha_maria#is_crashed(50ce9a9e25b4a850).() const |
| 2455 | { |
| 2456 | return (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.changed & (STATE_CRASHED_FLAGScxx . . $ `storage/maria/maria_def.h:1103:9`! | STATE_MOVEDcxx . . $ `storage/maria/maria_def.h:1097:9`!) || |
| 2457 | (my_disable_locking && filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.open_count)); |
| 2458 | } |
| 2459 | |
| 2460 | #define CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONINGcxx . . $ `storage/maria/ha_maria.cc:2460:9`!(msg) \ |
| 2461 | do { \ |
| 2462 | if (file->lock.type == TL_WRITE_CONCURRENT_INSERT && !table->s->sequence) \ |
| 2463 | { \ |
| 2464 | my_error(ER_CHECK_NOT_IMPLEMENTEDcxx . . $ `build/include/mysqld_error.h:183:9`!, MYFcxx . . $ `include/my_global.h:986:9`!(0), msg); \ |
| 2465 | return 1; \ |
| 2466 | } \ |
| 2467 | } while(0) |
| 2468 | |
| 2469 | int ha_mariacxx . . $ ha_maria#::update_rowcxx . . $ ha_maria#update_row(e46526da1a64e2fc).(const ucharcxx . . $ uchar# * old_data, const ucharcxx . . $ uchar# * new_data) |
| 2470 | { |
| 2471 | CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONINGcxx . . $ `storage/maria/ha_maria.cc:2460:9`!("UPDATE in WRITE CONCURRENT"); |
| 2472 | return maria_update(filecxx . . $ ha_maria#file., old_data, new_data); |
| 2473 | } |
| 2474 | |
| 2475 | |
| 2476 | int ha_mariacxx . . $ ha_maria#::delete_rowcxx . . $ ha_maria#delete_row(b84ccf4e0bb14b06).(const ucharcxx . . $ uchar# * buf) |
| 2477 | { |
| 2478 | CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONINGcxx . . $ `storage/maria/ha_maria.cc:2460:9`!("DELETE in WRITE CONCURRENT"); |
| 2479 | return maria_delete(filecxx . . $ ha_maria#file., buf); |
| 2480 | } |
| 2481 | |
| 2482 | int ha_mariacxx . . $ ha_maria#::index_read_mapcxx . . $ ha_maria#index_read_map(7b885921314fca32).(ucharcxx . . $ uchar# * buf, const ucharcxx . . $ uchar# * key, |
| 2483 | key_part_mapcxx . . $ key_part_map# keypart_map, |
| 2484 | enum ha_rkey_functioncxx . . $ ha_rkey_function# find_flag) |
| 2485 | { |
| 2486 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(inited == INDEX); |
| 2487 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2488 | int error= maria_rkey(filecxx . . $ ha_maria#file., buf, active_indexcxx . . $ handler#active_index., key, keypart_map, find_flag); |
| 2489 | return error; |
| 2490 | } |
| 2491 | |
| 2492 | |
| 2493 | int ha_mariacxx . . $ ha_maria#::index_read_idx_mapcxx . . $ ha_maria#index_read_idx_map(f8f1a1f168aa973c).(ucharcxx . . $ uchar# * buf, uint index, const ucharcxx . . $ uchar# * key, |
| 2494 | key_part_mapcxx . . $ key_part_map# keypart_map, |
| 2495 | enum ha_rkey_functioncxx . . $ ha_rkey_function# find_flag) |
| 2496 | { |
| 2497 | int error; |
| 2498 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2499 | |
| 2500 | /* Use the pushed index condition if it matches the index we're scanning */ |
| 2501 | end_rangecxx . . $ handler#end_range.= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 2502 | if (index == pushed_idx_cond_keynocxx . . $ handler#pushed_idx_cond_keyno.) |
| 2503 | ma_set_index_cond_func(filecxx . . $ ha_maria#file., handler_index_cond_checkcxx . . $ handler_index_cond_check(9d23bbd9b4d18766)., this); |
| 2504 | if (pushed_rowid_filtercxx . . $ handler#pushed_rowid_filter. && handler_rowid_filter_is_active(this)) |
| 2505 | ma_set_rowid_filter_func(filecxx . . $ ha_maria#file., handler_rowid_filter_checkcxx . . $ handler_rowid_filter_check(9d23bbd9b4d18766)., this); |
| 2506 | |
| 2507 | error= maria_rkey(filecxx . . $ ha_maria#file., buf, index, key, keypart_map, find_flag); |
| 2508 | |
| 2509 | ma_reset_index_filter_functions(filecxx . . $ ha_maria#file.); |
| 2510 | return error; |
| 2511 | } |
| 2512 | |
| 2513 | |
| 2514 | int ha_mariacxx . . $ ha_maria#::index_read_last_mapcxx . . $ ha_maria#index_read_last_map(b2b400a4aaec9333).(ucharcxx . . $ uchar# * buf, const ucharcxx . . $ uchar# * key, |
| 2515 | key_part_mapcxx . . $ key_part_map# keypart_map) |
| 2516 | { |
| 2517 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::index_read_last_map"); |
| 2518 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(inited == INDEX); |
| 2519 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2520 | int error= maria_rkey(filecxx . . $ ha_maria#file., buf, active_indexcxx . . $ handler#active_index., key, keypart_map, |
| 2521 | HA_READ_PREFIX_LASTcxx . . $ HA_READ_PREFIX_LAST.); |
| 2522 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error); |
| 2523 | } |
| 2524 | |
| 2525 | |
| 2526 | int ha_mariacxx . . $ ha_maria#::index_nextcxx . . $ ha_maria#index_next(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) |
| 2527 | { |
| 2528 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(inited == INDEX); |
| 2529 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2530 | int error= maria_rnext(filecxx . . $ ha_maria#file., buf, active_indexcxx . . $ handler#active_index.); |
| 2531 | return error; |
| 2532 | } |
| 2533 | |
| 2534 | |
| 2535 | int ha_mariacxx . . $ ha_maria#::index_prevcxx . . $ ha_maria#index_prev(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) |
| 2536 | { |
| 2537 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(inited == INDEX); |
| 2538 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2539 | int error= maria_rprev(filecxx . . $ ha_maria#file., buf, active_indexcxx . . $ handler#active_index.); |
| 2540 | return error; |
| 2541 | } |
| 2542 | |
| 2543 | |
| 2544 | int ha_mariacxx . . $ ha_maria#::index_firstcxx . . $ ha_maria#index_first(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) |
| 2545 | { |
| 2546 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(inited == INDEX); |
| 2547 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2548 | int error= maria_rfirst(filecxx . . $ ha_maria#file., buf, active_indexcxx . . $ handler#active_index.); |
| 2549 | return error; |
| 2550 | } |
| 2551 | |
| 2552 | |
| 2553 | int ha_mariacxx . . $ ha_maria#::index_lastcxx . . $ ha_maria#index_last(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) |
| 2554 | { |
| 2555 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(inited == INDEX); |
| 2556 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2557 | int error= maria_rlast(filecxx . . $ ha_maria#file., buf, active_indexcxx . . $ handler#active_index.); |
| 2558 | return error; |
| 2559 | } |
| 2560 | |
| 2561 | |
| 2562 | int ha_mariacxx . . $ ha_maria#::index_next_samecxx . . $ ha_maria#index_next_same(e1ec95732d0bf265).(ucharcxx . . $ uchar# * buf, |
| 2563 | const ucharcxx . . $ uchar# *key __attribute__ ((unused)), |
| 2564 | uint length __attribute__ ((unused))) |
| 2565 | { |
| 2566 | int error; |
| 2567 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(inited == INDEX); |
| 2568 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2569 | /* |
| 2570 | TODO: Delete this loop in Maria 1.5 as versioning will ensure this never |
| 2571 | happens |
| 2572 | */ |
| 2573 | do |
| 2574 | { |
| 2575 | error= maria_rnext_same(filecxx . . $ ha_maria#file.,buf); |
| 2576 | } while (error == HA_ERR_RECORD_DELETEDcxx . . $ `include/my_base.h:479:9`!); |
| 2577 | return error; |
| 2578 | } |
| 2579 | |
| 2580 | |
| 2581 | int ha_mariacxx . . $ ha_maria#::index_initcxx . . $ ha_maria#index_init(655f523120ea3b6c).(uint idx, bool sorted) |
| 2582 | { |
| 2583 | active_indexcxx . . $ handler#active_index.= idx; |
| 2584 | if (pushed_idx_cond_keynocxx . . $ handler#pushed_idx_cond_keyno. == idx) |
| 2585 | ma_set_index_cond_func(filecxx . . $ ha_maria#file., handler_index_cond_checkcxx . . $ handler_index_cond_check(9d23bbd9b4d18766)., this); |
| 2586 | if (pushed_rowid_filtercxx . . $ handler#pushed_rowid_filter. && handler_rowid_filter_is_active(this)) |
| 2587 | ma_set_rowid_filter_func(filecxx . . $ ha_maria#file., handler_rowid_filter_checkcxx . . $ handler_rowid_filter_check(9d23bbd9b4d18766)., this); |
| 2588 | return 0; |
| 2589 | } |
| 2590 | |
| 2591 | int ha_mariacxx . . $ ha_maria#::index_endcxx . . $ ha_maria#index_end(b126dc7c1de90089).() |
| 2592 | { |
| 2593 | /* |
| 2594 | in_range_check_pushed_down and index_id_cond_keyno are reset in |
| 2595 | handler::cancel_pushed_idx_cond() |
| 2596 | */ |
| 2597 | active_indexcxx . . $ handler#active_index.=MAX_KEYcxx . . $ `sql/sql_const.h:34:9`!; |
| 2598 | ma_reset_index_filter_functions(filecxx . . $ ha_maria#file.); |
| 2599 | ds_mrrcxx . . $ ha_maria#ds_mrr..dsmrr_closecxx . . $ DsMrr_impl#dsmrr_close(49f6e7a06ebc5aa8).(); |
| 2600 | return 0; |
| 2601 | } |
| 2602 | |
| 2603 | |
| 2604 | int ha_mariacxx . . $ ha_maria#::rnd_initcxx . . $ ha_maria#rnd_init(73da94e76e6bd037).(bool scan) |
| 2605 | { |
| 2606 | if (scan) |
| 2607 | return maria_scan_init(filecxx . . $ ha_maria#file.); |
| 2608 | return maria_reset(filecxx . . $ ha_maria#file.); // Free buffers |
| 2609 | } |
| 2610 | |
| 2611 | |
| 2612 | int ha_mariacxx . . $ ha_maria#::rnd_endcxx . . $ ha_maria#rnd_end(b126dc7c1de90089).() |
| 2613 | { |
| 2614 | ds_mrrcxx . . $ ha_maria#ds_mrr..dsmrr_closecxx . . $ DsMrr_impl#dsmrr_close(49f6e7a06ebc5aa8).(); |
| 2615 | /* Safe to call even if we don't have started a scan */ |
| 2616 | maria_scan_end(filecxx . . $ ha_maria#file.); |
| 2617 | return 0; |
| 2618 | } |
| 2619 | |
| 2620 | |
| 2621 | int ha_mariacxx . . $ ha_maria#::rnd_nextcxx . . $ ha_maria#rnd_next(b2e27cdb9bef2230).(ucharcxx . . $ uchar# *buf) |
| 2622 | { |
| 2623 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2624 | return maria_scan(filecxx . . $ ha_maria#file., buf); |
| 2625 | } |
| 2626 | |
| 2627 | |
| 2628 | int ha_mariacxx . . $ ha_maria#::remember_rnd_poscxx . . $ ha_maria#remember_rnd_pos(b126dc7c1de90089).() |
| 2629 | { |
| 2630 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2631 | return (*filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->scan_remember_pos)(filecxx . . $ ha_maria#file., &remember_poscxx . . $ ha_maria#remember_pos.); |
| 2632 | } |
| 2633 | |
| 2634 | |
| 2635 | int ha_mariacxx . . $ ha_maria#::restart_rnd_nextcxx . . $ ha_maria#restart_rnd_next(b2e27cdb9bef2230).(ucharcxx . . $ uchar# *buf) |
| 2636 | { |
| 2637 | int error; |
| 2638 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2639 | if ((error= (*filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->scan_restore_pos)(filecxx . . $ ha_maria#file., remember_poscxx . . $ ha_maria#remember_pos.))) |
| 2640 | return error; |
| 2641 | return rnd_nextcxx . . $ ha_maria#rnd_next(b2e27cdb9bef2230).(buf); |
| 2642 | } |
| 2643 | |
| 2644 | |
| 2645 | int ha_mariacxx . . $ ha_maria#::rnd_poscxx . . $ ha_maria#rnd_pos(b2844eacf1e6a17b).(ucharcxx . . $ uchar# *buf, ucharcxx . . $ uchar# *pos) |
| 2646 | { |
| 2647 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2648 | int error= maria_rrnd(filecxx . . $ ha_maria#file., buf, my_get_ptr(pos, ref_lengthcxx . . $ handler#ref_length.)); |
| 2649 | return error; |
| 2650 | } |
| 2651 | |
| 2652 | |
| 2653 | void ha_mariacxx . . $ ha_maria#::positioncxx . . $ ha_maria#position(28caea9380bfac8a).(const ucharcxx . . $ uchar# *record) |
| 2654 | { |
| 2655 | my_off_tcxx . . $ my_off_t# row_position= maria_position(filecxx . . $ ha_maria#file.); |
| 2656 | my_store_ptr(refcxx . . $ handler#ref., ref_lengthcxx . . $ handler#ref_length., row_position); |
| 2657 | } |
| 2658 | |
| 2659 | |
| 2660 | int ha_mariacxx . . $ ha_maria#::infocxx . . $ ha_maria#info(4c679297bf94b9eb).(uint flag) |
| 2661 | { |
| 2662 | MARIA_INFO maria_info; |
| 2663 | char name_buff[FN_REFLENcxx . . $ `include/my_global.h:603:9`!]; |
| 2664 | |
| 2665 | (void) maria_status(filecxx . . $ ha_maria#file., &maria_info, flag); |
| 2666 | if (flag & HA_STATUS_VARIABLEcxx . . $ `include/my_base.h:436:9`!) |
| 2667 | { |
| 2668 | statscxx . . $ handler#stats..recordscxx . . $ ha_statistics#records.= maria_info.records; |
| 2669 | statscxx . . $ handler#stats..deletedcxx . . $ ha_statistics#deleted.= maria_info.deleted; |
| 2670 | statscxx . . $ handler#stats..data_file_lengthcxx . . $ ha_statistics#data_file_length.= maria_info.data_file_length; |
| 2671 | statscxx . . $ handler#stats..index_file_lengthcxx . . $ ha_statistics#index_file_length.= maria_info.index_file_length; |
| 2672 | statscxx . . $ handler#stats..delete_lengthcxx . . $ ha_statistics#delete_length.= maria_info.delete_length; |
| 2673 | statscxx . . $ handler#stats..check_timecxx . . $ ha_statistics#check_time.= maria_info.check_time; |
| 2674 | statscxx . . $ handler#stats..mean_rec_lengthcxx . . $ ha_statistics#mean_rec_length.= maria_info.mean_reclength; |
| 2675 | statscxx . . $ handler#stats..checksumcxx . . $ ha_statistics#checksum.= filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->checksum; |
| 2676 | } |
| 2677 | if (flag & HA_STATUS_CONSTcxx . . $ `include/my_base.h:430:9`!) |
| 2678 | { |
| 2679 | TABLE_SHAREcxx . . $ TABLE_SHARE# *share= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.; |
| 2680 | statscxx . . $ handler#stats..max_data_file_lengthcxx . . $ ha_statistics#max_data_file_length.= maria_info.max_data_file_length; |
| 2681 | statscxx . . $ handler#stats..max_index_file_lengthcxx . . $ ha_statistics#max_index_file_length.= maria_info.max_index_file_length; |
| 2682 | statscxx . . $ handler#stats..create_timecxx . . $ ha_statistics#create_time.= maria_info.create_time; |
| 2683 | ref_lengthcxx . . $ handler#ref_length.= maria_info.reflength; |
| 2684 | share->db_options_in_usecxx . . $ TABLE_SHARE#db_options_in_use.= maria_info.options; |
| 2685 | statscxx . . $ handler#stats..block_sizecxx . . $ ha_statistics#block_size.= maria_block_size; |
| 2686 | statscxx . . $ handler#stats..mrr_length_per_reccxx . . $ ha_statistics#mrr_length_per_rec.= maria_info.reflength + 8; // 8 = MY_MAX(sizeof(void *)) |
| 2687 | |
| 2688 | /* Update share */ |
| 2689 | share->keys_in_usecxx . . $ TABLE_SHARE#keys_in_use..set_prefixcxx . . $ Bitmap#set_prefix(cb2f890c2fdad230).(share->keyscxx . . $ TABLE_SHARE#keys.); |
| 2690 | share->keys_in_usecxx . . $ TABLE_SHARE#keys_in_use..intersect_extendedcxx . . $ Bitmap#intersect_extended(891dc3055356b409).(maria_info.key_map); |
| 2691 | share->keys_for_keyreadcxx . . $ TABLE_SHARE#keys_for_keyread..intersectcxx . . $ Bitmap#intersect(a3bf8af87ee549d).(share->keys_in_usecxx . . $ TABLE_SHARE#keys_in_use.); |
| 2692 | share->db_record_offsetcxx . . $ TABLE_SHARE#db_record_offset.= maria_info.record_offset; |
| 2693 | if (share->key_partscxx . . $ TABLE_SHARE#key_parts.) |
| 2694 | { |
| 2695 | double *from= maria_info.rec_per_key; |
| 2696 | KEYcxx . . $ KEY# *key, *key_end; |
| 2697 | for (key= tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info., key_end= key + share->keyscxx . . $ TABLE_SHARE#keys.; |
| 2698 | key < key_end ; key++) |
| 2699 | { |
| 2700 | ulong *to= key->rec_per_keycxx . . $ st_key#rec_per_key.; |
| 2701 | /* Some temporary tables does not allocate rec_per_key */ |
| 2702 | if (to) |
| 2703 | { |
| 2704 | for (ulong *end= to+ key->user_defined_key_partscxx . . $ st_key#user_defined_key_parts. ; |
| 2705 | to < end ; |
| 2706 | to++, from++) |
| 2707 | *to= (ulong) (*from + 0.5); |
| 2708 | } |
| 2709 | } |
| 2710 | } |
| 2711 | /* |
| 2712 | Set data_file_name and index_file_name to point at the symlink value |
| 2713 | if table is symlinked (Ie; Real name is not same as generated name) |
| 2714 | */ |
| 2715 | data_file_namecxx . . $ ha_maria#data_file_name.= index_file_namecxx . . $ ha_maria#index_file_name.= 0; |
| 2716 | fn_format(name_buff, filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->open_file_name.strcxx . . $ st_mysql_lex_string#str., "", MARIA_NAME_DEXTcxx . . $ `storage/maria/maria_def.h:65:9`!, |
| 2717 | MY_APPEND_EXTcxx . . $ `include/my_sys.h:121:9`! | MY_UNPACK_FILENAMEcxx . . $ `include/my_sys.h:115:9`!); |
| 2718 | if (strcmp(name_buff, maria_info.data_file_name) && |
| 2719 | maria_info.data_file_name[0]) |
| 2720 | data_file_namecxx . . $ ha_maria#data_file_name.= maria_info.data_file_name; |
| 2721 | fn_format(name_buff, filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->open_file_name.strcxx . . $ st_mysql_lex_string#str., "", MARIA_NAME_IEXTcxx . . $ `storage/maria/maria_def.h:64:9`!, |
| 2722 | MY_APPEND_EXTcxx . . $ `include/my_sys.h:121:9`! | MY_UNPACK_FILENAMEcxx . . $ `include/my_sys.h:115:9`!); |
| 2723 | if (strcmp(name_buff, maria_info.index_file_name) && |
| 2724 | maria_info.index_file_name[0]) |
| 2725 | index_file_namecxx . . $ ha_maria#index_file_name.=maria_info.index_file_name; |
| 2726 | } |
| 2727 | if (flag & HA_STATUS_ERRKEYcxx . . $ `include/my_base.h:442:9`!) |
| 2728 | { |
| 2729 | errkeycxx . . $ handler#errkey.= maria_info.errkey; |
| 2730 | my_store_ptr(dup_refcxx . . $ handler#dup_ref., ref_lengthcxx . . $ handler#ref_length., maria_info.dup_key_pos); |
| 2731 | } |
| 2732 | if (flag & HA_STATUS_TIMEcxx . . $ `include/my_base.h:423:9`!) |
| 2733 | statscxx . . $ handler#stats..update_timecxx . . $ ha_statistics#update_time.= maria_info.update_time; |
| 2734 | if (flag & HA_STATUS_AUTOcxx . . $ `include/my_base.h:446:9`!) |
| 2735 | statscxx . . $ handler#stats..auto_increment_valuecxx . . $ ha_statistics#auto_increment_value.= maria_info.auto_increment; |
| 2736 | |
| 2737 | return 0; |
| 2738 | } |
| 2739 | |
| 2740 | |
| 2741 | int ha_mariacxx . . $ ha_maria#::extracxx . . $ ha_maria#extra(3f7d7dcfae14d7dd).(enum ha_extra_functioncxx . . $ ha_extra_function# operation) |
| 2742 | { |
| 2743 | int tmp; |
| 2744 | TRN *old_trn= filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.; |
| 2745 | if ((specialflagcxx . . $ specialflag. & SPECIAL_SAFE_MODEcxx . . $ `sql/unireg.h:70:9`!) && operation == HA_EXTRA_KEYREADcxx . . $ HA_EXTRA_KEYREAD.) |
| 2746 | return 0; |
| 2747 | #ifdef NOT_USED |
| 2748 | if (operation == HA_EXTRA_MMAP && !opt_maria_use_mmap) |
| 2749 | return 0; |
| 2750 | #endif |
| 2751 | if (operation == HA_EXTRA_WRITE_CACHEcxx . . $ HA_EXTRA_WRITE_CACHE. && has_long_uniquecxx . . $ handler#has_long_unique(c9857a73d68e59ba).()) |
| 2752 | return 0; |
| 2753 | |
| 2754 | /* |
| 2755 | We have to set file->trn here because in some cases we call |
| 2756 | extern_lock(F_UNLOCK) (which resets file->trn) followed by maria_close() |
| 2757 | without calling commit/rollback in between. If file->trn is not set |
| 2758 | we can't remove file->share from the transaction list in the extra() call. |
| 2759 | |
| 2760 | In current code we don't have to do this for HA_EXTRA_PREPARE_FOR_RENAME |
| 2761 | as this is only used the intermediate table used by ALTER TABLE which |
| 2762 | is not part of the transaction (it's not in the TRN list). Better to |
| 2763 | keep this for now, to not break anything in a stable release. |
| 2764 | When HA_EXTRA_PREPARE_FOR_RENAME is not handled below, we can change |
| 2765 | the warnings in _ma_remove_table_from_trnman() to asserts. |
| 2766 | |
| 2767 | table->in_use is not set in the case this is a done as part of closefrm() |
| 2768 | as part of drop table. |
| 2769 | */ |
| 2770 | |
| 2771 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->now_transactional && tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use. && |
| 2772 | (operation == HA_EXTRA_PREPARE_FOR_DROPcxx . . $ HA_EXTRA_PREPARE_FOR_DROP. || |
| 2773 | operation == HA_EXTRA_PREPARE_FOR_RENAMEcxx . . $ HA_EXTRA_PREPARE_FOR_RENAME. || |
| 2774 | operation == HA_EXTRA_PREPARE_FOR_FORCED_CLOSEcxx . . $ HA_EXTRA_PREPARE_FOR_FORCED_CLOSE.)) |
| 2775 | { |
| 2776 | THDcxx . . $ THD# *thd= tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use.; |
| 2777 | filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.= THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`!; |
| 2778 | } |
| 2779 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(file->s->base.born_transactional || file->trn == 0 || |
| 2780 | file->trn == &dummy_transaction_object); |
| 2781 | |
| 2782 | tmp= maria_extra(filecxx . . $ ha_maria#file., operation, 0); |
| 2783 | /* |
| 2784 | Restore trn if it was changed above. |
| 2785 | Note that table could be removed from trn->used_tables and |
| 2786 | trn->used_instances if trn was set and some of the above operations |
| 2787 | was used. This is ok as the table should not be part of any transaction |
| 2788 | after this and thus doesn't need to be part of any of the above lists. |
| 2789 | */ |
| 2790 | filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.= old_trn; |
| 2791 | return tmp; |
| 2792 | } |
| 2793 | |
| 2794 | int ha_mariacxx . . $ ha_maria#::resetcxx . . $ ha_maria#reset(b126dc7c1de90089).(void) |
| 2795 | { |
| 2796 | ma_reset_index_filter_functions(filecxx . . $ ha_maria#file.); |
| 2797 | ds_mrrcxx . . $ ha_maria#ds_mrr..dsmrr_closecxx . . $ DsMrr_impl#dsmrr_close(49f6e7a06ebc5aa8).(); |
| 2798 | if (filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.) |
| 2799 | { |
| 2800 | /* Next statement is a new statement. Ensure it's logged */ |
| 2801 | trnman_set_flagscxx . . $ `storage/maria/trnman_public.h:78:9`!(file->trn, |
| 2802 | trnman_get_flags(file->trn) & ~TRN_STATE_INFO_LOGGED); |
| 2803 | } |
| 2804 | return maria_reset(filecxx . . $ ha_maria#file.); |
| 2805 | } |
| 2806 | |
| 2807 | /* To be used with WRITE_CACHE and EXTRA_CACHE */ |
| 2808 | |
| 2809 | int ha_mariacxx . . $ ha_maria#::extra_optcxx . . $ ha_maria#extra_opt(81c841a2ebc5e0bd).(enum ha_extra_functioncxx . . $ ha_extra_function# operation, ulong cache_size) |
| 2810 | { |
| 2811 | if ((specialflagcxx . . $ specialflag. & SPECIAL_SAFE_MODEcxx . . $ `sql/unireg.h:70:9`!) && operation == HA_EXTRA_WRITE_CACHEcxx . . $ HA_EXTRA_WRITE_CACHE.) |
| 2812 | return 0; |
| 2813 | return maria_extra(filecxx . . $ ha_maria#file., operation, (void*) &cache_size); |
| 2814 | } |
| 2815 | |
| 2816 | |
| 2817 | bool ha_mariacxx . . $ ha_maria#::auto_repaircxx . . $ ha_maria#auto_repair(4a668f6de69bf818).(int error) const |
| 2818 | { |
| 2819 | /* Always auto-repair moved tables (error == HA_ERR_OLD_FILE) */ |
| 2820 | return ((MY_TESTcxx . . $ `include/my_global.h:467:9`!(maria_recover_options & HA_RECOVER_ANYcxx . . $ `storage/maria/maria_def.h:256:9`!) && |
| 2821 | error == HA_ERR_CRASHED_ON_USAGEcxx . . $ `include/my_base.h:490:9`!) || |
| 2822 | error == HA_ERR_OLD_FILEcxx . . $ `include/my_base.h:477:9`!); |
| 2823 | |
| 2824 | } |
| 2825 | |
| 2826 | |
| 2827 | int ha_mariacxx . . $ ha_maria#::delete_all_rowscxx . . $ ha_maria#delete_all_rows(b126dc7c1de90089).() |
| 2828 | { |
| 2829 | THDcxx . . $ THD# *thd= tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use.; |
| 2830 | TRN *trn= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->now_transactional ? filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn. : (TRN*) 0; |
| 2831 | CHECK_UNTIL_WE_FULLY_IMPLEMENTED_VERSIONINGcxx . . $ `storage/maria/ha_maria.cc:2460:9`!("TRUNCATE in WRITE CONCURRENT"); |
| 2832 | |
| 2833 | #ifdef EXTRA_DEBUG |
| 2834 | if (trn && ! (trnman_get_flags(trn) & TRN_STATE_INFO_LOGGED)) |
| 2835 | { |
| 2836 | trnman_set_flags(trn, trnman_get_flags(trn) | TRN_STATE_INFO_LOGGED | |
| 2837 | TRN_STATE_TABLES_CAN_CHANGE); |
| 2838 | (void) translog_log_debug_info(trn, LOGREC_DEBUG_INFO_QUERY, |
| 2839 | (uchar*) thd->query(), thd->query_length()); |
| 2840 | } |
| 2841 | #endif |
| 2842 | /* |
| 2843 | If we are under LOCK TABLES, we have to do a commit as |
| 2844 | delete_all_rows() can't be rolled back |
| 2845 | */ |
| 2846 | if (trn && tablecxx . . $ handler#table.->in_usecxx . . $ TABLE#in_use.->locked_tables_modecxx . . $ Open_tables_state#locked_tables_mode. && trnman_has_locked_tables(trn)) |
| 2847 | { |
| 2848 | int error; |
| 2849 | if ((error= implicit_commitcxx . . $ ha_maria#implicit_commit(a4bb9b94410fc259).(thd, 1))) |
| 2850 | return error; |
| 2851 | } |
| 2852 | |
| 2853 | /* Note that this can't be rolled back */ |
| 2854 | return maria_delete_all_rows(filecxx . . $ ha_maria#file.); |
| 2855 | } |
| 2856 | |
| 2857 | |
| 2858 | int ha_mariacxx . . $ ha_maria#::delete_tablecxx . . $ ha_maria#delete_table(5c4306d8553b3696).(const char *name) |
| 2859 | { |
| 2860 | THDcxx . . $ THD# *thd= current_thdcxx . . $ `sql/mysqld.h:916:9`!; |
| 2861 | (void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERYcxx . . $ LOGREC_DEBUG_INFO_QUERY., |
| 2862 | (ucharcxx . . $ uchar#*) thd->querycxx . . $ Statement#query(e7e5aa338b9d5147).(), thd->query_lengthcxx . . $ Statement#query_length(ddd8539a2fcdd4ce).()); |
| 2863 | return maria_delete_table(name); |
| 2864 | } |
| 2865 | |
| 2866 | |
| 2867 | /* This is mainly for temporary tables, so no logging necessary */ |
| 2868 | |
| 2869 | void ha_mariacxx . . $ ha_maria#::drop_tablecxx . . $ ha_maria#drop_table(85c52e162fed56f9).(const char *name) |
| 2870 | { |
| 2871 | my_boolcxx . . $ my_bool# tracked= filecxx . . $ ha_maria#file. && filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->tracked; |
| 2872 | struct tmp_file_tracking track_data; |
| 2873 | struct tmp_file_tracking track_index; |
| 2874 | |
| 2875 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(!file || file->s->temporary); |
| 2876 | |
| 2877 | if (tracked) |
| 2878 | { |
| 2879 | /* Inform tracking after files are deleted */ |
| 2880 | track_data= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->track_data; |
| 2881 | track_index= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->track_index; |
| 2882 | #ifndef DBUG_OFFcxx . . $ `<built-in>:485:9`! |
| 2883 | /* Avoid DBUG_ASSERT in maria_close() */ |
| 2884 | bzero(&file->s->track_data, sizeof(file->s->track_data)); |
| 2885 | bzero(&file->s->track_index, sizeof(file->s->track_index)); |
| 2886 | #endif |
| 2887 | } |
| 2888 | |
| 2889 | filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->deleting= 1; // Do not flush data |
| 2890 | (void) ha_closecxx . . $ handler#ha_close(b126dc7c1de90089).(); |
| 2891 | (void) maria_delete_table_files(name, 1, MY_WMEcxx . . $ `include/my_sys.h:57:9`!); |
| 2892 | |
| 2893 | if (tracked) |
| 2894 | { |
| 2895 | _ma_update_tmp_file_size(&track_data, 0); |
| 2896 | _ma_update_tmp_file_size(&track_index, 0); |
| 2897 | } |
| 2898 | } |
| 2899 | |
| 2900 | |
| 2901 | void ha_mariacxx . . $ ha_maria#::change_table_ptrcxx . . $ ha_maria#change_table_ptr(4617d8dd0876d66e).(TABLEcxx . . $ TABLE# *table_arg, TABLE_SHAREcxx . . $ TABLE_SHARE# *share) |
| 2902 | { |
| 2903 | handlercxx . . $ handler#::change_table_ptrcxx . . $ handler#change_table_ptr(4617d8dd0876d66e).(table_arg, share); |
| 2904 | if (filecxx . . $ ha_maria#file.) |
| 2905 | filecxx . . $ ha_maria#file.->external_refcxx . . $ st_maria_handler#external_ref.= table_arg; |
| 2906 | } |
| 2907 | |
| 2908 | |
| 2909 | int ha_mariacxx . . $ ha_maria#::external_lockcxx . . $ ha_maria#external_lock(55bfda0c556d7e61).(THDcxx . . $ THD# *thd, int lock_type) |
| 2910 | { |
| 2911 | int result= 0, result2; |
| 2912 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::external_lock"); |
| 2913 | filecxx . . $ ha_maria#file.->external_refcxx . . $ st_maria_handler#external_ref.= (void*) tablecxx . . $ handler#table.; // For ma_killed() |
| 2914 | /* |
| 2915 | We don't test now_transactional because it may vary between lock/unlock |
| 2916 | and thus confuse our reference counting. |
| 2917 | It is critical to skip non-transactional tables: user-visible temporary |
| 2918 | tables get an external_lock() when read/written for the first time, but no |
| 2919 | corresponding unlock (they just stay locked and are later dropped while |
| 2920 | locked); if a tmp table was transactional, "SELECT FROM non_tmp, tmp" |
| 2921 | would never commit as its "locked_tables" count would stay 1. |
| 2922 | When Maria has has_transactions()==TRUE, open_temporary_table() |
| 2923 | (sql_base.cc) will use TRANSACTIONAL_TMP_TABLE and thus the |
| 2924 | external_lock(F_UNLCK) will happen and we can then allow the user to |
| 2925 | create transactional temporary tables. |
| 2926 | */ |
| 2927 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->base.born_transactional) |
| 2928 | { |
| 2929 | /* Transactional table */ |
| 2930 | if (lock_type != F_UNLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:225:10`!) |
| 2931 | { |
| 2932 | if (filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.) |
| 2933 | { |
| 2934 | /* This can only happen with tables created with clone() */ |
| 2935 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info",("file->trn: %p", file->trn)); |
| 2936 | trnman_increment_locked_tables(filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn.); |
| 2937 | } |
| 2938 | |
| 2939 | if (!thd->transactioncxx . . $ THD#transaction.->oncxx . . $ THD#st_transactions#on.) |
| 2940 | { |
| 2941 | /* |
| 2942 | No need to log REDOs/UNDOs. If this is an internal temporary table |
| 2943 | which will be renamed to a permanent table (like in ALTER TABLE), |
| 2944 | the rename happens after unlocking so will be durable (and the table |
| 2945 | will get its create_rename_lsn). |
| 2946 | Note: if we wanted to enable users to have an old backup and apply |
| 2947 | tons of archived logs to roll-forward, we could then not disable |
| 2948 | REDOs/UNDOs in this case. |
| 2949 | */ |
| 2950 | if (likelycxx . . $ `include/my_global.h:360:9`!(file->s->now_transactional)) |
| 2951 | { |
| 2952 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", ("Disabling logging for table")); |
| 2953 | _ma_tmp_disable_logging_for_table(filecxx . . $ ha_maria#file., TRUEcxx . . $ `include/my_global.h:476:9`!); |
| 2954 | } |
| 2955 | filecxx . . $ ha_maria#file.->autocommitcxx . . $ st_maria_handler#autocommit.= 0; |
| 2956 | } |
| 2957 | else |
| 2958 | filecxx . . $ ha_maria#file.->autocommitcxx . . $ st_maria_handler#autocommit.= !(thd->variablescxx . . $ THD#variables..option_bitscxx . . $ system_variables#option_bits. & |
| 2959 | (OPTION_NOT_AUTOCOMMITcxx . . $ `sql/sql_priv.h:68:9`! | OPTION_BEGINcxx . . $ `sql/sql_priv.h:69:9`!)); |
| 2960 | #ifndef ARIA_HAS_TRANSACTIONS |
| 2961 | /* |
| 2962 | Until Aria has full transactions support, including MVCC support for |
| 2963 | delete and update and purging of old states, we have to commit for |
| 2964 | every statement. |
| 2965 | */ |
| 2966 | filecxx . . $ ha_maria#file.->autocommitcxx . . $ st_maria_handler#autocommit.=1; |
| 2967 | #endif |
| 2968 | } |
| 2969 | else |
| 2970 | { |
| 2971 | /* We have to test for THD_TRN to protect against implicit commits */ |
| 2972 | TRN *trn= (filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn. != &dummy_transaction_object && THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`! ? filecxx . . $ ha_maria#file.->trncxx . . $ st_maria_handler#trn. : 0); |
| 2973 | /* End of transaction */ |
| 2974 | |
| 2975 | /* |
| 2976 | We always re-enable, don't rely on thd->transaction.on as it is |
| 2977 | sometimes reset to true after unlocking (see mysql_truncate() for a |
| 2978 | partitioned table based on Maria). |
| 2979 | Note that we can come here without having an exclusive lock on the |
| 2980 | table, for example in this case: |
| 2981 | external_lock(F_(WR|RD)LCK); thr_lock() which fails due to lock |
| 2982 | abortion; external_lock(F_UNLCK). Fortunately, the re-enabling happens |
| 2983 | only if we were the thread which disabled logging. |
| 2984 | */ |
| 2985 | if (_ma_reenable_logging_for_table(filecxx . . $ ha_maria#file., TRUEcxx . . $ `include/my_global.h:476:9`!)) |
| 2986 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(1); |
| 2987 | _ma_reset_trn_for_tablecxx . . $ _ma_reset_trn_for_table(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 2988 | /* |
| 2989 | Ensure that file->state points to the current number of rows. This |
| 2990 | is needed if someone calls maria_info() without first doing an |
| 2991 | external lock of the table |
| 2992 | */ |
| 2993 | filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.= &filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.state; |
| 2994 | if (trn) |
| 2995 | { |
| 2996 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", |
| 2997 | ("locked_tables: %u", trnman_has_locked_tables(trn))); |
| 2998 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(trnman_has_locked_tables(trn) > 0); |
| 2999 | if (trnman_has_locked_tables(trn) && |
| 3000 | !trnman_decrement_locked_tables(trn)) |
| 3001 | { |
| 3002 | /* |
| 3003 | OK should not have been sent to client yet (ACID). |
| 3004 | This is a bit excessive, ACID requires this only if there are some |
| 3005 | changes to commit (rollback shouldn't be tested). |
| 3006 | */ |
| 3007 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(!thd->get_stmt_da()->is_sent() || |
| 3008 | thd->killed); |
| 3009 | /* |
| 3010 | If autocommit, commit transaction. This can happen when open and |
| 3011 | lock tables as part of creating triggers, in which case commit |
| 3012 | is not called. |
| 3013 | Until ARIA_HAS_TRANSACTIONS is not defined, always commit. |
| 3014 | */ |
| 3015 | if (filecxx . . $ ha_maria#file.->autocommitcxx . . $ st_maria_handler#autocommit.) |
| 3016 | { |
| 3017 | if (ma_commit(trn)) |
| 3018 | result= HA_ERR_COMMIT_ERRORcxx . . $ `include/my_base.h:555:9`!; |
| 3019 | thd_set_ha_data(thd, maria_htoncxx . . $ maria_hton., 0); |
| 3020 | } |
| 3021 | } |
| 3022 | trnman_set_flagscxx . . $ `storage/maria/trnman_public.h:78:9`!(trn, trnman_get_flags(trn) & ~ TRN_STATE_INFO_LOGGED); |
| 3023 | } |
| 3024 | } |
| 3025 | } /* if transactional table */ |
| 3026 | if ((result2= maria_lock_database(filecxx . . $ ha_maria#file., !tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->tmp_tablecxx . . $ TABLE_SHARE#tmp_table. ? |
| 3027 | lock_type : ((lock_type == F_UNLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:225:10`!) ? |
| 3028 | F_UNLCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:225:10`! : F_EXTRA_LCKcxx . . $ `storage/maria/maria_def.h:1073:9`!)))) |
| 3029 | result= result2; |
| 3030 | if (!filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->base.born_transactional) |
| 3031 | filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.= &filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.state; // Restore state if clone |
| 3032 | |
| 3033 | /* Remember stack end for this thread */ |
| 3034 | filecxx . . $ ha_maria#file.->stack_end_ptrcxx . . $ st_maria_handler#stack_end_ptr.= &ha_thdcxx . . $ handler#ha_thd(da00c4f4e081f1fe).()->mysys_varcxx . . $ THD#mysys_var.->stack_ends_here; |
| 3035 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(result); |
| 3036 | } |
| 3037 | |
| 3038 | int ha_mariacxx . . $ ha_maria#::start_stmtcxx . . $ ha_maria#start_stmt(f54dca89292b6bc7).(THDcxx . . $ THD# *thd, thr_lock_type lock_type) |
| 3039 | { |
| 3040 | TRN *trn; |
| 3041 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->base.born_transactional) |
| 3042 | { |
| 3043 | trn= THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`!; |
| 3044 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(trn); // this may be called only after external_lock() |
| 3045 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(trnman_has_locked_tables(trn)); |
| 3046 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(lock_type != TL_UNLOCK); |
| 3047 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(file->trn == trn); |
| 3048 | |
| 3049 | /* |
| 3050 | As external_lock() was already called, don't increment locked_tables. |
| 3051 | Note that we call the function below possibly several times when |
| 3052 | statement starts (once per table). This is ok as long as that function |
| 3053 | does cheap operations. Otherwise, we will need to do it only on first |
| 3054 | call to start_stmt(). |
| 3055 | */ |
| 3056 | trnman_new_statement(trn); |
| 3057 | |
| 3058 | #ifdef EXTRA_DEBUG |
| 3059 | if (!(trnman_get_flags(trn) & TRN_STATE_INFO_LOGGED) && |
| 3060 | trnman_get_flags(trn) & TRN_STATE_TABLES_CAN_CHANGE) |
| 3061 | { |
| 3062 | trnman_set_flags(trn, trnman_get_flags(trn) | TRN_STATE_INFO_LOGGED); |
| 3063 | (void) translog_log_debug_info(trn, LOGREC_DEBUG_INFO_QUERY, |
| 3064 | (uchar*) thd->query(), |
| 3065 | thd->query_length()); |
| 3066 | } |
| 3067 | #endif |
| 3068 | } |
| 3069 | return 0; |
| 3070 | } |
| 3071 | |
| 3072 | |
| 3073 | /* |
| 3074 | Reset THD_TRN and all file->trn related to the transaction |
| 3075 | This is needed as some calls, like extra() or external_lock() may access |
| 3076 | it before next transaction is started |
| 3077 | Note that trn for the table is already freed and may be reused by another |
| 3078 | thread. |
| 3079 | */ |
| 3080 | |
| 3081 | static void reset_thd_trncxx . . $ reset_thd_trn(c109590e3cccfeb8).(THDcxx . . $ THD# *thd, MARIA_HA *first_table) |
| 3082 | { |
| 3083 | MARIA_HA *next; |
| 3084 | TRN *trn __attribute__((unused)) = first_table ? first_table->trncxx . . $ st_maria_handler#trn. : 0; |
| 3085 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("reset_thd_trn"); |
| 3086 | thd_set_ha_data(thd, maria_htoncxx . . $ maria_hton., 0); |
| 3087 | for (MARIA_HA *table= first_table; table ; table= next) |
| 3088 | { |
| 3089 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(table->trn == trn); |
| 3090 | next= table->trn_nextcxx . . $ st_maria_handler#trn_next.; |
| 3091 | table->trn_prevcxx . . $ st_maria_handler#trn_prev.= 0; |
| 3092 | table->trn_nextcxx . . $ st_maria_handler#trn_next.= 0; |
| 3093 | table->trncxx . . $ st_maria_handler#trn.= 0; |
| 3094 | |
| 3095 | /* |
| 3096 | If table has changed by this statement, invalidate it from the query |
| 3097 | cache |
| 3098 | */ |
| 3099 | if (table->row_changescxx . . $ st_maria_handler#row_changes. != table->start_row_changescxx . . $ st_maria_handler#start_row_changes.) |
| 3100 | { |
| 3101 | table->start_row_changescxx . . $ st_maria_handler#start_row_changes.= table->row_changescxx . . $ st_maria_handler#row_changes.; |
| 3102 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(table->s->chst_invalidator != NULL); |
| 3103 | (*table->scxx . . $ st_maria_handler#s.->chst_invalidator)(table->scxx . . $ st_maria_handler#s.->data_file_name.strcxx . . $ st_mysql_lex_string#str.); |
| 3104 | } |
| 3105 | } |
| 3106 | DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!; |
| 3107 | } |
| 3108 | |
| 3109 | bool ha_mariacxx . . $ ha_maria#::has_active_transactioncxx . . $ ha_maria#has_active_transaction(ef3f197ce29d60f3).(THDcxx . . $ THD# *thd) |
| 3110 | { |
| 3111 | return (maria_htoncxx . . $ maria_hton. && THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`!); |
| 3112 | } |
| 3113 | |
| 3114 | /** |
| 3115 | Performs an implicit commit of the Maria transaction and creates a new |
| 3116 | one. |
| 3117 | |
| 3118 | This can be considered a hack. When Maria loses HA_NO_TRANSACTIONS it will |
| 3119 | be participant in the connection's transaction and so the implicit commits |
| 3120 | (ha_commit()) (like in end_active_trans()) will do the implicit commit |
| 3121 | without need to call this function which can then be removed. |
| 3122 | |
| 3123 | @param thd THD object |
| 3124 | @param new_trn if a new transaction should be created; a new |
| 3125 | transaction is not needed when we know that the |
| 3126 | tables will be unlocked very soon. |
| 3127 | */ |
| 3128 | |
| 3129 | int ha_mariacxx . . $ ha_maria#::implicit_commitcxx . . $ ha_maria#implicit_commit(a4bb9b94410fc259).(THDcxx . . $ THD# *thd, bool new_trn) |
| 3130 | { |
| 3131 | #ifndef MARIA_CANNOT_ROLLBACKcxx . . $ `storage/maria/maria_def.h:42:9`! |
| 3132 | #error this method should be removed |
| 3133 | #endif |
| 3134 | TRN *trn; |
| 3135 | int error; |
| 3136 | uint locked_tables; |
| 3137 | extern my_boolcxx . . $ my_bool# plugins_are_initializedcxx . . $ plugins_are_initialized.; |
| 3138 | MARIA_HA *used_tables, *trn_next; |
| 3139 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::implicit_commit"); |
| 3140 | |
| 3141 | if (!maria_htoncxx . . $ maria_hton. || !plugins_are_initializedcxx . . $ plugins_are_initialized. || !(trn= THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`!)) |
| 3142 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 3143 | if (!new_trn && (thd->locked_tables_modecxx . . $ Open_tables_state#locked_tables_mode. == LTM_LOCK_TABLEScxx . . $ LTM_LOCK_TABLES. || |
| 3144 | thd->locked_tables_modecxx . . $ Open_tables_state#locked_tables_mode. == LTM_PRELOCKED_UNDER_LOCK_TABLEScxx . . $ LTM_PRELOCKED_UNDER_LOCK_TABLES.)) |
| 3145 | { |
| 3146 | /* |
| 3147 | No commit inside LOCK TABLES. |
| 3148 | |
| 3149 | Note that we come here only at the end of the top statement |
| 3150 | (dispatch_command()), we are never committing inside a sub-statement./ |
| 3151 | */ |
| 3152 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("info", ("locked_tables, skipping")); |
| 3153 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 3154 | } |
| 3155 | |
| 3156 | /* Prepare to move used_instances and locked tables to new TRN object */ |
| 3157 | locked_tables= trnman_has_locked_tables(trn); |
| 3158 | trnman_reset_locked_tables(trn, 0); |
| 3159 | relink_trn_used_instancescxx . . $ relink_trn_used_instances(50f4cf7c152c91bf).(&used_tables, trn); |
| 3160 | |
| 3161 | error= 0; |
| 3162 | if (unlikelycxx . . $ `include/my_global.h:361:9`!(ma_commit(trn))) |
| 3163 | error= HA_ERR_COMMIT_ERRORcxx . . $ `include/my_base.h:555:9`!; |
| 3164 | if (!new_trn) |
| 3165 | { |
| 3166 | reset_thd_trncxx . . $ reset_thd_trn(c109590e3cccfeb8).(thd, used_tables); |
| 3167 | goto end; |
| 3168 | } |
| 3169 | |
| 3170 | /* |
| 3171 | We need to create a new transaction and put it in THD_TRN. Indeed, |
| 3172 | tables may be under LOCK TABLES, and so they will start the next |
| 3173 | statement assuming they have a trn (see ha_maria::start_stmt()). |
| 3174 | */ |
| 3175 | trn= trnman_new_trn(& thd->transactioncxx . . $ THD#transaction.->wtcxx . . $ THD#st_transactions#wt.); |
| 3176 | if (unlikelycxx . . $ `include/my_global.h:361:9`!(trn == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)) |
| 3177 | { |
| 3178 | reset_thd_trncxx . . $ reset_thd_trn(c109590e3cccfeb8).(thd, used_tables); // Calls thd_set_ha_data() |
| 3179 | error= HA_ERR_OUT_OF_MEMcxx . . $ `include/my_base.h:473:9`!; |
| 3180 | goto end; |
| 3181 | } |
| 3182 | else |
| 3183 | thd_set_ha_data(thd, maria_htoncxx . . $ maria_hton., trn); |
| 3184 | |
| 3185 | /* |
| 3186 | Move all locked tables to the new transaction |
| 3187 | We must do it here as otherwise file->thd and file->state may be |
| 3188 | stale pointers. We can't do this in start_stmt() as we don't know |
| 3189 | when we should call _ma_setup_live_state() and in some cases, like |
| 3190 | in check table, we use the table without calling start_stmt(). |
| 3191 | */ |
| 3192 | |
| 3193 | for (MARIA_HA *handler= used_tables; handler ; |
| 3194 | handler= trn_next) |
| 3195 | { |
| 3196 | trn_next= handler->trn_nextcxx . . $ st_maria_handler#trn_next.; |
| 3197 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(handler->s->base.born_transactional); |
| 3198 | |
| 3199 | /* |
| 3200 | We reset the link to the old trn to avoid the asserts |
| 3201 | in _ma_set_trn_for_table() |
| 3202 | */ |
| 3203 | handler->trn_nextcxx . . $ st_maria_handler#trn_next.= 0; |
| 3204 | handler->trn_prevcxx . . $ st_maria_handler#trn_prev.= 0; |
| 3205 | handler->trncxx . . $ st_maria_handler#trn.= 0; |
| 3206 | |
| 3207 | /* If handler uses versioning */ |
| 3208 | if (handler->scxx . . $ st_maria_handler#s.->lock_key_trees) |
| 3209 | { |
| 3210 | /* _ma_set_trn_for_table() will be called indirectly */ |
| 3211 | if (_ma_setup_live_state(handler)) |
| 3212 | error= HA_ERR_OUT_OF_MEMcxx . . $ `include/my_base.h:473:9`!; |
| 3213 | } |
| 3214 | else |
| 3215 | _ma_set_trn_for_tablecxx . . $ _ma_set_trn_for_table(de0e2855de83418e).(handler, trn); |
| 3216 | } |
| 3217 | /* This is just a commit, tables stay locked if they were: */ |
| 3218 | trnman_reset_locked_tables(trn, locked_tables); |
| 3219 | |
| 3220 | end: |
| 3221 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error); |
| 3222 | } |
| 3223 | |
| 3224 | |
| 3225 | THR_LOCK_DATA **ha_mariacxx . . $ ha_maria#::store_lockcxx . . $ ha_maria#store_lock(47e46f62a15ac189).(THDcxx . . $ THD# *thd, |
| 3226 | THR_LOCK_DATA **to, |
| 3227 | enum thr_lock_type lock_type) |
| 3228 | { |
| 3229 | /* Test if we can fix test below */ |
| 3230 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(lock_type != TL_UNLOCK && |
| 3231 | (lock_type == TL_IGNORE || file->lock.type == TL_UNLOCK)); |
| 3232 | if (lock_type != TL_IGNORE && filecxx . . $ ha_maria#file.->lockcxx . . $ st_maria_handler#lock..type == TL_UNLOCK) |
| 3233 | { |
| 3234 | const enum enum_sql_commandcxx . . $ enum_sql_command# sql_command= thd->lexcxx . . $ Statement#lex.->sql_commandcxx . . $ Query_tables_list#sql_command.; |
| 3235 | /* |
| 3236 | We have to disable concurrent inserts for INSERT ... SELECT or |
| 3237 | INSERT/UPDATE/DELETE with sub queries if we are using statement based |
| 3238 | logging. We take the safe route here and disable this for all commands |
| 3239 | that only does reading that are not SELECT. |
| 3240 | */ |
| 3241 | if (lock_type <= TL_READ_HIGH_PRIORITY && |
| 3242 | !thd->is_current_stmt_binlog_format_rowcxx . . $ THD#is_current_stmt_binlog_format_row(455f465bc33b4cdf).() && |
| 3243 | (sql_command != SQLCOM_SELECTcxx . . $ SQLCOM_SELECT. && |
| 3244 | sql_command != SQLCOM_LOCK_TABLEScxx . . $ SQLCOM_LOCK_TABLES.) && |
| 3245 | (thd->variablescxx . . $ THD#variables..option_bitscxx . . $ system_variables#option_bits. & OPTION_BIN_LOGcxx . . $ `sql/sql_priv.h:67:9`!) && |
| 3246 | mysql_bin_logcxx . . $ mysql_bin_log..is_opencxx . . $ MYSQL_LOG#is_open(c9857a73d68e59ba).()) |
| 3247 | lock_type= TL_READ_NO_INSERT; |
| 3248 | else if (lock_type == TL_WRITE_CONCURRENT_INSERT) |
| 3249 | { |
| 3250 | const enum enum_duplicatescxx . . $ enum_duplicates# duplicates= thd->lexcxx . . $ Statement#lex.->duplicatescxx . . $ LEX#duplicates.; |
| 3251 | /* |
| 3252 | Explanation for the 3 conditions below, in order: |
| 3253 | |
| 3254 | - Bulk insert may use repair, which will cause problems if other |
| 3255 | threads try to read/insert to the table: disable versioning. |
| 3256 | Note that our read of file->state->records is incorrect, as such |
| 3257 | variable may have changed when we come to start_bulk_insert() (worse |
| 3258 | case: we see != 0 so allow versioning, start_bulk_insert() sees 0 and |
| 3259 | uses repair). This is prevented because start_bulk_insert() will not |
| 3260 | try repair if we enabled versioning. |
| 3261 | - INSERT SELECT ON DUPLICATE KEY UPDATE comes here with |
| 3262 | TL_WRITE_CONCURRENT_INSERT but shouldn't because it can do |
| 3263 | update/delete of a row and versioning doesn't support that |
| 3264 | - same for LOAD DATA CONCURRENT REPLACE. |
| 3265 | */ |
| 3266 | if ((filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->records == 0) || |
| 3267 | (sql_command == SQLCOM_INSERT_SELECTcxx . . $ SQLCOM_INSERT_SELECT. && duplicates == DUP_UPDATEcxx . . $ DUP_UPDATE.) || |
| 3268 | (sql_command == SQLCOM_LOADcxx . . $ SQLCOM_LOAD. && duplicates == DUP_REPLACEcxx . . $ DUP_REPLACE.)) |
| 3269 | lock_type= TL_WRITE; |
| 3270 | } |
| 3271 | filecxx . . $ ha_maria#file.->lockcxx . . $ st_maria_handler#lock..type= lock_type; |
| 3272 | } |
| 3273 | *to++= &filecxx . . $ ha_maria#file.->lockcxx . . $ st_maria_handler#lock.; |
| 3274 | return to; |
| 3275 | } |
| 3276 | |
| 3277 | |
| 3278 | void ha_mariacxx . . $ ha_maria#::update_create_infocxx . . $ ha_maria#update_create_info(3ce3e72f07fbae22).(HA_CREATE_INFOcxx . . $ HA_CREATE_INFO# *create_info) |
| 3279 | { |
| 3280 | ha_mariacxx . . $ ha_maria#::infocxx . . $ ha_maria#info(4c679297bf94b9eb).(HA_STATUS_AUTOcxx . . $ `include/my_base.h:446:9`! | HA_STATUS_CONSTcxx . . $ `include/my_base.h:430:9`!); |
| 3281 | if (!(create_info->used_fieldscxx . . $ Table_scope_and_contents_source_pod_st#used_fields. & HA_CREATE_USED_AUTOcxx . . $ `sql/handler.h:623:9`!)) |
| 3282 | { |
| 3283 | create_info->auto_increment_valuecxx . . $ Table_scope_and_contents_source_pod_st#auto_increment_value.= statscxx . . $ handler#stats..auto_increment_valuecxx . . $ ha_statistics#auto_increment_value.; |
| 3284 | } |
| 3285 | create_info->data_file_namecxx . . $ Table_scope_and_contents_source_pod_st#data_file_name.= data_file_namecxx . . $ ha_maria#data_file_name.; |
| 3286 | create_info->index_file_namecxx . . $ Table_scope_and_contents_source_pod_st#index_file_name.= index_file_namecxx . . $ ha_maria#index_file_name.; |
| 3287 | /* |
| 3288 | Keep user-specified row_type for ALTER, |
| 3289 | but show the actually used one in SHOW |
| 3290 | */ |
| 3291 | if (create_info->row_typecxx . . $ Table_scope_and_contents_source_pod_st#row_type. != ROW_TYPE_DEFAULTcxx . . $ ROW_TYPE_DEFAULT. && |
| 3292 | !(thd_sql_command(ha_thdcxx . . $ handler#ha_thd(da00c4f4e081f1fe).()) == SQLCOM_ALTER_TABLEcxx . . $ SQLCOM_ALTER_TABLE.)) |
| 3293 | create_info->row_typecxx . . $ Table_scope_and_contents_source_pod_st#row_type.= get_row_typecxx . . $ ha_maria#get_row_type(288dcaa8a50eb472).(); |
| 3294 | /* |
| 3295 | Show always page checksums, as this can be forced with |
| 3296 | maria_page_checksums variable |
| 3297 | */ |
| 3298 | if (create_info->page_checksumcxx . . $ Table_scope_and_contents_source_pod_st#page_checksum. == HA_CHOICE_UNDEFcxx . . $ HA_CHOICE_UNDEF.) |
| 3299 | create_info->page_checksumcxx . . $ Table_scope_and_contents_source_pod_st#page_checksum.= |
| 3300 | (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->options & HA_OPTION_PAGE_CHECKSUMcxx . . $ `include/my_base.h:355:9`!) ? HA_CHOICE_YEScxx . . $ HA_CHOICE_YES. : |
| 3301 | HA_CHOICE_NOcxx . . $ HA_CHOICE_NO.; |
| 3302 | } |
| 3303 | |
| 3304 | |
| 3305 | enum row_typecxx . . $ row_type# ha_mariacxx . . $ ha_maria#::get_row_typecxx . . $ ha_maria#get_row_type(288dcaa8a50eb472).() const |
| 3306 | { |
| 3307 | switch (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->data_file_type) { |
| 3308 | case STATIC_RECORDcxx . . $ STATIC_RECORD.: return ROW_TYPE_FIXEDcxx . . $ ROW_TYPE_FIXED.; |
| 3309 | case DYNAMIC_RECORDcxx . . $ DYNAMIC_RECORD.: return ROW_TYPE_DYNAMICcxx . . $ ROW_TYPE_DYNAMIC.; |
| 3310 | case BLOCK_RECORDcxx . . $ BLOCK_RECORD.: return ROW_TYPE_PAGEcxx . . $ ROW_TYPE_PAGE.; |
| 3311 | case COMPRESSED_RECORDcxx . . $ COMPRESSED_RECORD.: return ROW_TYPE_COMPRESSEDcxx . . $ ROW_TYPE_COMPRESSED.; |
| 3312 | default: return ROW_TYPE_NOT_USEDcxx . . $ ROW_TYPE_NOT_USED.; |
| 3313 | } |
| 3314 | } |
| 3315 | |
| 3316 | |
| 3317 | static enum data_file_typecxx . . $ data_file_type# maria_row_typecxx . . $ maria_row_type(f6b14e6cc6324800).(HA_CREATE_INFOcxx . . $ HA_CREATE_INFO# *info) |
| 3318 | { |
| 3319 | if (info->transactionalcxx . . $ Table_scope_and_contents_source_pod_st#transactional. == HA_CHOICE_YEScxx . . $ HA_CHOICE_YES.) |
| 3320 | return BLOCK_RECORDcxx . . $ BLOCK_RECORD.; |
| 3321 | switch (info->row_typecxx . . $ Table_scope_and_contents_source_pod_st#row_type.) { |
| 3322 | case ROW_TYPE_FIXEDcxx . . $ ROW_TYPE_FIXED.: return STATIC_RECORDcxx . . $ STATIC_RECORD.; |
| 3323 | case ROW_TYPE_DYNAMICcxx . . $ ROW_TYPE_DYNAMIC.: return DYNAMIC_RECORDcxx . . $ DYNAMIC_RECORD.; |
| 3324 | default: return BLOCK_RECORDcxx . . $ BLOCK_RECORD.; |
| 3325 | } |
| 3326 | } |
| 3327 | |
| 3328 | |
| 3329 | int ha_mariacxx . . $ ha_maria#::createcxx . . $ ha_maria#create(cdb011dbefdc6262).(const char *name, TABLEcxx . . $ TABLE# *table_arg, |
| 3330 | HA_CREATE_INFOcxx . . $ HA_CREATE_INFO# *ha_create_info) |
| 3331 | { |
| 3332 | int error; |
| 3333 | uint create_flags= 0, record_count= 0, i; |
| 3334 | char buff[FN_REFLENcxx . . $ `include/my_global.h:603:9`!]; |
| 3335 | MARIA_KEYDEF *keydef; |
| 3336 | MARIA_COLUMNDEF *recinfo; |
| 3337 | MARIA_CREATE_INFO create_info; |
| 3338 | TABLE_SHAREcxx . . $ TABLE_SHARE# *share= table_arg->scxx . . $ TABLE#s.; |
| 3339 | uint options= share->db_options_in_usecxx . . $ TABLE_SHARE#db_options_in_use.; |
| 3340 | ha_table_option_structcxx . . $ ha_table_option_struct# *table_options= table_arg->scxx . . $ TABLE#s.->option_structcxx . . $ TABLE_SHARE#option_struct.; |
| 3341 | enum data_file_typecxx . . $ data_file_type# row_type; |
| 3342 | THDcxx . . $ THD# *thd= current_thdcxx . . $ `sql/mysqld.h:916:9`!; |
| 3343 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::create"); |
| 3344 | |
| 3345 | for (i= 0; i < share->keyscxx . . $ TABLE_SHARE#keys.; i++) |
| 3346 | { |
| 3347 | if (table_arg->key_infocxx . . $ TABLE#key_info.[i].flagscxx . . $ st_key#flags. & HA_USES_PARSERcxx . . $ `include/my_base.h:298:9`!) |
| 3348 | { |
| 3349 | create_flags|= HA_CREATE_RELIES_ON_SQL_LAYERcxx . . $ `include/my_base.h:389:9`!; |
| 3350 | break; |
| 3351 | } |
| 3352 | } |
| 3353 | /* Note: BLOCK_RECORD is used if table is transactional */ |
| 3354 | row_type= maria_row_typecxx . . $ maria_row_type(f6b14e6cc6324800).(ha_create_info); |
| 3355 | if (ha_create_info->transactionalcxx . . $ Table_scope_and_contents_source_pod_st#transactional. == HA_CHOICE_YEScxx . . $ HA_CHOICE_YES. && |
| 3356 | ha_create_info->row_typecxx . . $ Table_scope_and_contents_source_pod_st#row_type. != ROW_TYPE_PAGEcxx . . $ ROW_TYPE_PAGE. && |
| 3357 | ha_create_info->row_typecxx . . $ Table_scope_and_contents_source_pod_st#row_type. != ROW_TYPE_NOT_USEDcxx . . $ ROW_TYPE_NOT_USED. && |
| 3358 | ha_create_info->row_typecxx . . $ Table_scope_and_contents_source_pod_st#row_type. != ROW_TYPE_DEFAULTcxx . . $ ROW_TYPE_DEFAULT.) |
| 3359 | push_warningcxx . . $ push_warning(e5388ac74f886b26).(thd, Sql_conditioncxx . . $ Sql_condition#::WARN_LEVEL_NOTEcxx . . $ Sql_state_errno_level#WARN_LEVEL_NOTE., |
| 3360 | ER_ILLEGAL_HA_CREATE_OPTIONcxx . . $ `build/include/mysqld_error.h:483:9`!, |
| 3361 | "Row format set to PAGE because of TRANSACTIONAL=1 option"); |
| 3362 | |
| 3363 | if (share->table_typecxx . . $ TABLE_SHARE#table_type. == TABLE_TYPE_SEQUENCEcxx . . $ TABLE_TYPE_SEQUENCE.) |
| 3364 | { |
| 3365 | /* For sequences, the simples record type is appropriate */ |
| 3366 | row_type= STATIC_RECORDcxx . . $ STATIC_RECORD.; |
| 3367 | ha_create_info->transactionalcxx . . $ Table_scope_and_contents_source_pod_st#transactional.= HA_CHOICE_NOcxx . . $ HA_CHOICE_NO.; |
| 3368 | } |
| 3369 | |
| 3370 | bzerocxx . . $ `include/m_string.h:61:10`!((char*) &create_info, sizeof(create_info)); |
| 3371 | if ((error= table2mariacxx . . $ table2maria(f59b83681afcea70).(table_arg, row_type, &keydef, &recinfo, |
| 3372 | &record_count, &create_info))) |
| 3373 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error); /* purecov: inspected */ |
| 3374 | create_info.max_rows= share->max_rowscxx . . $ TABLE_SHARE#max_rows.; |
| 3375 | create_info.reloc_rows= share->min_rowscxx . . $ TABLE_SHARE#min_rows.; |
| 3376 | create_info.with_auto_increment= share->next_number_key_offsetcxx . . $ TABLE_SHARE#next_number_key_offset. == 0; |
| 3377 | create_info.auto_increment= (ha_create_info->auto_increment_valuecxx . . $ Table_scope_and_contents_source_pod_st#auto_increment_value. ? |
| 3378 | ha_create_info->auto_increment_valuecxx . . $ Table_scope_and_contents_source_pod_st#auto_increment_value. -1 : |
| 3379 | (ulonglongcxx . . $ ulonglong#) 0); |
| 3380 | create_info.data_file_length= ((ulonglongcxx . . $ ulonglong#) share->max_rowscxx . . $ TABLE_SHARE#max_rows. * |
| 3381 | share->avg_row_lengthcxx . . $ TABLE_SHARE#avg_row_length.); |
| 3382 | create_info.data_file_name= ha_create_info->data_file_namecxx . . $ Table_scope_and_contents_source_pod_st#data_file_name.; |
| 3383 | create_info.index_file_name= ha_create_info->index_file_namecxx . . $ Table_scope_and_contents_source_pod_st#index_file_name.; |
| 3384 | create_info.language= share->table_charsetcxx . . $ TABLE_SHARE#table_charset.->numbercxx . . $ charset_info_st#number.; |
| 3385 | if (htcxx . . $ handler#ht. != maria_htoncxx . . $ maria_hton.) |
| 3386 | { |
| 3387 | /* S3 engine */ |
| 3388 | create_info.s3_block_size= (ulong) table_options->s3_block_sizecxx . . $ ha_table_option_struct#s3_block_size.; |
| 3389 | create_info.compression_algorithm= table_options->compression_algorithmcxx . . $ ha_table_option_struct#compression_algorithm.; |
| 3390 | } |
| 3391 | |
| 3392 | /* |
| 3393 | Table is transactional: |
| 3394 | - If the user specify that table is transactional (in this case |
| 3395 | row type is forced to BLOCK_RECORD) |
| 3396 | - If they specify BLOCK_RECORD without specifying transactional behaviour |
| 3397 | |
| 3398 | Shouldn't this test be pushed down to maria_create()? Because currently, |
| 3399 | ma_test1 -T crashes: it creates a table with DYNAMIC_RECORD but has |
| 3400 | born_transactional==1, which confuses some recovery-related code. |
| 3401 | */ |
| 3402 | create_info.transactional= (row_type == BLOCK_RECORDcxx . . $ BLOCK_RECORD. && |
| 3403 | ha_create_info->transactionalcxx . . $ Table_scope_and_contents_source_pod_st#transactional. != HA_CHOICE_NOcxx . . $ HA_CHOICE_NO.); |
| 3404 | |
| 3405 | if (ha_create_info->tmp_tablecxx . . $ Table_scope_and_contents_source_pod_st#tmp_table(50ce9a9e25b4a850).()) |
| 3406 | { |
| 3407 | create_flags|= HA_CREATE_TMP_TABLEcxx . . $ `include/my_base.h:384:9`! | HA_CREATE_DELAY_KEY_WRITEcxx . . $ `include/my_base.h:388:9`!; |
| 3408 | if (ha_create_info->optionscxx . . $ Table_scope_and_contents_source_pod_st#options. & HA_LEX_CREATE_GLOBAL_TMP_TABLEcxx . . $ `sql/handler.h:516:9`!) |
| 3409 | create_flags|= HA_CREATE_GLOBAL_TMP_TABLEcxx . . $ `include/my_base.h:398:9`!; |
| 3410 | create_info.transactional= 0; |
| 3411 | } |
| 3412 | if (ha_create_info->optionscxx . . $ Table_scope_and_contents_source_pod_st#options. & HA_CREATE_KEEP_FILEScxx . . $ `include/my_base.h:386:9`!) |
| 3413 | create_flags|= HA_CREATE_KEEP_FILEScxx . . $ `include/my_base.h:386:9`!; |
| 3414 | if (options & HA_OPTION_PACK_RECORDcxx . . $ `include/my_base.h:344:9`!) |
| 3415 | create_flags|= HA_PACK_RECORDcxx . . $ `include/my_base.h:383:9`!; |
| 3416 | if (options & HA_OPTION_CHECKSUMcxx . . $ `include/my_base.h:349:9`!) |
| 3417 | create_flags|= HA_CREATE_CHECKSUMcxx . . $ `include/my_base.h:385:9`!; |
| 3418 | if (options & HA_OPTION_DELAY_KEY_WRITEcxx . . $ `include/my_base.h:350:9`!) |
| 3419 | create_flags|= HA_CREATE_DELAY_KEY_WRITEcxx . . $ `include/my_base.h:388:9`!; |
| 3420 | if ((ha_create_info->page_checksumcxx . . $ Table_scope_and_contents_source_pod_st#page_checksum. == HA_CHOICE_UNDEFcxx . . $ HA_CHOICE_UNDEF. && |
| 3421 | maria_page_checksums) || |
| 3422 | ha_create_info->page_checksumcxx . . $ Table_scope_and_contents_source_pod_st#page_checksum. == HA_CHOICE_YEScxx . . $ HA_CHOICE_YES.) |
| 3423 | create_flags|= HA_CREATE_PAGE_CHECKSUMcxx . . $ `include/my_base.h:387:9`!; |
| 3424 | |
| 3425 | (void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERYcxx . . $ LOGREC_DEBUG_INFO_QUERY., |
| 3426 | (ucharcxx . . $ uchar#*) thd->querycxx . . $ Statement#query(e7e5aa338b9d5147).(), thd->query_lengthcxx . . $ Statement#query_length(ddd8539a2fcdd4ce).()); |
| 3427 | |
| 3428 | create_info.encrypted= maria_encrypt_tables && htcxx . . $ handler#ht. == maria_htoncxx . . $ maria_hton.; |
| 3429 | /* TODO: Check that the following fn_format is really needed */ |
| 3430 | error= |
| 3431 | maria_create(fn_format(buff, name, "", "", |
| 3432 | MY_UNPACK_FILENAMEcxx . . $ `include/my_sys.h:115:9`! | MY_APPEND_EXTcxx . . $ `include/my_sys.h:121:9`!), |
| 3433 | row_type, share->keyscxx . . $ TABLE_SHARE#keys., keydef, |
| 3434 | record_count, recinfo, |
| 3435 | 0, (MARIA_UNIQUEDEF *) 0, |
| 3436 | &create_info, create_flags); |
| 3437 | |
| 3438 | my_free(recinfo); |
| 3439 | ref_lengthcxx . . $ handler#ref_length.= create_info.rec_reflength; |
| 3440 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(error); |
| 3441 | } |
| 3442 | |
| 3443 | |
| 3444 | int ha_mariacxx . . $ ha_maria#::rename_tablecxx . . $ ha_maria#rename_table(5ae29d726ae57f88).(const char *from, const char *to) |
| 3445 | { |
| 3446 | THDcxx . . $ THD# *thd= current_thdcxx . . $ `sql/mysqld.h:916:9`!; |
| 3447 | (void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERYcxx . . $ LOGREC_DEBUG_INFO_QUERY., |
| 3448 | (ucharcxx . . $ uchar#*) thd->querycxx . . $ Statement#query(e7e5aa338b9d5147).(), thd->query_lengthcxx . . $ Statement#query_length(ddd8539a2fcdd4ce).()); |
| 3449 | return maria_rename(from, to); |
| 3450 | } |
| 3451 | |
| 3452 | |
| 3453 | void ha_mariacxx . . $ ha_maria#::get_auto_incrementcxx . . $ ha_maria#get_auto_increment(a593684596ab789f).(ulonglongcxx . . $ ulonglong# offset, ulonglongcxx . . $ ulonglong# increment, |
| 3454 | ulonglongcxx . . $ ulonglong# nb_desired_values, |
| 3455 | ulonglongcxx . . $ ulonglong# *first_value, |
| 3456 | ulonglongcxx . . $ ulonglong# *nb_reserved_values) |
| 3457 | { |
| 3458 | ulonglongcxx . . $ ulonglong# nr; |
| 3459 | int error; |
| 3460 | ucharcxx . . $ uchar# key[MARIA_MAX_KEY_BUFFcxx . . $ `storage/maria/maria_def.h:532:9`!]; |
| 3461 | enum ha_rkey_functioncxx . . $ ha_rkey_function# search_flag= HA_READ_PREFIX_LASTcxx . . $ HA_READ_PREFIX_LAST.; |
| 3462 | |
| 3463 | if (!tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->next_number_key_offsetcxx . . $ TABLE_SHARE#next_number_key_offset.) |
| 3464 | { // Autoincrement at key-start |
| 3465 | ha_mariacxx . . $ ha_maria#::infocxx . . $ ha_maria#info(4c679297bf94b9eb).(HA_STATUS_AUTOcxx . . $ `include/my_base.h:446:9`!); |
| 3466 | *first_value= statscxx . . $ handler#stats..auto_increment_valuecxx . . $ ha_statistics#auto_increment_value.; |
| 3467 | /* Maria has only table-level lock for now, so reserves to +inf */ |
| 3468 | *nb_reserved_values= ULONGLONG_MAXcxx . . $ `include/my_global.h:766:9`!; |
| 3469 | return; |
| 3470 | } |
| 3471 | |
| 3472 | /* it's safe to call the following if bulk_insert isn't on */ |
| 3473 | maria_flush_bulk_insert(filecxx . . $ ha_maria#file., tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->next_number_indexcxx . . $ TABLE_SHARE#next_number_index.); |
| 3474 | |
| 3475 | if (unlikelycxx . . $ `include/my_global.h:361:9`!(table->key_info[table->s->next_number_index]. |
| 3476 | key_part[table->s->next_number_keypart].key_part_flag & |
| 3477 | HA_REVERSE_SORTcxx . . $ `include/my_base.h:337:9`!)) |
| 3478 | search_flag= HA_READ_KEY_EXACTcxx . . $ HA_READ_KEY_EXACT.; |
| 3479 | |
| 3480 | (void) extracxx . . $ ha_maria#extra(3f7d7dcfae14d7dd).(HA_EXTRA_KEYREADcxx . . $ HA_EXTRA_KEYREAD.); |
| 3481 | key_copycxx . . $ key_copy(b9cb032dc918416a).(key, tablecxx . . $ handler#table.->recordcxx . . $ TABLE#record.[0], |
| 3482 | tablecxx . . $ handler#table.->key_infocxx . . $ TABLE#key_info. + tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->next_number_indexcxx . . $ TABLE_SHARE#next_number_index., |
| 3483 | tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->next_number_key_offsetcxx . . $ TABLE_SHARE#next_number_key_offset.); |
| 3484 | error= maria_rkey(filecxx . . $ ha_maria#file., tablecxx . . $ handler#table.->recordcxx . . $ TABLE#record.[1], (int) tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->next_number_indexcxx . . $ TABLE_SHARE#next_number_index., |
| 3485 | key, make_prev_keypart_mapcxx . . $ make_prev_keypart_map(1892545c1754497d).(tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->next_number_keypartcxx . . $ TABLE_SHARE#next_number_keypart.), |
| 3486 | search_flag); |
| 3487 | if (error) |
| 3488 | nr= 1; |
| 3489 | else |
| 3490 | { |
| 3491 | /* Get data from record[1] */ |
| 3492 | nr= ((ulonglongcxx . . $ ulonglong#) tablecxx . . $ handler#table.->next_number_fieldcxx . . $ TABLE#next_number_field.-> |
| 3493 | val_int_offsetcxx . . $ Field#val_int_offset(be7fac6efae795de).(tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->rec_buff_lengthcxx . . $ TABLE_SHARE#rec_buff_length.) + 1); |
| 3494 | } |
| 3495 | extracxx . . $ ha_maria#extra(3f7d7dcfae14d7dd).(HA_EXTRA_NO_KEYREADcxx . . $ HA_EXTRA_NO_KEYREAD.); |
| 3496 | *first_value= nr; |
| 3497 | /* |
| 3498 | MySQL needs to call us for next row: assume we are inserting ("a",null) |
| 3499 | here, we return 3, and next this statement will want to insert ("b",null): |
| 3500 | there is no reason why ("b",3+1) would be the good row to insert: maybe it |
| 3501 | already exists, maybe 3+1 is too large... |
| 3502 | */ |
| 3503 | *nb_reserved_values= 1; |
| 3504 | } |
| 3505 | |
| 3506 | |
| 3507 | /* |
| 3508 | Find out how many rows there is in the given range |
| 3509 | |
| 3510 | SYNOPSIS |
| 3511 | records_in_range() |
| 3512 | inx Index to use |
| 3513 | min_key Start of range. Null pointer if from first key |
| 3514 | max_key End of range. Null pointer if to last key |
| 3515 | pages Store first and last page for the range in case of |
| 3516 | b-trees. In other cases it's not touched. |
| 3517 | |
| 3518 | NOTES |
| 3519 | min_key.flag can have one of the following values: |
| 3520 | HA_READ_KEY_EXACT Include the key in the range |
| 3521 | HA_READ_AFTER_KEY Don't include key in range |
| 3522 | |
| 3523 | max_key.flag can have one of the following values: |
| 3524 | HA_READ_BEFORE_KEY Don't include key in range |
| 3525 | HA_READ_AFTER_KEY Include all 'end_key' values in the range |
| 3526 | |
| 3527 | RETURN |
| 3528 | HA_POS_ERROR Something is wrong with the index tree. |
| 3529 | 0 There is no matching keys in the given range |
| 3530 | number > 0 There is approximately 'number' matching rows in |
| 3531 | the range. |
| 3532 | */ |
| 3533 | |
| 3534 | ha_rowscxx . . $ ha_rows# ha_mariacxx . . $ ha_maria#::records_in_rangecxx . . $ ha_maria#records_in_range(b018bf152a3ffa81).(uint inx, const key_rangecxx . . $ key_range# *min_key, |
| 3535 | const key_rangecxx . . $ key_range# *max_key, page_rangecxx . . $ page_range# *pages) |
| 3536 | { |
| 3537 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 3538 | return (ha_rowscxx . . $ ha_rows#) maria_records_in_range(filecxx . . $ ha_maria#file., (int) inx, min_key, max_key, |
| 3539 | pages); |
| 3540 | } |
| 3541 | |
| 3542 | |
| 3543 | FT_INFO *ha_mariacxx . . $ ha_maria#::ft_init_extcxx . . $ ha_maria#ft_init_ext(281c1b5398ceef01).(uint flags, uint inx, Stringcxx . . $ String# * key) |
| 3544 | { |
| 3545 | return maria_ft_init_search(flags, filecxx . . $ ha_maria#file., inx, |
| 3546 | (ucharcxx . . $ uchar# *) key->ptrcxx . . $ Binary_string#ptr(a9f41ea0e82d88cf).(), key->lengthcxx . . $ Binary_string#length(ddd8539a2fcdd4ce).(), |
| 3547 | key->charsetcxx . . $ Charset#charset(2209ea2d1c8c1ec1).(), tablecxx . . $ handler#table.->recordcxx . . $ TABLE#record.[0]); |
| 3548 | } |
| 3549 | |
| 3550 | |
| 3551 | int ha_mariacxx . . $ ha_maria#::ft_readcxx . . $ ha_maria#ft_read(b2e27cdb9bef2230).(ucharcxx . . $ uchar# * buf) |
| 3552 | { |
| 3553 | int error; |
| 3554 | |
| 3555 | if (!ft_handlercxx . . $ handler#ft_handler.) |
| 3556 | return -1; |
| 3557 | |
| 3558 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 3559 | |
| 3560 | thread_safe_incrementcxx . . $ `include/my_pthread.h:737:9`!(table->in_use->status_var.ha_read_next_count, |
| 3561 | &LOCK_status); // why ? |
| 3562 | |
| 3563 | error= ft_handlercxx . . $ handler#ft_handler.->pleasecxx . . $ st_ft_info#please.->read_next(ft_handlercxx . . $ handler#ft_handler., (char*) buf); |
| 3564 | |
| 3565 | return error; |
| 3566 | } |
| 3567 | |
| 3568 | |
| 3569 | bool ha_mariacxx . . $ ha_maria#::check_if_incompatible_datacxx . . $ ha_maria#check_if_incompatible_data(fd3c848ebdb5aff0).(HA_CREATE_INFOcxx . . $ HA_CREATE_INFO# *create_info, |
| 3570 | uint table_changes) |
| 3571 | { |
| 3572 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("check_if_incompatible_data"); |
| 3573 | uint options= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->db_options_in_usecxx . . $ TABLE_SHARE#db_options_in_use.; |
| 3574 | enum ha_choicecxx . . $ ha_choice# page_checksum= tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->page_checksumcxx . . $ TABLE_SHARE#page_checksum.; |
| 3575 | |
| 3576 | if (page_checksum == HA_CHOICE_UNDEFcxx . . $ HA_CHOICE_UNDEF.) |
| 3577 | page_checksum= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->options & HA_OPTION_PAGE_CHECKSUMcxx . . $ `include/my_base.h:355:9`! ? HA_CHOICE_YEScxx . . $ HA_CHOICE_YES. |
| 3578 | : HA_CHOICE_NOcxx . . $ HA_CHOICE_NO.; |
| 3579 | |
| 3580 | if (create_info->auto_increment_valuecxx . . $ Table_scope_and_contents_source_pod_st#auto_increment_value. != statscxx . . $ handler#stats..auto_increment_valuecxx . . $ ha_statistics#auto_increment_value. || |
| 3581 | create_info->data_file_namecxx . . $ Table_scope_and_contents_source_pod_st#data_file_name. != data_file_namecxx . . $ ha_maria#data_file_name. || |
| 3582 | create_info->index_file_namecxx . . $ Table_scope_and_contents_source_pod_st#index_file_name. != index_file_namecxx . . $ ha_maria#index_file_name. || |
| 3583 | create_info->page_checksumcxx . . $ Table_scope_and_contents_source_pod_st#page_checksum. != page_checksum || |
| 3584 | create_info->transactionalcxx . . $ Table_scope_and_contents_source_pod_st#transactional. != tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->transactionalcxx . . $ TABLE_SHARE#transactional. || |
| 3585 | (maria_row_typecxx . . $ maria_row_type(f6b14e6cc6324800).(create_info) != data_file_typecxx . . $ ha_maria#data_file_type. && |
| 3586 | create_info->row_typecxx . . $ Table_scope_and_contents_source_pod_st#row_type. != ROW_TYPE_DEFAULTcxx . . $ ROW_TYPE_DEFAULT.) || |
| 3587 | table_changes == IS_EQUAL_NOcxx . . $ `sql/sql_priv.h:315:9`! || |
| 3588 | (table_changes & IS_EQUAL_PACK_LENGTHcxx . . $ `sql/sql_priv.h:322:9`!)) // Not implemented yet |
| 3589 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(COMPATIBLE_DATA_NOcxx . . $ `sql/handler.h:904:9`!); |
| 3590 | |
| 3591 | if ((options & (HA_OPTION_CHECKSUMcxx . . $ `include/my_base.h:349:9`! | |
| 3592 | HA_OPTION_DELAY_KEY_WRITEcxx . . $ `include/my_base.h:350:9`!)) != |
| 3593 | (create_info->table_optionscxx . . $ Table_scope_and_contents_source_pod_st#table_options. & (HA_OPTION_CHECKSUMcxx . . $ `include/my_base.h:349:9`! | |
| 3594 | HA_OPTION_DELAY_KEY_WRITEcxx . . $ `include/my_base.h:350:9`!))) |
| 3595 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(COMPATIBLE_DATA_NOcxx . . $ `sql/handler.h:904:9`!); |
| 3596 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(COMPATIBLE_DATA_YEScxx . . $ `sql/handler.h:903:9`!); |
| 3597 | } |
| 3598 | |
| 3599 | |
| 3600 | static int maria_hton_paniccxx . . $ maria_hton_panic(1608599b6f4f877c).(handlertoncxx . . $ handlerton# *hton, ha_panic_functioncxx . . $ ha_panic_function# flag) |
| 3601 | { |
| 3602 | /* If no background checkpoints, we need to do one now */ |
| 3603 | int ret=0; |
| 3604 | |
| 3605 | if (!checkpoint_intervalcxx . . $ checkpoint_interval. && !aria_readonly) |
| 3606 | ret= ma_checkpoint_execute(CHECKPOINT_FULL, FALSEcxx . . $ `include/my_global.h:477:9`!); |
| 3607 | |
| 3608 | ret|= maria_panic(flag); |
| 3609 | |
| 3610 | maria_htoncxx . . $ maria_hton.= 0; |
| 3611 | return ret; |
| 3612 | } |
| 3613 | |
| 3614 | |
| 3615 | static int maria_commitcxx . . $ maria_commit(a4bb9b94410fc259).(THDcxx . . $ THD# *thd, bool all) |
| 3616 | { |
| 3617 | TRN *trn= THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`!; |
| 3618 | int res= 0; |
| 3619 | MARIA_HA *used_instances; |
| 3620 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("maria_commit"); |
| 3621 | |
| 3622 | /* No commit inside lock_tables() */ |
| 3623 | if ((!trn || |
| 3624 | thd->locked_tables_modecxx . . $ Open_tables_state#locked_tables_mode. == LTM_LOCK_TABLEScxx . . $ LTM_LOCK_TABLES. || |
| 3625 | thd->locked_tables_modecxx . . $ Open_tables_state#locked_tables_mode. == LTM_PRELOCKED_UNDER_LOCK_TABLEScxx . . $ LTM_PRELOCKED_UNDER_LOCK_TABLES.)) |
| 3626 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 3627 | |
| 3628 | /* statement or transaction ? */ |
| 3629 | if ((thd->variablescxx . . $ THD#variables..option_bitscxx . . $ system_variables#option_bits. & (OPTION_NOT_AUTOCOMMITcxx . . $ `sql/sql_priv.h:68:9`! | OPTION_BEGINcxx . . $ `sql/sql_priv.h:69:9`!)) && |
| 3630 | !all) |
| 3631 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); // end of statement |
| 3632 | |
| 3633 | used_instances= (MARIA_HA*) trn->used_instancescxx . . $ st_ma_transaction#used_instances.; |
| 3634 | trnman_reset_locked_tables(trn, 0); |
| 3635 | trnman_set_flagscxx . . $ `storage/maria/trnman_public.h:78:9`!(trn, trnman_get_flags(trn) & ~TRN_STATE_INFO_LOGGED); |
| 3636 | trn->used_instancescxx . . $ st_ma_transaction#used_instances.= 0; |
| 3637 | if (ma_commit(trn)) |
| 3638 | res= HA_ERR_COMMIT_ERRORcxx . . $ `include/my_base.h:555:9`!; |
| 3639 | reset_thd_trncxx . . $ reset_thd_trn(c109590e3cccfeb8).(thd, used_instances); |
| 3640 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(res); |
| 3641 | } |
| 3642 | |
| 3643 | #ifdef MARIA_CANNOT_ROLLBACKcxx . . $ `storage/maria/maria_def.h:42:9`! |
| 3644 | static int maria_rollbackcxx . . $ maria_rollback(a4bb9b94410fc259).(THDcxx . . $ THD# *thd, bool all) |
| 3645 | { |
| 3646 | TRN *trn= THD_TRNcxx . . $ `storage/maria/ha_maria.cc:58:9`!; |
| 3647 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("maria_rollback"); |
| 3648 | if (!trn) |
| 3649 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 3650 | if (trn->undo_lsncxx . . $ st_ma_transaction#undo_lsn.) |
| 3651 | push_warning_printfcxx . . $ push_warning_printf(aadc080f3f4146b5).(thd, Sql_conditioncxx . . $ Sql_condition#::WARN_LEVEL_NOTEcxx . . $ Sql_state_errno_level#WARN_LEVEL_NOTE., |
| 3652 | ER_DATA_WAS_COMMITED_UNDER_ROLLBACKcxx . . $ `build/include/mysqld_error.h:1322:9`!, |
| 3653 | ER_THDcxx . . $ `sql/unireg.h:54:9`!(thd, ER_DATA_WAS_COMMITED_UNDER_ROLLBACKcxx . . $ `build/include/mysqld_error.h:1322:9`!), |
| 3654 | "Aria"); |
| 3655 | if (all) |
| 3656 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(maria_commit(thd, all)); |
| 3657 | /* Statement rollbacks are ignored. Commit will happen in external_lock */ |
| 3658 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(0); |
| 3659 | } |
| 3660 | |
| 3661 | #else |
| 3662 | |
| 3663 | static int maria_rollback(THD *thd, bool all) |
| 3664 | { |
| 3665 | TRN *trn= THD_TRN; |
| 3666 | DBUG_ENTER("maria_rollback"); |
| 3667 | |
| 3668 | DBUG_ASSERT(trnman_has_locked_tables(trn) == 0); |
| 3669 | trnman_reset_locked_tables(trn, 0); |
| 3670 | /* statement or transaction ? */ |
| 3671 | if ((thd->variables.option_bits & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && |
| 3672 | !all) |
| 3673 | { |
| 3674 | trnman_rollback_statement(trn); |
| 3675 | DBUG_RETURN(0); // end of statement |
| 3676 | } |
| 3677 | reset_thd_trn(thd, (MARIA_HA*) trn->used_instances); |
| 3678 | DBUG_RETURN(trnman_rollback_trn(trn) ? |
| 3679 | HA_ERR_OUT_OF_MEM : 0); // end of transaction |
| 3680 | } |
| 3681 | #endif /* MARIA_CANNOT_ROLLBACK */ |
| 3682 | |
| 3683 | |
| 3684 | /** |
| 3685 | @brief flush log handler |
| 3686 | |
| 3687 | @param hton maria handlerton (unused) |
| 3688 | |
| 3689 | @retval FALSE OK |
| 3690 | @retval TRUE Error |
| 3691 | */ |
| 3692 | |
| 3693 | bool maria_flush_logscxx . . $ maria_flush_logs(a003c2f189b29293).(handlertoncxx . . $ handlerton# *hton) |
| 3694 | { |
| 3695 | return MY_TESTcxx . . $ `include/my_global.h:467:9`!(translog_purge_at_flush()); |
| 3696 | } |
| 3697 | |
| 3698 | |
| 3699 | void maria_checkpoint_statecxx . . $ maria_checkpoint_state(b45ddcbc8423892c).(bool disabled) |
| 3700 | { |
| 3701 | maria_checkpoint_disabled= (my_boolcxx . . $ my_bool#) disabled; |
| 3702 | } |
| 3703 | |
| 3704 | |
| 3705 | /* |
| 3706 | Handle backup calls |
| 3707 | */ |
| 3708 | |
| 3709 | void maria_prepare_for_backupcxx . . $ maria_prepare_for_backup(49f6e7a06ebc5aa8).() |
| 3710 | { |
| 3711 | translog_disable_purge(); |
| 3712 | } |
| 3713 | |
| 3714 | void maria_end_backupcxx . . $ maria_end_backup(49f6e7a06ebc5aa8).() |
| 3715 | { |
| 3716 | translog_enable_purge(); |
| 3717 | } |
| 3718 | |
| 3719 | |
| 3720 | |
| 3721 | #define SHOW_MSG_LENcxx . . $ `storage/maria/ha_maria.cc:3721:9`! (FN_REFLENcxx . . $ `include/my_global.h:603:9`! + 20) |
| 3722 | /** |
| 3723 | @brief show status handler |
| 3724 | |
| 3725 | @param hton maria handlerton |
| 3726 | @param thd thread handler |
| 3727 | @param print print function |
| 3728 | @param stat type of status |
| 3729 | */ |
| 3730 | |
| 3731 | bool maria_show_statuscxx . . $ maria_show_status(22e956e5df450e72).(handlertoncxx . . $ handlerton# *hton, |
| 3732 | THDcxx . . $ THD# *thd, |
| 3733 | stat_print_fncxx . . $ stat_print_fn# *print, |
| 3734 | enum ha_stat_typecxx . . $ ha_stat_type# stat) |
| 3735 | { |
| 3736 | const LEX_CSTRINGcxx . . $ LEX_CSTRING# *engine_name= hton_namecxx . . $ hton_name(94a10887d4bd3df6).(hton); |
| 3737 | switch (stat) { |
| 3738 | case HA_ENGINE_LOGScxx . . $ HA_ENGINE_LOGS.: |
| 3739 | { |
| 3740 | TRANSLOG_ADDRESS horizon= translog_get_horizon(); |
| 3741 | uint32cxx . . $ uint32# last_file= LSN_FILE_NOcxx . . $ `storage/maria/ma_loghandler_lsn.h:44:9`!(horizon); |
| 3742 | uint32cxx . . $ uint32# first_needed= translog_get_first_needed_file(); |
| 3743 | uint32cxx . . $ uint32# first_file= translog_get_first_file(horizon); |
| 3744 | uint32cxx . . $ uint32# i; |
| 3745 | const char unknown[]= "unknown"; |
| 3746 | const char needed[]= "in use"; |
| 3747 | const char unneeded[]= "free"; |
| 3748 | char path[FN_REFLENcxx . . $ `include/my_global.h:603:9`!]; |
| 3749 | |
| 3750 | if (first_file == 0) |
| 3751 | { |
| 3752 | const char error[]= "error"; |
| 3753 | print(thd, engine_name->str, engine_name->length, |
| 3754 | STRING_WITH_LENcxx . . $ `include/m_string.h:206:9`!(""), error, sizeof(error) - 1); |
| 3755 | break; |
| 3756 | } |
| 3757 | |
| 3758 | for (i= first_file; i <= last_file; i++) |
| 3759 | { |
| 3760 | char *file; |
| 3761 | const char *status; |
| 3762 | size_t length, status_len; |
| 3763 | MY_STATcxx . . $ `include/my_dir.h:82:9`! stat_buff, *stat; |
| 3764 | const char error[]= "can't stat"; |
| 3765 | char object[SHOW_MSG_LENcxx . . $ `storage/maria/ha_maria.cc:3721:9`!]; |
| 3766 | file= translog_filename_by_fileno(i, path); |
| 3767 | if (!(stat= mysql_file_statcxx . . $ `include/mysql/psi/mysql_file.h:177:11`!(key_file_translog, file, &stat_buff, MYFcxx . . $ `include/my_global.h:986:9`!(0)))) |
| 3768 | { |
| 3769 | status= error; |
| 3770 | status_len= sizeof(error) - 1; |
| 3771 | length= my_snprintf(object, SHOW_MSG_LENcxx . . $ `storage/maria/ha_maria.cc:3721:9`!, "Size unknown ; %s", file); |
| 3772 | } |
| 3773 | else |
| 3774 | { |
| 3775 | if (first_needed == 0) |
| 3776 | { |
| 3777 | status= unknown; |
| 3778 | status_len= sizeof(unknown) - 1; |
| 3779 | } |
| 3780 | else if (i < first_needed) |
| 3781 | { |
| 3782 | status= unneeded; |
| 3783 | status_len= sizeof(unneeded) - 1; |
| 3784 | } |
| 3785 | else |
| 3786 | { |
| 3787 | status= needed; |
| 3788 | status_len= sizeof(needed) - 1; |
| 3789 | } |
| 3790 | length= my_snprintf(object, SHOW_MSG_LENcxx . . $ `storage/maria/ha_maria.cc:3721:9`!, "Size %12llu ; %s", |
| 3791 | (ulonglongcxx . . $ ulonglong#) stat->st_size, file); |
| 3792 | } |
| 3793 | |
| 3794 | print(thd, engine_name->str, engine_name->length, |
| 3795 | object, length, status, status_len); |
| 3796 | } |
| 3797 | break; |
| 3798 | } |
| 3799 | case HA_ENGINE_STATUScxx . . $ HA_ENGINE_STATUS.: |
| 3800 | case HA_ENGINE_MUTEXcxx . . $ HA_ENGINE_MUTEX.: |
| 3801 | default: |
| 3802 | break; |
| 3803 | } |
| 3804 | return 0; |
| 3805 | } |
| 3806 | |
| 3807 | |
| 3808 | /** |
| 3809 | Callback to delete all logs in directory. This is lower-level than other |
| 3810 | functions in ma_loghandler.c which delete logs, as it does not rely on |
| 3811 | translog_init() having been called first. |
| 3812 | |
| 3813 | @param directory directory where file is |
| 3814 | @param filename base name of the file to delete |
| 3815 | */ |
| 3816 | |
| 3817 | static my_boolcxx . . $ my_bool# translog_callback_delete_allcxx . . $ translog_callback_delete_all(aec1f115fb68c8ab).(const char *directory, |
| 3818 | const char *filename) |
| 3819 | { |
| 3820 | char complete_name[FN_REFLENcxx . . $ `include/my_global.h:603:9`!]; |
| 3821 | fn_format(complete_name, filename, directory, "", MYFcxx . . $ `include/my_global.h:986:9`!(MY_UNPACK_FILENAMEcxx . . $ `include/my_sys.h:115:9`!)); |
| 3822 | return mysql_file_deletecxx . . $ `include/mysql/psi/mysql_file.h:418:11`!(key_file_translog, complete_name, MYFcxx . . $ `include/my_global.h:986:9`!(MY_WMEcxx . . $ `include/my_sys.h:57:9`!)); |
| 3823 | } |
| 3824 | |
| 3825 | |
| 3826 | /** |
| 3827 | Helper function for option aria-force-start-after-recovery-failures. |
| 3828 | Deletes logs if too many failures. Otherwise, increments the counter of |
| 3829 | failures in the control file. |
| 3830 | Notice how this has to be called _before_ translog_init() (if log is |
| 3831 | corrupted, translog_init() might crash the server, so we need to remove logs |
| 3832 | before). |
| 3833 | |
| 3834 | @param log_dir directory where logs to be deleted are |
| 3835 | */ |
| 3836 | |
| 3837 | static int mark_recovery_startcxx . . $ mark_recovery_start(5c4306d8553b3696).(const char* log_dir) |
| 3838 | { |
| 3839 | int res; |
| 3840 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("mark_recovery_start"); |
| 3841 | if (!(maria_recover_optionscxx . . $ maria_recover_options. & HA_RECOVER_ANYcxx . . $ `storage/maria/maria_def.h:256:9`!)) |
| 3842 | ma_message_no_usercxx . . $ `storage/maria/ma_checkpoint.h:91:9`!(ME_WARNINGcxx . . $ `include/my_sys.h:109:9`!, "Please consider using option" |
| 3843 | " --aria-recover-options[=...] to automatically check and" |
| 3844 | " repair tables when logs are removed by option" |
| 3845 | " --aria-force-start-after-recovery-failures=#"); |
| 3846 | if (recovery_failures >= force_start_after_recovery_failurescxx . . $ force_start_after_recovery_failures.) |
| 3847 | { |
| 3848 | /* |
| 3849 | Remove logs which cause the problem; keep control file which has |
| 3850 | critical info like uuid, max_trid (removing control file may make |
| 3851 | correct tables look corrupted!). |
| 3852 | */ |
| 3853 | char msg[100]; |
| 3854 | res= translog_walk_filenames(log_dir, &translog_callback_delete_allcxx . . $ translog_callback_delete_all(aec1f115fb68c8ab).); |
| 3855 | my_snprintf(msg, sizeof(msg), |
| 3856 | "%s logs after %u consecutive failures of" |
| 3857 | " recovery from logs", |
| 3858 | (res ? "failed to remove some" : "removed all"), |
| 3859 | recovery_failures); |
| 3860 | ma_message_no_usercxx . . $ `storage/maria/ma_checkpoint.h:91:9`!((res ? 0 : ME_WARNINGcxx . . $ `include/my_sys.h:109:9`!), msg); |
| 3861 | } |
| 3862 | else |
| 3863 | res= ma_control_file_write_and_force(last_checkpoint_lsn, last_logno, |
| 3864 | max_trid_in_control_file, |
| 3865 | recovery_failures + 1); |
| 3866 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(res); |
| 3867 | } |
| 3868 | |
| 3869 | |
| 3870 | /** |
| 3871 | Helper function for option aria-force-start-after-recovery-failures. |
| 3872 | Records in the control file that recovery was a success, so that it's not |
| 3873 | counted for aria-force-start-after-recovery-failures. |
| 3874 | */ |
| 3875 | |
| 3876 | static int mark_recovery_successcxx . . $ mark_recovery_success(b126dc7c1de90089).(void) |
| 3877 | { |
| 3878 | /* success of recovery, reset recovery_failures: */ |
| 3879 | int res; |
| 3880 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("mark_recovery_success"); |
| 3881 | res= ma_control_file_write_and_force(last_checkpoint_lsn, last_logno, |
| 3882 | max_trid_in_control_file, 0); |
| 3883 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(res); |
| 3884 | } |
| 3885 | |
| 3886 | |
| 3887 | /* |
| 3888 | Return 1 if table has changed during the current transaction |
| 3889 | */ |
| 3890 | |
| 3891 | bool ha_mariacxx . . $ ha_maria#::is_changedcxx . . $ ha_maria#is_changed(50ce9a9e25b4a850).() const |
| 3892 | { |
| 3893 | return filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->changed; |
| 3894 | } |
| 3895 | |
| 3896 | static void aria_update_optimizer_costscxx . . $ aria_update_optimizer_costs(de7659b82b708318).(OPTIMIZER_COSTScxx . . $ OPTIMIZER_COSTS# *costs) |
| 3897 | { |
| 3898 | } |
| 3899 | |
| 3900 | |
| 3901 | static int ha_maria_initcxx . . $ ha_maria_init(dedf1e9b1c614a07).(void *p) |
| 3902 | { |
| 3903 | int res= 0, tmp; |
| 3904 | const char *log_dir= maria_data_root; |
| 3905 | |
| 3906 | /* |
| 3907 | If aria_readonly is set, then we don't run recovery and we don't allow |
| 3908 | opening of tables that are crashed. Used by mysqld --help |
| 3909 | */ |
| 3910 | if ((aria_readonly= opt_helpcxx . . $ opt_help. != 0)) |
| 3911 | { |
| 3912 | maria_recover_optionscxx . . $ maria_recover_options.= 0; |
| 3913 | checkpoint_intervalcxx . . $ checkpoint_interval.= 0; |
| 3914 | } |
| 3915 | |
| 3916 | #ifdef HAVE_PSI_INTERFACEcxx . . $ `include/my_global.h:90:9`! |
| 3917 | init_aria_psi_keyscxx . . $ init_aria_psi_keys(49f6e7a06ebc5aa8).(); |
| 3918 | #endif |
| 3919 | |
| 3920 | maria_htoncxx . . $ maria_hton.= (handlertoncxx . . $ handlerton# *)p; |
| 3921 | maria_htoncxx . . $ maria_hton.->db_typecxx . . $ handlerton#db_type.= DB_TYPE_ARIAcxx . . $ DB_TYPE_ARIA.; |
| 3922 | maria_htoncxx . . $ maria_hton.->createcxx . . $ handlerton#create.= maria_create_handlercxx . . $ maria_create_handler(2b6d627a0912fa60).; |
| 3923 | maria_htoncxx . . $ maria_hton.->paniccxx . . $ handlerton#panic.= maria_hton_paniccxx . . $ maria_hton_panic(1608599b6f4f877c).; |
| 3924 | maria_htoncxx . . $ maria_hton.->tablefile_extensionscxx . . $ handlerton#tablefile_extensions.= ha_maria_extscxx . . $ ha_maria_exts.; |
| 3925 | maria_htoncxx . . $ maria_hton.->commitcxx . . $ transaction_participant#commit.= maria_commitcxx . . $ maria_commit(a4bb9b94410fc259).; |
| 3926 | maria_htoncxx . . $ maria_hton.->rollbackcxx . . $ transaction_participant#rollback.= maria_rollbackcxx . . $ maria_rollback(a4bb9b94410fc259).; |
| 3927 | maria_htoncxx . . $ maria_hton.->disable_internal_writescxx . . $ handlerton#disable_internal_writes.= maria_checkpoint_statecxx . . $ maria_checkpoint_state(b45ddcbc8423892c).; |
| 3928 | maria_htoncxx . . $ maria_hton.->flush_logscxx . . $ handlerton#flush_logs.= maria_flush_logscxx . . $ maria_flush_logs(a003c2f189b29293).; |
| 3929 | maria_htoncxx . . $ maria_hton.->show_statuscxx . . $ handlerton#show_status.= maria_show_statuscxx . . $ maria_show_status(22e956e5df450e72).; |
| 3930 | maria_htoncxx . . $ maria_hton.->prepare_for_backupcxx . . $ handlerton#prepare_for_backup.= maria_prepare_for_backupcxx . . $ maria_prepare_for_backup(49f6e7a06ebc5aa8).; |
| 3931 | maria_htoncxx . . $ maria_hton.->end_backupcxx . . $ handlerton#end_backup.= maria_end_backupcxx . . $ maria_end_backup(49f6e7a06ebc5aa8).; |
| 3932 | maria_htoncxx . . $ maria_hton.->update_optimizer_costscxx . . $ handlerton#update_optimizer_costs.= aria_update_optimizer_costscxx . . $ aria_update_optimizer_costs(de7659b82b708318).; |
| 3933 | |
| 3934 | /* TODO: decide if we support Maria being used for log tables */ |
| 3935 | maria_htoncxx . . $ maria_hton.->flagscxx . . $ transaction_participant#flags.= (HTON_CAN_RECREATEcxx . . $ `sql/handler.h:1772:9`! | HTON_SUPPORT_LOG_TABLEScxx . . $ `sql/handler.h:1776:9`! | |
| 3936 | HTON_NO_ROLLBACKcxx . . $ `sql/handler.h:1830:9`! | |
| 3937 | HTON_TRANSACTIONAL_AND_NON_TRANSACTIONALcxx . . $ `sql/handler.h:1836:9`!); |
| 3938 | bzerocxx . . $ `include/m_string.h:61:10`!(maria_log_pagecache, sizeof(*maria_log_pagecache)); |
| 3939 | maria_tmpdir= &mysql_tmpdir_listcxx . . $ mysql_tmpdir_list.; /* For REDO */ |
| 3940 | ma_debug_crash_here= maria_debug_crash_here; |
| 3941 | |
| 3942 | if (!aria_readonly) |
| 3943 | res= maria_upgrade(); |
| 3944 | res= res || maria_init(); |
| 3945 | tmp= ma_control_file_open(!aria_readonly, !aria_readonly, !aria_readonly, |
| 3946 | control_file_open_flagscxx . . $ `storage/maria/ma_loghandler.h:547:9`!); |
| 3947 | res= res || aria_readonly ? tmp == CONTROL_FILE_LOCKED : tmp != 0; |
| 3948 | res= res || |
| 3949 | ((force_start_after_recovery_failurescxx . . $ force_start_after_recovery_failures. != 0 && !aria_readonly) && |
| 3950 | mark_recovery_startcxx . . $ mark_recovery_start(5c4306d8553b3696).(log_dir)) || |
| 3951 | !init_pagecache(maria_pagecache, |
| 3952 | (size_t) pagecache_buffer_sizecxx . . $ pagecache_buffer_size., pagecache_division_limitcxx . . $ pagecache_division_limit., |
| 3953 | pagecache_age_thresholdcxx . . $ pagecache_age_threshold., maria_block_size, pagecache_file_hash_sizecxx . . $ pagecache_file_hash_size., |
| 3954 | 0) || |
| 3955 | !init_pagecache(maria_log_pagecache, |
| 3956 | TRANSLOG_PAGECACHE_SIZEcxx . . $ `storage/maria/ma_loghandler.h:22:9`!, 0, 0, |
| 3957 | TRANSLOG_PAGE_SIZEcxx . . $ `storage/maria/ma_loghandler.h:54:9`!, 0, 0) || |
| 3958 | (!aria_readonly && |
| 3959 | translog_initcxx . . $ `storage/maria/ma_loghandler.h:308:9`!(maria_data_root, log_file_size, |
| 3960 | MYSQL_VERSION_IDcxx . . $ `build/include/mysql_version.h:22:9`!, server_id, maria_log_pagecache, |
| 3961 | TRANSLOG_DEFAULT_FLAGScxx . . $ `storage/maria/ma_loghandler.h:31:9`!, 0)) || |
| 3962 | (!aria_readonly && |
| 3963 | (maria_recovery_from_log() || |
| 3964 | ((force_start_after_recovery_failurescxx . . $ force_start_after_recovery_failures. != 0 || |
| 3965 | maria_recovery_changed_data || recovery_failures) && |
| 3966 | mark_recovery_successcxx . . $ mark_recovery_success(b126dc7c1de90089).()))) || |
| 3967 | (aria_readonly && trnman_init(MAX_INTERNAL_TRIDcxx . . $ `storage/maria/trnman.h:62:9`!-16)) || |
| 3968 | ma_checkpoint_init(checkpoint_intervalcxx . . $ checkpoint_interval.); |
| 3969 | maria_multi_threaded= maria_in_ha_maria= TRUEcxx . . $ `include/my_global.h:476:9`!; |
| 3970 | maria_create_trn_hook= maria_create_trn_for_mysql; |
| 3971 | maria_pagecache->extra_debug= 1; |
| 3972 | maria_assert_if_crashed_table= debug_assert_if_crashed_tablecxx . . $ debug_assert_if_crashed_table.; |
| 3973 | |
| 3974 | if (res) |
| 3975 | { |
| 3976 | maria_htoncxx . . $ maria_hton.= 0; |
| 3977 | maria_panic(HA_PANIC_CLOSEcxx . . $ HA_PANIC_CLOSE.); |
| 3978 | } |
| 3979 | |
| 3980 | ma_killed= ma_killed_in_mariadb; |
| 3981 | if (res) |
| 3982 | maria_panic(HA_PANIC_CLOSEcxx . . $ HA_PANIC_CLOSE.); |
| 3983 | |
| 3984 | return res ? HA_ERR_INITIALIZATIONcxx . . $ `include/my_base.h:531:9`! : 0; |
| 3985 | } |
| 3986 | |
| 3987 | |
| 3988 | /** |
| 3989 | @brief Register a named table with a call back function to the query cache. |
| 3990 | |
| 3991 | @param thd The thread handle |
| 3992 | @param table_key A pointer to the table name in the table cache |
| 3993 | @param key_length The length of the table name |
| 3994 | @param[out] engine_callback The pointer to the storage engine call back |
| 3995 | function, currently 0 |
| 3996 | @param[out] engine_data Engine data will be set to 0. |
| 3997 | |
| 3998 | @note Despite the name of this function, it is used to check each statement |
| 3999 | before it is cached and not to register a table or callback function. |
| 4000 | |
| 4001 | @see handler::register_query_cache_table |
| 4002 | |
| 4003 | @return The error code. The engine_data and engine_callback will be set to 0. |
| 4004 | @retval TRUE Success |
| 4005 | @retval FALSE An error occurred |
| 4006 | */ |
| 4007 | |
| 4008 | my_boolcxx . . $ my_bool# ha_mariacxx . . $ ha_maria#::register_query_cache_tablecxx . . $ ha_maria#register_query_cache_table(197b24f09214b1ed).(THDcxx . . $ THD# *thd, const char *table_name, |
| 4009 | uint table_name_len, |
| 4010 | qc_engine_callbackcxx . . $ qc_engine_callback# |
| 4011 | *engine_callback, |
| 4012 | ulonglongcxx . . $ ulonglong# *engine_data) |
| 4013 | { |
| 4014 | ulonglongcxx . . $ ulonglong# actual_data_file_length; |
| 4015 | ulonglongcxx . . $ ulonglong# current_data_file_length; |
| 4016 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("ha_maria::register_query_cache_table"); |
| 4017 | |
| 4018 | /* |
| 4019 | No call back function is needed to determine if a cached statement |
| 4020 | is valid or not. |
| 4021 | */ |
| 4022 | *engine_callback= 0; |
| 4023 | |
| 4024 | /* |
| 4025 | No engine data is needed. |
| 4026 | */ |
| 4027 | *engine_data= 0; |
| 4028 | |
| 4029 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->now_transactional && filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->have_versioning) |
| 4030 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(file->trn->trid >= file->s->state.last_change_trn); |
| 4031 | |
| 4032 | /* |
| 4033 | If a concurrent INSERT has happened just before the currently processed |
| 4034 | SELECT statement, the total size of the table is unknown. |
| 4035 | |
| 4036 | To determine if the table size is known, the current thread's snap shot of |
| 4037 | the table size with the actual table size are compared. |
| 4038 | |
| 4039 | If the table size is unknown the SELECT statement can't be cached. |
| 4040 | */ |
| 4041 | |
| 4042 | /* |
| 4043 | POSIX visibility rules specify that "2. Whatever memory values a |
| 4044 | thread can see when it unlocks a mutex <...> can also be seen by any |
| 4045 | thread that later locks the same mutex". In this particular case, |
| 4046 | concurrent insert thread had modified the data_file_length in |
| 4047 | MYISAM_SHARE before it has unlocked (or even locked) |
| 4048 | structure_guard_mutex. So, here we're guaranteed to see at least that |
| 4049 | value after we've locked the same mutex. We can see a later value |
| 4050 | (modified by some other thread) though, but it's ok, as we only want |
| 4051 | to know if the variable was changed, the actual new value doesn't matter |
| 4052 | */ |
| 4053 | actual_data_file_length= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.state.data_file_length; |
| 4054 | current_data_file_length= filecxx . . $ ha_maria#file.->statecxx . . $ st_maria_handler#state.->data_file_length; |
| 4055 | |
| 4056 | /* Return whether is ok to try to cache current statement. */ |
| 4057 | DBUG_RETURNcxx . . $ `include/my_dbug.h:168:9`!(!(file->s->non_transactional_concurrent_insert && |
| 4058 | current_data_file_length != actual_data_file_length)); |
| 4059 | } |
| 4060 | |
| 4061 | static struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *system_variablescxx . . $ system_variables.[]= { |
| 4062 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(block_size), |
| 4063 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(checkpoint_interval), |
| 4064 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(checkpoint_log_activity), |
| 4065 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(force_start_after_recovery_failures), |
| 4066 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(group_commit), |
| 4067 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(group_commit_interval), |
| 4068 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(log_dir_path), |
| 4069 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(log_file_size), |
| 4070 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(log_purge_type), |
| 4071 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(max_sort_file_size), |
| 4072 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(page_checksum), |
| 4073 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(pagecache_age_threshold), |
| 4074 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(pagecache_buffer_size), |
| 4075 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(pagecache_division_limit), |
| 4076 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(pagecache_file_hash_size), |
| 4077 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(recover_options), |
| 4078 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(repair_threads), |
| 4079 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(sort_buffer_size), |
| 4080 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(stats_method), |
| 4081 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(sync_log_dir), |
| 4082 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(used_for_temp_tables), |
| 4083 | MYSQL_SYSVARcxx . . $ `include/mysql/plugin.h:324:9`!(encrypt_tables), |
| 4084 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! |
| 4085 | }; |
| 4086 | |
| 4087 | |
| 4088 | /** |
| 4089 | @brief Updates the checkpoint interval and restarts the background thread. |
| 4090 | */ |
| 4091 | |
| 4092 | static void update_checkpoint_intervalcxx . . $ update_checkpoint_interval(2e543e8da16c42d1).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd, |
| 4093 | struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *var, |
| 4094 | void *var_ptr, const void *save) |
| 4095 | { |
| 4096 | ma_checkpoint_end(); |
| 4097 | ma_checkpoint_init(*(ulong *)var_ptr= (ulong)(*(long *)save)); |
| 4098 | } |
| 4099 | |
| 4100 | |
| 4101 | /** |
| 4102 | @brief Updates group commit mode |
| 4103 | */ |
| 4104 | |
| 4105 | static void update_maria_group_commitcxx . . $ update_maria_group_commit(2e543e8da16c42d1).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd, |
| 4106 | struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *var, |
| 4107 | void *var_ptr, const void *save) |
| 4108 | { |
| 4109 | ulong value= (ulong)*((long *)var_ptr); |
| 4110 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("update_maria_group_commit"); |
| 4111 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("enter", ("old value: %lu new value %lu rate %lu", |
| 4112 | value, (ulong)(*(long *)save), |
| 4113 | maria_group_commit_interval)); |
| 4114 | /* old value */ |
| 4115 | switch (value) { |
| 4116 | case TRANSLOG_GCOMMIT_NONE: |
| 4117 | break; |
| 4118 | case TRANSLOG_GCOMMIT_HARD: |
| 4119 | translog_hard_group_commit(FALSEcxx . . $ `include/my_global.h:477:9`!); |
| 4120 | break; |
| 4121 | case TRANSLOG_GCOMMIT_SOFT: |
| 4122 | translog_soft_sync(FALSEcxx . . $ `include/my_global.h:477:9`!); |
| 4123 | if (maria_group_commit_interval) |
| 4124 | translog_soft_sync_end(); |
| 4125 | break; |
| 4126 | default: |
| 4127 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(0); /* impossible */ |
| 4128 | } |
| 4129 | value= *(ulong *)var_ptr= (ulong)(*(long *)save); |
| 4130 | translog_sync(); |
| 4131 | /* new value */ |
| 4132 | switch (value) { |
| 4133 | case TRANSLOG_GCOMMIT_NONE: |
| 4134 | break; |
| 4135 | case TRANSLOG_GCOMMIT_HARD: |
| 4136 | translog_hard_group_commit(TRUEcxx . . $ `include/my_global.h:476:9`!); |
| 4137 | break; |
| 4138 | case TRANSLOG_GCOMMIT_SOFT: |
| 4139 | translog_soft_sync(TRUEcxx . . $ `include/my_global.h:476:9`!); |
| 4140 | /* variable change made under global lock so we can just read it */ |
| 4141 | if (maria_group_commit_interval) |
| 4142 | translog_soft_sync_start(); |
| 4143 | break; |
| 4144 | default: |
| 4145 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(0); /* impossible */ |
| 4146 | } |
| 4147 | DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!; |
| 4148 | } |
| 4149 | |
| 4150 | /** |
| 4151 | @brief Updates group commit interval |
| 4152 | */ |
| 4153 | |
| 4154 | static void update_maria_group_commit_intervalcxx . . $ update_maria_group_commit_interval(2e543e8da16c42d1).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd, |
| 4155 | struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *var, |
| 4156 | void *var_ptr, const void *save) |
| 4157 | { |
| 4158 | ulong new_value= (ulong)*((long *)save); |
| 4159 | ulong *value_ptr= (ulong*) var_ptr; |
| 4160 | DBUG_ENTERcxx . . $ `include/my_dbug.h:165:9`!("update_maria_group_commit_interval"); |
| 4161 | DBUG_PRINTcxx . . $ `include/my_dbug.h:174:9`!("enter", ("old value: %lu new value %lu group commit %lu", |
| 4162 | *value_ptr, new_value, maria_group_commit)); |
| 4163 | |
| 4164 | /* variable change made under global lock so we can just read it */ |
| 4165 | switch (maria_group_commit) { |
| 4166 | case TRANSLOG_GCOMMIT_NONE: |
| 4167 | *value_ptr= new_value; |
| 4168 | translog_set_group_commit_interval(new_value); |
| 4169 | break; |
| 4170 | case TRANSLOG_GCOMMIT_HARD: |
| 4171 | *value_ptr= new_value; |
| 4172 | translog_set_group_commit_interval(new_value); |
| 4173 | break; |
| 4174 | case TRANSLOG_GCOMMIT_SOFT: |
| 4175 | if (*value_ptr) |
| 4176 | translog_soft_sync_end(); |
| 4177 | translog_set_group_commit_interval(new_value); |
| 4178 | if ((*value_ptr= new_value)) |
| 4179 | translog_soft_sync_start(); |
| 4180 | break; |
| 4181 | default: |
| 4182 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(0); /* impossible */ |
| 4183 | } |
| 4184 | DBUG_VOID_RETURNcxx . . $ `include/my_dbug.h:169:9`!; |
| 4185 | } |
| 4186 | |
| 4187 | /** |
| 4188 | @brief Updates the transaction log file limit. |
| 4189 | */ |
| 4190 | |
| 4191 | static void update_log_file_sizecxx . . $ update_log_file_size(2e543e8da16c42d1).(MYSQL_THDcxx . . $ `include/mysql/plugin.h:51:9`! thd, |
| 4192 | struct st_mysql_sys_varcxx . . $ st_mysql_sys_var# *var, |
| 4193 | void *var_ptr, const void *save) |
| 4194 | { |
| 4195 | uint32cxx . . $ uint32# size= (uint32cxx . . $ uint32#)((ulong)(*(long *)save)); |
| 4196 | translog_set_file_size(size); |
| 4197 | *(ulong *)var_ptr= size; |
| 4198 | } |
| 4199 | |
| 4200 | |
| 4201 | static SHOW_VARcxx . . $ SHOW_VAR# status_variablescxx . . $ status_variables.[]= { |
| 4202 | {"pagecache_blocks_not_flushed", (char*) &maria_pagecache_var.global_blocks_changed, SHOW_LONGcxx . . $ `include/mysql/plugin.h:198:9`!}, |
| 4203 | {"pagecache_blocks_unused", (char*) &maria_pagecache_var.blocks_unused, SHOW_LONGcxx . . $ `include/mysql/plugin.h:198:9`!}, |
| 4204 | {"pagecache_blocks_used", (char*) &maria_pagecache_var.blocks_used, SHOW_LONGcxx . . $ `include/mysql/plugin.h:198:9`!}, |
| 4205 | {"pagecache_read_requests", (char*) &maria_pagecache_var.global_cache_r_requests, SHOW_LONGLONGcxx . . $ `include/mysql/plugin.h:199:9`!}, |
| 4206 | {"pagecache_reads", (char*) &maria_pagecache_var.global_cache_read, SHOW_LONGLONGcxx . . $ `include/mysql/plugin.h:199:9`!}, |
| 4207 | {"pagecache_write_requests", (char*) &maria_pagecache_var.global_cache_w_requests, SHOW_LONGLONGcxx . . $ `include/mysql/plugin.h:199:9`!}, |
| 4208 | {"pagecache_writes", (char*) &maria_pagecache_var.global_cache_write, SHOW_LONGLONGcxx . . $ `include/mysql/plugin.h:199:9`!}, |
| 4209 | {"transaction_log_syncs", (char*) &translog_syncs, SHOW_LONGLONGcxx . . $ `include/mysql/plugin.h:199:9`!}, |
| 4210 | {NullScxx . . $ `include/my_global.h:844:9`!, NullScxx . . $ `include/my_global.h:844:9`!, SHOW_LONGcxx . . $ `include/mysql/plugin.h:198:9`!} |
| 4211 | }; |
| 4212 | |
| 4213 | /**************************************************************************** |
| 4214 | * Maria MRR implementation: use DS-MRR |
| 4215 | ***************************************************************************/ |
| 4216 | |
| 4217 | int ha_mariacxx . . $ ha_maria#::multi_range_read_initcxx . . $ ha_maria#multi_range_read_init(54d13f3421e63f5b).(RANGE_SEQ_IFcxx . . $ RANGE_SEQ_IF# *seq, void *seq_init_param, |
| 4218 | uint n_ranges, uint mode, |
| 4219 | HANDLER_BUFFERcxx . . $ HANDLER_BUFFER# *buf) |
| 4220 | { |
| 4221 | return ds_mrrcxx . . $ ha_maria#ds_mrr..dsmrr_initcxx . . $ DsMrr_impl#dsmrr_init(700594dd036fb6ae).(this, seq, seq_init_param, n_ranges, mode, buf); |
| 4222 | } |
| 4223 | |
| 4224 | int ha_mariacxx . . $ ha_maria#::multi_range_read_nextcxx . . $ ha_maria#multi_range_read_next(22ee7711e4bb6c63).(range_id_tcxx . . $ range_id_t# *range_info) |
| 4225 | { |
| 4226 | return ds_mrrcxx . . $ ha_maria#ds_mrr..dsmrr_nextcxx . . $ DsMrr_impl#dsmrr_next(22ee7711e4bb6c63).(range_info); |
| 4227 | } |
| 4228 | |
| 4229 | ha_rowscxx . . $ ha_rows# ha_mariacxx . . $ ha_maria#::multi_range_read_info_constcxx . . $ ha_maria#multi_range_read_info_const(55c9f585d35ee0a5).(uint keyno, RANGE_SEQ_IFcxx . . $ RANGE_SEQ_IF# *seq, |
| 4230 | void *seq_init_param, |
| 4231 | uint n_ranges, uint *bufsz, |
| 4232 | uint *flags, ha_rowscxx . . $ ha_rows# limit, |
| 4233 | Cost_estimatecxx . . $ Cost_estimate# *cost) |
| 4234 | { |
| 4235 | /* |
| 4236 | This call is here because there is no location where this->table would |
| 4237 | already be known. |
| 4238 | TODO: consider moving it into some per-query initialization call. |
| 4239 | */ |
| 4240 | ds_mrrcxx . . $ ha_maria#ds_mrr..initcxx . . $ DsMrr_impl#init(6f73af7121e55b40).(this, tablecxx . . $ handler#table.); |
| 4241 | return ds_mrrcxx . . $ ha_maria#ds_mrr..dsmrr_info_constcxx . . $ DsMrr_impl#dsmrr_info_const(55c9f585d35ee0a5).(keyno, seq, seq_init_param, n_ranges, bufsz, |
| 4242 | flags, limit, cost); |
| 4243 | } |
| 4244 | |
| 4245 | ha_rowscxx . . $ ha_rows# ha_mariacxx . . $ ha_maria#::multi_range_read_infocxx . . $ ha_maria#multi_range_read_info(e814fdf10591bafe).(uint keyno, uint n_ranges, uint keys, |
| 4246 | uint key_parts, uint *bufsz, |
| 4247 | uint *flags, Cost_estimatecxx . . $ Cost_estimate# *cost) |
| 4248 | { |
| 4249 | ds_mrrcxx . . $ ha_maria#ds_mrr..initcxx . . $ DsMrr_impl#init(6f73af7121e55b40).(this, tablecxx . . $ handler#table.); |
| 4250 | return ds_mrrcxx . . $ ha_maria#ds_mrr..dsmrr_infocxx . . $ DsMrr_impl#dsmrr_info(e814fdf10591bafe).(keyno, n_ranges, keys, key_parts, bufsz, flags, cost); |
| 4251 | } |
| 4252 | |
| 4253 | int ha_mariacxx . . $ ha_maria#::multi_range_read_explain_infocxx . . $ ha_maria#multi_range_read_explain_info(5f300255004bca25).(uint mrr_mode, char *str, |
| 4254 | size_t size) |
| 4255 | { |
| 4256 | return ds_mrrcxx . . $ ha_maria#ds_mrr..dsmrr_explain_infocxx . . $ DsMrr_impl#dsmrr_explain_info(5f300255004bca25).(mrr_mode, str, size); |
| 4257 | } |
| 4258 | /* MyISAM MRR implementation ends */ |
| 4259 | |
| 4260 | |
| 4261 | /* Index condition pushdown implementation*/ |
| 4262 | |
| 4263 | |
| 4264 | Itemcxx . . $ Item# *ha_mariacxx . . $ ha_maria#::idx_cond_pushcxx . . $ ha_maria#idx_cond_push(ecf3501f3facef99).(uint keyno_arg, Itemcxx . . $ Item#* idx_cond_arg) |
| 4265 | { |
| 4266 | /* |
| 4267 | Check if the key contains a blob field. If it does then MyISAM |
| 4268 | should not accept the pushed index condition since MyISAM will not |
| 4269 | read the blob field from the index entry during evaluation of the |
| 4270 | pushed index condition and the BLOB field might be part of the |
| 4271 | range evaluation done by the ICP code. |
| 4272 | */ |
| 4273 | const KEYcxx . . $ KEY# *key= &table_sharecxx . . $ handler#table_share.->key_infocxx . . $ TABLE_SHARE#key_info.[keyno_arg]; |
| 4274 | |
| 4275 | for (uint k= 0; k < key->user_defined_key_partscxx . . $ st_key#user_defined_key_parts.; ++k) |
| 4276 | { |
| 4277 | const KEY_PART_INFOcxx . . $ KEY_PART_INFO# *key_part= &key->key_partcxx . . $ st_key#key_part.[k]; |
| 4278 | if (key_part->key_part_flagcxx . . $ st_key_part_info#key_part_flag. & HA_BLOB_PARTcxx . . $ `include/my_base.h:335:9`!) |
| 4279 | { |
| 4280 | /* Let the server handle the index condition */ |
| 4281 | return idx_cond_arg; |
| 4282 | } |
| 4283 | } |
| 4284 | |
| 4285 | pushed_idx_cond_keynocxx . . $ handler#pushed_idx_cond_keyno.= keyno_arg; |
| 4286 | pushed_idx_condcxx . . $ handler#pushed_idx_cond.= idx_cond_arg; |
| 4287 | in_range_check_pushed_downcxx . . $ handler#in_range_check_pushed_down.= TRUEcxx . . $ `include/my_global.h:476:9`!; |
| 4288 | if (active_indexcxx . . $ handler#active_index. == pushed_idx_cond_keynocxx . . $ handler#pushed_idx_cond_keyno.) |
| 4289 | ma_set_index_cond_func(filecxx . . $ ha_maria#file., handler_index_cond_checkcxx . . $ handler_index_cond_check(9d23bbd9b4d18766)., this); |
| 4290 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 4291 | } |
| 4292 | |
| 4293 | bool ha_mariacxx . . $ ha_maria#::rowid_filter_pushcxx . . $ ha_maria#rowid_filter_push(dae781baa2b17af5).(Rowid_filtercxx . . $ Rowid_filter#* rowid_filter) |
| 4294 | { |
| 4295 | /* This will be used in index_init() */ |
| 4296 | pushed_rowid_filtercxx . . $ handler#pushed_rowid_filter.= rowid_filter; |
| 4297 | return false; |
| 4298 | } |
| 4299 | |
| 4300 | |
| 4301 | /* Enable / disable rowid filter depending if it's active or not */ |
| 4302 | |
| 4303 | void ha_mariacxx . . $ ha_maria#::rowid_filter_changedcxx . . $ ha_maria#rowid_filter_changed(49f6e7a06ebc5aa8).() |
| 4304 | { |
| 4305 | if (pushed_rowid_filtercxx . . $ handler#pushed_rowid_filter. && handler_rowid_filter_is_active(this)) |
| 4306 | ma_set_rowid_filter_func(filecxx . . $ ha_maria#file., handler_rowid_filter_checkcxx . . $ handler_rowid_filter_check(9d23bbd9b4d18766)., this); |
| 4307 | else |
| 4308 | ma_set_rowid_filter_func(filecxx . . $ ha_maria#file., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, this); |
| 4309 | } |
| 4310 | |
| 4311 | |
| 4312 | |
| 4313 | /** |
| 4314 | Find record by unique constrain (used in temporary tables) |
| 4315 | |
| 4316 | @param record (IN|OUT) the record to find |
| 4317 | @param constrain_no (IN) number of constrain (for this engine) |
| 4318 | |
| 4319 | @note It is like hp_search but uses function for raw where hp_search |
| 4320 | uses functions for index. |
| 4321 | |
| 4322 | @retval 0 OK |
| 4323 | @retval 1 Not found |
| 4324 | @retval -1 Error |
| 4325 | */ |
| 4326 | |
| 4327 | int ha_mariacxx . . $ ha_maria#::find_unique_rowcxx . . $ ha_maria#find_unique_row(c271a33def0f2b11).(ucharcxx . . $ uchar# *record, uint constrain_no) |
| 4328 | { |
| 4329 | int rc; |
| 4330 | register_handlercxx . . $ ha_maria#register_handler(1e8279855a45f04d).(filecxx . . $ ha_maria#file.); |
| 4331 | if (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->state.header.uniques) |
| 4332 | { |
| 4333 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(file->s->state.header.uniques > constrain_no); |
| 4334 | MARIA_UNIQUEDEF *def= filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->uniqueinfo + constrain_no; |
| 4335 | ha_checksum unique_hash= _ma_unique_hash(def, record); |
| 4336 | rc= _ma_check_unique(filecxx . . $ ha_maria#file., def, record, unique_hash, HA_OFFSET_ERRORcxx . . $ `include/my_base.h:695:9`!); |
| 4337 | if (rc) |
| 4338 | { |
| 4339 | filecxx . . $ ha_maria#file.->cur_rowcxx . . $ st_maria_handler#cur_row..lastpos= filecxx . . $ ha_maria#file.->dup_key_poscxx . . $ st_maria_handler#dup_key_pos.; |
| 4340 | if ((*filecxx . . $ ha_maria#file.->read_recordcxx . . $ st_maria_handler#read_record.)(filecxx . . $ ha_maria#file., record, filecxx . . $ ha_maria#file.->cur_rowcxx . . $ st_maria_handler#cur_row..lastpos)) |
| 4341 | return -1; |
| 4342 | filecxx . . $ ha_maria#file.->updatecxx . . $ st_maria_handler#update.|= HA_STATE_AKTIVcxx . . $ `include/my_base.h:618:9`!; /* Record is read */ |
| 4343 | } |
| 4344 | // invert logic |
| 4345 | rc= !MY_TESTcxx . . $ `include/my_global.h:467:9`!(rc); |
| 4346 | } |
| 4347 | else |
| 4348 | { |
| 4349 | /* |
| 4350 | It is case when just unique index used instead unicue constrain |
| 4351 | (conversion from heap table). |
| 4352 | */ |
| 4353 | DBUG_ASSERTcxx . . $ `include/my_dbug.h:207:9`!(file->s->state.header.keys > constrain_no); |
| 4354 | MARIA_KEY key; |
| 4355 | filecxx . . $ ha_maria#file.->once_flagscxx . . $ st_maria_handler#once_flags.|= USE_PACKED_KEYScxx . . $ `storage/maria/maria_def.h:1083:9`!; |
| 4356 | (*filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->keyinfo[constrain_no].make_key) |
| 4357 | (filecxx . . $ ha_maria#file., &key, constrain_no, filecxx . . $ ha_maria#file.->lastkey_buff2cxx . . $ st_maria_handler#lastkey_buff2., record, 0, 0); |
| 4358 | rc= maria_rkey(filecxx . . $ ha_maria#file., record, constrain_no, key.datacxx . . $ st_maria_key#data., key.data_lengthcxx . . $ st_maria_key#data_length., |
| 4359 | HA_READ_KEY_EXACTcxx . . $ HA_READ_KEY_EXACT.); |
| 4360 | rc= MY_TESTcxx . . $ `include/my_global.h:467:9`!(rc); |
| 4361 | } |
| 4362 | return rc; |
| 4363 | } |
| 4364 | |
| 4365 | |
| 4366 | /** |
| 4367 | Check if a table needs to be repaired |
| 4368 | */ |
| 4369 | |
| 4370 | int ha_mariacxx . . $ ha_maria#::check_for_upgradecxx . . $ ha_maria#check_for_upgrade(9d73cdc268cfd06b).(HA_CHECK_OPTcxx . . $ HA_CHECK_OPT# *check) |
| 4371 | { |
| 4372 | if (tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->mysql_versioncxx . . $ TABLE_SHARE#mysql_version. && tablecxx . . $ handler#table.->scxx . . $ TABLE#s.->mysql_versioncxx . . $ TABLE_SHARE#mysql_version. <= 100509 && |
| 4373 | (filecxx . . $ ha_maria#file.->scxx . . $ st_maria_handler#s.->base.extra_options & MA_EXTRA_OPTIONS_ENCRYPTEDcxx . . $ `storage/maria/maria_def.h:555:9`!)) |
| 4374 | { |
| 4375 | /* |
| 4376 | Encrypted tables before 10.5.9 had a bug where LSN was not |
| 4377 | stored on the pages. These must be repaired! |
| 4378 | */ |
| 4379 | return HA_ADMIN_NEEDS_ALTERcxx . . $ `sql/handler.h:84:9`!; |
| 4380 | } |
| 4381 | return HA_ADMIN_OKcxx . . $ `sql/handler.h:61:9`!; |
| 4382 | } |
| 4383 | |
| 4384 | |
| 4385 | struct st_mysql_storage_enginecxx . . $ st_mysql_storage_engine# maria_storage_enginecxx . . $ maria_storage_engine.= |
| 4386 | { MYSQL_HANDLERTON_INTERFACE_VERSIONcxx . . $ `include/mysql/plugin.h:636:9`! }; |
| 4387 | |
| 4388 | maria_declare_plugincxx . . $ `include/mysql/plugin.h:175:9`!(aria) |
| 4389 | { |
| 4390 | MYSQL_STORAGE_ENGINE_PLUGINcxx . . $ `include/mysql/plugin.h:93:9`!, |
| 4391 | &maria_storage_enginecxx . . $ maria_storage_engine., |
| 4392 | "Aria", |
| 4393 | "MariaDB Corporation Ab", |
| 4394 | "Crash-safe tables with MyISAM heritage. Used for internal temporary tables and privilege tables", |
| 4395 | PLUGIN_LICENSE_GPLcxx . . $ `include/mysql/plugin.h:114:9`!, |
| 4396 | ha_maria_initcxx . . $ ha_maria_init(dedf1e9b1c614a07)., /* Plugin Init */ |
| 4397 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, /* Plugin Deinit */ |
| 4398 | 0x0105, /* 1.5 */ |
| 4399 | status_variablescxx . . $ status_variables., /* status variables */ |
| 4400 | system_variablescxx . . $ system_variables., /* system variables */ |
| 4401 | "1.5", /* string version */ |
| 4402 | MariaDB_PLUGIN_MATURITY_STABLEcxx . . $ `include/mysql/plugin.h:127:9`! /* maturity */ |
| 4403 | } |
| 4404 | maria_declare_plugin_endcxx . . $ `include/mysql/plugin.h:182:9`!; |