24
24
Mostly this file is used in the server. But a little part of it is used in
25
mysqlbinlog too (definition of SELECT_DISTINCT and others).
26
The consequence is that 90% of the file is wrapped in \#ifndef DRIZZLE_CLIENT,
27
except the part which must be in the server and in the client.
25
definition of SELECT_DISTINCT and others.
29
27
@TODO Name this file better. "priv" could mean private, privileged, privileges.
32
#ifndef DRIZZLE_SERVER_SERVER_INCLUDES_H
33
#define DRIZZLE_SERVER_SERVER_INCLUDES_H
35
/* Some forward declarations just for the server */
38
typedef Comp_creator* (*chooser_compare_func_creator)(bool invert);
41
* Contains all headers, definitions, and declarations common to
42
* the server and the plugin infrastructure, and not the client
44
#include <drizzled/common_includes.h>
30
#ifndef DRIZZLED_SERVER_INCLUDES_H
31
#define DRIZZLED_SERVER_INCLUDES_H
33
/* Cross-platform portability code and standard includes */
34
#include <drizzled/global.h>
35
/* Contains system-wide constants and #defines */
36
#include <drizzled/definitions.h>
38
/* Lots of system-wide struct definitions like IO_CACHE,
39
prototypes for all my_* functions */
40
#include <mysys/my_sys.h>
41
/* Custom C string functions */
42
#include <mystrings/m_string.h>
44
/* The <strong>INTERNAL</strong> plugin API - not the external, or public, server plugin API */
45
#include <drizzled/sql_plugin.h>
45
46
/* Range optimization API/library */
46
47
#include <drizzled/opt_range.h>
47
48
/* Simple error injection (crash) module */
48
49
#include <drizzled/error_injection.h>
49
/* API for connecting, logging in to a drizzled server */
50
#include <drizzled/connect.h>
51
50
/* Routines for dropping, repairing, checking schema tables */
52
51
#include <drizzled/sql_table.h>
55
int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create, bool silent);
56
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
57
bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
58
bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name,
60
bool mysql_opt_change_db(THD *thd,
61
const LEX_STRING *new_db_name,
62
LEX_STRING *saved_db_name,
64
bool *cur_db_changed);
67
void write_bin_log(THD *thd, bool clear_error,
68
char const *query, ulong query_length);
69
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, uint16_t flags);
70
void mysql_client_binlog_statement(THD *thd);
73
bool mysql_rename_tables(THD *thd, TableList *table_list, bool silent);
74
bool do_rename(THD *thd, TableList *ren_table, char *new_db,
75
char *new_table_name, char *new_table_alias,
79
void mysql_parse(THD *thd, const char *inBuf, uint32_t length,
80
const char ** semicolon);
82
bool mysql_test_parse_for_slave(THD *thd,char *inBuf,uint32_t length);
85
bool is_update_query(enum enum_sql_command command);
87
bool alloc_query(THD *thd, const char *packet, uint32_t packet_length);
89
void mysql_reset_thd_for_next_command(THD *thd);
91
void create_select_for_variable(const char *var_name);
93
void mysql_init_multi_delete(LEX *lex);
95
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
97
void init_update_queries(void);
99
bool do_command(THD *thd);
101
bool dispatch_command(enum enum_server_command command, THD *thd,
102
char* packet, uint32_t packet_length);
104
void log_slow_statement(THD *thd);
106
bool append_file_to_dir(THD *thd, const char **filename_ptr,
107
const char *table_name);
109
bool reload_cache(THD *thd, ulong options, TableList *tables, bool *write_to_binlog);
111
bool check_simple_select();
114
void mysql_init_select(LEX *lex);
115
bool mysql_new_select(LEX *lex, bool move_down);
116
void init_max_user_conn(void);
117
void free_max_user_conn(void);
118
pthread_handler_t handle_bootstrap(void *arg);
119
int mysql_execute_command(THD *thd);
120
bool check_dup(const char *db, const char *name, TableList *tables);
121
bool check_table_access(THD *thd, ulong want_access, TableList *tables,
123
bool any_combination_of_privileges_will_do,
126
General routine to change field->ptr of a NULL-terminated array of Field
127
objects. Useful when needed to call val_int, val_str or similar and the
128
field data is not in table->record[0] but in some other structure.
129
set_key_field_ptr changes all fields of an index using a key_info object.
130
All methods presume that there is at least one field to change.
132
void set_field_ptr(Field **ptr, const unsigned char *new_buf, const unsigned char *old_buf);
133
void set_key_field_ptr(KEY *key_info, const unsigned char *new_buf,
134
const unsigned char *old_buf);
138
void table_cache_free(void);
139
bool table_cache_init(void);
140
bool table_def_init(void);
141
void table_def_free(void);
142
void assign_new_table_id(TABLE_SHARE *share);
143
uint32_t cached_open_tables(void);
144
uint32_t cached_table_definitions(void);
147
void kill_mysql(void);
148
void close_connection(THD *thd, uint32_t errcode, bool lock);
151
Table *create_virtual_tmp_table(THD *thd, List<Create_field> &field_list);
154
bool mysql_xa_recover(THD *thd);
156
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
157
SORT_FIELD *sortorder);
158
int setup_order(THD *thd, Item **ref_pointer_array, TableList *tables,
159
List<Item> &fields, List <Item> &all_fields, order_st *order);
160
int setup_group(THD *thd, Item **ref_pointer_array, TableList *tables,
161
List<Item> &fields, List<Item> &all_fields, order_st *order,
162
bool *hidden_group_fields);
163
bool fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
164
Item **ref_pointer_array);
166
bool handle_select(THD *thd, LEX *lex, select_result *result,
167
ulong setup_tables_done_option);
168
bool mysql_select(THD *thd, Item ***rref_pointer_array,
169
TableList *tables, uint32_t wild_num, List<Item> &list,
170
COND *conds, uint32_t og_num, order_st *order, order_st *group,
171
Item *having, order_st *proc_param, uint64_t select_type,
172
select_result *result, SELECT_LEX_UNIT *unit,
173
SELECT_LEX *select_lex);
174
void free_underlaid_joins(THD *thd, SELECT_LEX *select);
175
bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit,
176
select_result *result);
177
int mysql_explain_select(THD *thd, SELECT_LEX *sl, char const *type,
178
select_result *result);
179
bool mysql_union(THD *thd, LEX *lex, select_result *result,
180
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
181
bool mysql_handle_derived(LEX *lex, bool (*processor)(THD *thd,
184
bool mysql_derived_prepare(THD *thd, LEX *lex, TableList *t);
185
bool mysql_derived_filling(THD *thd, LEX *lex, TableList *t);
186
Field *create_tmp_field(THD *thd, Table *table,Item *item, Item::Type type,
187
Item ***copy_func, Field **from_field,
189
bool group, bool modify_item,
190
bool table_cant_handle_bit_fields,
191
bool make_copy_field,
192
uint32_t convert_blob_length);
193
void sp_prepare_create_field(THD *thd, Create_field *sql_field);
194
int prepare_create_field(Create_field *sql_field,
195
uint32_t *blob_columns,
196
int *timestamps, int *timestamps_with_niladic,
197
int64_t table_flags);
198
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
199
HA_CREATE_INFO *create_info,
200
Alter_info *alter_info,
201
bool tmp_table, uint32_t select_field_count);
202
bool mysql_create_table_no_lock(THD *thd, const char *db,
203
const char *table_name,
204
HA_CREATE_INFO *create_info,
205
Alter_info *alter_info,
206
bool tmp_table, uint32_t select_field_count);
208
bool mysql_alter_table(THD *thd, char *new_db, char *new_name,
209
HA_CREATE_INFO *create_info,
210
TableList *table_list,
211
Alter_info *alter_info,
212
uint32_t order_num, order_st *order, bool ignore);
213
bool mysql_recreate_table(THD *thd, TableList *table_list);
214
bool mysql_create_like_table(THD *thd, TableList *table,
215
TableList *src_table,
216
HA_CREATE_INFO *create_info);
217
bool mysql_rename_table(handlerton *base, const char *old_db,
218
const char * old_name, const char *new_db,
219
const char * new_name, uint32_t flags);
220
bool mysql_prepare_update(THD *thd, TableList *table_list,
221
Item **conds, uint32_t order_num, order_st *order);
222
int mysql_update(THD *thd,TableList *tables,List<Item> &fields,
223
List<Item> &values,COND *conds,
224
uint32_t order_num, order_st *order, ha_rows limit,
225
enum enum_duplicates handle_duplicates, bool ignore);
226
bool mysql_multi_update(THD *thd, TableList *table_list,
227
List<Item> *fields, List<Item> *values,
228
COND *conds, uint64_t options,
229
enum enum_duplicates handle_duplicates, bool ignore,
230
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
231
bool mysql_prepare_insert(THD *thd, TableList *table_list, Table *table,
232
List<Item> &fields, List_item *values,
233
List<Item> &update_fields,
234
List<Item> &update_values, enum_duplicates duplic,
235
COND **where, bool select_insert,
236
bool check_fields, bool abort_on_warning);
237
bool mysql_insert(THD *thd,TableList *table,List<Item> &fields,
238
List<List_item> &values, List<Item> &update_fields,
239
List<Item> &update_values, enum_duplicates flag,
241
int check_that_all_fields_are_given_values(THD *thd, Table *entry,
242
TableList *table_list);
243
void prepare_triggers_for_insert_stmt(Table *table);
244
int mysql_prepare_delete(THD *thd, TableList *table_list, Item **conds);
245
bool mysql_delete(THD *thd, TableList *table_list, COND *conds,
246
SQL_LIST *order, ha_rows rows, uint64_t options,
247
bool reset_auto_increment);
248
bool mysql_truncate(THD *thd, TableList *table_list, bool dont_send_ok);
249
uint32_t create_table_def_key(THD *thd, char *key, TableList *table_list,
251
TABLE_SHARE *get_table_share(THD *thd, TableList *table_list, char *key,
252
uint32_t key_length, uint32_t db_flags, int *error);
253
void release_table_share(TABLE_SHARE *share, enum release_type type);
254
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
255
Table *open_ltable(THD *thd, TableList *table_list, thr_lock_type update,
256
uint32_t lock_flags);
257
Table *open_table(THD *thd, TableList *table_list, bool *refresh, uint32_t flags);
258
bool name_lock_locked_table(THD *thd, TableList *tables);
259
bool reopen_name_locked_table(THD* thd, TableList* table_list, bool link_in);
260
Table *table_cache_insert_placeholder(THD *thd, const char *key,
261
uint32_t key_length);
262
bool lock_table_name_if_not_cached(THD *thd, const char *db,
263
const char *table_name, Table **table);
264
Table *find_locked_table(THD *thd, const char *db,const char *table_name);
265
void detach_merge_children(Table *table, bool clear_refs);
266
bool fix_merge_after_open(TableList *old_child_list, TableList **old_last,
267
TableList *new_child_list, TableList **new_last);
268
bool reopen_table(Table *table);
269
bool reopen_tables(THD *thd,bool get_locks,bool in_refresh);
270
void close_data_files_and_morph_locks(THD *thd, const char *db,
271
const char *table_name);
272
void close_handle_and_leave_table_as_lock(Table *table);
273
bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
274
uint32_t db_stat, uint32_t prgflag,
275
uint32_t ha_open_flags, Table *outparam,
276
TableList *table_desc, MEM_ROOT *mem_root);
277
bool wait_for_tables(THD *thd);
278
bool table_is_used(Table *table, bool wait_for_name_lock);
279
Table *drop_locked_tables(THD *thd,const char *db, const char *table_name);
280
void abort_locked_tables(THD *thd,const char *db, const char *table_name);
281
void execute_init_command(THD *thd, sys_var_str *init_command_var,
282
rw_lock_t *var_mutex);
283
extern Field *not_found_field;
284
extern Field *view_ref_found;
286
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
287
IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
288
IGNORE_EXCEPT_NON_UNIQUE};
290
find_field_in_tables(THD *thd, Item_ident *item,
291
TableList *first_table, TableList *last_table,
292
Item **ref, find_item_error_report_type report_error,
293
bool check_privileges, bool register_tree_change);
295
find_field_in_table_ref(THD *thd, TableList *table_list,
296
const char *name, uint32_t length,
297
const char *item_name, const char *db_name,
298
const char *table_name, Item **ref,
299
bool check_privileges, bool allow_rowid,
300
uint32_t *cached_field_index_ptr,
301
bool register_tree_change, TableList **actual_table);
303
find_field_in_table(THD *thd, Table *table, const char *name, uint32_t length,
304
bool allow_rowid, uint32_t *cached_field_index_ptr);
306
find_field_in_table_sef(Table *table, const char *name);
309
bool mysql_do(THD *thd, List<Item> &values);
312
bool append_escaped(String *to_str, String *from_str);
314
#include <drizzled/show.h>
53
/* Routines for printing error messages */
54
#include <drizzled/errmsg_print.h>
61
extern const CHARSET_INFO *system_charset_info, *files_charset_info ;
62
extern const CHARSET_INFO *national_charset_info, *table_alias_charset;
64
typedef struct drizzled_lock_st DRIZZLE_LOCK;
65
typedef struct st_ha_create_information HA_CREATE_INFO;
316
67
/* information schema */
317
extern LEX_STRING INFORMATION_SCHEMA_NAME;
319
extern LEX_STRING DRIZZLE_SCHEMA_NAME;
320
extern LEX_STRING GENERAL_LOG_NAME;
321
extern LEX_STRING SLOW_LOG_NAME;
323
extern const LEX_STRING partition_keywords[];
324
ST_SCHEMA_TABLE *find_schema_table(THD *thd, const char* table_name);
325
ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
326
int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
327
enum enum_schema_tables schema_table_idx);
328
int make_schema_select(THD *thd, SELECT_LEX *sel,
329
enum enum_schema_tables schema_table_idx);
330
int mysql_schema_table(THD *thd, LEX *lex, TableList *table_list);
331
bool get_schema_tables_result(JOIN *join,
332
enum enum_schema_table_state executed_place);
333
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
335
#define is_schema_db(X) \
336
!my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))
339
bool mysql_ha_open(THD *thd, TableList *tables, bool reopen);
340
bool mysql_ha_close(THD *thd, TableList *tables);
341
bool mysql_ha_read(THD *, TableList *,enum enum_ha_read_modes,char *,
342
List<Item> *,enum ha_rkey_function,Item *,ha_rows,ha_rows);
343
void mysql_ha_flush(THD *thd);
344
void mysql_ha_rm_tables(THD *thd, TableList *tables, bool is_locked);
345
void mysql_ha_cleanup(THD *thd);
348
#define TMP_TABLE_KEY_EXTRA 8
349
void set_item_name(Item *item,char *pos,uint32_t length);
350
bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum enum_field_types type,
351
char *length, char *decimal,
352
uint32_t type_modifier,
353
enum column_format_type column_format,
354
Item *default_value, Item *on_update_value,
356
char *change, List<String> *interval_list,
357
const CHARSET_INFO * const cs);
358
Create_field * new_create_field(THD *thd, char *field_name, enum_field_types type,
359
char *length, char *decimals,
360
uint32_t type_modifier,
361
Item *default_value, Item *on_update_value,
362
LEX_STRING *comment, char *change,
363
List<String> *interval_list, CHARSET_INFO *cs);
364
void store_position_for_column(const char *name);
365
bool add_to_list(THD *thd, SQL_LIST &list,Item *group,bool asc);
366
bool push_new_name_resolution_context(THD *thd,
368
TableList *right_op);
369
void add_join_on(TableList *b,Item *expr);
370
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
372
bool add_proc_to_list(THD *thd, Item *item);
373
void unlink_open_table(THD *thd, Table *find, bool unlock);
374
void drop_open_table(THD *thd, Table *table, const char *db_name,
375
const char *table_name);
376
void update_non_unique_table_error(TableList *update,
377
const char *operation,
378
TableList *duplicate);
380
SQL_SELECT *make_select(Table *head, table_map const_tables,
381
table_map read_tables, COND *conds,
382
bool allow_null_cond, int *error);
383
extern Item **not_found_item;
386
A set of constants used for checking non aggregated fields and sum
387
functions mixture in the ONLY_FULL_GROUP_BY_MODE.
389
#define NON_AGG_FIELD_USED 1
390
#define SUM_FUNC_USED 2
393
This enumeration type is used only by the function find_item_in_list
394
to return the info on how an item has been resolved against a list
395
of possibly aliased items.
396
The item can be resolved:
397
- against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
398
- against non-aliased field name of the list (RESOLVED_WITH_NO_ALIAS)
399
- against an aliased field name of the list (RESOLVED_BEHIND_ALIAS)
400
- ignoring the alias name in cases when SQL requires to ignore aliases
401
(e.g. when the resolved field reference contains a table name or
402
when the resolved item is an expression) (RESOLVED_IGNORING_ALIAS)
404
enum enum_resolution_type {
406
RESOLVED_IGNORING_ALIAS,
407
RESOLVED_BEHIND_ALIAS,
408
RESOLVED_WITH_NO_ALIAS,
409
RESOLVED_AGAINST_ALIAS
411
Item ** find_item_in_list(Item *item, List<Item> &items, uint32_t *counter,
412
find_item_error_report_type report_error,
413
enum_resolution_type *resolution);
414
bool get_key_map_from_key_list(key_map *map, Table *table,
415
List<String> *index_list);
416
bool insert_fields(THD *thd, Name_resolution_context *context,
417
const char *db_name, const char *table_name,
418
List_iterator<Item> *it, bool any_privileges);
419
bool setup_tables(THD *thd, Name_resolution_context *context,
420
List<TableList> *from_clause, TableList *tables,
421
TableList **leaves, bool select_insert);
422
bool setup_tables_and_check_access(THD *thd,
423
Name_resolution_context *context,
424
List<TableList> *from_clause,
428
int setup_wild(THD *thd, TableList *tables, List<Item> &fields,
429
List<Item> *sum_func_list, uint32_t wild_num);
430
bool setup_fields(THD *thd, Item** ref_pointer_array,
431
List<Item> &item, enum_mark_columns mark_used_columns,
432
List<Item> *sum_func_list, bool allow_sum_func);
433
inline bool setup_fields_with_no_wrap(THD *thd, Item **ref_pointer_array,
435
enum_mark_columns mark_used_columns,
436
List<Item> *sum_func_list,
440
res= setup_fields(thd, ref_pointer_array, item, mark_used_columns, sum_func_list,
444
int setup_conds(THD *thd, TableList *tables, TableList *leaves,
446
int setup_ftfuncs(SELECT_LEX* select);
447
int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order);
448
void wait_for_condition(THD *thd, pthread_mutex_t *mutex,
449
pthread_cond_t *cond);
450
int open_tables(THD *thd, TableList **tables, uint32_t *counter, uint32_t flags);
451
/* open_and_lock_tables with optional derived handling */
452
int open_and_lock_tables_derived(THD *thd, TableList *tables, bool derived);
453
/* simple open_and_lock_tables without derived handling */
454
inline int simple_open_n_lock_tables(THD *thd, TableList *tables)
456
return open_and_lock_tables_derived(thd, tables, false);
458
/* open_and_lock_tables with derived handling */
459
inline int open_and_lock_tables(THD *thd, TableList *tables)
461
return open_and_lock_tables_derived(thd, tables, true);
463
/* simple open_and_lock_tables without derived handling for single table */
464
Table *open_n_lock_single_table(THD *thd, TableList *table_l,
465
thr_lock_type lock_type);
466
bool open_normal_and_derived_tables(THD *thd, TableList *tables, uint32_t flags);
467
int lock_tables(THD *thd, TableList *tables, uint32_t counter, bool *need_reopen);
468
int decide_logging_format(THD *thd, TableList *tables);
469
Table *open_temporary_table(THD *thd, const char *path, const char *db,
470
const char *table_name, bool link_in_list,
471
open_table_mode open_mode);
472
bool rm_temporary_table(handlerton *base, char *path, bool frm_only);
473
void free_io_cache(Table *entry);
474
void intern_close_table(Table *entry);
475
bool close_thread_table(THD *thd, Table **table_ptr);
476
void close_temporary_tables(THD *thd);
477
void close_tables_for_reopen(THD *thd, TableList **tables);
478
TableList *find_table_in_list(TableList *table,
479
TableList *TableList::*link,
481
const char *table_name);
482
TableList *unique_table(THD *thd, TableList *table, TableList *table_list,
484
Table *find_temporary_table(THD *thd, const char *db, const char *table_name);
485
Table *find_temporary_table(THD *thd, TableList *table_list);
486
int drop_temporary_table(THD *thd, TableList *table_list);
487
void close_temporary_table(THD *thd, Table *table, bool free_share,
489
void close_temporary(Table *table, bool free_share, bool delete_table);
490
bool rename_temporary_table(THD* thd, Table *table, const char *new_db,
491
const char *table_name);
492
void remove_db_from_cache(const char *db);
494
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
495
char *make_default_log_name(char *buff,const char* log_ext);
497
/* bits for last argument to remove_table_from_cache() */
498
#define RTFC_NO_FLAG 0x0000
499
#define RTFC_OWNED_BY_THD_FLAG 0x0001
500
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
501
#define RTFC_CHECK_KILLED_FLAG 0x0004
502
bool remove_table_from_cache(THD *thd, const char *db, const char *table,
505
#define NORMAL_PART_NAME 0
506
#define TEMP_PART_NAME 1
507
#define RENAMED_PART_NAME 2
509
void mem_alloc_error(size_t size);
511
#define WFRM_WRITE_SHADOW 1
512
#define WFRM_INSTALL_SHADOW 2
513
#define WFRM_PACK_FRM 4
514
#define WFRM_KEEP_SHARE 8
516
bool close_cached_tables(THD *thd, TableList *tables, bool have_lock,
517
bool wait_for_refresh, bool wait_for_placeholders);
518
bool close_cached_connection_tables(THD *thd, bool wait_for_refresh,
519
LEX_STRING *connect_string,
520
bool have_lock= false);
521
void copy_field_from_tmp_record(Field *field,int offset);
522
bool fill_record(THD * thd, List<Item> &fields, List<Item> &values, bool ignore_errors);
523
bool fill_record(THD *thd, Field **field, List<Item> &values, bool ignore_errors);
524
OPEN_TableList *list_open_tables(THD *thd, const char *db, const char *wild);
526
inline TableList *find_table_in_global_list(TableList *table,
528
const char *table_name)
530
return find_table_in_list(table, &TableList::next_global,
531
db_name, table_name);
534
inline TableList *find_table_in_local_list(TableList *table,
536
const char *table_name)
538
return find_table_in_list(table, &TableList::next_local,
539
db_name, table_name);
544
bool eval_const_cond(COND *cond);
547
int mysql_load(THD *thd, sql_exchange *ex, TableList *table_list,
548
List<Item> &fields_vars, List<Item> &set_fields,
549
List<Item> &set_values_list,
550
enum enum_duplicates handle_duplicates, bool ignore,
552
int write_record(THD *thd, Table *table, COPY_INFO *info);
556
void print_where(COND *cond,const char *info, enum_query_type query_type);
557
void print_cached_tables(void);
558
void TEST_filesort(SORT_FIELD *sortorder,uint32_t s_length);
559
void print_plan(JOIN* join,uint32_t idx, double record_count, double read_time,
560
double current_read_time, const char *info);
561
void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array);
562
void dump_TableList_graph(SELECT_LEX *select_lex, TableList* tl);
563
void mysql_print_status();
566
int find_ref_key(KEY *key, uint32_t key_count, unsigned char *record, Field *field,
567
uint32_t *key_length, uint32_t *keypart);
568
void key_copy(unsigned char *to_key, unsigned char *from_record, KEY *key_info, uint32_t key_length);
569
void key_restore(unsigned char *to_record, unsigned char *from_key, KEY *key_info,
570
uint16_t key_length);
571
void key_zero_nulls(unsigned char *tuple, KEY *key_info);
572
bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
573
void key_unpack(String *to,Table *form,uint32_t index);
574
bool is_key_used(Table *table, uint32_t idx, const MY_BITMAP *fields);
575
int key_cmp(KEY_PART_INFO *key_part, const unsigned char *key, uint32_t key_length);
576
extern "C" int key_rec_cmp(void *key_info, unsigned char *a, unsigned char *b);
578
bool init_errmessage(void);
579
File open_binlog(IO_CACHE *log, const char *log_file_name,
580
const char **errmsg);
68
static const std::string INFORMATION_SCHEMA_NAME("information_schema");
583
extern void MYSQLerror(const char*);
584
void refresh_status(THD *thd);
585
bool mysql_rm_tmp_tables(void);
586
void handle_connection_in_main_thread(THD *thd);
587
void create_thread_to_handle_connection(THD *thd);
588
void unlink_thd(THD *thd);
589
bool one_thread_per_connection_end(THD *thd, bool put_in_cache);
590
void flush_thread_cache();
73
void refresh_status(Session *session);
74
bool drizzle_rm_tmp_tables(void);
75
void unlink_session(Session *session);
592
77
/* item_func.cc */
593
78
extern bool check_reserved_words(LEX_STRING *name);
607
92
const CHARSET_INFO * const cs);
610
bool is_keyword(const char *name, uint32_t len);
612
#define MY_DB_OPT_FILE "db.opt"
613
bool my_database_names_init(void);
614
void my_database_names_free(void);
615
bool check_db_dir_existence(const char *db_name);
616
bool load_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create);
617
bool load_db_opt_by_name(THD *thd, const char *db_name,
618
HA_CREATE_INFO *db_create_info);
619
const CHARSET_INFO *get_default_db_collation(THD *thd, const char *db_name);
620
bool my_dbopt_init(void);
621
void my_dbopt_cleanup(void);
622
extern int creating_database; // How many database locks are made
623
extern int creating_table; // How many mysql_create_table() are running
626
96
External variables
629
extern time_t server_start_time, flush_status_time;
630
extern char *opt_mysql_tmpdir;
632
#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
633
extern MY_TMPDIR mysql_tmpdir_list;
99
extern char *drizzle_tmpdir;
634
100
extern const LEX_STRING command_name[];
635
101
extern const char *first_keyword, *my_localhost, *delayed_user, *binary_keyword;
636
102
extern const char *myisam_recover_options_str;
637
103
extern const char *in_left_expr_name, *in_additional_cond, *in_having_cond;
638
104
extern const char * const TRG_EXT;
639
105
extern const char * const TRN_EXT;
640
extern Eq_creator eq_creator;
641
extern Ne_creator ne_creator;
642
extern Gt_creator gt_creator;
643
extern Lt_creator lt_creator;
644
extern Ge_creator ge_creator;
645
extern Le_creator le_creator;
646
106
extern char language[FN_REFLEN];
647
extern char glob_hostname[FN_REFLEN], mysql_home[FN_REFLEN];
648
extern char pidfile_name[FN_REFLEN], system_time_zone[30], *opt_init_file;
649
extern char log_error_file[FN_REFLEN], *opt_tc_log_file;
107
extern char glob_hostname[FN_REFLEN], drizzle_home[FN_REFLEN];
108
extern char pidfile_name[FN_REFLEN], system_time_zone[30];
109
extern char *opt_tc_log_file;
650
110
extern const double log_10[309];
651
111
extern uint64_t log_10_int[20];
652
112
extern uint64_t keybuff_size;
653
extern uint64_t thd_startup_options;
654
extern ulong thread_id;
655
extern ulong binlog_cache_use, binlog_cache_disk_use;
656
extern ulong aborted_threads,aborted_connects;
657
extern ulong slave_open_temp_tables;
658
extern ulong slow_launch_threads, slow_launch_time;
659
extern ulong table_cache_size, table_def_size;
660
extern ulong max_connections,max_connect_errors, connect_timeout;
661
extern bool slave_allow_batching;
662
extern ulong slave_net_timeout, slave_trans_retries;
663
extern uint32_t max_user_connections;
664
extern ulong what_to_log,flush_time;
665
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
666
extern ulong max_binlog_size, max_relay_log_size;
667
extern ulong opt_binlog_rows_event_max_size;
668
extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
669
extern ulong back_log;
670
extern ulong current_pid;
671
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
672
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
673
extern ulong tc_log_page_waits;
674
extern bool relay_log_purge;
675
extern bool opt_innodb_safe_binlog, opt_innodb;
113
extern uint64_t session_startup_options;
114
extern uint32_t thread_id;
115
extern uint64_t aborted_threads;
116
extern uint64_t aborted_connects;
117
extern uint64_t slow_launch_threads;
118
extern uint64_t table_cache_size;
119
extern uint64_t table_def_size;
120
extern uint64_t max_connect_errors;
121
extern uint32_t connect_timeout;
122
extern uint32_t back_log;
123
extern pid_t current_pid;
124
extern uint64_t expire_logs_days;
125
extern uint64_t tc_log_max_pages_used;
126
extern uint64_t tc_log_page_size;
127
extern uint64_t opt_tc_log_size;
128
extern uint64_t tc_log_page_waits;
129
extern bool opt_innodb;
676
130
extern uint32_t test_flags,select_errors,ha_open_options;
677
extern uint32_t protocol_version, mysqld_port, dropping_tables;
131
extern uint32_t protocol_version, drizzled_port, dropping_tables;
678
132
extern uint32_t delay_key_write_options;
679
133
extern bool opt_endinfo, using_udf_functions;
680
134
extern bool locked_in_memory;
681
extern bool opt_using_transactions;
682
135
extern bool using_update_log, server_id_supplied;
683
extern bool opt_update_log, opt_bin_log, opt_error_log;
685
extern bool opt_slow_log;
686
137
extern ulong log_output_options;
687
extern bool opt_log_queries_not_using_indexes;
688
138
extern bool opt_character_set_client_handshake;
689
139
extern bool volatile abort_loop, shutdown_in_progress;
690
extern uint32_t volatile thread_count, thread_running, global_read_lock;
691
extern uint32_t connection_count;
692
extern bool opt_sql_bin_update;
140
extern uint32_t volatile thread_running, global_read_lock;
693
141
extern bool opt_safe_user_create;
694
142
extern bool opt_no_mix_types;
695
143
extern bool opt_safe_show_db, opt_myisam_use_mmap;
696
extern bool opt_local_infile;
697
extern bool opt_slave_compressed_protocol;
698
144
extern bool use_temp_pool;
699
extern ulong slave_exec_mode_options;
700
145
extern bool opt_readonly;
701
extern bool opt_secure_auth;
702
146
extern char* opt_secure_file_priv;
703
extern bool opt_log_slow_admin_statements;
704
extern bool opt_log_slow_slave_statements;
705
147
extern bool opt_noacl;
706
148
extern bool opt_old_style_user_limits;
707
extern uint32_t opt_crash_binlog_innodb;
708
149
extern char *default_tz_name;
709
extern char *opt_logname, *opt_slow_logname;
710
extern const char *log_output_str;
150
extern char *opt_logname;
712
extern DRIZZLE_BIN_LOG mysql_bin_log;
713
extern LOGGER logger;
714
152
extern TableList general_log, slow_log;
715
153
extern FILE *stderror_file;
716
extern pthread_key(MEM_ROOT**,THR_MALLOC);
717
extern pthread_mutex_t LOCK_mysql_create_db,LOCK_open, LOCK_lock_db,
154
extern pthread_mutex_t LOCK_create_db,LOCK_open, LOCK_lock_db,
718
155
LOCK_thread_count,LOCK_user_locks, LOCK_status,
719
LOCK_error_log, LOCK_uuid_generator,
720
LOCK_crypt, LOCK_timezone,
721
LOCK_slave_list, LOCK_active_mi, LOCK_global_read_lock,
722
LOCK_global_system_variables, LOCK_user_conn,
723
LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
724
extern pthread_mutex_t LOCK_server_started;
725
extern rw_lock_t LOCK_sys_init_connect, LOCK_sys_init_slave;
726
extern rw_lock_t LOCK_system_variables_hash;
727
extern pthread_cond_t COND_refresh, COND_thread_count, COND_manager;
156
LOCK_global_read_lock,
157
LOCK_global_system_variables;
159
extern pthread_rwlock_t LOCK_system_variables_hash;
160
extern pthread_cond_t COND_refresh, COND_thread_count;
728
161
extern pthread_cond_t COND_global_read_lock;
729
162
extern pthread_attr_t connection_attrib;
730
extern I_List<THD> threads;
731
extern I_List<NAMED_LIST> key_caches;
163
extern I_List<Session> session_list;
732
164
extern MY_BITMAP temp_pool;
733
165
extern String my_empty_string;
734
166
extern const String my_null_string;
737
169
extern struct system_status_var global_status_var;
738
170
extern struct rand_struct sql_rand;
740
extern const char *opt_date_time_formats[];
741
extern KNOWN_DATE_TIME_FORMAT known_date_time_formats[];
743
extern HASH open_cache, lock_db_cache;
744
172
extern Table *unused_tables;
745
173
extern const char* any_db;
746
174
extern struct my_option my_long_options[];
747
175
extern const LEX_STRING view_type;
748
extern scheduler_functions thread_scheduler;
749
176
extern TYPELIB thread_handling_typelib;
750
177
extern uint8_t uc_update_queries[SQLCOM_END+1];
751
extern uint32_t sql_command_flags[];
178
extern std::bitset<5> sql_command_flags[];
752
179
extern TYPELIB log_output_typelib;
754
/* optional things, have_* variables */
755
extern SHOW_COMP_OPTION have_community_features;
757
extern handlerton *myisam_hton;
758
extern handlerton *heap_hton;
181
extern StorageEngine *myisam_engine;
182
extern StorageEngine *heap_engine;
760
184
extern SHOW_COMP_OPTION have_symlink;
761
extern SHOW_COMP_OPTION have_compress;
764
186
extern pthread_t signal_thread;
766
DRIZZLE_LOCK *mysql_lock_tables(THD *thd, Table **table, uint32_t count,
767
uint32_t flags, bool *need_reopen);
768
/* mysql_lock_tables() and open_table() flags bits */
769
#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_LOCK 0x0001
770
#define DRIZZLE_LOCK_IGNORE_FLUSH 0x0002
771
#define DRIZZLE_LOCK_NOTIFY_IF_NEED_REOPEN 0x0004
772
#define DRIZZLE_OPEN_TEMPORARY_ONLY 0x0008
773
#define DRIZZLE_LOCK_IGNORE_GLOBAL_READ_ONLY 0x0010
774
#define DRIZZLE_LOCK_PERF_SCHEMA 0x0020
776
void mysql_unlock_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
777
void mysql_unlock_read_tables(THD *thd, DRIZZLE_LOCK *sql_lock);
778
void mysql_unlock_some_tables(THD *thd, Table **table,uint32_t count);
779
void mysql_lock_remove(THD *thd, DRIZZLE_LOCK *locked,Table *table,
781
void mysql_lock_abort(THD *thd, Table *table, bool upgrade_lock);
782
void mysql_lock_downgrade_write(THD *thd, Table *table,
783
thr_lock_type new_lock_type);
784
bool mysql_lock_abort_for_thread(THD *thd, Table *table);
785
DRIZZLE_LOCK *mysql_lock_merge(DRIZZLE_LOCK *a,DRIZZLE_LOCK *b);
786
TableList *mysql_lock_have_duplicate(THD *thd, TableList *needle,
787
TableList *haystack);
788
bool lock_global_read_lock(THD *thd);
789
void unlock_global_read_lock(THD *thd);
790
bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
792
void start_waiting_global_read_lock(THD *thd);
793
bool make_global_read_lock_block_commit(THD *thd);
794
bool set_protect_against_global_read_lock(void);
795
void unset_protect_against_global_read_lock(void);
796
void broadcast_refresh(void);
797
int try_transactional_lock(THD *thd, TableList *table_list);
798
int check_transactional_lock(THD *thd, TableList *table_list);
799
int set_handler_table_locks(THD *thd, TableList *table_list,
802
/* Lock based on name */
803
int lock_and_wait_for_table_name(THD *thd, TableList *table_list);
804
int lock_table_name(THD *thd, TableList *table_list, bool check_in_use);
805
void unlock_table_name(THD *thd, TableList *table_list);
806
bool wait_for_locked_table_names(THD *thd, TableList *table_list);
807
bool lock_table_names(THD *thd, TableList *table_list);
808
void unlock_table_names(THD *thd, TableList *table_list,
809
TableList *last_table);
810
bool lock_table_names_exclusively(THD *thd, TableList *table_list);
811
bool is_table_name_exclusively_locked_by_this_thread(THD *thd,
812
TableList *table_list);
813
bool is_table_name_exclusively_locked_by_this_thread(THD *thd, unsigned char *key,
817
/* old unireg functions */
819
void unireg_init(ulong options);
820
void unireg_end(void) __attribute__((noreturn));
821
bool mysql_create_frm(THD *thd, const char *file_name,
822
const char *db, const char *table,
823
HA_CREATE_INFO *create_info,
824
List<Create_field> &create_field,
825
uint32_t key_count,KEY *key_info,handler *db_type);
826
int rea_create_table(THD *thd, const char *path,
827
const char *db, const char *table_name,
828
HA_CREATE_INFO *create_info,
829
List<Create_field> &create_field,
830
uint32_t key_count,KEY *key_info,
832
int format_number(uint32_t inputflag,uint32_t max_length,char * pos,uint32_t length,
836
TABLE_SHARE *alloc_table_share(TableList *table_list, char *key,
190
TableShare *alloc_table_share(TableList *table_list, char *key,
837
191
uint32_t key_length);
838
void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
840
const char *table_name, const char *path);
841
void free_table_share(TABLE_SHARE *share);
842
int open_table_def(THD *thd, TABLE_SHARE *share, uint32_t db_flags);
843
void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg);
844
int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
192
int open_table_def(Session *session, TableShare *share);
193
void open_table_error(TableShare *share, int error, int db_errno, int errarg);
194
int open_table_from_share(Session *session, TableShare *share, const char *alias,
845
195
uint32_t db_stat, uint32_t prgflag, uint32_t ha_open_flags,
846
196
Table *outparam, open_table_mode open_mode);
847
197
int readfrm(const char *name, unsigned char **data, size_t *length);
848
198
int writefrm(const char* name, const unsigned char* data, size_t len);
849
int closefrm(Table *table, bool free_share);
850
199
int read_string(File file, unsigned char* *to, size_t length);
851
200
void free_blobs(Table *table);
852
201
int set_zone(int nr,int min_zone,int max_zone);
853
ulong convert_period_to_month(ulong period);
854
ulong convert_month_to_period(ulong month);
202
uint32_t convert_period_to_month(uint32_t period);
203
uint32_t convert_month_to_period(uint32_t month);
855
204
void get_date_from_daynr(long daynr,uint32_t *year, uint32_t *month,
857
my_time_t TIME_to_timestamp(THD *thd, const DRIZZLE_TIME *t, bool *not_exist);
858
206
bool str_to_time_with_warn(const char *str,uint32_t length,DRIZZLE_TIME *l_time);
859
207
enum enum_drizzle_timestamp_type str_to_datetime_with_warn(const char *str, uint32_t length,
860
208
DRIZZLE_TIME *l_time, uint32_t flags);
861
209
void localtime_to_TIME(DRIZZLE_TIME *to, struct tm *from);
862
210
void calc_time_from_sec(DRIZZLE_TIME *to, long seconds, long microseconds);
864
void make_truncated_value_warning(THD *thd, DRIZZLE_ERROR::enum_warning_level level,
212
void make_truncated_value_warning(Session *session, DRIZZLE_ERROR::enum_warning_level level,
865
213
const char *str_val,
866
214
uint32_t str_length, enum enum_drizzle_timestamp_type time_type,
867
215
const char *field_name);