The world's most popular open source database
00001 /* Copyright (C) 2000-2003 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* 00018 Mostly this file is used in the server. But a little part of it is used in 00019 mysqlbinlog too (definition of SELECT_DISTINCT and others). 00020 The consequence is that 90% of the file is wrapped in #ifndef MYSQL_CLIENT, 00021 except the part which must be in the server and in the client. 00022 */ 00023 00024 #ifndef MYSQL_CLIENT 00025 00026 #include <my_global.h> 00027 #include <mysql_version.h> 00028 #include <mysql_embed.h> 00029 #include <my_sys.h> 00030 #include <my_time.h> 00031 #include <m_string.h> 00032 #include <hash.h> 00033 #include <signal.h> 00034 #include <thr_lock.h> 00035 #include <my_base.h> /* Needed by field.h */ 00036 #include "sql_bitmap.h" 00037 #include "sql_array.h" 00038 00039 /* TODO convert all these three maps to Bitmap classes */ 00040 typedef ulonglong table_map; /* Used for table bits in join */ 00041 #if MAX_INDEXES <= 64 00042 typedef Bitmap<64> key_map; /* Used for finding keys */ 00043 #else 00044 typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */ 00045 #endif 00046 typedef ulong key_part_map; /* Used for finding key parts */ 00047 typedef ulong nesting_map; /* Used for flags of nesting constructs */ 00048 /* 00049 Used to identify NESTED_JOIN structures within a join (applicable only to 00050 structures that have not been simplified away and embed more the one 00051 element) 00052 */ 00053 typedef ulonglong nested_join_map; 00054 00055 /* query_id */ 00056 typedef ulonglong query_id_t; 00057 extern query_id_t query_id; 00058 00059 /* increment query_id and return it. */ 00060 inline query_id_t next_query_id() { return query_id++; } 00061 00062 /* useful constants */ 00063 extern const key_map key_map_empty; 00064 extern key_map key_map_full; /* Should be threaded as const */ 00065 extern const char *primary_key_name; 00066 00067 #include "mysql_com.h" 00068 #include <violite.h> 00069 #include "unireg.h" 00070 00071 void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size); 00072 gptr sql_alloc(unsigned size); 00073 gptr sql_calloc(unsigned size); 00074 char *sql_strdup(const char *str); 00075 char *sql_strmake(const char *str,uint len); 00076 gptr sql_memdup(const void * ptr,unsigned size); 00077 void sql_element_free(void *ptr); 00078 char *sql_strmake_with_convert(const char *str, uint32 arg_length, 00079 CHARSET_INFO *from_cs, 00080 uint32 max_res_length, 00081 CHARSET_INFO *to_cs, uint32 *result_length); 00082 uint kill_one_thread(THD *thd, ulong id, bool only_kill_query); 00083 void sql_kill(THD *thd, ulong id, bool only_kill_query); 00084 bool net_request_file(NET* net, const char* fname); 00085 char* query_table_status(THD *thd,const char *db,const char *table_name); 00086 00087 #define x_free(A) { my_free((gptr) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); } 00088 #define safeFree(x) { if(x) { my_free((gptr) x,MYF(0)); x = NULL; } } 00089 #define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1)) 00090 #define all_bits_set(A,B) ((A) & (B) != (B)) 00091 00092 #define WARN_DEPRECATED(Thd,Ver,Old,New) \ 00093 do { \ 00094 DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) >= 0); \ 00095 push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \ 00096 ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), \ 00097 (Old), (Ver), (New)); \ 00098 } while(0) 00099 00100 00101 extern CHARSET_INFO *system_charset_info, *files_charset_info ; 00102 extern CHARSET_INFO *national_charset_info, *table_alias_charset; 00103 00104 00105 typedef struct my_locale_st 00106 { 00107 const char *name; 00108 const char *description; 00109 const bool is_ascii; 00110 TYPELIB *month_names; 00111 TYPELIB *ab_month_names; 00112 TYPELIB *day_names; 00113 TYPELIB *ab_day_names; 00114 } MY_LOCALE; 00115 00116 extern MY_LOCALE my_locale_en_US; 00117 extern MY_LOCALE *my_locales[]; 00118 00119 MY_LOCALE *my_locale_by_name(const char *name); 00120 00121 /*************************************************************************** 00122 Configuration parameters 00123 ****************************************************************************/ 00124 00125 #define ACL_CACHE_SIZE 256 00126 #define MAX_PASSWORD_LENGTH 32 00127 #define HOST_CACHE_SIZE 128 00128 #define MAX_ACCEPT_RETRY 10 // Test accept this many times 00129 #define MAX_FIELDS_BEFORE_HASH 32 00130 #define USER_VARS_HASH_SIZE 16 00131 #define STACK_MIN_SIZE 8192 // Abort if less stack during eval. 00132 #define STACK_MIN_SIZE_FOR_OPEN 1024*80 00133 #define STACK_BUFF_ALLOC 256 // For stack overrun checks 00134 #ifndef MYSQLD_NET_RETRY_COUNT 00135 #define MYSQLD_NET_RETRY_COUNT 10 // Abort read after this many int. 00136 #endif 00137 #define TEMP_POOL_SIZE 128 00138 00139 #define QUERY_ALLOC_BLOCK_SIZE 8192 00140 #define QUERY_ALLOC_PREALLOC_SIZE 8192 00141 #define TRANS_ALLOC_BLOCK_SIZE 4096 00142 #define TRANS_ALLOC_PREALLOC_SIZE 4096 00143 #define RANGE_ALLOC_BLOCK_SIZE 2048 00144 #define ACL_ALLOC_BLOCK_SIZE 1024 00145 #define UDF_ALLOC_BLOCK_SIZE 1024 00146 #define TABLE_ALLOC_BLOCK_SIZE 1024 00147 #define BDB_LOG_ALLOC_BLOCK_SIZE 1024 00148 #define WARN_ALLOC_BLOCK_SIZE 2048 00149 #define WARN_ALLOC_PREALLOC_SIZE 1024 00150 00151 /* 00152 The following parameters is to decide when to use an extra cache to 00153 optimise seeks when reading a big table in sorted order 00154 */ 00155 #define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024) 00156 #define MIN_ROWS_TO_USE_TABLE_CACHE 100 00157 #define MIN_ROWS_TO_USE_BULK_INSERT 100 00158 00159 /* 00160 The following is used to decide if MySQL should use table scanning 00161 instead of reading with keys. The number says how many evaluation of the 00162 WHERE clause is comparable to reading one extra row from a table. 00163 */ 00164 #define TIME_FOR_COMPARE 5 // 5 compares == one read 00165 00166 /* 00167 Number of comparisons of table rowids equivalent to reading one row from a 00168 table. 00169 */ 00170 #define TIME_FOR_COMPARE_ROWID (TIME_FOR_COMPARE*2) 00171 00172 /* 00173 For sequential disk seeks the cost formula is: 00174 DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip 00175 00176 The cost of average seek 00177 DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0. 00178 */ 00179 #define DISK_SEEK_BASE_COST ((double)0.5) 00180 00181 #define BLOCKS_IN_AVG_SEEK 128 00182 00183 #define DISK_SEEK_PROP_COST ((double)0.5/BLOCKS_IN_AVG_SEEK) 00184 00185 00186 /* 00187 Number of rows in a reference table when refereed through a not unique key. 00188 This value is only used when we don't know anything about the key 00189 distribution. 00190 */ 00191 #define MATCHING_ROWS_IN_OTHER_TABLE 10 00192 00193 /* Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used) */ 00194 #define KEY_DEFAULT_PACK_LENGTH 8 00195 00196 /* Characters shown for the command in 'show processlist' */ 00197 #define PROCESS_LIST_WIDTH 100 00198 /* Characters shown for the command in 'information_schema.processlist' */ 00199 #define PROCESS_LIST_INFO_WIDTH 65535 00200 00201 /* Time handling defaults */ 00202 #define TIMESTAMP_MAX_YEAR 2038 00203 #define YY_PART_YEAR 70 00204 #define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1) 00205 #define TIMESTAMP_MAX_VALUE 2145916799 00206 #define TIMESTAMP_MIN_VALUE 1 00207 #define PRECISION_FOR_DOUBLE 53 00208 #define PRECISION_FOR_FLOAT 24 00209 00210 /* The following can also be changed from the command line */ 00211 #define CONNECT_TIMEOUT 5 // Do not wait long for connect 00212 #define DEFAULT_CONCURRENCY 10 00213 #define DELAYED_LIMIT 100 /* pause after xxx inserts */ 00214 #define DELAYED_QUEUE_SIZE 1000 00215 #define DELAYED_WAIT_TIMEOUT 5*60 /* Wait for delayed insert */ 00216 #define FLUSH_TIME 0 /* Don't flush tables */ 00217 #define MAX_CONNECT_ERRORS 10 // errors before disabling host 00218 00219 #ifdef __NETWARE__ 00220 #define IF_NETWARE(A,B) (A) 00221 #else 00222 #define IF_NETWARE(A,B) (B) 00223 #endif 00224 00225 #if defined(__WIN__) 00226 #define IF_WIN(A,B) (A) 00227 #undef FLUSH_TIME 00228 #define FLUSH_TIME 1800 /* Flush every half hour */ 00229 00230 #define INTERRUPT_PRIOR -2 00231 #define CONNECT_PRIOR -1 00232 #define WAIT_PRIOR 0 00233 #define QUERY_PRIOR 2 00234 #else 00235 #define IF_WIN(A,B) (B) 00236 #define INTERRUPT_PRIOR 10 00237 #define CONNECT_PRIOR 9 00238 #define WAIT_PRIOR 8 00239 #define QUERY_PRIOR 6 00240 #endif /* __WIN92__ */ 00241 00242 /* Bits from testflag */ 00243 #define TEST_PRINT_CACHED_TABLES 1 00244 #define TEST_NO_KEY_GROUP 2 00245 #define TEST_MIT_THREAD 4 00246 #define TEST_BLOCKING 8 00247 #define TEST_KEEP_TMP_TABLES 16 00248 #define TEST_NO_THREADS 32 /* For debugging under Linux */ 00249 #define TEST_READCHECK 64 /* Force use of readcheck */ 00250 #define TEST_NO_EXTRA 128 00251 #define TEST_CORE_ON_SIGNAL 256 /* Give core if signal */ 00252 #define TEST_NO_STACKTRACE 512 00253 #define TEST_SIGINT 1024 /* Allow sigint on threads */ 00254 #define TEST_SYNCHRONIZATION 2048 /* get server to do sleep in 00255 some places */ 00256 #endif 00257 00258 /* 00259 This is included in the server and in the client. 00260 Options for select set by the yacc parser (stored in lex->options). 00261 00262 XXX: 00263 log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD 00264 options list are written into binlog. These options can NOT change their 00265 values, or it will break replication between version. 00266 00267 context is encoded as following: 00268 SELECT - SELECT_LEX_NODE::options 00269 THD - THD::options 00270 intern - neither. used only as 00271 func(..., select_node->options | thd->options | OPTION_XXX, ...) 00272 00273 TODO: separate three contexts above, move them to separate bitfields. 00274 */ 00275 00276 #define SELECT_DISTINCT (LL(1) << 0) // SELECT, user 00277 #define SELECT_STRAIGHT_JOIN (LL(1) << 1) // SELECT, user 00278 #define SELECT_DESCRIBE (LL(1) << 2) // SELECT, user 00279 #define SELECT_SMALL_RESULT (LL(1) << 3) // SELECT, user 00280 #define SELECT_BIG_RESULT (LL(1) << 4) // SELECT, user 00281 #define OPTION_FOUND_ROWS (LL(1) << 5) // SELECT, user 00282 #define OPTION_TO_QUERY_CACHE (LL(1) << 6) // SELECT, user 00283 #define SELECT_NO_JOIN_CACHE (LL(1) << 7) // intern 00284 #define OPTION_BIG_TABLES (LL(1) << 8) // THD, user 00285 #define OPTION_BIG_SELECTS (LL(1) << 9) // THD, user 00286 #define OPTION_LOG_OFF (LL(1) << 10) // THD, user 00287 #define OPTION_QUOTE_SHOW_CREATE (LL(1) << 11) // THD, user 00288 #define TMP_TABLE_ALL_COLUMNS (LL(1) << 12) // SELECT, intern 00289 #define OPTION_WARNINGS (LL(1) << 13) // THD, user 00290 #define OPTION_AUTO_IS_NULL (LL(1) << 14) // THD, user, binlog 00291 #define OPTION_FOUND_COMMENT (LL(1) << 15) // SELECT, intern, parser 00292 #define OPTION_SAFE_UPDATES (LL(1) << 16) // THD, user 00293 #define OPTION_BUFFER_RESULT (LL(1) << 17) // SELECT, user 00294 #define OPTION_BIN_LOG (LL(1) << 18) // THD, user 00295 #define OPTION_NOT_AUTOCOMMIT (LL(1) << 19) // THD, user 00296 #define OPTION_BEGIN (LL(1) << 20) // THD, intern 00297 #define OPTION_TABLE_LOCK (LL(1) << 21) // THD, intern 00298 #define OPTION_QUICK (LL(1) << 22) // SELECT (for DELETE) 00299 #define OPTION_KEEP_LOG (LL(1) << 23) // Keep binlog on rollback 00300 00301 /* The following is used to detect a conflict with DISTINCT */ 00302 #define SELECT_ALL (LL(1) << 24) // SELECT, user, parser 00303 00304 /* Set if we are updating a non-transaction safe table */ 00305 #define OPTION_STATUS_NO_TRANS_UPDATE (LL(1) << 25) // THD, intern 00306 00307 /* The following can be set when importing tables in a 'wrong order' 00308 to suppress foreign key checks */ 00309 #define OPTION_NO_FOREIGN_KEY_CHECKS (LL(1) << 26) // THD, user, binlog 00310 /* The following speeds up inserts to InnoDB tables by suppressing unique 00311 key checks in some cases */ 00312 #define OPTION_RELAXED_UNIQUE_CHECKS (LL(1) << 27) // THD, user, binlog 00313 #define SELECT_NO_UNLOCK (LL(1) << 28) // SELECT, intern 00314 #define OPTION_SCHEMA_TABLE (LL(1) << 29) // SELECT, intern 00315 /* Flag set if setup_tables already done */ 00316 #define OPTION_SETUP_TABLES_DONE (LL(1) << 30) // intern 00317 /* If not set then the thread will ignore all warnings with level notes. */ 00318 #define OPTION_SQL_NOTES (LL(1) << 31) // THD, user 00319 /* 00320 Force the used temporary table to be a MyISAM table (because we will use 00321 fulltext functions when reading from it. 00322 */ 00323 #define TMP_TABLE_FORCE_MYISAM (LL(1) << 32) 00324 00325 /* 00326 Maximum length of time zone name that we support 00327 (Time zone name is char(64) in db). mysqlbinlog needs it. 00328 */ 00329 #define MAX_TIME_ZONE_NAME_LENGTH 72 00330 00331 /* The rest of the file is included in the server only */ 00332 #ifndef MYSQL_CLIENT 00333 00334 /* Bits for different SQL modes modes (including ANSI mode) */ 00335 #define MODE_REAL_AS_FLOAT 1 00336 #define MODE_PIPES_AS_CONCAT 2 00337 #define MODE_ANSI_QUOTES 4 00338 #define MODE_IGNORE_SPACE 8 00339 #define MODE_NOT_USED 16 00340 #define MODE_ONLY_FULL_GROUP_BY 32 00341 #define MODE_NO_UNSIGNED_SUBTRACTION 64 00342 #define MODE_NO_DIR_IN_CREATE 128 00343 #define MODE_POSTGRESQL 256 00344 #define MODE_ORACLE 512 00345 #define MODE_MSSQL 1024 00346 #define MODE_DB2 2048 00347 #define MODE_MAXDB 4096 00348 #define MODE_NO_KEY_OPTIONS 8192 00349 #define MODE_NO_TABLE_OPTIONS 16384 00350 #define MODE_NO_FIELD_OPTIONS 32768 00351 #define MODE_MYSQL323 65536 00352 #define MODE_MYSQL40 (MODE_MYSQL323*2) 00353 #define MODE_ANSI (MODE_MYSQL40*2) 00354 #define MODE_NO_AUTO_VALUE_ON_ZERO (MODE_ANSI*2) 00355 #define MODE_NO_BACKSLASH_ESCAPES (MODE_NO_AUTO_VALUE_ON_ZERO*2) 00356 #define MODE_STRICT_TRANS_TABLES (MODE_NO_BACKSLASH_ESCAPES*2) 00357 #define MODE_STRICT_ALL_TABLES (MODE_STRICT_TRANS_TABLES*2) 00358 #define MODE_NO_ZERO_IN_DATE (MODE_STRICT_ALL_TABLES*2) 00359 #define MODE_NO_ZERO_DATE (MODE_NO_ZERO_IN_DATE*2) 00360 #define MODE_INVALID_DATES (MODE_NO_ZERO_DATE*2) 00361 #define MODE_ERROR_FOR_DIVISION_BY_ZERO (MODE_INVALID_DATES*2) 00362 #define MODE_TRADITIONAL (MODE_ERROR_FOR_DIVISION_BY_ZERO*2) 00363 #define MODE_NO_AUTO_CREATE_USER (MODE_TRADITIONAL*2) 00364 #define MODE_HIGH_NOT_PRECEDENCE (MODE_NO_AUTO_CREATE_USER*2) 00365 #define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2) 00366 /* 00367 Replication uses 8 bytes to store SQL_MODE in the binary log. The day you 00368 use strictly more than 64 bits by adding one more define above, you should 00369 contact the replication team because the replication code should then be 00370 updated (to store more bytes on disk). 00371 00372 NOTE: When adding new SQL_MODE types, make sure to also add them to 00373 ../scripts/mysql_create_system_tables.sh and 00374 ../scripts/mysql_fix_privilege_tables.sql 00375 */ 00376 00377 #define RAID_BLOCK_SIZE 1024 00378 00379 #define MY_CHARSET_BIN_MB_MAXLEN 1 00380 00381 // uncachable cause 00382 #define UNCACHEABLE_DEPENDENT 1 00383 #define UNCACHEABLE_RAND 2 00384 #define UNCACHEABLE_SIDEEFFECT 4 00385 // forcing to save JOIN for explain 00386 #define UNCACHEABLE_EXPLAIN 8 00387 /* Don't evaluate subqueries in prepare even if they're not correlated */ 00388 #define UNCACHEABLE_PREPARE 16 00389 00390 #ifdef EXTRA_DEBUG 00391 /* 00392 Sync points allow us to force the server to reach a certain line of code 00393 and block there until the client tells the server it is ok to go on. 00394 The client tells the server to block with SELECT GET_LOCK() 00395 and unblocks it with SELECT RELEASE_LOCK(). Used for debugging difficult 00396 concurrency problems 00397 */ 00398 #define DBUG_SYNC_POINT(lock_name,lock_timeout) \ 00399 debug_sync_point(lock_name,lock_timeout) 00400 void debug_sync_point(const char* lock_name, uint lock_timeout); 00401 #else 00402 #define DBUG_SYNC_POINT(lock_name,lock_timeout) 00403 #endif /* EXTRA_DEBUG */ 00404 00405 /* BINLOG_DUMP options */ 00406 00407 #define BINLOG_DUMP_NON_BLOCK 1 00408 00409 /* sql_show.cc:show_log_files() */ 00410 #define SHOW_LOG_STATUS_FREE "FREE" 00411 #define SHOW_LOG_STATUS_INUSE "IN USE" 00412 00413 struct st_table_list; 00414 class String; 00415 void view_store_options(THD *thd, st_table_list *table, String *buff); 00416 00417 /* Options to add_table_to_list() */ 00418 #define TL_OPTION_UPDATING 1 00419 #define TL_OPTION_FORCE_INDEX 2 00420 #define TL_OPTION_IGNORE_LEAVES 4 00421 00422 /* Some portable defines */ 00423 00424 #define portable_sizeof_char_ptr 8 00425 00426 #define tmp_file_prefix "#sql" /* Prefix for tmp tables */ 00427 #define tmp_file_prefix_length 4 00428 00429 /* Flags for calc_week() function. */ 00430 #define WEEK_MONDAY_FIRST 1 00431 #define WEEK_YEAR 2 00432 #define WEEK_FIRST_WEEKDAY 4 00433 00434 #define STRING_BUFFER_USUAL_SIZE 80 00435 00436 /* 00437 Some defines for exit codes for ::is_equal class functions. 00438 */ 00439 #define IS_EQUAL_NO 0 00440 #define IS_EQUAL_YES 1 00441 #define IS_EQUAL_PACK_LENGTH 2 00442 00443 enum enum_parsing_place 00444 { 00445 NO_MATTER, 00446 IN_HAVING, 00447 SELECT_LIST, 00448 IN_WHERE 00449 }; 00450 00451 struct st_table; 00452 class THD; 00453 00454 /* Struct to handle simple linked lists */ 00455 00456 typedef struct st_sql_list { 00457 uint elements; 00458 byte *first; 00459 byte **next; 00460 00461 st_sql_list() {} /* Remove gcc warning */ 00462 inline void empty() 00463 { 00464 elements=0; 00465 first=0; 00466 next= &first; 00467 } 00468 inline void link_in_list(byte *element,byte **next_ptr) 00469 { 00470 elements++; 00471 (*next)=element; 00472 next= next_ptr; 00473 *next=0; 00474 } 00475 inline void save_and_clear(struct st_sql_list *save) 00476 { 00477 *save= *this; 00478 empty(); 00479 } 00480 inline void push_front(struct st_sql_list *save) 00481 { 00482 *save->next= first; /* link current list last */ 00483 first= save->first; 00484 elements+= save->elements; 00485 } 00486 inline void push_back(struct st_sql_list *save) 00487 { 00488 if (save->first) 00489 { 00490 *next= save->first; 00491 next= save->next; 00492 elements+= save->elements; 00493 } 00494 } 00495 } SQL_LIST; 00496 00497 00498 extern pthread_key(THD*, THR_THD); 00499 inline THD *_current_thd(void) 00500 { 00501 return my_pthread_getspecific_ptr(THD*,THR_THD); 00502 } 00503 #define current_thd _current_thd() 00504 00505 /* below functions are required for plugins as THD class is opaque */ 00506 my_bool thd_in_lock_tables(const THD *thd); 00507 my_bool thd_tablespace_op(const THD *thd); 00508 const char *thd_proc_info(THD *thd, const char *info); 00509 void **thd_ha_data(const THD *thd, const struct handlerton *hton); 00510 00511 /* 00512 External variables 00513 */ 00514 extern ulong server_id, concurrency; 00515 00516 00517 typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key, 00518 uint key_length, 00519 ulonglong *engine_data); 00520 #include "sql_string.h" 00521 #include "sql_list.h" 00522 #include "sql_map.h" 00523 #include "my_decimal.h" 00524 #include "sql_plugin.h" 00525 #include "handler.h" 00526 #include "parse_file.h" 00527 #include "table.h" 00528 #include "sql_error.h" 00529 #include "field.h" /* Field definitions */ 00530 #include "protocol.h" 00531 #include "sql_udf.h" 00532 #include "sql_partition.h" 00533 00534 class user_var_entry; 00535 class Security_context; 00536 enum enum_var_type 00537 { 00538 OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL 00539 }; 00540 class sys_var; 00541 #ifdef MYSQL_SERVER 00542 class Comp_creator; 00543 typedef Comp_creator* (*chooser_compare_func_creator)(bool invert); 00544 #endif 00545 #include "item.h" 00546 extern my_decimal decimal_zero; 00547 00548 /* sql_parse.cc */ 00549 void free_items(Item *item); 00550 void cleanup_items(Item *item); 00551 class THD; 00552 void close_thread_tables(THD *thd, bool locked=0, bool skip_derived=0); 00553 bool check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables); 00554 bool check_single_table_access(THD *thd, ulong privilege, 00555 TABLE_LIST *tables); 00556 bool check_routine_access(THD *thd,ulong want_access,char *db,char *name, 00557 bool is_proc, bool no_errors); 00558 bool check_some_access(THD *thd, ulong want_access, TABLE_LIST *table); 00559 bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *table_list); 00560 bool check_some_routine_access(THD *thd, const char *db, const char *name, bool is_proc); 00561 bool multi_update_precheck(THD *thd, TABLE_LIST *tables); 00562 bool multi_delete_precheck(THD *thd, TABLE_LIST *tables); 00563 bool mysql_multi_update_prepare(THD *thd); 00564 bool mysql_multi_delete_prepare(THD *thd); 00565 bool mysql_insert_select_prepare(THD *thd); 00566 bool update_precheck(THD *thd, TABLE_LIST *tables); 00567 bool delete_precheck(THD *thd, TABLE_LIST *tables); 00568 bool insert_precheck(THD *thd, TABLE_LIST *tables); 00569 bool create_table_precheck(THD *thd, TABLE_LIST *tables, 00570 TABLE_LIST *create_table); 00571 int append_query_string(CHARSET_INFO *csinfo, 00572 String const *from, String *to); 00573 00574 void get_default_definer(THD *thd, LEX_USER *definer); 00575 LEX_USER *create_default_definer(THD *thd); 00576 LEX_USER *create_definer(THD *thd, LEX_STRING *user_name, LEX_STRING *host_name); 00577 LEX_USER *get_current_user(THD *thd, LEX_USER *user); 00578 00579 enum enum_mysql_completiontype { 00580 ROLLBACK_RELEASE=-2, ROLLBACK=1, ROLLBACK_AND_CHAIN=7, 00581 COMMIT_RELEASE=-1, COMMIT=0, COMMIT_AND_CHAIN=6 00582 }; 00583 00584 bool begin_trans(THD *thd); 00585 bool end_active_trans(THD *thd); 00586 int end_trans(THD *thd, enum enum_mysql_completiontype completion); 00587 00588 Item *negate_expression(THD *thd, Item *expr); 00589 #include "sql_class.h" 00590 #include "sql_acl.h" 00591 #include "tztime.h" 00592 #ifdef MYSQL_SERVER 00593 #include "opt_range.h" 00594 00595 #ifdef HAVE_QUERY_CACHE 00596 struct Query_cache_query_flags 00597 { 00598 unsigned int client_long_flag:1; 00599 unsigned int client_protocol_41:1; 00600 unsigned int more_results_exists:1; 00601 unsigned int pkt_nr; 00602 uint character_set_client_num; 00603 uint character_set_results_num; 00604 uint collation_connection_num; 00605 ha_rows limit; 00606 Time_zone *time_zone; 00607 ulong sql_mode; 00608 ulong max_sort_length; 00609 ulong group_concat_max_len; 00610 MY_LOCALE *lc_time_names; 00611 }; 00612 #define QUERY_CACHE_FLAGS_SIZE sizeof(Query_cache_query_flags) 00613 #include "sql_cache.h" 00614 #define query_cache_store_query(A, B) query_cache.store_query(A, B) 00615 #define query_cache_destroy() query_cache.destroy() 00616 #define query_cache_result_size_limit(A) query_cache.result_size_limit(A) 00617 #define query_cache_init() query_cache.init() 00618 #define query_cache_resize(A) query_cache.resize(A) 00619 #define query_cache_set_min_res_unit(A) query_cache.set_min_res_unit(A) 00620 #define query_cache_invalidate3(A, B, C) query_cache.invalidate(A, B, C) 00621 #define query_cache_invalidate1(A) query_cache.invalidate(A) 00622 #define query_cache_send_result_to_client(A, B, C) \ 00623 query_cache.send_result_to_client(A, B, C) 00624 #define query_cache_invalidate_by_MyISAM_filename_ref \ 00625 &query_cache_invalidate_by_MyISAM_filename 00626 #else 00627 #define QUERY_CACHE_FLAGS_SIZE 0 00628 #define query_cache_store_query(A, B) 00629 #define query_cache_destroy() 00630 #define query_cache_result_size_limit(A) 00631 #define query_cache_init() 00632 #define query_cache_resize(A) 00633 #define query_cache_set_min_res_unit(A) 00634 #define query_cache_invalidate3(A, B, C) 00635 #define query_cache_invalidate1(A) 00636 #define query_cache_send_result_to_client(A, B, C) 0 00637 #define query_cache_invalidate_by_MyISAM_filename_ref NULL 00638 00639 #define query_cache_abort(A) 00640 #define query_cache_end_of_result(A) 00641 #define query_cache_invalidate_by_MyISAM_filename_ref NULL 00642 #endif /*HAVE_QUERY_CACHE*/ 00643 00644 /* 00645 Error injector Macros to enable easy testing of recovery after failures 00646 in various error cases. 00647 */ 00648 #ifndef ERROR_INJECT_SUPPORT 00649 00650 #define ERROR_INJECT(x) 0 00651 #define ERROR_INJECT_ACTION(x,action) 0 00652 #define ERROR_INJECT_CRASH(x) 0 00653 #define ERROR_INJECT_VALUE(x) 0 00654 #define ERROR_INJECT_VALUE_ACTION(x,action) 0 00655 #define ERROR_INJECT_VALUE_CRASH(x) 0 00656 #define SET_ERROR_INJECT_VALUE(x) 00657 00658 #else 00659 00660 inline bool check_and_unset_keyword(const char *dbug_str) 00661 { 00662 const char *extra_str= "-d,"; 00663 char total_str[200]; 00664 if (_db_strict_keyword_ (dbug_str)) 00665 { 00666 strxmov(total_str, extra_str, dbug_str, NullS); 00667 DBUG_SET(total_str); 00668 return 1; 00669 } 00670 return 0; 00671 } 00672 00673 00674 inline bool 00675 check_and_unset_inject_value(int value) 00676 { 00677 THD *thd= current_thd; 00678 if (thd->error_inject_value == (uint)value) 00679 { 00680 thd->error_inject_value= 0; 00681 return 1; 00682 } 00683 return 0; 00684 } 00685 00686 /* 00687 ERROR INJECT MODULE: 00688 -------------------- 00689 These macros are used to insert macros from the application code. 00690 The event that activates those error injections can be activated 00691 from SQL by using: 00692 SET SESSION dbug=+d,code; 00693 00694 After the error has been injected, the macros will automatically 00695 remove the debug code, thus similar to using: 00696 SET SESSION dbug=-d,code 00697 from SQL. 00698 00699 ERROR_INJECT_CRASH will inject a crash of the MySQL Server if code 00700 is set when macro is called. ERROR_INJECT_CRASH can be used in 00701 if-statements, it will always return FALSE unless of course it 00702 crashes in which case it doesn't return at all. 00703 00704 ERROR_INJECT_ACTION will inject the action specified in the action 00705 parameter of the macro, before performing the action the code will 00706 be removed such that no more events occur. ERROR_INJECT_ACTION 00707 can also be used in if-statements and always returns FALSE. 00708 ERROR_INJECT can be used in a normal if-statement, where the action 00709 part is performed in the if-block. The macro returns TRUE if the 00710 error was activated and otherwise returns FALSE. If activated the 00711 code is removed. 00712 00713 Sometimes it is necessary to perform error inject actions as a serie 00714 of events. In this case one can use one variable on the THD object. 00715 Thus one sets this value by using e.g. SET_ERROR_INJECT_VALUE(100). 00716 Then one can later test for it by using ERROR_INJECT_CRASH_VALUE, 00717 ERROR_INJECT_ACTION_VALUE and ERROR_INJECT_VALUE. This have the same 00718 behaviour as the above described macros except that they use the 00719 error inject value instead of a code used by DBUG macros. 00720 */ 00721 #define SET_ERROR_INJECT_VALUE(x) \ 00722 current_thd->error_inject_value= (x) 00723 #define ERROR_INJECT_CRASH(code) \ 00724 DBUG_EVALUATE_IF(code, (abort(), 0), 0) 00725 #define ERROR_INJECT_ACTION(code, action) \ 00726 (check_and_unset_keyword(code) ? ((action), 0) : 0) 00727 #define ERROR_INJECT(code) \ 00728 check_and_unset_keyword(code) 00729 #define ERROR_INJECT_VALUE(value) \ 00730 check_and_unset_inject_value(value) 00731 #define ERROR_INJECT_VALUE_ACTION(value,action) \ 00732 (check_and_unset_inject_value(value) ? (action) : 0) 00733 #define ERROR_INJECT_VALUE_CRASH(value) \ 00734 ERROR_INJECT_VALUE_ACTION(value, (abort(), 0)) 00735 00736 #endif 00737 00738 uint build_table_path(char *buff, size_t bufflen, const char *db, 00739 const char *table, const char *ext); 00740 void write_bin_log(THD *thd, bool clear_error, 00741 char const *query, ulong query_length); 00742 00743 bool mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent); 00744 bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create); 00745 bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent); 00746 bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db); 00747 void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags); 00748 void mysql_client_binlog_statement(THD *thd); 00749 bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists, 00750 my_bool drop_temporary); 00751 int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, 00752 bool drop_temporary, bool drop_view, bool log_query); 00753 int mysql_rm_table_part2_with_lock(THD *thd, TABLE_LIST *tables, 00754 bool if_exists, bool drop_temporary, 00755 bool log_query); 00756 bool quick_rm_table(handlerton *base,const char *db, 00757 const char *table_name, uint flags); 00758 void close_cached_table(THD *thd, TABLE *table); 00759 bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent); 00760 bool mysql_change_db(THD *thd,const char *name,bool no_access_check); 00761 void mysql_parse(THD *thd,char *inBuf,uint length); 00762 bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length); 00763 bool is_update_query(enum enum_sql_command command); 00764 bool alloc_query(THD *thd, const char *packet, uint packet_length); 00765 void mysql_init_select(LEX *lex); 00766 void mysql_reset_thd_for_next_command(THD *thd); 00767 void mysql_init_query(THD *thd, uchar *buf, uint length); 00768 bool mysql_new_select(LEX *lex, bool move_down); 00769 void create_select_for_variable(const char *var_name); 00770 void mysql_init_multi_delete(LEX *lex); 00771 bool multi_delete_set_locks_and_link_aux_tables(LEX *lex); 00772 void init_max_user_conn(void); 00773 void init_update_queries(void); 00774 void free_max_user_conn(void); 00775 pthread_handler_t handle_one_connection(void *arg); 00776 pthread_handler_t handle_bootstrap(void *arg); 00777 void end_thread(THD *thd,bool put_in_cache); 00778 void flush_thread_cache(); 00779 bool mysql_execute_command(THD *thd); 00780 bool do_command(THD *thd); 00781 bool dispatch_command(enum enum_server_command command, THD *thd, 00782 char* packet, uint packet_length); 00783 void log_slow_statement(THD *thd); 00784 bool check_dup(const char *db, const char *name, TABLE_LIST *tables); 00785 bool append_file_to_dir(THD *thd, const char **filename_ptr, 00786 const char *table_name); 00787 00788 bool table_cache_init(void); 00789 void table_cache_free(void); 00790 bool table_def_init(void); 00791 void table_def_free(void); 00792 void assign_new_table_id(TABLE_SHARE *share); 00793 uint cached_open_tables(void); 00794 uint cached_table_definitions(void); 00795 void kill_mysql(void); 00796 void close_connection(THD *thd, uint errcode, bool lock); 00797 bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, 00798 bool *write_to_binlog); 00799 bool check_access(THD *thd, ulong access, const char *db, ulong *save_priv, 00800 bool no_grant, bool no_errors, bool schema_db); 00801 bool check_table_access(THD *thd, ulong want_access, TABLE_LIST *tables, 00802 bool no_errors); 00803 bool check_global_access(THD *thd, ulong want_access); 00804 00805 /* 00806 Support routine for SQL parser on partitioning syntax 00807 */ 00808 my_bool is_partition_management(LEX *lex); 00809 /* 00810 General routine to change field->ptr of a NULL-terminated array of Field 00811 objects. Useful when needed to call val_int, val_str or similar and the 00812 field data is not in table->record[0] but in some other structure. 00813 set_key_field_ptr changes all fields of an index using a key_info object. 00814 All methods presume that there is at least one field to change. 00815 */ 00816 00817 void set_field_ptr(Field **ptr, const byte *new_buf, const byte *old_buf); 00818 void set_key_field_ptr(KEY *key_info, const byte *new_buf, 00819 const byte *old_buf); 00820 00821 bool mysql_backup_table(THD* thd, TABLE_LIST* table_list); 00822 bool mysql_restore_table(THD* thd, TABLE_LIST* table_list); 00823 00824 bool mysql_checksum_table(THD* thd, TABLE_LIST* table_list, 00825 HA_CHECK_OPT* check_opt); 00826 bool mysql_check_table(THD* thd, TABLE_LIST* table_list, 00827 HA_CHECK_OPT* check_opt); 00828 bool mysql_repair_table(THD* thd, TABLE_LIST* table_list, 00829 HA_CHECK_OPT* check_opt); 00830 bool mysql_analyze_table(THD* thd, TABLE_LIST* table_list, 00831 HA_CHECK_OPT* check_opt); 00832 bool mysql_optimize_table(THD* thd, TABLE_LIST* table_list, 00833 HA_CHECK_OPT* check_opt); 00834 bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list, 00835 LEX_STRING *key_cache_name); 00836 bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list); 00837 int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache, 00838 KEY_CACHE *dst_cache); 00839 TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list); 00840 00841 bool mysql_xa_recover(THD *thd); 00842 00843 bool check_simple_select(); 00844 int mysql_alter_tablespace(THD* thd, st_alter_tablespace *ts_info); 00845 00846 SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length); 00847 int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, 00848 List<Item> &fields, List <Item> &all_fields, ORDER *order); 00849 int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, 00850 List<Item> &fields, List<Item> &all_fields, ORDER *order, 00851 bool *hidden_group_fields); 00852 00853 bool handle_select(THD *thd, LEX *lex, select_result *result, 00854 ulong setup_tables_done_option); 00855 bool mysql_select(THD *thd, Item ***rref_pointer_array, 00856 TABLE_LIST *tables, uint wild_num, List<Item> &list, 00857 COND *conds, uint og_num, ORDER *order, ORDER *group, 00858 Item *having, ORDER *proc_param, ulong select_type, 00859 select_result *result, SELECT_LEX_UNIT *unit, 00860 SELECT_LEX *select_lex); 00861 void free_underlaid_joins(THD *thd, SELECT_LEX *select); 00862 bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, 00863 select_result *result); 00864 int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type, 00865 select_result *result); 00866 bool mysql_union(THD *thd, LEX *lex, select_result *result, 00867 SELECT_LEX_UNIT *unit, ulong setup_tables_done_option); 00868 bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd, 00869 LEX *lex, 00870 TABLE_LIST *table)); 00871 bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t); 00872 bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t); 00873 Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, 00874 Item ***copy_func, Field **from_field, 00875 Field **def_field, 00876 bool group, bool modify_item, 00877 bool table_cant_handle_bit_fields, 00878 bool make_copy_field, 00879 uint convert_blob_length); 00880 void sp_prepare_create_field(THD *thd, create_field *sql_field); 00881 int prepare_create_field(create_field *sql_field, 00882 uint *blob_columns, 00883 int *timestamps, int *timestamps_with_niladic, 00884 uint table_flags); 00885 bool mysql_create_table(THD *thd,const char *db, const char *table_name, 00886 HA_CREATE_INFO *create_info, 00887 List<create_field> &fields, List<Key> &keys, 00888 bool tmp_table, uint select_field_count, 00889 bool use_copy_create_info); 00890 00891 bool mysql_alter_table(THD *thd, char *new_db, char *new_name, 00892 HA_CREATE_INFO *create_info, 00893 TABLE_LIST *table_list, 00894 List<create_field> &fields, 00895 List<Key> &keys, 00896 uint order_num, ORDER *order, bool ignore, 00897 ALTER_INFO *alter_info, bool do_send_ok); 00898 bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list, bool do_send_ok); 00899 bool mysql_create_like_table(THD *thd, TABLE_LIST *table, 00900 HA_CREATE_INFO *create_info, 00901 Table_ident *src_table); 00902 bool mysql_rename_table(handlerton *base, const char *old_db, 00903 const char * old_name, const char *new_db, 00904 const char * new_name, uint flags); 00905 bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys); 00906 bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, 00907 ALTER_INFO *alter_info); 00908 bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, 00909 Item **conds, uint order_num, ORDER *order); 00910 int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields, 00911 List<Item> &values,COND *conds, 00912 uint order_num, ORDER *order, ha_rows limit, 00913 enum enum_duplicates handle_duplicates, bool ignore); 00914 bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, 00915 List<Item> *fields, List<Item> *values, 00916 COND *conds, ulonglong options, 00917 enum enum_duplicates handle_duplicates, bool ignore, 00918 SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex); 00919 bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table, 00920 List<Item> &fields, List_item *values, 00921 List<Item> &update_fields, 00922 List<Item> &update_values, enum_duplicates duplic, 00923 COND **where, bool select_insert); 00924 bool mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields, 00925 List<List_item> &values, List<Item> &update_fields, 00926 List<Item> &update_values, enum_duplicates flag, 00927 bool ignore); 00928 int check_that_all_fields_are_given_values(THD *thd, TABLE *entry, 00929 TABLE_LIST *table_list); 00930 bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds); 00931 bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, 00932 SQL_LIST *order, ha_rows rows, ulonglong options, 00933 bool reset_auto_increment); 00934 bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok); 00935 bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create); 00936 uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list, 00937 bool tmp_table); 00938 TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, 00939 uint key_length, uint db_flags, int *error); 00940 void release_table_share(TABLE_SHARE *share, enum release_type type); 00941 TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name); 00942 TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update); 00943 TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem, 00944 bool *refresh, uint flags); 00945 bool reopen_name_locked_table(THD* thd, TABLE_LIST* table); 00946 TABLE *find_locked_table(THD *thd, const char *db,const char *table_name); 00947 bool reopen_tables(THD *thd,bool get_locks,bool in_refresh); 00948 bool close_data_tables(THD *thd,const char *db, const char *table_name); 00949 bool wait_for_tables(THD *thd); 00950 bool table_is_used(TABLE *table, bool wait_for_name_lock); 00951 TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name); 00952 void abort_locked_tables(THD *thd,const char *db, const char *table_name); 00953 void execute_init_command(THD *thd, sys_var_str *init_command_var, 00954 rw_lock_t *var_mutex); 00955 extern Field *not_found_field; 00956 extern Field *view_ref_found; 00957 00958 enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND, 00959 IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE, 00960 IGNORE_EXCEPT_NON_UNIQUE}; 00961 Field * 00962 find_field_in_tables(THD *thd, Item_ident *item, 00963 TABLE_LIST *first_table, TABLE_LIST *last_table, 00964 Item **ref, find_item_error_report_type report_error, 00965 bool check_privileges, bool register_tree_change); 00966 Field * 00967 find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, 00968 const char *name, uint length, 00969 const char *item_name, const char *db_name, 00970 const char *table_name, Item **ref, 00971 bool check_privileges, bool allow_rowid, 00972 uint *cached_field_index_ptr, 00973 bool register_tree_change, TABLE_LIST **actual_table); 00974 Field * 00975 find_field_in_table(THD *thd, TABLE *table, const char *name, uint length, 00976 bool allow_rowid, uint *cached_field_index_ptr); 00977 Field * 00978 find_field_in_table_sef(TABLE *table, const char *name); 00979 00980 #endif /* MYSQL_SERVER */ 00981 00982 #ifdef HAVE_OPENSSL 00983 #include <openssl/des.h> 00984 struct st_des_keyblock 00985 { 00986 DES_cblock key1, key2, key3; 00987 }; 00988 struct st_des_keyschedule 00989 { 00990 DES_key_schedule ks1, ks2, ks3; 00991 }; 00992 extern char *des_key_file; 00993 extern struct st_des_keyschedule des_keyschedule[10]; 00994 extern uint des_default_key; 00995 extern pthread_mutex_t LOCK_des_key_file; 00996 bool load_des_key_file(const char *file_name); 00997 #endif /* HAVE_OPENSSL */ 00998 00999 #ifdef MYSQL_SERVER 01000 /* sql_do.cc */ 01001 bool mysql_do(THD *thd, List<Item> &values); 01002 01003 /* sql_analyse.h */ 01004 bool append_escaped(String *to_str, String *from_str); 01005 01006 /* sql_show.cc */ 01007 bool mysqld_show_open_tables(THD *thd,const char *wild); 01008 bool mysqld_show_logs(THD *thd); 01009 void append_identifier(THD *thd, String *packet, const char *name, 01010 uint length); 01011 int get_quote_char_for_identifier(THD *thd, const char *name, uint length); 01012 void mysqld_list_fields(THD *thd,TABLE_LIST *table, const char *wild); 01013 int mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd); 01014 bool mysqld_show_create(THD *thd, TABLE_LIST *table_list); 01015 bool mysqld_show_create_db(THD *thd, char *dbname, HA_CREATE_INFO *create); 01016 01017 void mysqld_list_processes(THD *thd,const char *user,bool verbose); 01018 int mysqld_show_status(THD *thd); 01019 int mysqld_show_variables(THD *thd,const char *wild); 01020 bool mysqld_show_storage_engines(THD *thd); 01021 bool mysqld_show_authors(THD *thd); 01022 bool mysqld_show_contributors(THD *thd); 01023 bool mysqld_show_privileges(THD *thd); 01024 bool mysqld_show_column_types(THD *thd); 01025 bool mysqld_help (THD *thd, const char *text); 01026 void calc_sum_of_all_status(STATUS_VAR *to); 01027 01028 void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user, 01029 const LEX_STRING *definer_host); 01030 01031 int add_status_vars(SHOW_VAR *list); 01032 void remove_status_vars(SHOW_VAR *list); 01033 void init_status_vars(); 01034 void free_status_vars(); 01035 01036 /* information schema */ 01037 extern LEX_STRING information_schema_name; 01038 extern const LEX_STRING partition_keywords[]; 01039 LEX_STRING *make_lex_string(THD *thd, LEX_STRING *lex_str, 01040 const char* str, uint length, 01041 bool allocate_lex_string); 01042 ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name); 01043 ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx); 01044 int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, 01045 enum enum_schema_tables schema_table_idx); 01046 int make_schema_select(THD *thd, SELECT_LEX *sel, 01047 enum enum_schema_tables schema_table_idx); 01048 int mysql_schema_table(THD *thd, LEX *lex, TABLE_LIST *table_list); 01049 int fill_schema_user_privileges(THD *thd, TABLE_LIST *tables, COND *cond); 01050 int fill_schema_schema_privileges(THD *thd, TABLE_LIST *tables, COND *cond); 01051 int fill_schema_table_privileges(THD *thd, TABLE_LIST *tables, COND *cond); 01052 int fill_schema_column_privileges(THD *thd, TABLE_LIST *tables, COND *cond); 01053 bool get_schema_tables_result(JOIN *join); 01054 #define is_schema_db(X) \ 01055 !my_strcasecmp(system_charset_info, information_schema_name.str, (X)) 01056 01057 /* sql_prepare.cc */ 01058 01059 void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length); 01060 void mysql_stmt_execute(THD *thd, char *packet, uint packet_length); 01061 void mysql_stmt_close(THD *thd, char *packet); 01062 void mysql_sql_stmt_prepare(THD *thd); 01063 void mysql_sql_stmt_execute(THD *thd); 01064 void mysql_sql_stmt_close(THD *thd); 01065 void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length); 01066 void mysql_stmt_reset(THD *thd, char *packet); 01067 void mysql_stmt_get_longdata(THD *thd, char *pos, ulong packet_length); 01068 void reinit_stmt_before_use(THD *thd, LEX *lex); 01069 01070 /* sql_handler.cc */ 01071 bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen); 01072 bool mysql_ha_close(THD *thd, TABLE_LIST *tables); 01073 bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *, 01074 List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows); 01075 int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags, 01076 bool is_locked); 01077 /* mysql_ha_flush mode_flags bits */ 01078 #define MYSQL_HA_CLOSE_FINAL 0x00 01079 #define MYSQL_HA_REOPEN_ON_USAGE 0x01 01080 #define MYSQL_HA_FLUSH_ALL 0x02 01081 01082 /* sql_base.cc */ 01083 #define TMP_TABLE_KEY_EXTRA 8 01084 void set_item_name(Item *item,char *pos,uint length); 01085 bool add_field_to_list(THD *thd, char *field_name, enum enum_field_types type, 01086 char *length, char *decimal, 01087 uint type_modifier, 01088 Item *default_value, Item *on_update_value, 01089 LEX_STRING *comment, 01090 char *change, List<String> *interval_list, 01091 CHARSET_INFO *cs, 01092 uint uint_geom_type); 01093 create_field * new_create_field(THD *thd, char *field_name, enum_field_types type, 01094 char *length, char *decimals, 01095 uint type_modifier, 01096 Item *default_value, Item *on_update_value, 01097 LEX_STRING *comment, char *change, 01098 List<String> *interval_list, CHARSET_INFO *cs, 01099 uint uint_geom_type); 01100 void store_position_for_column(const char *name); 01101 bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc); 01102 bool push_new_name_resolution_context(THD *thd, 01103 TABLE_LIST *left_op, 01104 TABLE_LIST *right_op); 01105 void add_join_on(TABLE_LIST *b,Item *expr); 01106 void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields); 01107 bool add_proc_to_list(THD *thd, Item *item); 01108 TABLE *unlink_open_table(THD *thd,TABLE *list,TABLE *find); 01109 void update_non_unique_table_error(TABLE_LIST *update, 01110 const char *operation, 01111 TABLE_LIST *duplicate); 01112 01113 SQL_SELECT *make_select(TABLE *head, table_map const_tables, 01114 table_map read_tables, COND *conds, 01115 bool allow_null_cond, int *error); 01116 extern Item **not_found_item; 01117 Item ** find_item_in_list(Item *item, List<Item> &items, uint *counter, 01118 find_item_error_report_type report_error, 01119 bool *unaliased); 01120 bool get_key_map_from_key_list(key_map *map, TABLE *table, 01121 List<String> *index_list); 01122 bool insert_fields(THD *thd, Name_resolution_context *context, 01123 const char *db_name, const char *table_name, 01124 List_iterator<Item> *it, bool any_privileges); 01125 bool setup_tables(THD *thd, Name_resolution_context *context, 01126 List<TABLE_LIST> *from_clause, TABLE_LIST *tables, 01127 TABLE_LIST **leaves, bool select_insert); 01128 bool setup_tables_and_check_access(THD *thd, 01129 Name_resolution_context *context, 01130 List<TABLE_LIST> *from_clause, 01131 TABLE_LIST *tables, 01132 TABLE_LIST **leaves, 01133 bool select_insert, 01134 ulong want_access); 01135 int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, 01136 List<Item> *sum_func_list, uint wild_num); 01137 bool setup_fields(THD *thd, Item** ref_pointer_array, 01138 List<Item> &item, enum_mark_columns mark_used_columns, 01139 List<Item> *sum_func_list, bool allow_sum_func); 01140 inline bool setup_fields_with_no_wrap(THD *thd, Item **ref_pointer_array, 01141 List<Item> &item, 01142 enum_mark_columns mark_used_columns, 01143 List<Item> *sum_func_list, 01144 bool allow_sum_func) 01145 { 01146 bool res; 01147 thd->lex->select_lex.no_wrap_view_item= TRUE; 01148 res= setup_fields(thd, ref_pointer_array, item, mark_used_columns, sum_func_list, 01149 allow_sum_func); 01150 thd->lex->select_lex.no_wrap_view_item= FALSE; 01151 return res; 01152 } 01153 int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, 01154 COND **conds); 01155 int setup_ftfuncs(SELECT_LEX* select); 01156 int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order); 01157 void wait_for_condition(THD *thd, pthread_mutex_t *mutex, 01158 pthread_cond_t *cond); 01159 int open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags); 01160 int simple_open_n_lock_tables(THD *thd,TABLE_LIST *tables); 01161 bool open_and_lock_tables(THD *thd,TABLE_LIST *tables); 01162 bool open_normal_and_derived_tables(THD *thd, TABLE_LIST *tables, uint flags); 01163 int lock_tables(THD *thd, TABLE_LIST *tables, uint counter, bool *need_reopen); 01164 TABLE *open_temporary_table(THD *thd, const char *path, const char *db, 01165 const char *table_name, bool link_in_list); 01166 bool rm_temporary_table(handlerton *base, char *path); 01167 void free_io_cache(TABLE *entry); 01168 void intern_close_table(TABLE *entry); 01169 bool close_thread_table(THD *thd, TABLE **table_ptr); 01170 void close_temporary_tables(THD *thd); 01171 void close_tables_for_reopen(THD *thd, TABLE_LIST **tables); 01172 TABLE_LIST *find_table_in_list(TABLE_LIST *table, 01173 st_table_list *TABLE_LIST::*link, 01174 const char *db_name, 01175 const char *table_name); 01176 TABLE_LIST *unique_table(THD *thd, TABLE_LIST *table, TABLE_LIST *table_list); 01177 TABLE *find_temporary_table(THD *thd, const char *db, const char *table_name); 01178 TABLE *find_temporary_table(THD *thd, TABLE_LIST *table_list); 01179 bool close_temporary_table(THD *thd, TABLE_LIST *table_list); 01180 void close_temporary_table(THD *thd, TABLE *table, bool free_share, 01181 bool delete_table); 01182 void close_temporary(TABLE *table, bool free_share, bool delete_table); 01183 bool rename_temporary_table(THD* thd, TABLE *table, const char *new_db, 01184 const char *table_name); 01185 void remove_db_from_cache(const char *db); 01186 void flush_tables(); 01187 bool is_equal(const LEX_STRING *a, const LEX_STRING *b); 01188 char *make_default_log_name(char *buff,const char* log_ext); 01189 01190 #ifdef WITH_PARTITION_STORAGE_ENGINE 01191 uint fast_alter_partition_table(THD *thd, TABLE *table, 01192 ALTER_INFO *alter_info, 01193 HA_CREATE_INFO *create_info, 01194 TABLE_LIST *table_list, 01195 List<create_field> *create_list, 01196 List<Key> *key_list, char *db, 01197 const char *table_name, 01198 uint fast_alter_partition); 01199 uint prep_alter_part_table(THD *thd, TABLE *table, ALTER_INFO *alter_info, 01200 HA_CREATE_INFO *create_info, 01201 handlerton *old_db_type, 01202 bool *partition_changed, 01203 uint *fast_alter_partition); 01204 #endif 01205 01206 /* bits for last argument to remove_table_from_cache() */ 01207 #define RTFC_NO_FLAG 0x0000 01208 #define RTFC_OWNED_BY_THD_FLAG 0x0001 01209 #define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002 01210 #define RTFC_CHECK_KILLED_FLAG 0x0004 01211 bool remove_table_from_cache(THD *thd, const char *db, const char *table, 01212 uint flags); 01213 01214 #define NORMAL_PART_NAME 0 01215 #define TEMP_PART_NAME 1 01216 #define RENAMED_PART_NAME 2 01217 void create_partition_name(char *out, const char *in1, 01218 const char *in2, uint name_variant, 01219 bool translate); 01220 void create_subpartition_name(char *out, const char *in1, 01221 const char *in2, const char *in3, 01222 uint name_variant); 01223 01224 typedef struct st_lock_param_type 01225 { 01226 TABLE_LIST table_list; 01227 ulonglong copied; 01228 ulonglong deleted; 01229 THD *thd; 01230 HA_CREATE_INFO *create_info; 01231 ALTER_INFO *alter_info; 01232 List<create_field> *create_list; 01233 List<create_field> new_create_list; 01234 List<Key> *key_list; 01235 List<Key> new_key_list; 01236 TABLE *table; 01237 KEY *key_info_buffer; 01238 const char *db; 01239 const char *table_name; 01240 const void *pack_frm_data; 01241 enum thr_lock_type old_lock_type; 01242 uint key_count; 01243 uint db_options; 01244 uint pack_frm_len; 01245 partition_info *part_info; 01246 } ALTER_PARTITION_PARAM_TYPE; 01247 01248 void mem_alloc_error(size_t size); 01249 01250 enum ddl_log_entry_code 01251 { 01252 /* 01253 DDL_LOG_EXECUTE_CODE: 01254 This is a code that indicates that this is a log entry to 01255 be executed, from this entry a linked list of log entries 01256 can be found and executed. 01257 DDL_LOG_ENTRY_CODE: 01258 An entry to be executed in a linked list from an execute log 01259 entry. 01260 DDL_IGNORE_LOG_ENTRY_CODE: 01261 An entry that is to be ignored 01262 */ 01263 DDL_LOG_EXECUTE_CODE = 'e', 01264 DDL_LOG_ENTRY_CODE = 'l', 01265 DDL_IGNORE_LOG_ENTRY_CODE = 'i' 01266 }; 01267 01268 enum ddl_log_action_code 01269 { 01270 /* 01271 The type of action that a DDL_LOG_ENTRY_CODE entry is to 01272 perform. 01273 DDL_LOG_DELETE_ACTION: 01274 Delete an entity 01275 DDL_LOG_RENAME_ACTION: 01276 Rename an entity 01277 DDL_LOG_REPLACE_ACTION: 01278 Rename an entity after removing the previous entry with the 01279 new name, that is replace this entry. 01280 */ 01281 DDL_LOG_DELETE_ACTION = 'd', 01282 DDL_LOG_RENAME_ACTION = 'r', 01283 DDL_LOG_REPLACE_ACTION = 's' 01284 }; 01285 01286 01287 typedef struct st_ddl_log_entry 01288 { 01289 const char *name; 01290 const char *from_name; 01291 const char *handler_name; 01292 uint next_entry; 01293 uint entry_pos; 01294 enum ddl_log_entry_code entry_type; 01295 enum ddl_log_action_code action_type; 01296 /* 01297 Most actions have only one phase. REPLACE does however have two 01298 phases. The first phase removes the file with the new name if 01299 there was one there before and the second phase renames the 01300 old name to the new name. 01301 */ 01302 char phase; 01303 } DDL_LOG_ENTRY; 01304 01305 typedef struct st_ddl_log_memory_entry 01306 { 01307 uint entry_pos; 01308 struct st_ddl_log_memory_entry *next_log_entry; 01309 struct st_ddl_log_memory_entry *prev_log_entry; 01310 struct st_ddl_log_memory_entry *next_active_log_entry; 01311 } DDL_LOG_MEMORY_ENTRY; 01312 01313 01314 bool write_ddl_log_entry(DDL_LOG_ENTRY *ddl_log_entry, 01315 DDL_LOG_MEMORY_ENTRY **active_entry); 01316 bool write_execute_ddl_log_entry(uint first_entry, 01317 bool complete, 01318 DDL_LOG_MEMORY_ENTRY **active_entry); 01319 bool deactivate_ddl_log_entry(uint entry_no); 01320 void release_ddl_log_memory_entry(DDL_LOG_MEMORY_ENTRY *log_entry); 01321 bool sync_ddl_log(); 01322 void release_ddl_log(); 01323 void execute_ddl_log_recovery(); 01324 bool execute_ddl_log_entry(THD *thd, uint first_entry); 01325 01326 extern pthread_mutex_t LOCK_gdl; 01327 01328 #define WFRM_WRITE_SHADOW 1 01329 #define WFRM_INSTALL_SHADOW 2 01330 #define WFRM_PACK_FRM 4 01331 bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags); 01332 int abort_and_upgrade_lock(ALTER_PARTITION_PARAM_TYPE *lpt); 01333 void close_open_tables_and_downgrade(ALTER_PARTITION_PARAM_TYPE *lpt); 01334 void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table); 01335 01336 bool close_cached_tables(THD *thd, bool wait_for_refresh, TABLE_LIST *tables, bool have_lock = FALSE); 01337 void copy_field_from_tmp_record(Field *field,int offset); 01338 bool fill_record(THD *thd, Field **field, List<Item> &values, 01339 bool ignore_errors); 01340 bool fill_record_n_invoke_before_triggers(THD *thd, List<Item> &fields, 01341 List<Item> &values, 01342 bool ignore_errors, 01343 Table_triggers_list *triggers, 01344 enum trg_event_type event); 01345 bool fill_record_n_invoke_before_triggers(THD *thd, Field **field, 01346 List<Item> &values, 01347 bool ignore_errors, 01348 Table_triggers_list *triggers, 01349 enum trg_event_type event); 01350 OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *db, const char *wild); 01351 01352 inline TABLE_LIST *find_table_in_global_list(TABLE_LIST *table, 01353 const char *db_name, 01354 const char *table_name) 01355 { 01356 return find_table_in_list(table, &TABLE_LIST::next_global, 01357 db_name, table_name); 01358 } 01359 01360 inline TABLE_LIST *find_table_in_local_list(TABLE_LIST *table, 01361 const char *db_name, 01362 const char *table_name) 01363 { 01364 return find_table_in_list(table, &TABLE_LIST::next_local, 01365 db_name, table_name); 01366 } 01367 01368 01369 /* sql_calc.cc */ 01370 bool eval_const_cond(COND *cond); 01371 01372 /* sql_load.cc */ 01373 bool mysql_load(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, 01374 List<Item> &fields_vars, List<Item> &set_fields, 01375 List<Item> &set_values_list, 01376 enum enum_duplicates handle_duplicates, bool ignore, 01377 bool local_file); 01378 int write_record(THD *thd, TABLE *table, COPY_INFO *info); 01379 01380 /* sql_manager.cc */ 01381 extern ulong volatile manager_status; 01382 extern bool volatile manager_thread_in_use, mqh_used; 01383 extern pthread_t manager_thread; 01384 pthread_handler_t handle_manager(void *arg); 01385 bool mysql_manager_submit(void (*action)()); 01386 01387 01388 /* sql_test.cc */ 01389 #ifndef DBUG_OFF 01390 void print_where(COND *cond,const char *info); 01391 void print_cached_tables(void); 01392 void TEST_filesort(SORT_FIELD *sortorder,uint s_length); 01393 void print_plan(JOIN* join,uint idx, double record_count, double read_time, 01394 double current_read_time, const char *info); 01395 #endif 01396 void mysql_print_status(); 01397 /* key.cc */ 01398 int find_ref_key(KEY *key, uint key_count, Field *field, uint *key_length); 01399 void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length); 01400 void key_restore(byte *to_record, byte *from_key, KEY *key_info, 01401 uint key_length); 01402 bool key_cmp_if_same(TABLE *form,const byte *key,uint index,uint key_length); 01403 void key_unpack(String *to,TABLE *form,uint index); 01404 bool check_if_key_used(TABLE *table, uint idx, List<Item> &fields); 01405 int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length); 01406 int key_rec_cmp(void *key_info, byte *a, byte *b); 01407 01408 bool init_errmessage(void); 01409 #endif /* MYSQL_SERVER */ 01410 void sql_perror(const char *message); 01411 01412 01413 int vprint_msg_to_log(enum loglevel level, const char *format, va_list args); 01414 void sql_print_error(const char *format, ...); 01415 void sql_print_warning(const char *format, ...); 01416 void sql_print_information(const char *format, ...); 01417 typedef void (*sql_print_message_func)(const char *format, ...); 01418 extern sql_print_message_func sql_print_message_handlers[]; 01419 01420 /* type of the log table */ 01421 #define QUERY_LOG_SLOW 1 01422 #define QUERY_LOG_GENERAL 2 01423 01424 int error_log_print(enum loglevel level, const char *format, 01425 va_list args); 01426 01427 bool slow_log_print(THD *thd, const char *query, uint query_length, 01428 time_t query_start_arg); 01429 01430 bool general_log_print(THD *thd, enum enum_server_command command, 01431 const char *format,...); 01432 01433 bool fn_format_relative_to_data_home(my_string to, const char *name, 01434 const char *dir, const char *extension); 01435 #ifdef MYSQL_SERVER 01436 File open_binlog(IO_CACHE *log, const char *log_file_name, 01437 const char **errmsg); 01438 01439 /* mysqld.cc */ 01440 extern void MYSQLerror(const char*); 01441 void refresh_status(THD *thd); 01442 01443 /* item_func.cc */ 01444 extern bool check_reserved_words(LEX_STRING *name); 01445 01446 /* strfunc.cc */ 01447 ulonglong find_set(TYPELIB *lib, const char *x, uint length, CHARSET_INFO *cs, 01448 char **err_pos, uint *err_len, bool *set_warning); 01449 uint find_type(TYPELIB *lib, const char *find, uint length, bool part_match); 01450 uint find_type2(TYPELIB *lib, const char *find, uint length, CHARSET_INFO *cs); 01451 void unhex_type2(TYPELIB *lib); 01452 uint check_word(TYPELIB *lib, const char *val, const char *end, 01453 const char **end_of_word); 01454 01455 01456 bool is_keyword(const char *name, uint len); 01457 01458 #define MY_DB_OPT_FILE "db.opt" 01459 bool my_database_names_init(void); 01460 void my_database_names_free(void); 01461 bool check_db_dir_existence(const char *db_name); 01462 bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create); 01463 bool load_db_opt_by_name(THD *thd, const char *db_name, 01464 HA_CREATE_INFO *db_create_info); 01465 bool my_dbopt_init(void); 01466 void my_dbopt_cleanup(void); 01467 extern int creating_database; // How many database locks are made 01468 extern int creating_table; // How many mysql_create_table() are running 01469 01470 /* 01471 External variables 01472 */ 01473 01474 extern time_t start_time; 01475 extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH], 01476 mysql_real_data_home[], *opt_mysql_tmpdir, mysql_charsets_dir[], 01477 def_ft_boolean_syntax[sizeof(ft_boolean_syntax)]; 01478 #define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list)) 01479 extern MY_TMPDIR mysql_tmpdir_list; 01480 extern const LEX_STRING command_name[]; 01481 extern const char *first_keyword, *my_localhost, *delayed_user, *binary_keyword; 01482 extern const char **errmesg; /* Error messages */ 01483 extern const char *myisam_recover_options_str; 01484 extern const char *in_left_expr_name, *in_additional_cond; 01485 extern const char * const triggers_file_ext; 01486 extern const char * const trigname_file_ext; 01487 extern Eq_creator eq_creator; 01488 extern Ne_creator ne_creator; 01489 extern Gt_creator gt_creator; 01490 extern Lt_creator lt_creator; 01491 extern Ge_creator ge_creator; 01492 extern Le_creator le_creator; 01493 extern char language[FN_REFLEN], reg_ext[FN_EXTLEN]; 01494 extern uint reg_ext_length; 01495 extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN]; 01496 extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file; 01497 extern char log_error_file[FN_REFLEN], *opt_tc_log_file; 01498 extern double log_10[32]; 01499 extern ulonglong log_10_int[20]; 01500 extern ulonglong keybuff_size; 01501 extern ulonglong thd_startup_options; 01502 extern ulong refresh_version,flush_version, thread_id; 01503 extern ulong binlog_cache_use, binlog_cache_disk_use; 01504 extern ulong aborted_threads,aborted_connects; 01505 extern ulong delayed_insert_timeout; 01506 extern ulong delayed_insert_limit, delayed_queue_size; 01507 extern ulong delayed_insert_threads, delayed_insert_writes; 01508 extern ulong delayed_rows_in_use,delayed_insert_errors; 01509 extern ulong slave_open_temp_tables; 01510 extern ulong query_cache_size, query_cache_min_res_unit; 01511 extern ulong slow_launch_threads, slow_launch_time; 01512 extern ulong table_cache_size, table_def_size; 01513 extern ulong max_connections,max_connect_errors, connect_timeout; 01514 extern ulong slave_net_timeout, slave_trans_retries; 01515 extern uint max_user_connections; 01516 extern ulong what_to_log,flush_time; 01517 extern ulong query_buff_size, thread_stack; 01518 extern ulong max_prepared_stmt_count, prepared_stmt_count; 01519 extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit; 01520 extern ulong max_binlog_size, max_relay_log_size; 01521 #ifdef HAVE_ROW_BASED_REPLICATION 01522 extern ulong opt_binlog_rows_event_max_size; 01523 #endif 01524 extern ulong rpl_recovery_rank, thread_cache_size; 01525 extern ulong back_log; 01526 extern ulong specialflag, current_pid; 01527 extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter; 01528 extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size; 01529 extern ulong tc_log_page_waits; 01530 extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb; 01531 extern uint test_flags,select_errors,ha_open_options; 01532 extern uint protocol_version, mysqld_port, dropping_tables; 01533 extern uint delay_key_write_options, lower_case_table_names; 01534 extern bool opt_endinfo, using_udf_functions; 01535 extern my_bool locked_in_memory; 01536 extern bool opt_using_transactions, mysqld_embedded; 01537 extern bool using_update_log, opt_large_files, server_id_supplied; 01538 extern bool opt_update_log, opt_bin_log, opt_error_log; 01539 extern my_bool opt_log, opt_slow_log; 01540 extern ulong log_output_options; 01541 extern my_bool opt_log_queries_not_using_indexes; 01542 extern bool opt_disable_networking, opt_skip_show_db; 01543 extern my_bool opt_character_set_client_handshake; 01544 extern bool volatile abort_loop, shutdown_in_progress, grant_option; 01545 extern bool mysql_proc_table_exists; 01546 extern uint volatile thread_count, thread_running, global_read_lock; 01547 extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; 01548 extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap; 01549 extern my_bool opt_slave_compressed_protocol, use_temp_pool; 01550 extern my_bool opt_readonly, lower_case_file_system; 01551 extern my_bool opt_enable_named_pipe, opt_sync_frm, opt_allow_suspicious_udfs; 01552 extern my_bool opt_secure_auth; 01553 extern my_bool opt_log_slow_admin_statements; 01554 extern my_bool sp_automatic_privileges, opt_noacl; 01555 extern my_bool opt_old_style_user_limits, trust_function_creators; 01556 extern uint opt_crash_binlog_innodb; 01557 extern char *shared_memory_base_name, *mysqld_unix_port; 01558 extern my_bool opt_enable_shared_memory; 01559 extern char *default_tz_name; 01560 extern my_bool opt_large_pages; 01561 extern uint opt_large_page_size; 01562 extern char *opt_logname, *opt_slow_logname; 01563 extern const char *log_output_str; 01564 01565 extern MYSQL_BIN_LOG mysql_bin_log; 01566 extern LOGGER logger; 01567 extern TABLE_LIST general_log, slow_log; 01568 extern FILE *bootstrap_file; 01569 extern int bootstrap_error; 01570 extern FILE *stderror_file; 01571 extern pthread_key(MEM_ROOT**,THR_MALLOC); 01572 extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db, 01573 LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status, 01574 LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator, 01575 LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, 01576 LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock, 01577 LOCK_global_system_variables, LOCK_user_conn, 01578 LOCK_prepared_stmt_count, 01579 LOCK_bytes_sent, LOCK_bytes_received; 01580 #ifdef HAVE_OPENSSL 01581 extern pthread_mutex_t LOCK_des_key_file; 01582 #endif 01583 extern pthread_mutex_t LOCK_server_started; 01584 extern pthread_cond_t COND_server_started; 01585 extern int mysqld_server_started; 01586 extern rw_lock_t LOCK_grant, LOCK_sys_init_connect, LOCK_sys_init_slave; 01587 extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager; 01588 extern pthread_cond_t COND_global_read_lock; 01589 extern pthread_attr_t connection_attrib; 01590 extern I_List<THD> threads; 01591 extern I_List<NAMED_LIST> key_caches; 01592 extern MY_BITMAP temp_pool; 01593 extern String my_empty_string; 01594 extern const String my_null_string; 01595 extern SHOW_VAR init_vars[], status_vars[], internal_vars[]; 01596 extern struct system_variables global_system_variables; 01597 extern struct system_variables max_system_variables; 01598 extern struct system_status_var global_status_var; 01599 extern struct rand_struct sql_rand; 01600 01601 extern const char *opt_date_time_formats[]; 01602 extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[]; 01603 01604 extern String null_string; 01605 extern HASH open_cache, lock_db_cache; 01606 extern TABLE *unused_tables; 01607 extern const char* any_db; 01608 extern struct my_option my_long_options[]; 01609 extern const LEX_STRING view_type; 01610 extern uint sql_command_flags[]; 01611 extern TYPELIB log_output_typelib; 01612 01613 /* optional things, have_* variables */ 01614 01615 #ifdef WITH_INNOBASE_STORAGE_ENGINE 01616 extern handlerton innobase_hton; 01617 #define have_innodb innobase_hton.state 01618 #else 01619 extern SHOW_COMP_OPTION have_innodb; 01620 #endif 01621 #ifdef WITH_EXAMPLE_STORAGE_ENGINE 01622 extern handlerton example_hton; 01623 #define have_example_db example_hton.state 01624 #else 01625 extern SHOW_COMP_OPTION have_example_db; 01626 #endif 01627 #ifdef WITH_ARCHIVE_STORAGE_ENGINE 01628 extern handlerton archive_hton; 01629 #define have_archive_db archive_hton.state 01630 #else 01631 extern SHOW_COMP_OPTION have_archive_db; 01632 #endif 01633 #ifdef WITH_CSV_STORAGE_ENGINE 01634 extern handlerton tina_hton; 01635 #define have_csv_db tina_hton.state 01636 #else 01637 extern SHOW_COMP_OPTION have_csv_db; 01638 #endif 01639 #ifdef WITH_FEDERATED_STORAGE_ENGINE 01640 extern handlerton federated_hton; 01641 #define have_federated_db federated_hton.state 01642 #else 01643 extern SHOW_COMP_OPTION have_federated_db; 01644 #endif 01645 #ifdef WITH_BLACKHOLE_STORAGE_ENGINE 01646 extern handlerton blackhole_hton; 01647 #define have_blackhole_db blackhole_hton.state 01648 #else 01649 extern SHOW_COMP_OPTION have_blackhole_db; 01650 #endif 01651 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE 01652 extern handlerton ndbcluster_hton; 01653 #define have_ndbcluster ndbcluster_hton.state 01654 #else 01655 extern SHOW_COMP_OPTION have_ndbcluster; 01656 #endif 01657 #ifdef WITH_PARTITION_STORAGE_ENGINE 01658 extern handlerton partition_hton; 01659 #define have_partition_db partition_hton.state 01660 #else 01661 extern SHOW_COMP_OPTION have_partition_db; 01662 #endif 01663 01664 extern handlerton myisammrg_hton; 01665 /* MRG_MYISAM handler is always built, but may be skipped */ 01666 #define have_merge_db myisammrg_hton.state 01667 01668 extern handlerton myisam_hton; 01669 extern handlerton myisammrg_hton; 01670 extern handlerton heap_hton; 01671 01672 extern SHOW_COMP_OPTION have_row_based_replication; 01673 extern SHOW_COMP_OPTION have_raid, have_openssl, have_symlink, have_dlopen; 01674 extern SHOW_COMP_OPTION have_query_cache; 01675 extern SHOW_COMP_OPTION have_geometry, have_rtree_keys; 01676 extern SHOW_COMP_OPTION have_crypt; 01677 extern SHOW_COMP_OPTION have_compress; 01678 01679 #ifndef __WIN__ 01680 extern pthread_t signal_thread; 01681 #endif 01682 01683 #ifdef HAVE_OPENSSL 01684 extern struct st_VioSSLFd * ssl_acceptor_fd; 01685 #endif /* HAVE_OPENSSL */ 01686 01687 MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **table, uint count, 01688 uint flags, bool *need_reopen); 01689 /* mysql_lock_tables() and open_table() flags bits */ 01690 #define MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001 01691 #define MYSQL_LOCK_IGNORE_FLUSH 0x0002 01692 #define MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004 01693 #define MYSQL_OPEN_IGNORE_LOCKED_TABLES 0x0008 01694 01695 void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock); 01696 void mysql_unlock_read_tables(THD *thd, MYSQL_LOCK *sql_lock); 01697 void mysql_unlock_some_tables(THD *thd, TABLE **table,uint count); 01698 void mysql_lock_remove(THD *thd, MYSQL_LOCK *locked,TABLE *table); 01699 void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock); 01700 void mysql_lock_downgrade_write(THD *thd, TABLE *table, 01701 thr_lock_type new_lock_type); 01702 bool mysql_lock_abort_for_thread(THD *thd, TABLE *table); 01703 MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b); 01704 TABLE_LIST *mysql_lock_have_duplicate(THD *thd, TABLE_LIST *needle, 01705 TABLE_LIST *haystack); 01706 bool lock_global_read_lock(THD *thd); 01707 void unlock_global_read_lock(THD *thd); 01708 bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh, 01709 bool is_not_commit); 01710 void start_waiting_global_read_lock(THD *thd); 01711 bool make_global_read_lock_block_commit(THD *thd); 01712 bool set_protect_against_global_read_lock(void); 01713 void unset_protect_against_global_read_lock(void); 01714 void broadcast_refresh(void); 01715 01716 /* Lock based on name */ 01717 int lock_and_wait_for_table_name(THD *thd, TABLE_LIST *table_list); 01718 int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use); 01719 void unlock_table_name(THD *thd, TABLE_LIST *table_list); 01720 bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list); 01721 bool lock_table_names(THD *thd, TABLE_LIST *table_list); 01722 void unlock_table_names(THD *thd, TABLE_LIST *table_list, 01723 TABLE_LIST *last_table); 01724 01725 01726 /* old unireg functions */ 01727 01728 void unireg_init(ulong options); 01729 void unireg_end(void); 01730 bool mysql_create_frm(THD *thd, const char *file_name, 01731 const char *db, const char *table, 01732 HA_CREATE_INFO *create_info, 01733 List<create_field> &create_field, 01734 uint key_count,KEY *key_info,handler *db_type); 01735 int rea_create_table(THD *thd, const char *path, 01736 const char *db, const char *table_name, 01737 HA_CREATE_INFO *create_info, 01738 List<create_field> &create_field, 01739 uint key_count,KEY *key_info, 01740 handler *file); 01741 int format_number(uint inputflag,uint max_length,my_string pos,uint length, 01742 my_string *errpos); 01743 01744 /* table.cc */ 01745 TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key, 01746 uint key_length); 01747 void init_tmp_table_share(TABLE_SHARE *share, const char *key, uint key_length, 01748 const char *table_name, const char *path); 01749 void free_table_share(TABLE_SHARE *share); 01750 int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags); 01751 void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg); 01752 int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, 01753 uint db_stat, uint prgflag, uint ha_open_flags, 01754 TABLE *outparam, bool is_create_table); 01755 int readfrm(const char *name, const void** data, uint* length); 01756 int writefrm(const char* name, const void* data, uint len); 01757 int closefrm(TABLE *table, bool free_share); 01758 int read_string(File file, gptr *to, uint length); 01759 void free_blobs(TABLE *table); 01760 int set_zone(int nr,int min_zone,int max_zone); 01761 ulong convert_period_to_month(ulong period); 01762 ulong convert_month_to_period(ulong month); 01763 void get_date_from_daynr(long daynr,uint *year, uint *month, 01764 uint *day); 01765 my_time_t TIME_to_timestamp(THD *thd, const TIME *t, my_bool *not_exist); 01766 bool str_to_time_with_warn(const char *str,uint length,TIME *l_time); 01767 timestamp_type str_to_datetime_with_warn(const char *str, uint length, 01768 TIME *l_time, uint flags); 01769 void localtime_to_TIME(TIME *to, struct tm *from); 01770 void calc_time_from_sec(TIME *to, long seconds, long microseconds); 01771 01772 void make_truncated_value_warning(THD *thd, const char *str_val, 01773 uint str_length, timestamp_type time_type, 01774 const char *field_name); 01775 01776 bool date_add_interval(TIME *ltime, interval_type int_type, INTERVAL interval); 01777 bool calc_time_diff(TIME *l_time1, TIME *l_time2, int l_sign, 01778 longlong *seconds_out, long *microseconds_out); 01779 01780 extern LEX_STRING interval_type_to_name[]; 01781 01782 extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type, 01783 const char *format_str, 01784 uint format_length); 01785 extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd, 01786 DATE_TIME_FORMAT *format); 01787 const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format, 01788 timestamp_type type); 01789 extern bool make_date_time(DATE_TIME_FORMAT *format, TIME *l_time, 01790 timestamp_type type, String *str); 01791 void make_datetime(const DATE_TIME_FORMAT *format, const TIME *l_time, 01792 String *str); 01793 void make_date(const DATE_TIME_FORMAT *format, const TIME *l_time, 01794 String *str); 01795 void make_time(const DATE_TIME_FORMAT *format, const TIME *l_time, 01796 String *str); 01797 int my_time_compare(TIME *a, TIME *b); 01798 01799 int test_if_number(char *str,int *res,bool allow_wildcards); 01800 void change_byte(byte *,uint,char,char); 01801 void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form, 01802 SQL_SELECT *select, 01803 int use_record_cache, bool print_errors); 01804 void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, 01805 bool print_error, uint idx); 01806 void end_read_record(READ_RECORD *info); 01807 ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder, 01808 uint s_length, SQL_SELECT *select, 01809 ha_rows max_rows, bool sort_positions, 01810 ha_rows *examined_rows); 01811 void filesort_free_buffers(TABLE *table); 01812 void change_double_for_sort(double nr,byte *to); 01813 double my_double_round(double value, int dec, bool truncate); 01814 int get_quick_record(SQL_SELECT *select); 01815 01816 int calc_weekday(long daynr,bool sunday_first_day_of_week); 01817 uint calc_week(TIME *l_time, uint week_behaviour, uint *year); 01818 void find_date(char *pos,uint *vek,uint flag); 01819 TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end); 01820 TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings); 01821 ulong get_form_pos(File file, uchar *head, TYPELIB *save_names); 01822 ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames, 01823 const char *newname); 01824 ulong next_io_size(ulong pos); 01825 void append_unescaped(String *res, const char *pos, uint length); 01826 int create_frm(THD *thd, const char *name, const char *db, const char *table, 01827 uint reclength, uchar *fileinfo, 01828 HA_CREATE_INFO *create_info, uint keys); 01829 void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form); 01830 int rename_file_ext(const char * from,const char * to,const char * ext); 01831 bool check_db_name(char *db); 01832 bool check_column_name(const char *name); 01833 bool check_table_name(const char *name, uint length); 01834 char *get_field(MEM_ROOT *mem, Field *field); 01835 bool get_field(MEM_ROOT *mem, Field *field, class String *res); 01836 int wild_case_compare(CHARSET_INFO *cs, const char *str,const char *wildstr); 01837 char *fn_rext(char *name); 01838 01839 /* Conversion functions */ 01840 uint strconvert(CHARSET_INFO *from_cs, const char *from, 01841 CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors); 01842 uint filename_to_tablename(const char *from, char *to, uint to_length); 01843 uint tablename_to_filename(const char *from, char *to, uint to_length); 01844 uint build_table_filename(char *buff, size_t bufflen, const char *db, 01845 const char *table, const char *ext, uint flags); 01846 /* Flags for conversion functions. */ 01847 #define FN_FROM_IS_TMP (1 << 0) 01848 #define FN_TO_IS_TMP (1 << 1) 01849 #define FN_IS_TMP (FN_FROM_IS_TMP | FN_TO_IS_TMP) 01850 01851 /* from hostname.cc */ 01852 struct in_addr; 01853 my_string ip_to_hostname(struct in_addr *in,uint *errors); 01854 void inc_host_errors(struct in_addr *in); 01855 void reset_host_errors(struct in_addr *in); 01856 bool hostname_cache_init(); 01857 void hostname_cache_free(); 01858 void hostname_cache_refresh(void); 01859 01860 /* sql_cache.cc */ 01861 extern bool sql_cache_init(); 01862 extern void sql_cache_free(); 01863 extern int sql_cache_hit(THD *thd, char *inBuf, uint length); 01864 01865 /* item_func.cc */ 01866 Item *get_system_var(THD *thd, enum_var_type var_type, LEX_STRING name, 01867 LEX_STRING component); 01868 int get_var_with_binlog(THD *thd, enum_sql_command sql_command, 01869 LEX_STRING &name, user_var_entry **out_entry); 01870 /* log.cc */ 01871 bool flush_error_log(void); 01872 01873 /* sql_list.cc */ 01874 void free_list(I_List <i_string_pair> *list); 01875 void free_list(I_List <i_string> *list); 01876 01877 /* sql_yacc.cc */ 01878 extern int MYSQLparse(void *thd); 01879 01880 /* frm_crypt.cc */ 01881 #ifdef HAVE_CRYPTED_FRM 01882 SQL_CRYPT *get_crypt_for_frm(void); 01883 #endif 01884 01885 #include "sql_view.h" 01886 01887 /* Some inline functions for more speed */ 01888 01889 inline bool add_item_to_list(THD *thd, Item *item) 01890 { 01891 return thd->lex->current_select->add_item_to_list(thd, item); 01892 } 01893 01894 inline bool add_value_to_list(THD *thd, Item *value) 01895 { 01896 return thd->lex->value_list.push_back(value); 01897 } 01898 01899 inline bool add_order_to_list(THD *thd, Item *item, bool asc) 01900 { 01901 return thd->lex->current_select->add_order_to_list(thd, item, asc); 01902 } 01903 01904 inline bool add_group_to_list(THD *thd, Item *item, bool asc) 01905 { 01906 return thd->lex->current_select->add_group_to_list(thd, item, asc); 01907 } 01908 01909 inline void mark_as_null_row(TABLE *table) 01910 { 01911 table->null_row=1; 01912 table->status|=STATUS_NULL_ROW; 01913 bfill(table->null_flags,table->s->null_bytes,255); 01914 } 01915 01916 inline void table_case_convert(char * name, uint length) 01917 { 01918 if (lower_case_table_names) 01919 files_charset_info->cset->casedn(files_charset_info, 01920 name, length, name, length); 01921 } 01922 01923 inline const char *table_case_name(HA_CREATE_INFO *info, const char *name) 01924 { 01925 return ((lower_case_table_names == 2 && info->alias) ? info->alias : name); 01926 } 01927 01928 inline ulong sql_rnd_with_mutex() 01929 { 01930 pthread_mutex_lock(&LOCK_thread_count); 01931 ulong tmp=(ulong) (my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */ 01932 pthread_mutex_unlock(&LOCK_thread_count); 01933 return tmp; 01934 } 01935 01936 Comp_creator *comp_eq_creator(bool invert); 01937 Comp_creator *comp_ge_creator(bool invert); 01938 Comp_creator *comp_gt_creator(bool invert); 01939 Comp_creator *comp_le_creator(bool invert); 01940 Comp_creator *comp_lt_creator(bool invert); 01941 Comp_creator *comp_ne_creator(bool invert); 01942 01943 Item * all_any_subquery_creator(Item *left_expr, 01944 chooser_compare_func_creator cmp, 01945 bool all, 01946 SELECT_LEX *select_lex); 01947 01948 /* 01949 clean/setup table fields and map 01950 01951 SYNOPSYS 01952 setup_table_map() 01953 table - TABLE structure pointer (which should be setup) 01954 table_list TABLE_LIST structure pointer (owner of TABLE) 01955 tablenr - table number 01956 */ 01957 01958 inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr) 01959 { 01960 table->used_fields= 0; 01961 table->const_table= 0; 01962 table->null_row= 0; 01963 table->status= STATUS_NO_RECORD; 01964 table->keys_in_use_for_query= table->s->keys_in_use; 01965 table->maybe_null= table_list->outer_join; 01966 TABLE_LIST *embedding= table_list->embedding; 01967 while (!table->maybe_null && embedding) 01968 { 01969 table->maybe_null= embedding->outer_join; 01970 embedding= embedding->embedding; 01971 } 01972 table->tablenr= tablenr; 01973 table->map= (table_map) 1 << tablenr; 01974 table->force_index= table_list->force_index; 01975 } 01976 01977 01978 /* 01979 SYNOPSYS 01980 hexchar_to_int() 01981 convert a hex digit into number 01982 */ 01983 01984 inline int hexchar_to_int(char c) 01985 { 01986 if (c <= '9' && c >= '0') 01987 return c-'0'; 01988 c|=32; 01989 if (c <= 'f' && c >= 'a') 01990 return c-'a'+10; 01991 return -1; 01992 } 01993 01994 /* 01995 is_user_table() 01996 return true if the table was created explicitly 01997 */ 01998 01999 inline bool is_user_table(TABLE * table) 02000 { 02001 const char *name= table->s->table_name.str; 02002 return strncmp(name, tmp_file_prefix, tmp_file_prefix_length); 02003 } 02004 02005 /* 02006 Some functions that are different in the embedded library and the normal 02007 server 02008 */ 02009 02010 #ifndef EMBEDDED_LIBRARY 02011 extern "C" void unireg_abort(int exit_code); 02012 void kill_delayed_threads(void); 02013 bool check_stack_overrun(THD *thd, long margin, char *dummy); 02014 #else 02015 #define unireg_abort(exit_code) DBUG_RETURN(exit_code) 02016 inline void kill_delayed_threads(void) {} 02017 #define check_stack_overrun(A, B, C) 0 02018 #endif 02019 02020 /* Used by handlers to store things in schema tables */ 02021 bool schema_table_store_record(THD *thd, TABLE *table); 02022 02023 #endif /* MYSQL_SERVER */ 02024 #endif /* MYSQL_CLIENT */
1.4.7

