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 uint64_t 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 uint64_t nested_join_map;
82
typedef uint64_t 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))
118
extern CHARSET_INFO *system_charset_info, *files_charset_info ;
119
extern CHARSET_INFO *national_charset_info, *table_alias_charset;
123
DERIVATION_IGNORABLE= 5,
124
DERIVATION_COERCIBLE= 4,
125
DERIVATION_SYSCONST= 3,
126
DERIVATION_IMPLICIT= 2,
128
DERIVATION_EXPLICIT= 0
132
typedef struct my_locale_st
136
const char *description;
138
TYPELIB *month_names;
139
TYPELIB *ab_month_names;
141
TYPELIB *ab_day_names;
143
my_locale_st(uint number_par,
144
const char *name_par, const char *descr_par, bool is_ascii_par,
145
TYPELIB *month_names_par, TYPELIB *ab_month_names_par,
146
TYPELIB *day_names_par, TYPELIB *ab_day_names_par) :
148
name(name_par), description(descr_par), is_ascii(is_ascii_par),
149
month_names(month_names_par), ab_month_names(ab_month_names_par),
150
day_names(day_names_par), ab_day_names(ab_day_names_par)
155
extern MY_LOCALE my_locale_en_US;
156
extern MY_LOCALE *my_locales[];
157
extern MY_LOCALE *my_default_lc_time_names;
159
MY_LOCALE *my_locale_by_name(const char *name);
160
MY_LOCALE *my_locale_by_number(uint number);
162
/*************************************************************************/
165
Object_creation_ctx -- interface for creation context of database objects
166
(views, stored routines, events, triggers). Creation context -- is a set
167
of attributes, that should be fixed at the creation time and then be used
168
each time the object is parsed or executed.
171
class Object_creation_ctx
174
Object_creation_ctx *set_n_backup(THD *thd);
176
void restore_env(THD *thd, Object_creation_ctx *backup_ctx);
179
Object_creation_ctx() {}
180
virtual Object_creation_ctx *create_backup_ctx(THD *thd) const = 0;
182
virtual void change_env(THD *thd) const = 0;
185
virtual ~Object_creation_ctx()
189
/*************************************************************************/
192
Default_object_creation_ctx -- default implementation of
196
class Default_object_creation_ctx : public Object_creation_ctx
199
CHARSET_INFO *get_client_cs()
204
CHARSET_INFO *get_connection_cl()
206
return m_connection_cl;
210
Default_object_creation_ctx(THD *thd);
212
Default_object_creation_ctx(CHARSET_INFO *client_cs,
213
CHARSET_INFO *connection_cl);
216
virtual Object_creation_ctx *create_backup_ctx(THD *thd) const;
218
virtual void change_env(THD *thd) const;
222
client_cs stores the value of character_set_client session variable.
223
The only character set attribute is used.
225
Client character set is included into query context, because we save
226
query in the original character set, which is client character set. So,
227
in order to parse the query properly we have to switch client character
230
CHARSET_INFO *m_client_cs;
233
connection_cl stores the value of collation_connection session
234
variable. Both character set and collation attributes are used.
236
Connection collation is included into query context, becase it defines
237
the character set and collation of text literals in internal
238
representation of query (item-objects).
240
CHARSET_INFO *m_connection_cl;
245
Opening modes for open_temporary_table and open_table_from_share
255
/***************************************************************************
256
Configuration parameters
257
****************************************************************************/
259
#define ACL_CACHE_SIZE 256
260
#define MAX_PASSWORD_LENGTH 32
261
#define HOST_CACHE_SIZE 128
262
#define MAX_ACCEPT_RETRY 10 // Test accept this many times
263
#define MAX_FIELDS_BEFORE_HASH 32
264
#define USER_VARS_HASH_SIZE 16
265
#define TABLE_OPEN_CACHE_MIN 64
266
#define TABLE_OPEN_CACHE_DEFAULT 64
269
Value of 9236 discovered through binary search 2006-09-26 on Ubuntu Dapper
270
Drake, libc6 2.3.6-0ubuntu2, Linux kernel 2.6.15-27-686, on x86. (Added
271
100 bytes as reasonable buffer against growth and other environments'
274
Feel free to raise this by the smallest amount you can to get the
275
"execution_constants" test to pass.
277
#define STACK_MIN_SIZE 12000 ///< Abort if less stack during eval.
279
#define STACK_MIN_SIZE_FOR_OPEN 1024*80
280
#define STACK_BUFF_ALLOC 352 ///< For stack overrun checks
281
#ifndef MYSQLD_NET_RETRY_COUNT
282
#define MYSQLD_NET_RETRY_COUNT 10 ///< Abort read after this many int.
284
#define TEMP_POOL_SIZE 128
286
#define QUERY_ALLOC_BLOCK_SIZE 8192
287
#define QUERY_ALLOC_PREALLOC_SIZE 8192
288
#define TRANS_ALLOC_BLOCK_SIZE 4096
289
#define TRANS_ALLOC_PREALLOC_SIZE 4096
290
#define RANGE_ALLOC_BLOCK_SIZE 4096
291
#define ACL_ALLOC_BLOCK_SIZE 1024
292
#define UDF_ALLOC_BLOCK_SIZE 1024
293
#define TABLE_ALLOC_BLOCK_SIZE 1024
294
#define BDB_LOG_ALLOC_BLOCK_SIZE 1024
295
#define WARN_ALLOC_BLOCK_SIZE 2048
296
#define WARN_ALLOC_PREALLOC_SIZE 1024
297
#define PROFILE_ALLOC_BLOCK_SIZE 2048
298
#define PROFILE_ALLOC_PREALLOC_SIZE 1024
301
The following parameters is to decide when to use an extra cache to
302
optimise seeks when reading a big table in sorted order
304
#define MIN_FILE_LENGTH_TO_USE_ROW_CACHE (10L*1024*1024)
305
#define MIN_ROWS_TO_USE_TABLE_CACHE 100
306
#define MIN_ROWS_TO_USE_BULK_INSERT 100
309
The following is used to decide if MySQL should use table scanning
310
instead of reading with keys. The number says how many evaluation of the
311
WHERE clause is comparable to reading one extra row from a table.
313
#define TIME_FOR_COMPARE 5 // 5 compares == one read
316
Number of comparisons of table rowids equivalent to reading one row from a
319
#define TIME_FOR_COMPARE_ROWID (TIME_FOR_COMPARE*2)
322
For sequential disk seeks the cost formula is:
323
DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST * #blocks_to_skip
325
The cost of average seek
326
DISK_SEEK_BASE_COST + DISK_SEEK_PROP_COST*BLOCKS_IN_AVG_SEEK =1.0.
328
#define DISK_SEEK_BASE_COST ((double)0.9)
330
#define BLOCKS_IN_AVG_SEEK 128
332
#define DISK_SEEK_PROP_COST ((double)0.1/BLOCKS_IN_AVG_SEEK)
336
Number of rows in a reference table when refereed through a not unique key.
337
This value is only used when we don't know anything about the key
340
#define MATCHING_ROWS_IN_OTHER_TABLE 10
342
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */
343
#define KEY_DEFAULT_PACK_LENGTH 8
345
/** Characters shown for the command in 'show processlist'. */
346
#define PROCESS_LIST_WIDTH 100
347
/* Characters shown for the command in 'information_schema.processlist' */
348
#define PROCESS_LIST_INFO_WIDTH 65535
350
#define PRECISION_FOR_DOUBLE 53
351
#define PRECISION_FOR_FLOAT 24
354
Default time to wait before aborting a new client connection
355
that does not respond to "initial server greeting" timely
357
#define CONNECT_TIMEOUT 10
359
/* The following can also be changed from the command line */
360
#define DEFAULT_CONCURRENCY 10
361
#define FLUSH_TIME 0 /**< Don't flush tables */
362
#define MAX_CONNECT_ERRORS 10 ///< errors before disabling host
364
#define INTERRUPT_PRIOR 10
365
#define CONNECT_PRIOR 9
367
#define QUERY_PRIOR 6
369
/* Bits from testflag */
370
#define TEST_PRINT_CACHED_TABLES 1
371
#define TEST_NO_KEY_GROUP 2
372
#define TEST_MIT_THREAD 4
373
#define TEST_BLOCKING 8
374
#define TEST_KEEP_TMP_TABLES 16
375
#define TEST_READCHECK 64 /**< Force use of readcheck */
376
#define TEST_NO_EXTRA 128
377
#define TEST_CORE_ON_SIGNAL 256 /**< Give core if signal */
378
#define TEST_NO_STACKTRACE 512
379
#define TEST_SIGINT 1024 /**< Allow sigint on threads */
380
#define TEST_SYNCHRONIZATION 2048 /**< get server to do sleep in
385
This is included in the server and in the client.
386
Options for select set by the yacc parser (stored in lex->options).
389
log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
390
options list are written into binlog. These options can NOT change their
391
values, or it will break replication between version.
393
context is encoded as following:
394
SELECT - SELECT_LEX_NODE::options
396
intern - neither. used only as
397
func(..., select_node->options | thd->options | OPTION_XXX, ...)
399
TODO: separate three contexts above, move them to separate bitfields.
402
#define SELECT_DISTINCT (1ULL << 0) // SELECT, user
403
#define SELECT_STRAIGHT_JOIN (1ULL << 1) // SELECT, user
404
#define SELECT_DESCRIBE (1ULL << 2) // SELECT, user
405
#define SELECT_SMALL_RESULT (1ULL << 3) // SELECT, user
406
#define SELECT_BIG_RESULT (1ULL << 4) // SELECT, user
407
#define OPTION_FOUND_ROWS (1ULL << 5) // SELECT, user
408
#define SELECT_NO_JOIN_CACHE (1ULL << 7) // intern
409
#define OPTION_BIG_TABLES (1ULL << 8) // THD, user
410
#define OPTION_BIG_SELECTS (1ULL << 9) // THD, user
411
#define OPTION_LOG_OFF (1ULL << 10) // THD, user
412
#define OPTION_QUOTE_SHOW_CREATE (1ULL << 11) // THD, user, unused
413
#define TMP_TABLE_ALL_COLUMNS (1ULL << 12) // SELECT, intern
414
#define OPTION_WARNINGS (1ULL << 13) // THD, user
415
#define OPTION_AUTO_IS_NULL (1ULL << 14) // THD, user, binlog
416
#define OPTION_FOUND_COMMENT (1ULL << 15) // SELECT, intern, parser
417
#define OPTION_SAFE_UPDATES (1ULL << 16) // THD, user
418
#define OPTION_BUFFER_RESULT (1ULL << 17) // SELECT, user
419
#define OPTION_BIN_LOG (1ULL << 18) // THD, user
420
#define OPTION_NOT_AUTOCOMMIT (1ULL << 19) // THD, user
421
#define OPTION_BEGIN (1ULL << 20) // THD, intern
422
#define OPTION_TABLE_LOCK (1ULL << 21) // THD, intern
423
#define OPTION_QUICK (1ULL << 22) // SELECT (for DELETE)
424
#define OPTION_KEEP_LOG (1ULL << 23) // THD, user
426
/* The following is used to detect a conflict with DISTINCT */
427
#define SELECT_ALL (1ULL << 24) // SELECT, user, parser
429
/** The following can be set when importing tables in a 'wrong order'
430
to suppress foreign key checks */
431
#define OPTION_NO_FOREIGN_KEY_CHECKS (1ULL << 26) // THD, user, binlog
432
/** The following speeds up inserts to InnoDB tables by suppressing unique
433
key checks in some cases */
434
#define OPTION_RELAXED_UNIQUE_CHECKS (1ULL << 27) // THD, user, binlog
435
#define SELECT_NO_UNLOCK (1ULL << 28) // SELECT, intern
436
#define OPTION_SCHEMA_TABLE (1ULL << 29) // SELECT, intern
437
/** Flag set if setup_tables already done */
438
#define OPTION_SETUP_TABLES_DONE (1ULL << 30) // intern
439
/** If not set then the thread will ignore all warnings with level notes. */
440
#define OPTION_SQL_NOTES (1ULL << 31) // THD, user
442
Force the used temporary table to be a MyISAM table (because we will use
443
fulltext functions when reading from it.
445
#define TMP_TABLE_FORCE_MYISAM (1ULL << 32)
446
#define OPTION_PROFILING (1ULL << 33)
449
Dont report errors for individual rows,
450
But just report error on commit (or read ofcourse)
452
#define OPTION_ALLOW_BATCH (1ULL << 33) // THD, intern (slave)
455
Maximum length of time zone name that we support
456
(Time zone name is char(64) in db). mysqlbinlog needs it.
458
#define MAX_TIME_ZONE_NAME_LENGTH (NAME_LEN + 1)
460
/* The rest of the file is included in the server only */
463
/* Bits for different SQL modes modes (including ANSI mode) */
464
#define MODE_REAL_AS_FLOAT 1
465
#define MODE_PIPES_AS_CONCAT 2
466
#define MODE_ANSI_QUOTES 4
467
#define MODE_IGNORE_SPACE 8
468
#define MODE_NOT_USED 16
469
#define MODE_ONLY_FULL_GROUP_BY 32
470
#define MODE_NO_UNSIGNED_SUBTRACTION 64
471
#define MODE_NO_DIR_IN_CREATE 128
472
#define MODE_POSTGRESQL 256
473
#define MODE_ORACLE 512
474
#define MODE_MSSQL 1024
475
#define MODE_DB2 2048
476
#define MODE_MAXDB 4096
477
#define MODE_NO_KEY_OPTIONS 8192
478
#define MODE_NO_TABLE_OPTIONS 16384
479
#define MODE_NO_FIELD_OPTIONS 32768
480
#define MODE_MYSQL323 65536L
481
#define MODE_MYSQL40 (MODE_MYSQL323*2)
482
#define MODE_ANSI (MODE_MYSQL40*2)
483
#define MODE_NO_AUTO_VALUE_ON_ZERO (MODE_ANSI*2)
484
#define MODE_NO_BACKSLASH_ESCAPES (MODE_NO_AUTO_VALUE_ON_ZERO*2)
485
#define MODE_STRICT_TRANS_TABLES (MODE_NO_BACKSLASH_ESCAPES*2)
486
#define MODE_STRICT_ALL_TABLES (MODE_STRICT_TRANS_TABLES*2)
487
#define MODE_NO_ZERO_IN_DATE (MODE_STRICT_ALL_TABLES*2)
488
#define MODE_NO_ZERO_DATE (MODE_NO_ZERO_IN_DATE*2)
489
#define MODE_INVALID_DATES (MODE_NO_ZERO_DATE*2)
490
#define MODE_ERROR_FOR_DIVISION_BY_ZERO (MODE_INVALID_DATES*2)
491
#define MODE_TRADITIONAL (MODE_ERROR_FOR_DIVISION_BY_ZERO*2)
492
#define MODE_NO_AUTO_CREATE_USER (MODE_TRADITIONAL*2)
493
#define MODE_HIGH_NOT_PRECEDENCE (MODE_NO_AUTO_CREATE_USER*2)
494
#define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2)
495
#define MODE_PAD_CHAR_TO_FULL_LENGTH (1ULL << 31)
498
/* @@optimizer_switch flags */
499
#define OPTIMIZER_SWITCH_NO_MATERIALIZATION 1
500
#define OPTIMIZER_SWITCH_NO_SEMIJOIN 2
504
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
505
use strictly more than 64 bits by adding one more define above, you should
506
contact the replication team because the replication code should then be
507
updated (to store more bytes on disk).
509
NOTE: When adding new SQL_MODE types, make sure to also add them to
510
the scripts used for creating the MySQL system tables
511
in scripts/mysql_system_tables.sql and scripts/mysql_system_tables_fix.sql
515
#define RAID_BLOCK_SIZE 1024
517
#define MY_CHARSET_BIN_MB_MAXLEN 1
520
#define UNCACHEABLE_DEPENDENT 1
521
#define UNCACHEABLE_RAND 2
522
#define UNCACHEABLE_SIDEEFFECT 4
523
/// forcing to save JOIN for explain
524
#define UNCACHEABLE_EXPLAIN 8
525
/** Don't evaluate subqueries in prepare even if they're not correlated */
526
#define UNCACHEABLE_PREPARE 16
527
/* For uncorrelated SELECT in an UNION with some correlated SELECTs */
528
#define UNCACHEABLE_UNITED 32
530
/* Used to check GROUP BY list in the MODE_ONLY_FULL_GROUP_BY mode */
531
#define UNDEF_POS (-1)
533
/* BINLOG_DUMP options */
535
#define BINLOG_DUMP_NON_BLOCK 1
537
/* sql_show.cc:show_log_files() */
538
#define SHOW_LOG_STATUS_FREE "FREE"
539
#define SHOW_LOG_STATUS_INUSE "IN USE"
543
void view_store_options(THD *thd, TABLE_LIST *table, String *buff);
545
/* Options to add_table_to_list() */
546
#define TL_OPTION_UPDATING 1
547
#define TL_OPTION_FORCE_INDEX 2
548
#define TL_OPTION_IGNORE_LEAVES 4
549
#define TL_OPTION_ALIAS 8
551
/* Some portable defines */
553
#define portable_sizeof_char_ptr 8
555
#define tmp_file_prefix "#sql" /**< Prefix for tmp tables */
556
#define tmp_file_prefix_length 4
558
/* Flags for calc_week() function. */
559
#define WEEK_MONDAY_FIRST 1
561
#define WEEK_FIRST_WEEKDAY 4
563
#define STRING_BUFFER_USUAL_SIZE 80
566
Some defines for exit codes for ::is_equal class functions.
568
#define IS_EQUAL_NO 0
569
#define IS_EQUAL_YES 1
570
#define IS_EQUAL_PACK_LENGTH 2
572
enum enum_parsing_place
583
#define thd_proc_info(thd, msg) set_thd_proc_info(thd, msg, __func__, __FILE__, __LINE__)
586
enum enum_check_fields
590
CHECK_FIELD_ERROR_FOR_NULL
594
/** Struct to handle simple linked lists. */
595
typedef struct st_sql_list {
600
st_sql_list() {} /* Remove gcc warning */
607
inline void link_in_list(uchar *element,uchar **next_ptr)
614
inline void save_and_clear(struct st_sql_list *save)
619
inline void push_front(struct st_sql_list *save)
621
*save->next= first; /* link current list last */
623
elements+= save->elements;
625
inline void push_back(struct st_sql_list *save)
631
elements+= save->elements;
637
extern pthread_key(THD*, THR_THD);
638
inline THD *_current_thd(void)
640
return (THD *)pthread_getspecific(THR_THD);
642
#define current_thd _current_thd()
645
The meat of thd_proc_info(THD*, char*), a macro that packs the last
646
three calling-info parameters.
649
const char *set_thd_proc_info(THD *thd, const char *info,
650
const char *calling_func,
651
const char *calling_file,
652
const unsigned int calling_line);
657
extern ulong server_id;
660
typedef my_bool (*qc_engine_callback)(THD *thd, char *table_key,
662
uint64_t *engine_data);
663
#include "sql_string.h"
664
#include "sql_list.h"
666
#include "my_decimal.h"
669
#include "sql_error.h"
670
#include "field.h" /* Field definitions */
671
#include "protocol.h"
674
class user_var_entry;
675
class Security_context;
678
OPT_DEFAULT= 0, OPT_SESSION, OPT_GLOBAL
35
682
class Comp_creator;
36
683
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>
686
extern my_decimal decimal_zero;
689
void free_items(Item *item);
690
void cleanup_items(Item *item);
692
void close_thread_tables(THD *thd);
694
bool multi_update_precheck(THD *thd, TABLE_LIST *tables);
695
bool multi_delete_precheck(THD *thd, TABLE_LIST *tables);
696
int mysql_multi_update_prepare(THD *thd);
697
int mysql_multi_delete_prepare(THD *thd);
698
bool mysql_insert_select_prepare(THD *thd);
699
bool update_precheck(THD *thd, TABLE_LIST *tables);
700
bool delete_precheck(THD *thd, TABLE_LIST *tables);
701
bool insert_precheck(THD *thd, TABLE_LIST *tables);
702
bool create_table_precheck(THD *thd, TABLE_LIST *tables,
703
TABLE_LIST *create_table);
704
int append_query_string(CHARSET_INFO *csinfo,
705
String const *from, String *to);
707
bool check_string_byte_length(LEX_STRING *str, const char *err_msg,
708
uint max_byte_length);
709
bool check_string_char_length(LEX_STRING *str, const char *err_msg,
710
uint max_char_length, CHARSET_INFO *cs,
712
bool check_identifier_name(LEX_STRING *str, uint max_char_length,
713
uint err_code, const char *param_for_err_msg);
714
inline bool check_identifier_name(LEX_STRING *str, uint err_code)
716
return check_identifier_name(str, NAME_CHAR_LEN, err_code, "");
718
inline bool check_identifier_name(LEX_STRING *str)
720
return check_identifier_name(str, NAME_CHAR_LEN, 0, "");
723
bool test_if_data_home_dir(const char *dir);
725
bool parse_sql(THD *thd,
726
class Lex_input_stream *lip,
727
class Object_creation_ctx *creation_ctx);
729
enum enum_mysql_completiontype {
730
ROLLBACK_RELEASE=-2, ROLLBACK=1, ROLLBACK_AND_CHAIN=7,
731
COMMIT_RELEASE=-1, COMMIT=0, COMMIT_AND_CHAIN=6
734
bool begin_trans(THD *thd);
735
bool end_active_trans(THD *thd);
736
int end_trans(THD *thd, enum enum_mysql_completiontype completion);
738
Item *negate_expression(THD *thd, Item *expr);
741
int vprint_msg_to_log(enum loglevel level, const char *format, va_list args);
742
void sql_print_error(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
743
void sql_print_warning(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
744
void sql_print_information(const char *format, ...)
745
ATTRIBUTE_FORMAT(printf, 1, 2);
746
typedef void (*sql_print_message_func)(const char *format, ...)
747
ATTRIBUTE_FORMAT(printf, 1, 2);
748
extern sql_print_message_func sql_print_message_handlers[];
750
int error_log_print(enum loglevel level, const char *format,
753
bool slow_log_print(THD *thd, const char *query, uint query_length,
754
uint64_t current_utime);
756
bool general_log_print(THD *thd, enum enum_server_command command,
757
const char *format,...);
759
bool general_log_write(THD *thd, enum enum_server_command command,
760
const char *query, uint query_length);
762
#include "sql_class.h"
763
#include "slave.h" // for tables_ok(), rpl_filter
766
#include "opt_range.h"
770
Error injector Macros to enable easy testing of recovery after failures
771
in various error cases.
773
#ifndef ERROR_INJECT_SUPPORT
775
#define ERROR_INJECT(x) 0
776
#define ERROR_INJECT_ACTION(x,action) 0
777
#define ERROR_INJECT_CRASH(x) 0
778
#define ERROR_INJECT_VALUE(x) 0
779
#define ERROR_INJECT_VALUE_ACTION(x,action) 0
780
#define ERROR_INJECT_VALUE_CRASH(x) 0
781
#define SET_ERROR_INJECT_VALUE(x)
785
inline bool check_and_unset_keyword(const char *dbug_str)
787
const char *extra_str= "-d,";
789
if (_db_strict_keyword_ (dbug_str))
791
strxmov(total_str, extra_str, dbug_str, NullS);
799
check_and_unset_inject_value(int value)
801
THD *thd= current_thd;
802
if (thd->error_inject_value == (uint)value)
804
thd->error_inject_value= 0;
813
These macros are used to insert macros from the application code.
814
The event that activates those error injections can be activated
816
SET SESSION dbug=+d,code;
818
After the error has been injected, the macros will automatically
819
remove the debug code, thus similar to using:
820
SET SESSION dbug=-d,code
823
ERROR_INJECT_CRASH will inject a crash of the MySQL Server if code
824
is set when macro is called. ERROR_INJECT_CRASH can be used in
825
if-statements, it will always return false unless of course it
826
crashes in which case it doesn't return at all.
828
ERROR_INJECT_ACTION will inject the action specified in the action
829
parameter of the macro, before performing the action the code will
830
be removed such that no more events occur. ERROR_INJECT_ACTION
831
can also be used in if-statements and always returns FALSE.
832
ERROR_INJECT can be used in a normal if-statement, where the action
833
part is performed in the if-block. The macro returns TRUE if the
834
error was activated and otherwise returns FALSE. If activated the
837
Sometimes it is necessary to perform error inject actions as a serie
838
of events. In this case one can use one variable on the THD object.
839
Thus one sets this value by using e.g. SET_ERROR_INJECT_VALUE(100).
840
Then one can later test for it by using ERROR_INJECT_CRASH_VALUE,
841
ERROR_INJECT_ACTION_VALUE and ERROR_INJECT_VALUE. This have the same
842
behaviour as the above described macros except that they use the
843
error inject value instead of a code used by debug macros.
845
#define SET_ERROR_INJECT_VALUE(x) \
846
current_thd->error_inject_value= (x)
847
#define ERROR_INJECT_ACTION(code, action) \
848
(check_and_unset_keyword(code) ? ((action), 0) : 0)
849
#define ERROR_INJECT(code) \
850
check_and_unset_keyword(code)
851
#define ERROR_INJECT_VALUE(value) \
852
check_and_unset_inject_value(value)
853
#define ERROR_INJECT_VALUE_ACTION(value,action) \
854
(check_and_unset_inject_value(value) ? (action) : 0)
855
#define ERROR_INJECT_VALUE_CRASH(value) \
856
ERROR_INJECT_VALUE_ACTION(value, (abort(), 0))
860
void write_bin_log(THD *thd, bool clear_error,
861
char const *query, ulong query_length);
864
int check_user(THD *thd, enum enum_server_command command,
865
const char *passwd, uint passwd_len, const char *db,
867
pthread_handler_t handle_one_connection(void *arg);
868
bool init_new_connection_handler_thread();
869
void reset_mqh(LEX_USER *lu, bool get_them);
870
bool check_mqh(THD *thd, uint check_command);
871
void time_out_user_resource_limits(THD *thd, USER_CONN *uc);
872
void decrease_user_connections(USER_CONN *uc);
873
void thd_init_client_charset(THD *thd, uint cs_number);
874
bool setup_connection_thread_globals(THD *thd);
875
bool login_connection(THD *thd);
876
void prepare_new_connection_state(THD* thd);
877
void end_connection(THD *thd);
53
880
int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
54
881
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
55
882
bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
883
bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db);
884
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
885
void mysql_client_binlog_statement(THD *thd);
886
bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
887
my_bool drop_temporary);
888
int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists,
889
bool drop_temporary, bool drop_view, bool log_query);
890
bool quick_rm_table(handlerton *base,const char *db,
891
const char *table_name, uint flags);
892
void close_cached_table(THD *thd, TABLE *table);
893
bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list, bool silent);
894
bool do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db,
895
char *new_table_name, char *new_table_alias,
56
898
bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
57
899
bool force_switch);
58
901
bool mysql_opt_change_db(THD *thd,
59
902
const LEX_STRING *new_db_name,
60
903
LEX_STRING *saved_db_name,
61
904
bool force_switch,
62
905
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,
907
void mysql_parse(THD *thd, const char *inBuf, uint length,
78
908
const char ** semicolon);
80
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint32_t length);
910
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint length);
83
911
bool is_update_query(enum enum_sql_command command);
85
bool alloc_query(THD *thd, const char *packet, uint32_t packet_length);
912
bool alloc_query(THD *thd, const char *packet, uint packet_length);
913
void mysql_init_select(LEX *lex);
87
914
void mysql_reset_thd_for_next_command(THD *thd);
915
bool mysql_new_select(LEX *lex, bool move_down);
89
916
void create_select_for_variable(const char *var_name);
91
917
void mysql_init_multi_delete(LEX *lex);
93
918
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
919
void init_max_user_conn(void);
95
920
void init_update_queries(void);
921
void free_max_user_conn(void);
922
pthread_handler_t handle_bootstrap(void *arg);
923
int mysql_execute_command(THD *thd);
97
924
bool do_command(THD *thd);
99
925
bool dispatch_command(enum enum_server_command command, THD *thd,
100
char* packet, uint32_t packet_length);
926
char* packet, uint packet_length);
102
927
void log_slow_statement(THD *thd);
928
bool check_dup(const char *db, const char *name, TABLE_LIST *tables);
929
bool compare_record(TABLE *table);
104
930
bool append_file_to_dir(THD *thd, const char **filename_ptr,
105
931
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);
932
void wait_while_table_is_used(THD *thd, TABLE *table,
933
enum ha_extra_function function);
934
bool table_cache_init(void);
115
935
void table_cache_free(void);
116
bool table_cache_init(void);
117
936
bool table_def_init(void);
118
937
void table_def_free(void);
119
938
void assign_new_table_id(TABLE_SHARE *share);
120
uint32_t cached_open_tables(void);
121
uint32_t cached_table_definitions(void);
939
uint cached_open_tables(void);
940
uint cached_table_definitions(void);
124
941
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);
942
void close_connection(THD *thd, uint errcode, bool lock);
943
bool reload_cache(THD *thd, ulong options, TABLE_LIST *tables, bool *write_to_binlog);
944
bool check_table_access(THD *thd, ulong want_access, TABLE_LIST *tables,
946
bool any_combination_of_privileges_will_do,
949
#endif /* MYSQL_SERVER */
950
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
951
bool check_global_access(THD *thd, ulong want_access);
952
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
956
General routine to change field->ptr of a NULL-terminated array of Field
957
objects. Useful when needed to call val_int, val_str or similar and the
958
field data is not in table->record[0] but in some other structure.
959
set_key_field_ptr changes all fields of an index using a key_info object.
960
All methods presume that there is at least one field to change.
963
void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf);
964
void set_key_field_ptr(KEY *key_info, const uchar *new_buf,
965
const uchar *old_buf);
967
bool mysql_checksum_table(THD* thd, TABLE_LIST* table_list,
968
HA_CHECK_OPT* check_opt);
969
bool mysql_check_table(THD* thd, TABLE_LIST* table_list,
970
HA_CHECK_OPT* check_opt);
971
bool mysql_repair_table(THD* thd, TABLE_LIST* table_list,
972
HA_CHECK_OPT* check_opt);
973
bool mysql_analyze_table(THD* thd, TABLE_LIST* table_list,
974
HA_CHECK_OPT* check_opt);
975
bool mysql_optimize_table(THD* thd, TABLE_LIST* table_list,
976
HA_CHECK_OPT* check_opt);
977
bool mysql_assign_to_keycache(THD* thd, TABLE_LIST* table_list,
978
LEX_STRING *key_cache_name);
979
bool mysql_preload_keys(THD* thd, TABLE_LIST* table_list);
980
int reassign_keycache_tables(THD* thd, KEY_CACHE *src_cache,
981
KEY_CACHE *dst_cache);
982
TABLE *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
131
984
bool mysql_xa_recover(THD *thd);
133
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
986
bool check_simple_select();
988
SORT_FIELD * make_unireg_sortorder(ORDER *order, uint *length,
134
989
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,
990
int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
991
List<Item> &fields, List <Item> &all_fields, ORDER *order);
992
int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
993
List<Item> &fields, List<Item> &all_fields, ORDER *order,
139
994
bool *hidden_group_fields);
140
995
bool fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
141
996
Item **ref_pointer_array);
157
1012
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
158
1013
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,
1015
TABLE_LIST *table));
1016
bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *t);
1017
bool mysql_derived_filling(THD *thd, LEX *lex, TABLE_LIST *t);
1018
Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
164
1019
Item ***copy_func, Field **from_field,
165
1020
Field **def_field,
166
1021
bool group, bool modify_item,
167
1022
bool table_cant_handle_bit_fields,
168
1023
bool make_copy_field,
169
uint32_t convert_blob_length);
1024
uint convert_blob_length);
170
1025
void sp_prepare_create_field(THD *thd, Create_field *sql_field);
171
1026
int prepare_create_field(Create_field *sql_field,
172
uint32_t *blob_columns,
173
1028
int *timestamps, int *timestamps_with_niladic,
174
1029
int64_t table_flags);
175
1030
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
176
1031
HA_CREATE_INFO *create_info,
177
1032
Alter_info *alter_info,
178
bool tmp_table, uint32_t select_field_count);
1033
bool tmp_table, uint select_field_count);
179
1034
bool mysql_create_table_no_lock(THD *thd, const char *db,
180
1035
const char *table_name,
181
1036
HA_CREATE_INFO *create_info,
182
1037
Alter_info *alter_info,
183
bool tmp_table, uint32_t select_field_count,
184
bool lock_open_lock);
1038
bool tmp_table, uint select_field_count);
186
1040
bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
187
1041
HA_CREATE_INFO *create_info,
188
TableList *table_list,
1042
TABLE_LIST *table_list,
189
1043
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,
1044
uint order_num, ORDER *order, bool ignore);
1045
bool mysql_recreate_table(THD *thd, TABLE_LIST *table_list);
1046
bool mysql_create_like_table(THD *thd, TABLE_LIST *table,
1047
TABLE_LIST *src_table,
194
1048
HA_CREATE_INFO *create_info);
195
1049
bool mysql_rename_table(handlerton *base, const char *old_db,
196
1050
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,
1051
const char * new_name, uint flags);
1052
bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list,
1053
Item **conds, uint order_num, ORDER *order);
1054
int mysql_update(THD *thd,TABLE_LIST *tables,List<Item> &fields,
201
1055
List<Item> &values,COND *conds,
202
uint32_t order_num, order_st *order, ha_rows limit,
1056
uint order_num, ORDER *order, ha_rows limit,
203
1057
enum enum_duplicates handle_duplicates, bool ignore);
204
bool mysql_multi_update(THD *thd, TableList *table_list,
1058
bool mysql_multi_update(THD *thd, TABLE_LIST *table_list,
205
1059
List<Item> *fields, List<Item> *values,
206
1060
COND *conds, uint64_t options,
207
1061
enum enum_duplicates handle_duplicates, bool ignore,
208
1062
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
209
bool mysql_prepare_insert(THD *thd, TableList *table_list, Table *table,
1063
bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, TABLE *table,
210
1064
List<Item> &fields, List_item *values,
211
1065
List<Item> &update_fields,
212
1066
List<Item> &update_values, enum_duplicates duplic,
213
1067
COND **where, bool select_insert,
214
1068
bool check_fields, bool abort_on_warning);
215
bool mysql_insert(THD *thd,TableList *table,List<Item> &fields,
1069
bool mysql_insert(THD *thd,TABLE_LIST *table,List<Item> &fields,
216
1070
List<List_item> &values, List<Item> &update_fields,
217
1071
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,
1073
int check_that_all_fields_are_given_values(THD *thd, TABLE *entry,
1074
TABLE_LIST *table_list);
1075
void prepare_triggers_for_insert_stmt(TABLE *table);
1076
int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds);
1077
bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
224
1078
SQL_LIST *order, ha_rows rows, uint64_t options,
225
1079
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,
1080
bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok);
1081
bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create);
1082
uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list,
228
1083
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);
1084
TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key,
1085
uint key_length, uint db_flags, int *error);
231
1086
void release_table_share(TABLE_SHARE *share, enum release_type type);
232
1087
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);
1088
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
1090
TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT* mem,
1091
bool *refresh, uint flags);
1092
bool name_lock_locked_table(THD *thd, TABLE_LIST *tables);
1093
bool reopen_name_locked_table(THD* thd, TABLE_LIST* table_list, bool link_in);
1094
TABLE *table_cache_insert_placeholder(THD *thd, const char *key,
240
1096
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);
1097
const char *table_name, TABLE **table);
1098
TABLE *find_locked_table(THD *thd, const char *db,const char *table_name);
1099
void detach_merge_children(TABLE *table, bool clear_refs);
1100
bool fix_merge_after_open(TABLE_LIST *old_child_list, TABLE_LIST **old_last,
1101
TABLE_LIST *new_child_list, TABLE_LIST **new_last);
1102
bool reopen_table(TABLE *table);
247
1103
bool reopen_tables(THD *thd,bool get_locks,bool in_refresh);
248
1104
void close_data_files_and_morph_locks(THD *thd, const char *db,
249
1105
const char *table_name);
250
void close_handle_and_leave_table_as_lock(Table *table);
1106
void close_handle_and_leave_table_as_lock(TABLE *table);
251
1107
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);
1108
uint db_stat, uint prgflag,
1109
uint ha_open_flags, TABLE *outparam,
1110
TABLE_LIST *table_desc, MEM_ROOT *mem_root);
255
1111
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);
1112
bool table_is_used(TABLE *table, bool wait_for_name_lock);
1113
TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name);
258
1114
void abort_locked_tables(THD *thd,const char *db, const char *table_name);
259
1115
void execute_init_command(THD *thd, sys_var_str *init_command_var,
260
1116
rw_lock_t *var_mutex);
801
1858
const char *db, const char *table,
802
1859
HA_CREATE_INFO *create_info,
803
1860
List<Create_field> &create_field,
804
uint32_t key_count,KEY *key_info,handler *db_type);
1861
uint key_count,KEY *key_info,handler *db_type);
805
1862
int rea_create_table(THD *thd, const char *path,
806
1863
const char *db, const char *table_name,
807
1864
HA_CREATE_INFO *create_info,
808
1865
List<Create_field> &create_field,
809
uint32_t key_count,KEY *key_info,
1866
uint key_count,KEY *key_info,
811
int format_number(uint32_t inputflag,uint32_t max_length,char * pos,uint32_t length,
1868
int format_number(uint inputflag,uint max_length,char * pos,uint length,
812
1869
char * *errpos);
815
TABLE_SHARE *alloc_table_share(TableList *table_list, char *key,
816
uint32_t key_length);
1872
TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key,
817
1874
void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
819
1876
const char *table_name, const char *path);
820
1877
void free_table_share(TABLE_SHARE *share);
821
int open_table_def(THD *thd, TABLE_SHARE *share, uint32_t db_flags);
1878
int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags);
822
1879
void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
823
1880
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);
1881
uint db_stat, uint prgflag, uint ha_open_flags,
1882
TABLE *outparam, open_table_mode open_mode);
1883
int readfrm(const char *name, uchar **data, size_t *length);
1884
int writefrm(const char* name, const uchar* data, size_t len);
1885
int closefrm(TABLE *table, bool free_share);
1886
int read_string(File file, uchar* *to, size_t length);
1887
void free_blobs(TABLE *table);
831
1888
int set_zone(int nr,int min_zone,int max_zone);
832
1889
ulong convert_period_to_month(ulong period);
833
1890
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);
1891
void get_date_from_daynr(long daynr,uint *year, uint *month,
1893
my_time_t TIME_to_timestamp(THD *thd, const MYSQL_TIME *t, bool *not_exist);
1894
bool str_to_time_with_warn(const char *str,uint length,MYSQL_TIME *l_time);
1895
timestamp_type str_to_datetime_with_warn(const char *str, uint length,
1896
MYSQL_TIME *l_time, uint flags);
1897
void localtime_to_TIME(MYSQL_TIME *to, struct tm *from);
1898
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,
1900
void make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,
844
1901
const char *str_val,
845
uint32_t str_length, enum enum_drizzle_timestamp_type time_type,
1902
uint str_length, timestamp_type time_type,
846
1903
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,
1905
bool date_add_interval(MYSQL_TIME *ltime, interval_type int_type, INTERVAL interval);
1906
bool calc_time_diff(MYSQL_TIME *l_time1, MYSQL_TIME *l_time2, int l_sign,
850
1907
int64_t *seconds_out, long *microseconds_out);
852
1909
extern LEX_STRING interval_type_to_name[];
854
extern DATE_TIME_FORMAT *date_time_format_make(enum enum_drizzle_timestamp_type format_type,
1911
extern DATE_TIME_FORMAT *date_time_format_make(timestamp_type format_type,
855
1912
const char *format_str,
856
uint32_t format_length);
1913
uint format_length);
857
1914
extern DATE_TIME_FORMAT *date_time_format_copy(THD *thd,
858
1915
DATE_TIME_FORMAT *format);
859
1916
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,
1917
timestamp_type type);
1918
extern bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
1919
timestamp_type type, String *str);
1920
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);
1922
void make_date(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
1924
void make_time(const DATE_TIME_FORMAT *format, const MYSQL_TIME *l_time,
1926
int my_time_compare(MYSQL_TIME *a, MYSQL_TIME *b);
870
1927
uint64_t get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
871
1928
Item *warn_item, bool *is_null);
873
1930
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,
1931
void change_byte(uchar *,uint,char,char);
1932
void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
876
1933
SQL_SELECT *select,
877
1934
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);
1935
void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
1936
bool print_error, uint idx);
880
1937
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,
1938
ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder,
1939
uint s_length, SQL_SELECT *select,
883
1940
ha_rows max_rows, bool sort_positions,
884
1941
ha_rows *examined_rows);
885
void filesort_free_buffers(Table *table, bool full);
886
void change_double_for_sort(double nr,unsigned char *to);
1942
void filesort_free_buffers(TABLE *table, bool full);
1943
void change_double_for_sort(double nr,uchar *to);
887
1944
double my_double_round(double value, int64_t dec, bool dec_unsigned,
889
1946
int get_quick_record(SQL_SELECT *select);
891
1948
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);
1949
uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year);
1950
void find_date(char *pos,uint *vek,uint flag);
894
1951
TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end);
895
1952
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,
1953
ulong get_form_pos(File file, uchar *head, TYPELIB *save_names);
1954
ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames,
898
1955
const char *newname);
899
1956
ulong next_io_size(ulong pos);
900
void append_unescaped(String *res, const char *pos, uint32_t length);
1957
void append_unescaped(String *res, const char *pos, uint length);
901
1958
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);
1959
uint reclength, uchar *fileinfo,
1960
HA_CREATE_INFO *create_info, uint keys, KEY *key_info);
1961
void update_create_info_from_table(HA_CREATE_INFO *info, TABLE *form);
904
1962
int rename_file_ext(const char * from,const char * to,const char * ext);
905
1963
bool check_db_name(LEX_STRING *db);
906
1964
bool check_column_name(const char *name);
907
bool check_table_name(const char *name, uint32_t length);
1965
bool check_table_name(const char *name, uint length);
908
1966
char *get_field(MEM_ROOT *mem, Field *field);
909
1967
bool get_field(MEM_ROOT *mem, Field *field, class String *res);
910
1968
char *fn_rext(char *name);
912
1970
/* 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);
1971
#endif /* MYSQL_SERVER */
1972
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS
1973
uint strconvert(CHARSET_INFO *from_cs, const char *from,
1974
CHARSET_INFO *to_cs, char *to, uint to_length, uint *errors);
1975
uint filename_to_tablename(const char *from, char *to, uint to_length);
1976
uint tablename_to_filename(const char *from, char *to, uint to_length);
1977
#endif /* MYSQL_SERVER || INNODB_COMPATIBILITY_HOOKS */
1979
uint build_table_filename(char *buff, size_t bufflen, const char *db,
1980
const char *table, const char *ext, uint flags);
916
1982
#define MYSQL50_TABLE_NAME_PREFIX "#mysql50#"
917
1983
#define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9