24
20
Mostly this file is used in the server. But a little part of it is used in
25
21
mysqlbinlog too (definition of SELECT_DISTINCT and others).
27
@TODO Name this file better. "priv" could mean private, privileged, privileges.
30
#ifndef DRIZZLE_SERVER_SERVER_INCLUDES_H
31
#define DRIZZLE_SERVER_SERVER_INCLUDES_H
33
/* Some forward declarations just for the server */
22
The consequence is that 90% of the file is wrapped in \#ifndef MYSQL_CLIENT,
23
except the part which must be in the server and in the client.
31
#include <my_global.h>
32
#include <drizzle_version.h>
39
#include <my_base.h> /* Needed by field.h */
41
#include "sql_bitmap.h"
42
#include "sql_array.h"
43
#include "sql_plugin.h"
44
#include "scheduler.h"
47
#define _DTRACE_VERSION 1
56
QT_ORDINARY -- ordinary SQL query.
57
QT_IS -- SQL query to be shown in INFORMATION_SCHEMA (in utf8 and without
58
character set introducers).
66
/* TODO convert all these three maps to Bitmap classes */
67
typedef ulonglong table_map; /* Used for table bits in join */
69
typedef Bitmap<64> key_map; /* Used for finding keys */
71
typedef Bitmap<((MAX_INDEXES+7)/8*8)> key_map; /* Used for finding keys */
73
typedef ulong nesting_map; /* Used for flags of nesting constructs */
75
Used to identify NESTED_JOIN structures within a join (applicable only to
76
structures that have not been simplified away and embed more the one
79
typedef ulonglong nested_join_map;
82
typedef ulonglong query_id_t;
83
extern query_id_t global_query_id;
85
/* increment query_id and return it. */
86
inline query_id_t next_query_id() { return global_query_id++; }
88
/* useful constants */
89
extern const key_map key_map_empty;
90
extern key_map key_map_full; /* Should be threaded as const */
91
extern const char *primary_key_name;
93
#include "drizzle_com.h"
97
void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size);
98
void *sql_alloc(size_t);
99
void *sql_calloc(size_t);
100
char *sql_strdup(const char *str);
101
char *sql_strmake(const char *str, size_t len);
102
void *sql_memdup(const void * ptr, size_t size);
103
void sql_element_free(void *ptr);
104
char *sql_strmake_with_convert(const char *str, size_t arg_length,
105
CHARSET_INFO *from_cs,
106
size_t max_res_length,
107
CHARSET_INFO *to_cs, size_t *result_length);
108
uint kill_one_thread(THD *thd, ulong id, bool only_kill_query);
109
void sql_kill(THD *thd, ulong id, bool only_kill_query);
110
bool net_request_file(NET* net, const char* fname);
111
char* query_table_status(THD *thd,const char *db,const char *table_name);
113
#define x_free(A) { my_free((uchar*) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); }
114
#define safeFree(x) { if(x) { my_free((uchar*) x,MYF(0)); x = NULL; } }
115
#define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1))
116
#define all_bits_set(A,B) ((A) & (B) != (B))
119
Generates a warning that a feature is deprecated. After a specified version
120
asserts that the feature is removed.
124
WARN_DEPRECATED(thd, 6,2, "BAD", "'GOOD'");
126
Will result in a warning
128
"The syntax 'BAD' is deprecated and will be removed in MySQL 6.2. Please
131
Note, that in macro arguments BAD is not quoted, while 'GOOD' is.
132
Note, that the version is TWO numbers, separated with a comma
133
(two macro arguments, that is)
135
#define WARN_DEPRECATED(Thd,VerHi,VerLo,Old,New) \
137
compile_time_assert(MYSQL_VERSION_ID < VerHi * 10000 + VerLo * 100); \
139
push_warning_printf((Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \
140
ER_WARN_DEPRECATED_SYNTAX, \
141
ER(ER_WARN_DEPRECATED_SYNTAX_WITH_VER), \
142
(Old), #VerHi "." #VerLo, (New)); \
144
sql_print_warning("The syntax '%s' is deprecated and will be removed " \
145
"in MySQL %s. Please use %s instead.", \
146
(Old), #VerHi "." #VerLo, (New)); \
149
extern CHARSET_INFO *system_charset_info, *files_charset_info ;
150
extern CHARSET_INFO *national_charset_info, *table_alias_charset;
155
DERIVATION_IGNORABLE= 5,
156
DERIVATION_COERCIBLE= 4,
157
DERIVATION_SYSCONST= 3,
158
DERIVATION_IMPLICIT= 2,
160
DERIVATION_EXPLICIT= 0
164
typedef struct my_locale_st
168
const char *description;
170
TYPELIB *month_names;
171
TYPELIB *ab_month_names;
173
TYPELIB *ab_day_names;
175
my_locale_st(uint number_par,
176
const char *name_par, const char *descr_par, bool is_ascii_par,
177
TYPELIB *month_names_par, TYPELIB *ab_month_names_par,
178
TYPELIB *day_names_par, TYPELIB *ab_day_names_par) :
180
name(name_par), description(descr_par), is_ascii(is_ascii_par),
181
month_names(month_names_par), ab_month_names(ab_month_names_par),
182
day_names(day_names_par), ab_day_names(ab_day_names_par)
187
extern MY_LOCALE my_locale_en_US;
188
extern MY_LOCALE *my_locales[];
189
extern MY_LOCALE *my_default_lc_time_names;
191
MY_LOCALE *my_locale_by_name(const char *name);
192
MY_LOCALE *my_locale_by_number(uint number);
194
/*************************************************************************/
197
Object_creation_ctx -- interface for creation context of database objects
198
(views, stored routines, events, triggers). Creation context -- is a set
199
of attributes, that should be fixed at the creation time and then be used
200
each time the object is parsed or executed.
203
class Object_creation_ctx
206
Object_creation_ctx *set_n_backup(THD *thd);
208
void restore_env(THD *thd, Object_creation_ctx *backup_ctx);
211
Object_creation_ctx() {}
212
virtual Object_creation_ctx *create_backup_ctx(THD *thd) const = 0;
214
virtual void change_env(THD *thd) const = 0;
217
virtual ~Object_creation_ctx()
221
/*************************************************************************/
224
Default_object_creation_ctx -- default implementation of
228
class Default_object_creation_ctx : public Object_creation_ctx
231
CHARSET_INFO *get_client_cs()
236
CHARSET_INFO *get_connection_cl()
238
return m_connection_cl;
242
Default_object_creation_ctx(THD *thd);
244
Default_object_creation_ctx(CHARSET_INFO *client_cs,
245
CHARSET_INFO *connection_cl);
248
virtual Object_creation_ctx *create_backup_ctx(THD *thd) const;
250
virtual void change_env(THD *thd) const;
254
client_cs stores the value of character_set_client session variable.
255
The only character set attribute is used.
257
Client character set is included into query context, because we save
258
query in the original character set, which is client character set. So,
259
in order to parse the query properly we have to switch client character
262
CHARSET_INFO *m_client_cs;
265
connection_cl stores the value of collation_connection session
266
variable. Both character set and collation attributes are used.
268
Connection collation is included into query context, becase it defines
269
the character set and collation of text literals in internal
270
representation of query (item-objects).
272
CHARSET_INFO *m_connection_cl;
277
Opening modes for open_temporary_table and open_table_from_share
287
/***************************************************************************
288
Configuration parameters
289
****************************************************************************/
291
#define ACL_CACHE_SIZE 256
292
#define MAX_PASSWORD_LENGTH 32
293
#define HOST_CACHE_SIZE 128
294
#define MAX_ACCEPT_RETRY 10 // Test accept this many times
295
#define MAX_FIELDS_BEFORE_HASH 32
296
#define USER_VARS_HASH_SIZE 16
297
#define TABLE_OPEN_CACHE_MIN 64
298
#define TABLE_OPEN_CACHE_DEFAULT 64
301
Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
302
Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86. (Added
303
100 bytes as reasonable buffer against growth and other environments'
306
Feel free to raise this by the smallest amount you can to get the
307
"execution_constants" test to pass.
309
#define STACK_MIN_SIZE 12000 ///< Abort if less stack during eval.
311
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
312
#define STACK_BUFF_ALLOC 352 ///< For stack overrun checks
313
#ifndef MYSQLD_NET_RETRY_COUNT
314
#define MYSQLD_NET_RETRY_COUNT 10 ///< Abort read after this many int.
316
#define TEMP_POOL_SIZE 128
318
#define QUERY_ALLOC_BLOCK_SIZE 8192
319
#define QUERY_ALLOC_PREALLOC_SIZE 8192
320
#define TRANS_ALLOC_BLOCK_SIZE 4096
321
#define TRANS_ALLOC_PREALLOC_SIZE 4096
322
#define RANGE_ALLOC_BLOCK_SIZE 4096
323
#define ACL_ALLOC_BLOCK_SIZE 1024
324
#define UDF_ALLOC_BLOCK_SIZE 1024
325
#define TABLE_ALLOC_BLOCK_SIZE 1024
326
#define BDB_LOG_ALLOC_BLOCK_SIZE 1024
327
#define WARN_ALLOC_BLOCK_SIZE 2048
328
#define WARN_ALLOC_PREALLOC_SIZE 1024
329
#define PROFILE_ALLOC_BLOCK_SIZE 2048
330
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
333
The following parameters is to decide when to use an extra cache to
334
optimise seeks when reading a big table in sorted order
336
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
337
#define MIN_ROWS_TO_USE_TABLE_CACHE 100
338
#define MIN_ROWS_TO_USE_BULK_INSERT 100
341
The following is used to decide if MySQL should use table scanning
342
instead of reading with keys. The number says how many evaluation of the
343
WHERE clause is comparable to reading one extra row from a table.
345
#define TIME_FOR_COMPARE 5 // 5 compares == one read
348
Number of comparisons of table rowids equivalent to reading one row from a
351
#define TIME_FOR_COMPARE_ROWID (TIME_FOR_COMPARE*2)
354
For sequential disk seeks the cost formula is:
355
DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
357
The cost of average seek
358
DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
360
#define DISK_SEEK_BASE_COST ((double)0.9)
362
#define BLOCKS_IN_AVG_SEEK 128
364
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
368
Number of rows in a reference table when refereed through a not unique key.
369
This value is only used when we don't know anything about the key
372
#define MATCHING_ROWS_IN_OTHER_TABLE 10
374
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
375
#define KEY_DEFAULT_PACK_LENGTH 8
377
/** Characters shown for the command in 'show processlist'. */
378
#define PROCESS_LIST_WIDTH 100
379
/* Characters shown for the command in 'information_schema.processlist' */
380
#define PROCESS_LIST_INFO_WIDTH 65535
382
#define PRECISION_FOR_DOUBLE 53
383
#define PRECISION_FOR_FLOAT 24
386
Default time to wait before aborting a new client connection
387
that does not respond to "initial server greeting" timely
389
#define CONNECT_TIMEOUT 10
391
/* The following can also be changed from the command line */
392
#define DEFAULT_CONCURRENCY 10
393
#define FLUSH_TIME 0 /**< Don't flush tables */
394
#define MAX_CONNECT_ERRORS 10 ///< errors before disabling host
396
#define INTERRUPT_PRIOR 10
397
#define CONNECT_PRIOR 9
399
#define QUERY_PRIOR 6
401
/* Bits from testflag */
402
#define TEST_PRINT_CACHED_TABLES 1
403
#define TEST_NO_KEY_GROUP 2
404
#define TEST_MIT_THREAD 4
405
#define TEST_BLOCKING 8
406
#define TEST_KEEP_TMP_TABLES 16
407
#define TEST_READCHECK 64 /**< Force use of readcheck */
408
#define TEST_NO_EXTRA 128
409
#define TEST_CORE_ON_SIGNAL 256 /**< Give core if signal */
410
#define TEST_NO_STACKTRACE 512
411
#define TEST_SIGINT 1024 /**< Allow sigint on threads */
412
#define TEST_SYNCHRONIZATION 2048 /**< get server to do sleep in
417
This is included in the server and in the client.
418
Options for select set by the yacc parser (stored in lex->options).
421
log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
422
options list are written into binlog. These options can NOT change their
423
values, or it will break replication between version.
425
context is encoded as following:
426
SELECT - SELECT_LEX_NODE::options
428
intern - neither. used only as
429
func(..., select_node->options | thd->options | OPTION_XXX, ...)
431
TODO: separate three contexts above, move them to separate bitfields.
434
#define SELECT_DISTINCT (1ULL << 0) // SELECT, user
435
#define SELECT_STRAIGHT_JOIN (1ULL << 1) // SELECT, user
436
#define SELECT_DESCRIBE (1ULL << 2) // SELECT, user
437
#define SELECT_SMALL_RESULT (1ULL << 3) // SELECT, user
438
#define SELECT_BIG_RESULT (1ULL << 4) // SELECT, user
439
#define OPTION_FOUND_ROWS (1ULL << 5) // SELECT, user
440
#define SELECT_NO_JOIN_CACHE (1ULL << 7) // intern
441
#define OPTION_BIG_TABLES (1ULL << 8) // THD, user
442
#define OPTION_BIG_SELECTS (1ULL << 9) // THD, user
443
#define OPTION_LOG_OFF (1ULL << 10) // THD, user
444
#define OPTION_QUOTE_SHOW_CREATE (1ULL << 11) // THD, user, unused
445
#define TMP_TABLE_ALL_COLUMNS (1ULL << 12) // SELECT, intern
446
#define OPTION_WARNINGS (1ULL << 13) // THD, user
447
#define OPTION_AUTO_IS_NULL (1ULL << 14) // THD, user, binlog
448
#define OPTION_FOUND_COMMENT (1ULL << 15) // SELECT, intern, parser
449
#define OPTION_SAFE_UPDATES (1ULL << 16) // THD, user
450
#define OPTION_BUFFER_RESULT (1ULL << 17) // SELECT, user
451
#define OPTION_BIN_LOG (1ULL << 18) // THD, user
452
#define OPTION_NOT_AUTOCOMMIT (1ULL << 19) // THD, user
453
#define OPTION_BEGIN (1ULL << 20) // THD, intern
454
#define OPTION_TABLE_LOCK (1ULL << 21) // THD, intern
455
#define OPTION_QUICK (1ULL << 22) // SELECT (for DELETE)
456
#define OPTION_KEEP_LOG (1ULL << 23) // THD, user
458
/* The following is used to detect a conflict with DISTINCT */
459
#define SELECT_ALL (1ULL << 24) // SELECT, user, parser
461
/** The following can be set when importing tables in a 'wrong order'
462
to suppress foreign key checks */
463
#define OPTION_NO_FOREIGN_KEY_CHECKS (1ULL << 26) // THD, user, binlog
464
/** The following speeds up inserts to InnoDB tables by suppressing unique
465
key checks in some cases */
466
#define OPTION_RELAXED_UNIQUE_CHECKS (1ULL << 27) // THD, user, binlog
467
#define SELECT_NO_UNLOCK (1ULL << 28) // SELECT, intern
468
#define OPTION_SCHEMA_TABLE (1ULL << 29) // SELECT, intern
469
/** Flag set if setup_tables already done */
470
#define OPTION_SETUP_TABLES_DONE (1ULL << 30) // intern
471
/** If not set then the thread will ignore all warnings with level notes. */
472
#define OPTION_SQL_NOTES (1ULL << 31) // THD, user
474
Force the used temporary table to be a MyISAM table (because we will use
475
fulltext functions when reading from it.
477
#define TMP_TABLE_FORCE_MYISAM (1ULL << 32)
478
#define OPTION_PROFILING (1ULL << 33)
481
Dont report errors for individual rows,
482
But just report error on commit (or read ofcourse)
484
#define OPTION_ALLOW_BATCH (1ULL << 33) // THD, intern (slave)
487
Maximum length of time zone name that we support
488
(Time zone name is char(64) in db). mysqlbinlog needs it.
490
#define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1)
492
/* The rest of the file is included in the server only */
495
/* Bits for different SQL modes modes (including ANSI mode) */
496
#define MODE_REAL_AS_FLOAT 1
497
#define MODE_PIPES_AS_CONCAT 2
498
#define MODE_ANSI_QUOTES 4
499
#define MODE_IGNORE_SPACE 8
500
#define MODE_NOT_USED 16
501
#define MODE_ONLY_FULL_GROUP_BY 32
502
#define MODE_NO_UNSIGNED_SUBTRACTION 64
503
#define MODE_NO_DIR_IN_CREATE 128
504
#define MODE_POSTGRESQL 256
505
#define MODE_ORACLE 512
506
#define MODE_MSSQL 1024
507
#define MODE_DB2 2048
508
#define MODE_MAXDB 4096
509
#define MODE_NO_KEY_OPTIONS 8192
510
#define MODE_NO_TABLE_OPTIONS 16384
511
#define MODE_NO_FIELD_OPTIONS 32768
512
#define MODE_MYSQL323 65536L
513
#define MODE_MYSQL40 (MODE_MYSQL323*2)
514
#define MODE_ANSI (MODE_MYSQL40*2)
515
#define MODE_NO_AUTO_VALUE_ON_ZERO (MODE_ANSI*2)
516
#define MODE_NO_BACKSLASH_ESCAPES (MODE_NO_AUTO_VALUE_ON_ZERO*2)
517
#define MODE_STRICT_TRANS_TABLES (MODE_NO_BACKSLASH_ESCAPES*2)
518
#define MODE_STRICT_ALL_TABLES (MODE_STRICT_TRANS_TABLES*2)
519
#define MODE_NO_ZERO_IN_DATE (MODE_STRICT_ALL_TABLES*2)
520
#define MODE_NO_ZERO_DATE (MODE_NO_ZERO_IN_DATE*2)
521
#define MODE_INVALID_DATES (MODE_NO_ZERO_DATE*2)
522
#define MODE_ERROR_FOR_DIVISION_BY_ZERO (MODE_INVALID_DATES*2)
523
#define MODE_TRADITIONAL (MODE_ERROR_FOR_DIVISION_BY_ZERO*2)
524
#define MODE_NO_AUTO_CREATE_USER (MODE_TRADITIONAL*2)
525
#define MODE_HIGH_NOT_PRECEDENCE (MODE_NO_AUTO_CREATE_USER*2)
526
#define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2)
527
#define MODE_PAD_CHAR_TO_FULL_LENGTH (1ULL << 31)
530
/* @@optimizer_switch flags */
531
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
532
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
536
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
537
use strictly more than 64 bits by adding one more define above, you should
538
contact the replication team because the replication code should then be
539
updated (to store more bytes on disk).
541
NOTE: When adding new SQL_MODE types, make sure to also add them to
542
the scripts used for creating the MySQL system tables
543
in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
547
#define RAID_BLOCK_SIZE 1024
549
#define MY_CHARSET_BIN_MB_MAXLEN 1
552
#define UNCACHEABLE_DEPENDENT 1
553
#define UNCACHEABLE_RAND 2
554
#define UNCACHEABLE_SIDEEFFECT 4
555
/// forcing to save JOIN for explain
556
#define UNCACHEABLE_EXPLAIN 8
557
/** Don't evaluate subqueries in prepare even if they're not correlated */
558
#define UNCACHEABLE_PREPARE 16
559
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
560
#define UNCACHEABLE_UNITED 32
562
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
563
#define UNDEF_POS (-1)
566
Sync points allow us to force the server to reach a certain line of code
567
and block there until the client tells the server it is ok to go on.
568
The client tells the server to block with SELECT GET_LOCK()
569
and unblocks it with SELECT RELEASE_LOCK(). Used for debugging difficult
572
#define DBUG_SYNC_POINT(lock_name,lock_timeout) \
573
debug_sync_point(lock_name,lock_timeout)
574
void debug_sync_point(const char* lock_name, uint lock_timeout);
576
#define DBUG_SYNC_POINT(lock_name,lock_timeout)
577
#endif /* EXTRA_DEBUG */
579
/* BINLOG_DUMP options */
581
#define BINLOG_DUMP_NON_BLOCK 1
583
/* sql_show.cc:show_log_files() */
584
#define SHOW_LOG_STATUS_FREE "FREE"
585
#define SHOW_LOG_STATUS_INUSE "IN USE"
589
void view_store_options(THD *thd, TABLE_LIST *table, String *buff);
591
/* Options to add_table_to_list() */
592
#define TL_OPTION_UPDATING 1
593
#define TL_OPTION_FORCE_INDEX 2
594
#define TL_OPTION_IGNORE_LEAVES 4
595
#define TL_OPTION_ALIAS 8
597
/* Some portable defines */
599
#define portable_sizeof_char_ptr 8
601
#define tmp_file_prefix "#sql" /**< Prefix for tmp tables */
602
#define tmp_file_prefix_length 4
604
/* Flags for calc_week() function. */
605
#define WEEK_MONDAY_FIRST 1
607
#define WEEK_FIRST_WEEKDAY 4
609
#define STRING_BUFFER_USUAL_SIZE 80
612
Some defines for exit codes for ::is_equal class functions.
614
#define IS_EQUAL_NO 0
615
#define IS_EQUAL_YES 1
616
#define IS_EQUAL_PACK_LENGTH 2
618
enum enum_parsing_place
629
#define thd_proc_info(thd, msg) set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
632
enum enum_check_fields
636
CHECK_FIELD_ERROR_FOR_NULL
640
/** Struct to handle simple linked lists. */
641
typedef struct st_sql_list {
646
st_sql_list() {} /* Remove gcc warning */
653
inline void link_in_list(uchar *element,uchar **next_ptr)
660
inline void save_and_clear(struct st_sql_list *save)
665
inline void push_front(struct st_sql_list *save)
667
*save->next= first; /* link current list last */
669
elements+= save->elements;
671
inline void push_back(struct st_sql_list *save)
677
elements+= save->elements;
683
extern pthread_key(THD*, THR_THD);
684
inline THD *_current_thd(void)
686
return (THD *)pthread_getspecific(THR_THD);
688
#define current_thd _current_thd()
691
The meat of thd_proc_info(THD*, char*), a macro that packs the last
692
three calling-info parameters.
695
const char *set_thd_proc_info(THD *thd, const char *info,
696
const char *calling_func,
697
const char *calling_file,
698
const unsigned int calling_line);
703
extern ulong server_id;
706
typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
708
ulonglong *engine_data);
709
#include "sql_string.h"
710
#include "sql_list.h"
712
#include "my_decimal.h"
715
#include "sql_error.h"
716
#include "field.h" /* Field definitions */
717
#include "protocol.h"
720
class user_var_entry;
721
class Security_context;
724
OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL
35
728
class Comp_creator;
36
729
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
39
* Contains all headers, definitions, and declarations common to
40
* the server and the plugin infrastructure, and not the client
42
#include <drizzled/common_includes.h>
43
/* Range optimization API/library */
44
#include <drizzled/opt_range.h>
45
/* Simple error injection (crash) module */
46
#include <drizzled/error_injection.h>
47
/* API for connecting, logging in to a drizzled server */
48
#include <drizzled/connect.h>
49
/* Routines for dropping, repairing, checking schema tables */
50
#include <drizzled/sql_table.h>
732
extern my_decimal decimal_zero;
735
void free_items(Item *item);
736
void cleanup_items(Item *item);
738
void close_thread_tables(THD *thd);
740
bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
741
bool multi_delete_precheck(THD *thd, TABLE_LIST *tables);
742
int mysql_multi_update_prepare(THD *thd);
743
int mysql_multi_delete_prepare(THD *thd);
744
bool mysql_insert_select_prepare(THD *thd);
745
bool update_precheck(THD *thd, TABLE_LIST *tables);
746
bool delete_precheck(THD *thd, TABLE_LIST *tables);
747
bool insert_precheck(THD *thd, TABLE_LIST *tables);
748
bool create_table_precheck(THD *thd, TABLE_LIST *tables,
749
TABLE_LIST *create_table);
750
int append_query_string(CHARSET_INFO *csinfo,
751
String const *from, String *to);
753
bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
754
uint max_byte_length);
755
bool check_string_char_length(LEX_STRING *str, const char *err_msg,
756
uint max_char_length, CHARSET_INFO *cs,
758
bool check_identifier_name(LEX_STRING *str, uint max_char_length,
759
uint err_code, const char *param_for_err_msg);
760
inline bool check_identifier_name(LEX_STRING *str, uint err_code)
762
return check_identifier_name(str, NAME_CHAR_LEN, err_code, "");
764
inline bool check_identifier_name(LEX_STRING *str)
766
return check_identifier_name(str, NAME_CHAR_LEN, 0, "");
769
bool test_if_data_home_dir(const char *dir);
771
bool parse_sql(THD *thd,
772
class Lex_input_stream *lip,
773
class Object_creation_ctx *creation_ctx);
775
enum enum_mysql_completiontype {
776
ROLLBACK_RELEASE=-2, ROLLBACK=1, ROLLBACK_AND_CHAIN=7,
777
COMMIT_RELEASE=-1, COMMIT=0, COMMIT_AND_CHAIN=6
780
bool begin_trans(THD *thd);
781
bool end_active_trans(THD *thd);
782
int end_trans(THD *thd, enum enum_mysql_completiontype completion);
784
Item *negate_expression(THD *thd, Item *expr);
787
int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
788
void sql_print_error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
789
void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
790
void sql_print_information(const char *format, ...)
791
ATTRIBUTE_FORMAT(printf, 1, 2);
792
typedef void (*sql_print_message_func)(const char *format, ...)
793
ATTRIBUTE_FORMAT(printf, 1, 2);
794
extern sql_print_message_func sql_print_message_handlers[];
796
int error_log_print(enum loglevel level, const char *format,
799
bool slow_log_print(THD *thd, const char *query, uint query_length,
800
ulonglong current_utime);
802
bool general_log_print(THD *thd, enum enum_server_command command,
803
const char *format,...);
805
bool general_log_write(THD *thd, enum enum_server_command command,
806
const char *query, uint query_length);
808
#include "sql_class.h"
809
#include "slave.h" // for tables_ok(), rpl_filter
812
#include "opt_range.h"
816
Error injector Macros to enable easy testing of recovery after failures
817
in various error cases.
819
#ifndef ERROR_INJECT_SUPPORT
821
#define ERROR_INJECT(x) 0
822
#define ERROR_INJECT_ACTION(x,action) 0
823
#define ERROR_INJECT_CRASH(x) 0
824
#define ERROR_INJECT_VALUE(x) 0
825
#define ERROR_INJECT_VALUE_ACTION(x,action) 0
826
#define ERROR_INJECT_VALUE_CRASH(x) 0
827
#define SET_ERROR_INJECT_VALUE(x)
831
inline bool check_and_unset_keyword(const char *dbug_str)
833
const char *extra_str= "-d,";
835
if (_db_strict_keyword_ (dbug_str))
837
strxmov(total_str, extra_str, dbug_str, NullS);
845
check_and_unset_inject_value(int value)
847
THD *thd= current_thd;
848
if (thd->error_inject_value == (uint)value)
850
thd->error_inject_value= 0;
859
These macros are used to insert macros from the application code.
860
The event that activates those error injections can be activated
862
SET SESSION dbug=+d,code;
864
After the error has been injected, the macros will automatically
865
remove the debug code, thus similar to using:
866
SET SESSION dbug=-d,code
869
ERROR_INJECT_CRASH will inject a crash of the MySQL Server if code
870
is set when macro is called. ERROR_INJECT_CRASH can be used in
871
if-statements, it will always return false unless of course it
872
crashes in which case it doesn't return at all.
874
ERROR_INJECT_ACTION will inject the action specified in the action
875
parameter of the macro, before performing the action the code will
876
be removed such that no more events occur. ERROR_INJECT_ACTION
877
can also be used in if-statements and always returns FALSE.
878
ERROR_INJECT can be used in a normal if-statement, where the action
879
part is performed in the if-block. The macro returns TRUE if the
880
error was activated and otherwise returns FALSE. If activated the
883
Sometimes it is necessary to perform error inject actions as a serie
884
of events. In this case one can use one variable on the THD object.
885
Thus one sets this value by using e.g. SET_ERROR_INJECT_VALUE(100).
886
Then one can later test for it by using ERROR_INJECT_CRASH_VALUE,
887
ERROR_INJECT_ACTION_VALUE and ERROR_INJECT_VALUE. This have the same
888
behaviour as the above described macros except that they use the
889
error inject value instead of a code used by DBUG macros.
891
#define SET_ERROR_INJECT_VALUE(x) \
892
current_thd->error_inject_value= (x)
893
#define ERROR_INJECT_CRASH(code) \
894
DBUG_EVALUATE_IF(code, (abort(), 0), 0)
895
#define ERROR_INJECT_ACTION(code, action) \
896
(check_and_unset_keyword(code) ? ((action), 0) : 0)
897
#define ERROR_INJECT(code) \
898
check_and_unset_keyword(code)
899
#define ERROR_INJECT_VALUE(value) \
900
check_and_unset_inject_value(value)
901
#define ERROR_INJECT_VALUE_ACTION(value,action) \
902
(check_and_unset_inject_value(value) ? (action) : 0)
903
#define ERROR_INJECT_VALUE_CRASH(value) \
904
ERROR_INJECT_VALUE_ACTION(value, (abort(), 0))
908
void write_bin_log(THD *thd, bool clear_error,
909
char const *query, ulong query_length);
912
int check_user(THD *thd, enum enum_server_command command,
913
const char *passwd, uint passwd_len, const char *db,
915
pthread_handler_t handle_one_connection(void *arg);
916
bool init_new_connection_handler_thread();
917
void reset_mqh(LEX_USER *lu, bool get_them);
918
bool check_mqh(THD *thd, uint check_command);
919
void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
920
void decrease_user_connections(USER_CONN *uc);
921
void thd_init_client_charset(THD *thd, uint cs_number);
922
bool setup_connection_thread_globals(THD *thd);
923
bool login_connection(THD *thd);
924
void prepare_new_connection_state(THD* thd);
925
void end_connection(THD *thd);
53
928
int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
54
929
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
55
930
bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
931
bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db);
932
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
933
void mysql_client_binlog_statement(THD *thd);
934
bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
935
my_bool drop_temporary);
936
int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
937
bool drop_temporary, bool drop_view, bool log_query);
938
bool quick_rm_table(handlerton *base,const char *db,
939
const char *table_name, uint flags);
940
void close_cached_table(THD *thd, TABLE *table);
941
bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent);
942
bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
943
char *new_table_name, char *new_table_alias,
56
946
bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
57
947
bool force_switch);
58
949
bool mysql_opt_change_db(THD *thd,
59
950
const LEX_STRING *new_db_name,
60
951
LEX_STRING *saved_db_name,
61
952
bool force_switch,
62
953
bool *cur_db_changed);
65
void write_bin_log(THD *thd, bool clear_error,
66
char const *query, ulong query_length);
67
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, uint16_t flags);
68
void mysql_client_binlog_statement(THD *thd);
71
bool mysql_rename_tables(THD *thd, TableList *table_list, bool silent);
72
bool do_rename(THD *thd, TableList *ren_table, char *new_db,
73
char *new_table_name, char *new_table_alias,
77
void mysql_parse(THD *thd, const char *inBuf, uint32_t length,
955
void mysql_parse(THD *thd, const char *inBuf, uint length,
78
956
const char ** semicolon);
80
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint32_t length);
958
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
83
959
bool is_update_query(enum enum_sql_command command);
85
bool alloc_query(THD *thd, const char *packet, uint32_t packet_length);
960
bool alloc_query(THD *thd, const char *packet, uint packet_length);
961
void mysql_init_select(LEX *lex);
87
962
void mysql_reset_thd_for_next_command(THD *thd);
963
bool mysql_new_select(LEX *lex, bool move_down);
89
964
void create_select_for_variable(const char *var_name);
91
965
void mysql_init_multi_delete(LEX *lex);
93
966
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
967
void init_max_user_conn(void);
95
968
void init_update_queries(void);
969
void free_max_user_conn(void);
970
pthread_handler_t handle_bootstrap(void *arg);
971
int mysql_execute_command(THD *thd);
97
972
bool do_command(THD *thd);
99
973
bool dispatch_command(enum enum_server_command command, THD *thd,
100
char* packet, uint32_t packet_length);
974
char* packet, uint packet_length);
102
975
void log_slow_statement(THD *thd);
976
bool check_dup(const char *db, const char *name, TABLE_LIST *tables);
977
bool compare_record(TABLE *table);
104
978
bool append_file_to_dir(THD *thd, const char **filename_ptr,
105
979
const char *table_name);
107
bool reload_cache(THD *thd, ulong options, TableList *tables, bool *write_to_binlog);
109
bool check_simple_select();
111
void mysql_init_select(LEX *lex);
112
bool mysql_new_select(LEX *lex, bool move_down);
980
void wait_while_table_is_used(THD *thd, TABLE *table,
981
enum ha_extra_function function);
982
bool table_cache_init(void);
115
983
void table_cache_free(void);
116
bool table_cache_init(void);
117
984
bool table_def_init(void);
118
985
void table_def_free(void);
119
986
void assign_new_table_id(TABLE_SHARE *share);
120
uint32_t cached_open_tables(void);
121
uint32_t cached_table_definitions(void);
987
uint cached_open_tables(void);
988
uint cached_table_definitions(void);
124
989
void kill_mysql(void);
125
void close_connection(THD *thd, uint32_t errcode, bool lock);
128
Table *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
990
void close_connection(THD *thd, uint errcode, bool lock);
991
bool reload_cache(THD *thd, ulong options, TABLE_LIST *tables, bool *write_to_binlog);
992
bool check_table_access(THD *thd, ulong want_access, TABLE_LIST *tables,
994
bool any_combination_of_privileges_will_do,
997
#endif /* MYSQL_SERVER */
998
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
999
bool check_global_access(THD *thd, ulong want_access);
1000
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1004
General routine to change field->ptr of a NULL-terminated array of Field
1005
objects. Useful when needed to call val_int, val_str or similar and the
1006
field data is not in table->record[0] but in some other structure.
1007
set_key_field_ptr changes all fields of an index using a key_info object.
1008
All methods presume that there is at least one field to change.
1011
void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf);
1012
void set_key_field_ptr(KEY *key_info, const uchar *new_buf,
1013
const uchar *old_buf);
1015
bool mysql_checksum_table(THD* thd, TABLE_LIST* table_list,
1016
HA_CHECK_OPT* check_opt);
1017
bool mysql_check_table(THD* thd, TABLE_LIST* table_list,
1018
HA_CHECK_OPT* check_opt);
1019
bool mysql_repair_table(THD* thd, TABLE_LIST* table_list,
1020
HA_CHECK_OPT* check_opt);
1021
bool mysql_analyze_table(THD* thd, TABLE_LIST* table_list,
1022
HA_CHECK_OPT* check_opt);
1023
bool mysql_optimize_table(THD* thd, TABLE_LIST* table_list,
1024
HA_CHECK_OPT* check_opt);
1025
bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list,
1026
LEX_STRING *key_cache_name);
1027
bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list);
1028
int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
1029
KEY_CACHE *dst_cache);
1030
TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
131
1032
bool mysql_xa_recover(THD *thd);
133
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
1034
bool check_simple_select();
1036
SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length,
134
1037
SORT_FIELD *sortorder);
135
int setup_order(THD *thd, Item **ref_pointer_array, TableList *tables,
136
List<Item> &fields, List <Item> &all_fields, order_st *order);
137
int setup_group(THD *thd, Item **ref_pointer_array, TableList *tables,
138
List<Item> &fields, List<Item> &all_fields, order_st *order,
1038
int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
1039
List<Item> &fields, List <Item> &all_fields, ORDER *order);
1040
int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
1041
List<Item> &fields, List<Item> &all_fields, ORDER *order,
139
1042
bool *hidden_group_fields);
140
1043
bool fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
141
1044
Item **ref_pointer_array);
157
1060
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
158
1061
bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd,
161
bool mysql_derived_prepare(THD *thd, LEX *lex, TableList *t);
162
bool mysql_derived_filling(THD *thd, LEX *lex, TableList *t);
163
Field *create_tmp_field(THD *thd, Table *table,Item *item, Item::Type type,
1063
TABLE_LIST *table));
1064
bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t);
1065
bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t);
1066
Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
164
1067
Item ***copy_func, Field **from_field,
165
1068
Field **def_field,
166
1069
bool group, bool modify_item,
167
1070
bool table_cant_handle_bit_fields,
168
1071
bool make_copy_field,
169
uint32_t convert_blob_length);
1072
uint convert_blob_length);
170
1073
void sp_prepare_create_field(THD *thd, Create_field *sql_field);
171
1074
int prepare_create_field(Create_field *sql_field,
172
uint32_t *blob_columns,
173
1076
int *timestamps, int *timestamps_with_niladic,
174
int64_t table_flags);
1077
longlong table_flags);
175
1078
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
176
1079
HA_CREATE_INFO *create_info,
177
1080
Alter_info *alter_info,
178
bool tmp_table, uint32_t select_field_count);
1081
bool tmp_table, uint select_field_count);
179
1082
bool mysql_create_table_no_lock(THD *thd, const char *db,
180
1083
const char *table_name,
181
1084
HA_CREATE_INFO *create_info,
182
1085
Alter_info *alter_info,
183
bool tmp_table, uint32_t select_field_count,
184
bool lock_open_lock);
1086
bool tmp_table, uint select_field_count);
186
1088
bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
187
1089
HA_CREATE_INFO *create_info,
188
TableList *table_list,
1090
TABLE_LIST *table_list,
189
1091
Alter_info *alter_info,
190
uint32_t order_num, order_st *order, bool ignore);
191
bool mysql_recreate_table(THD *thd, TableList *table_list);
192
bool mysql_create_like_table(THD *thd, TableList *table,
193
TableList *src_table,
1092
uint order_num, ORDER *order, bool ignore);
1093
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list);
1094
bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
1095
TABLE_LIST *src_table,
194
1096
HA_CREATE_INFO *create_info);
195
1097
bool mysql_rename_table(handlerton *base, const char *old_db,
196
1098
const char * old_name, const char *new_db,
197
const char * new_name, uint32_t flags);
198
bool mysql_prepare_update(THD *thd, TableList *table_list,
199
Item **conds, uint32_t order_num, order_st *order);
200
int mysql_update(THD *thd,TableList *tables,List<Item> &fields,
1099
const char * new_name, uint flags);
1100
bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
1101
Item **conds, uint order_num, ORDER *order);
1102
int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
201
1103
List<Item> &values,COND *conds,
202
uint32_t order_num, order_st *order, ha_rows limit,
1104
uint order_num, ORDER *order, ha_rows limit,
203
1105
enum enum_duplicates handle_duplicates, bool ignore);
204
bool mysql_multi_update(THD *thd, TableList *table_list,
1106
bool mysql_multi_update(THD *thd, TABLE_LIST *table_list,
205
1107
List<Item> *fields, List<Item> *values,
206
COND *conds, uint64_t options,
1108
COND *conds, ulonglong options,
207
1109
enum enum_duplicates handle_duplicates, bool ignore,
208
1110
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
209
bool mysql_prepare_insert(THD *thd, TableList *table_list, Table *table,
1111
bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
210
1112
List<Item> &fields, List_item *values,
211
1113
List<Item> &update_fields,
212
1114
List<Item> &update_values, enum_duplicates duplic,
213
1115
COND **where, bool select_insert,
214
1116
bool check_fields, bool abort_on_warning);
215
bool mysql_insert(THD *thd,TableList *table,List<Item> &fields,
1117
bool mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields,
216
1118
List<List_item> &values, List<Item> &update_fields,
217
1119
List<Item> &update_values, enum_duplicates flag,
219
int check_that_all_fields_are_given_values(THD *thd, Table *entry,
220
TableList *table_list);
221
void prepare_triggers_for_insert_stmt(Table *table);
222
int mysql_prepare_delete(THD *thd, TableList *table_list, Item **conds);
223
bool mysql_delete(THD *thd, TableList *table_list, COND *conds,
224
SQL_LIST *order, ha_rows rows, uint64_t options,
1121
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
1122
TABLE_LIST *table_list);
1123
void prepare_triggers_for_insert_stmt(TABLE *table);
1124
int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
1125
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
1126
SQL_LIST *order, ha_rows rows, ulonglong options,
225
1127
bool reset_auto_increment);
226
bool mysql_truncate(THD *thd, TableList *table_list, bool dont_send_ok);
227
uint32_t create_table_def_key(THD *thd, char *key, TableList *table_list,
1128
bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
1129
bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
1130
uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
228
1131
bool tmp_table);
229
TABLE_SHARE *get_table_share(THD *thd, TableList *table_list, char *key,
230
uint32_t key_length, uint32_t db_flags, int *error);
1132
TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
1133
uint key_length, uint db_flags, int *error);
231
1134
void release_table_share(TABLE_SHARE *share, enum release_type type);
232
1135
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
233
Table *open_ltable(THD *thd, TableList *table_list, thr_lock_type update,
234
uint32_t lock_flags);
235
Table *open_table(THD *thd, TableList *table_list, bool *refresh, uint32_t flags);
236
bool name_lock_locked_table(THD *thd, TableList *tables);
237
bool reopen_name_locked_table(THD* thd, TableList* table_list, bool link_in);
238
Table *table_cache_insert_placeholder(THD *thd, const char *key,
239
uint32_t key_length);
1136
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
1138
TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem,
1139
bool *refresh, uint flags);
1140
bool name_lock_locked_table(THD *thd, TABLE_LIST *tables);
1141
bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in);
1142
TABLE *table_cache_insert_placeholder(THD *thd, const char *key,
240
1144
bool lock_table_name_if_not_cached(THD *thd, const char *db,
241
const char *table_name, Table **table);
242
Table *find_locked_table(THD *thd, const char *db,const char *table_name);
243
void detach_merge_children(Table *table, bool clear_refs);
244
bool fix_merge_after_open(TableList *old_child_list, TableList **old_last,
245
TableList *new_child_list, TableList **new_last);
246
bool reopen_table(Table *table);
1145
const char *table_name, TABLE **table);
1146
TABLE *find_locked_table(THD *thd, const char *db,const char *table_name);
1147
void detach_merge_children(TABLE *table, bool clear_refs);
1148
bool fix_merge_after_open(TABLE_LIST *old_child_list, TABLE_LIST **old_last,
1149
TABLE_LIST *new_child_list, TABLE_LIST **new_last);
1150
bool reopen_table(TABLE *table);
247
1151
bool reopen_tables(THD *thd,bool get_locks,bool in_refresh);
248
1152
void close_data_files_and_morph_locks(THD *thd, const char *db,
249
1153
const char *table_name);
250
void close_handle_and_leave_table_as_lock(Table *table);
1154
void close_handle_and_leave_table_as_lock(TABLE *table);
251
1155
bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
252
uint32_t db_stat, uint32_t prgflag,
253
uint32_t ha_open_flags, Table *outparam,
254
TableList *table_desc, MEM_ROOT *mem_root);
1156
uint db_stat, uint prgflag,
1157
uint ha_open_flags, TABLE *outparam,
1158
TABLE_LIST *table_desc, MEM_ROOT *mem_root);
255
1159
bool wait_for_tables(THD *thd);
256
bool table_is_used(Table *table, bool wait_for_name_lock);
257
Table *drop_locked_tables(THD *thd,const char *db, const char *table_name);
1160
bool table_is_used(TABLE *table, bool wait_for_name_lock);
1161
TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name);
258
1162
void abort_locked_tables(THD *thd,const char *db, const char *table_name);
259
1163
void execute_init_command(THD *thd, sys_var_str *init_command_var,
260
1164
rw_lock_t *var_mutex);
626
1689
extern Ge_creator ge_creator;
627
1690
extern Le_creator le_creator;
628
1691
extern char language[FN_REFLEN];
1692
#endif /* MYSQL_SERVER */
1693
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1694
extern char reg_ext[FN_EXTLEN];
1695
extern uint reg_ext_length;
1696
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
629
1698
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
630
1699
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
631
1700
extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
632
1701
extern const double log_10[309];
633
extern uint64_t log_10_int[20];
634
extern uint64_t keybuff_size;
635
extern uint64_t thd_startup_options;
1702
extern ulonglong log_10_int[20];
1703
extern ulonglong keybuff_size;
1704
extern ulonglong thd_startup_options;
636
1705
extern ulong thread_id;
637
1706
extern ulong binlog_cache_use, binlog_cache_disk_use;
638
1707
extern ulong aborted_threads,aborted_connects;
639
1708
extern ulong slave_open_temp_tables;
1709
extern ulong query_cache_size, query_cache_min_res_unit;
640
1710
extern ulong slow_launch_threads, slow_launch_time;
641
1711
extern ulong table_cache_size, table_def_size;
642
1712
extern ulong max_connections,max_connect_errors, connect_timeout;
643
extern bool slave_allow_batching;
1713
extern my_bool slave_allow_batching;
644
1714
extern ulong slave_net_timeout, slave_trans_retries;
645
extern uint32_t max_user_connections;
1715
extern uint max_user_connections;
646
1716
extern ulong what_to_log,flush_time;
1717
extern ulong query_buff_size;
1718
extern ulong max_prepared_stmt_count, prepared_stmt_count;
647
1719
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
648
1720
extern ulong max_binlog_size, max_relay_log_size;
649
1721
extern ulong opt_binlog_rows_event_max_size;
650
1722
extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
651
1723
extern ulong back_log;
1724
#endif /* MYSQL_SERVER */
1725
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1726
extern ulong specialflag;
1727
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
652
1729
extern ulong current_pid;
653
1730
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
654
1731
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
655
1732
extern ulong tc_log_page_waits;
656
extern bool relay_log_purge;
657
extern bool opt_innodb_safe_binlog, opt_innodb;
658
extern uint32_t test_flags,select_errors,ha_open_options;
659
extern uint32_t protocol_version, mysqld_port, dropping_tables;
660
extern uint32_t delay_key_write_options;
1733
extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb;
1734
extern uint test_flags,select_errors,ha_open_options;
1735
extern uint protocol_version, mysqld_port, dropping_tables;
1736
extern uint delay_key_write_options;
1737
#endif /* MYSQL_SERVER */
1738
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1739
extern uint lower_case_table_names;
1740
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
661
1742
extern bool opt_endinfo, using_udf_functions;
662
extern bool locked_in_memory;
1743
extern my_bool locked_in_memory;
663
1744
extern bool opt_using_transactions;
1745
#endif /* MYSQL_SERVER */
1746
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1747
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
664
1749
extern bool using_update_log, server_id_supplied;
665
1750
extern bool opt_update_log, opt_bin_log, opt_error_log;
667
extern bool opt_slow_log;
1751
extern my_bool opt_log, opt_slow_log;
668
1752
extern ulong log_output_options;
669
extern bool opt_log_queries_not_using_indexes;
670
extern bool opt_character_set_client_handshake;
1753
extern my_bool opt_log_queries_not_using_indexes;
1754
extern bool opt_disable_networking, opt_skip_show_db;
1755
extern my_bool opt_character_set_client_handshake;
671
1756
extern bool volatile abort_loop, shutdown_in_progress;
672
extern uint32_t volatile thread_count, thread_running, global_read_lock;
673
extern uint32_t connection_count;
674
extern bool opt_sql_bin_update;
675
extern bool opt_safe_user_create;
676
extern bool opt_no_mix_types;
677
extern bool opt_safe_show_db, opt_myisam_use_mmap;
678
extern bool opt_local_infile;
679
extern bool opt_slave_compressed_protocol;
680
extern bool use_temp_pool;
1757
extern uint volatile thread_count, thread_running, global_read_lock;
1758
extern uint connection_count;
1759
extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types;
1760
extern my_bool opt_safe_show_db, opt_local_infile, opt_myisam_use_mmap;
1761
extern my_bool opt_slave_compressed_protocol, use_temp_pool;
681
1762
extern ulong slave_exec_mode_options;
682
extern bool opt_readonly;
1763
extern my_bool opt_readonly, lower_case_file_system;
1764
extern my_bool opt_enable_named_pipe, opt_sync_frm;
1765
extern my_bool opt_secure_auth;
683
1766
extern char* opt_secure_file_priv;
684
extern bool opt_noacl;
685
extern bool opt_old_style_user_limits;
686
extern uint32_t opt_crash_binlog_innodb;
1767
extern my_bool opt_log_slow_admin_statements, opt_log_slow_slave_statements;
1768
extern my_bool opt_noacl;
1769
extern my_bool opt_old_style_user_limits;
1770
extern uint opt_crash_binlog_innodb;
1771
extern char *shared_memory_base_name;
1772
extern my_bool opt_enable_shared_memory;
687
1773
extern char *default_tz_name;
1774
#endif /* MYSQL_SERVER */
688
1776
extern char *opt_logname, *opt_slow_logname;
689
1777
extern const char *log_output_str;
691
extern DRIZZLE_BIN_LOG mysql_bin_log;
1779
extern MYSQL_BIN_LOG mysql_bin_log;
692
1780
extern LOGGER logger;
693
extern TableList general_log, slow_log;
1781
extern TABLE_LIST general_log, slow_log;
1782
extern FILE *bootstrap_file;
1783
extern int bootstrap_error;
694
1784
extern FILE *stderror_file;
695
1785
extern pthread_key(MEM_ROOT**,THR_MALLOC);
696
1786
extern pthread_mutex_t LOCK_mysql_create_db,LOCK_open, LOCK_lock_db,
697
LOCK_thread_count,LOCK_user_locks, LOCK_status,
1787
LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status,
698
1788
LOCK_error_log, LOCK_uuid_generator,
699
1789
LOCK_crypt, LOCK_timezone,
700
LOCK_slave_list, LOCK_active_mi, LOCK_global_read_lock,
1790
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
701
1791
LOCK_global_system_variables, LOCK_user_conn,
702
1792
LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
703
1793
extern pthread_mutex_t LOCK_server_started;
801
1898
const char *db, const char *table,
802
1899
HA_CREATE_INFO *create_info,
803
1900
List<Create_field> &create_field,
804
uint32_t key_count,KEY *key_info,handler *db_type);
1901
uint key_count,KEY *key_info,handler *db_type);
805
1902
int rea_create_table(THD *thd, const char *path,
806
1903
const char *db, const char *table_name,
807
1904
HA_CREATE_INFO *create_info,
808
1905
List<Create_field> &create_field,
809
uint32_t key_count,KEY *key_info,
1906
uint key_count,KEY *key_info,
811
int format_number(uint32_t inputflag,uint32_t max_length,char * pos,uint32_t length,
1908
int format_number(uint inputflag,uint max_length,char * pos,uint length,
812
1909
char * *errpos);
815
TABLE_SHARE *alloc_table_share(TableList *table_list, char *key,
816
uint32_t key_length);
1912
TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key,
817
1914
void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
819
1916
const char *table_name, const char *path);
820
1917
void free_table_share(TABLE_SHARE *share);
821
int open_table_def(THD *thd, TABLE_SHARE *share, uint32_t db_flags);
1918
int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags);
822
1919
void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
823
1920
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
824
uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
825
Table *outparam, open_table_mode open_mode);
826
int readfrm(const char *name, unsigned char **data, size_t *length);
827
int writefrm(const char* name, const unsigned char* data, size_t len);
828
int closefrm(Table *table, bool free_share);
829
int read_string(File file, unsigned char* *to, size_t length);
830
void free_blobs(Table *table);
1921
uint db_stat, uint prgflag, uint ha_open_flags,
1922
TABLE *outparam, open_table_mode open_mode);
1923
int readfrm(const char *name, uchar **data, size_t *length);
1924
int writefrm(const char* name, const uchar* data, size_t len);
1925
int closefrm(TABLE *table, bool free_share);
1926
int read_string(File file, uchar* *to, size_t length);
1927
void free_blobs(TABLE *table);
831
1928
int set_zone(int nr,int min_zone,int max_zone);
832
1929
ulong convert_period_to_month(ulong period);
833
1930
ulong convert_month_to_period(ulong month);
834
void get_date_from_daynr(long daynr,uint32_t *year, uint32_t *month,
836
my_time_t TIME_to_timestamp(THD *thd, const DRIZZLE_TIME *t, bool *not_exist);
837
bool str_to_time_with_warn(const char *str,uint32_t length,DRIZZLE_TIME *l_time);
838
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, uint32_t length,
839
DRIZZLE_TIME *l_time, uint32_t flags);
840
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
841
void calc_time_from_sec(DRIZZLE_TIME *to, long seconds, long microseconds);
1931
void get_date_from_daynr(long daynr,uint *year, uint *month,
1933
my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, bool *not_exist);
1934
bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time);
1935
timestamp_type str_to_datetime_with_warn(const char *str, uint length,
1936
MYSQL_TIME *l_time, uint flags);
1937
void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
1938
void calc_time_from_sec(MYSQL_TIME *to, long seconds, long microseconds);
843
void make_truncated_value_warning(THD *thd, DRIZZLE_ERROR::enum_warning_level level,
1940
void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
844
1941
const char *str_val,
845
uint32_t str_length, enum enum_drizzle_timestamp_type time_type,
1942
uint str_length, timestamp_type time_type,
846
1943
const char *field_name);
848
bool date_add_interval(DRIZZLE_TIME *ltime, interval_type int_type, INTERVAL interval);
849
bool calc_time_diff(DRIZZLE_TIME *l_time1, DRIZZLE_TIME *l_time2, int l_sign,
850
int64_t *seconds_out, long *microseconds_out);
1945
bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval);
1946
bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign,
1947
longlong *seconds_out, long *microseconds_out);
852
1949
extern LEX_STRING interval_type_to_name[];
854
extern DATE_TIME_FORMAT *date_time_format_make(enum enum_drizzle_timestamp_type format_type,
1951
extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type,
855
1952
const char *format_str,
856
uint32_t format_length);
1953
uint format_length);
857
1954
extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd,
858
1955
DATE_TIME_FORMAT *format);
859
1956
const char *get_date_time_format_str(KNOWN_DATE_TIME_FORMAT *format,
860
enum enum_drizzle_timestamp_type type);
861
extern bool make_date_time(DATE_TIME_FORMAT *format, DRIZZLE_TIME *l_time,
862
enum enum_drizzle_timestamp_type type, String *str);
863
void make_datetime(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
1957
timestamp_type type);
1958
extern bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
1959
timestamp_type type, String *str);
1960
void make_datetime(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
865
void make_date(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
867
void make_time(const DATE_TIME_FORMAT *format, const DRIZZLE_TIME *l_time,
869
int my_time_compare(DRIZZLE_TIME *a, DRIZZLE_TIME *b);
870
uint64_t get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
1962
void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
1964
void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
1966
int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
1967
ulonglong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
871
1968
Item *warn_item, bool *is_null);
873
1970
int test_if_number(char *str,int *res,bool allow_wildcards);
874
void change_byte(unsigned char *,uint,char,char);
875
void init_read_record(READ_RECORD *info, THD *thd, Table *reg_form,
1971
void change_byte(uchar *,uint,char,char);
1972
void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
876
1973
SQL_SELECT *select,
877
1974
int use_record_cache, bool print_errors);
878
void init_read_record_idx(READ_RECORD *info, THD *thd, Table *table,
879
bool print_error, uint32_t idx);
1975
void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
1976
bool print_error, uint idx);
880
1977
void end_read_record(READ_RECORD *info);
881
ha_rows filesort(THD *thd, Table *form,struct st_sort_field *sortorder,
882
uint32_t s_length, SQL_SELECT *select,
1978
ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
1979
uint s_length, SQL_SELECT *select,
883
1980
ha_rows max_rows, bool sort_positions,
884
1981
ha_rows *examined_rows);
885
void filesort_free_buffers(Table *table, bool full);
886
void change_double_for_sort(double nr,unsigned char *to);
887
double my_double_round(double value, int64_t dec, bool dec_unsigned,
1982
void filesort_free_buffers(TABLE *table, bool full);
1983
void change_double_for_sort(double nr,uchar *to);
1984
double my_double_round(double value, longlong dec, bool dec_unsigned,
889
1986
int get_quick_record(SQL_SELECT *select);
891
1988
int calc_weekday(long daynr,bool sunday_first_day_of_week);
892
uint32_t calc_week(DRIZZLE_TIME *l_time, uint32_t week_behaviour, uint32_t *year);
893
void find_date(char *pos,uint32_t *vek,uint32_t flag);
1989
uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year);
1990
void find_date(char *pos,uint *vek,uint flag);
894
1991
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
895
1992
TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings);
896
ulong get_form_pos(File file, unsigned char *head, TYPELIB *save_names);
897
ulong make_new_entry(File file,unsigned char *fileinfo,TYPELIB *formnames,
1993
ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
1994
ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
898
1995
const char *newname);
899
1996
ulong next_io_size(ulong pos);
900
void append_unescaped(String *res, const char *pos, uint32_t length);
1997
void append_unescaped(String *res, const char *pos, uint length);
901
1998
int create_frm(THD *thd, const char *name, const char *db, const char *table,
902
uint32_t reclength, unsigned char *fileinfo,
903
HA_CREATE_INFO *create_info, uint32_t keys, KEY *key_info);
1999
uint reclength, uchar *fileinfo,
2000
HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
2001
void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
904
2002
int rename_file_ext(const char * from,const char * to,const char * ext);
905
2003
bool check_db_name(LEX_STRING *db);
906
2004
bool check_column_name(const char *name);
907
bool check_table_name(const char *name, uint32_t length);
2005
bool check_table_name(const char *name, uint length);
908
2006
char *get_field(MEM_ROOT *mem, Field *field);
909
2007
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
910
2008
char *fn_rext(char *name);
912
2010
/* Conversion functions */
913
uint32_t build_table_filename(char *buff, size_t bufflen, const char *db,
914
const char *table, const char *ext, uint32_t flags);
2011
#endif /* MYSQL_SERVER */
2012
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
2013
uint strconvert(CHARSET_INFO *from_cs, const char *from,
2014
CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors);
2015
uint filename_to_tablename(const char *from, char *to, uint to_length);
2016
uint tablename_to_filename(const char *from, char *to, uint to_length);
2017
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
2019
uint build_table_filename(char *buff, size_t bufflen, const char *db,
2020
const char *table, const char *ext, uint flags);
916
2022
#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#"
917
2023
#define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9