74
56
#define is_schema_db(X) \
75
57
!my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))
60
#define TMP_TABLE_KEY_EXTRA 8
61
void set_item_name(Item *item,char *pos,uint32_t length);
62
bool add_field_to_list(Session *session, LEX_STRING *field_name, enum enum_field_types type,
63
char *length, char *decimal,
64
uint32_t type_modifier,
65
enum column_format_type column_format,
66
Item *default_value, Item *on_update_value,
68
char *change, List<String> *interval_list,
69
const CHARSET_INFO * const cs,
70
virtual_column_info *vcol_info);
71
Create_field * new_create_field(Session *session, char *field_name, enum_field_types type,
72
char *length, char *decimals,
73
uint32_t type_modifier,
74
Item *default_value, Item *on_update_value,
75
LEX_STRING *comment, char *change,
76
List<String> *interval_list, CHARSET_INFO *cs,
77
virtual_column_info *vcol_info);
78
void store_position_for_column(const char *name);
79
bool add_to_list(Session *session, SQL_LIST &list,Item *group,bool asc);
80
bool push_new_name_resolution_context(Session *session,
83
void add_join_on(TableList *b,Item *expr);
84
void add_join_natural(TableList *a,TableList *b,List<String> *using_fields,
86
bool add_proc_to_list(Session *session, Item *item);
87
void unlink_open_table(Session *session, Table *find, bool unlock);
88
void drop_open_table(Session *session, Table *table, const char *db_name,
89
const char *table_name);
90
void update_non_unique_table_error(TableList *update,
91
const char *operation,
92
TableList *duplicate);
94
SQL_SELECT *make_select(Table *head, table_map const_tables,
95
table_map read_tables, COND *conds,
96
bool allow_null_cond, int *error);
97
extern Item **not_found_item;
100
A set of constants used for checking non aggregated fields and sum
101
functions mixture in the ONLY_FULL_GROUP_BY_MODE.
103
#define NON_AGG_FIELD_USED 1
104
#define SUM_FUNC_USED 2
107
This enumeration type is used only by the function find_item_in_list
108
to return the info on how an item has been resolved against a list
109
of possibly aliased items.
110
The item can be resolved:
111
- against an alias name of the list's element (RESOLVED_AGAINST_ALIAS)
112
- against non-aliased field name of the list (RESOLVED_WITH_NO_ALIAS)
113
- against an aliased field name of the list (RESOLVED_BEHIND_ALIAS)
114
- ignoring the alias name in cases when SQL requires to ignore aliases
115
(e.g. when the resolved field reference contains a table name or
116
when the resolved item is an expression) (RESOLVED_IGNORING_ALIAS)
118
enum enum_resolution_type {
120
RESOLVED_IGNORING_ALIAS,
121
RESOLVED_BEHIND_ALIAS,
122
RESOLVED_WITH_NO_ALIAS,
123
RESOLVED_AGAINST_ALIAS
125
Item ** find_item_in_list(Item *item, List<Item> &items, uint32_t *counter,
126
find_item_error_report_type report_error,
127
enum_resolution_type *resolution);
128
bool get_key_map_from_key_list(key_map *map, Table *table,
129
List<String> *index_list);
130
bool insert_fields(Session *session, Name_resolution_context *context,
131
const char *db_name, const char *table_name,
132
List_iterator<Item> *it, bool any_privileges);
133
bool setup_tables(Session *session, Name_resolution_context *context,
134
List<TableList> *from_clause, TableList *tables,
135
TableList **leaves, bool select_insert);
136
bool setup_tables_and_check_access(Session *session,
137
Name_resolution_context *context,
138
List<TableList> *from_clause,
142
int setup_wild(Session *session, TableList *tables, List<Item> &fields,
143
List<Item> *sum_func_list, uint32_t wild_num);
144
bool setup_fields(Session *session, Item** ref_pointer_array,
145
List<Item> &item, enum_mark_columns mark_used_columns,
146
List<Item> *sum_func_list, bool allow_sum_func);
147
inline bool setup_fields_with_no_wrap(Session *session, Item **ref_pointer_array,
149
enum_mark_columns mark_used_columns,
150
List<Item> *sum_func_list,
154
res= setup_fields(session, ref_pointer_array, item, mark_used_columns, sum_func_list,
158
int setup_conds(Session *session, TableList *tables, TableList *leaves,
160
int setup_ftfuncs(SELECT_LEX* select);
161
int init_ftfuncs(Session *session, SELECT_LEX* select, bool no_order);
162
void wait_for_condition(Session *session, pthread_mutex_t *mutex,
163
pthread_cond_t *cond);
164
int open_tables(Session *session, TableList **tables, uint32_t *counter, uint32_t flags);
165
/* open_and_lock_tables with optional derived handling */
166
int open_and_lock_tables_derived(Session *session, TableList *tables, bool derived);
167
/* simple open_and_lock_tables without derived handling */
168
inline int simple_open_n_lock_tables(Session *session, TableList *tables)
170
return open_and_lock_tables_derived(session, tables, false);
172
/* open_and_lock_tables with derived handling */
173
inline int open_and_lock_tables(Session *session, TableList *tables)
175
return open_and_lock_tables_derived(session, tables, true);
177
/* simple open_and_lock_tables without derived handling for single table */
178
Table *open_n_lock_single_table(Session *session, TableList *table_l,
179
thr_lock_type lock_type);
180
bool open_normal_and_derived_tables(Session *session, TableList *tables, uint32_t flags);
181
int lock_tables(Session *session, TableList *tables, uint32_t counter, bool *need_reopen);
182
int decide_logging_format(Session *session);
183
Table *open_temporary_table(Session *session, const char *path, const char *db,
184
const char *table_name, bool link_in_list,
185
open_table_mode open_mode);
186
bool rm_temporary_table(handlerton *base, char *path, bool frm_only);
187
void free_io_cache(Table *entry);
188
void intern_close_table(Table *entry);
189
bool close_thread_table(Session *session, Table **table_ptr);
190
void close_temporary_tables(Session *session);
191
void close_tables_for_reopen(Session *session, TableList **tables);
192
TableList *find_table_in_list(TableList *table,
193
TableList *TableList::*link,
195
const char *table_name);
196
TableList *unique_table(Session *session, TableList *table, TableList *table_list,
198
Table *find_temporary_table(Session *session, const char *db, const char *table_name);
199
Table *find_temporary_table(Session *session, TableList *table_list);
200
int drop_temporary_table(Session *session, TableList *table_list);
201
void close_temporary_table(Session *session, Table *table, bool free_share,
203
void close_temporary(Table *table, bool free_share, bool delete_table);
204
bool rename_temporary_table(Session* session, Table *table, const char *new_db,
205
const char *table_name);
206
void remove_db_from_cache(const char *db);
208
bool is_equal(const LEX_STRING *a, const LEX_STRING *b);
209
char *make_default_log_name(char *buff,const char* log_ext);
211
/* bits for last argument to remove_table_from_cache() */
212
#define RTFC_NO_FLAG 0x0000
213
#define RTFC_OWNED_BY_Session_FLAG 0x0001
214
#define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002
215
#define RTFC_CHECK_KILLED_FLAG 0x0004
216
bool remove_table_from_cache(Session *session, const char *db, const char *table,
219
#define NORMAL_PART_NAME 0
220
#define TEMP_PART_NAME 1
221
#define RENAMED_PART_NAME 2
223
void mem_alloc_error(size_t size);
225
#define WFRM_WRITE_SHADOW 1
226
#define WFRM_INSTALL_SHADOW 2
227
#define WFRM_PACK_FRM 4
228
#define WFRM_KEEP_SHARE 8
230
bool close_cached_tables(Session *session, TableList *tables, bool have_lock,
231
bool wait_for_refresh, bool wait_for_placeholders);
232
bool close_cached_connection_tables(Session *session, bool wait_for_refresh,
233
LEX_STRING *connect_string,
234
bool have_lock= false);
235
void copy_field_from_tmp_record(Field *field,int offset);
236
bool fill_record(Session * session, List<Item> &fields, List<Item> &values, bool ignore_errors);
237
bool fill_record(Session *session, Field **field, List<Item> &values, bool ignore_errors);
238
OPEN_TableList *list_open_tables(Session *session, const char *db, const char *wild);
240
inline TableList *find_table_in_global_list(TableList *table,
242
const char *table_name)
244
return find_table_in_list(table, &TableList::next_global,
245
db_name, table_name);
248
inline TableList *find_table_in_local_list(TableList *table,
250
const char *table_name)
252
return find_table_in_list(table, &TableList::next_local,
253
db_name, table_name);
258
bool eval_const_cond(COND *cond);
261
int mysql_load(Session *session, sql_exchange *ex, TableList *table_list,
262
List<Item> &fields_vars, List<Item> &set_fields,
263
List<Item> &set_values_list,
264
enum enum_duplicates handle_duplicates, bool ignore,
266
int write_record(Session *session, Table *table, COPY_INFO *info);
78
270
void print_where(COND *cond,const char *info, enum_query_type query_type);
79
271
void print_cached_tables(void);
272
void TEST_filesort(SORT_FIELD *sortorder,uint32_t s_length);
80
273
void print_plan(JOIN* join,uint32_t idx, double record_count, double read_time,
81
274
double current_read_time, const char *info);
82
275
void print_keyuse_array(DYNAMIC_ARRAY *keyuse_array);
83
276
void dump_TableList_graph(SELECT_LEX *select_lex, TableList* tl);
84
277
void mysql_print_status();
280
int find_ref_key(KEY *key, uint32_t key_count, unsigned char *record, Field *field,
281
uint32_t *key_length, uint32_t *keypart);
282
void key_copy(unsigned char *to_key, unsigned char *from_record, KEY *key_info, uint32_t key_length);
283
void key_restore(unsigned char *to_record, unsigned char *from_key, KEY *key_info,
284
uint16_t key_length);
285
void key_zero_nulls(unsigned char *tuple, KEY *key_info);
286
bool key_cmp_if_same(Table *form,const unsigned char *key,uint32_t index,uint32_t key_length);
287
void key_unpack(String *to,Table *form,uint32_t index);
288
bool is_key_used(Table *table, uint32_t idx, const MY_BITMAP *fields);
289
int key_cmp(KEY_PART_INFO *key_part, const unsigned char *key, uint32_t key_length);
290
extern "C" int key_rec_cmp(void *key_info, unsigned char *a, unsigned char *b);
87
292
bool init_errmessage(void);
88
293
File open_binlog(IO_CACHE *log, const char *log_file_name,
141
365
extern uint64_t keybuff_size;
142
366
extern uint64_t session_startup_options;
143
367
extern ulong thread_id;
144
extern uint64_t binlog_cache_use;
145
extern uint64_t binlog_cache_disk_use;
146
extern uint64_t aborted_threads;
147
extern uint64_t aborted_connects;
148
extern uint64_t slave_open_temp_tables;
149
extern uint64_t slow_launch_threads;
150
extern uint64_t slow_launch_time;
151
extern uint64_t table_cache_size;
152
extern uint64_t table_def_size;
153
extern uint64_t max_connections;
154
extern uint64_t max_connect_errors;
155
extern uint64_t connect_timeout;
368
extern ulong binlog_cache_use, binlog_cache_disk_use;
369
extern ulong aborted_threads,aborted_connects;
370
extern ulong slave_open_temp_tables;
371
extern ulong slow_launch_threads, slow_launch_time;
372
extern ulong table_cache_size, table_def_size;
373
extern ulong max_connections,max_connect_errors, connect_timeout;
156
374
extern bool slave_allow_batching;
157
extern uint64_t slave_net_timeout;
158
extern uint64_t slave_trans_retries;
375
extern ulong slave_net_timeout, slave_trans_retries;
159
376
extern uint32_t max_user_connections;
160
extern ulong what_to_log;
161
extern uint64_t binlog_cache_size;
162
extern uint64_t max_binlog_cache_size;
163
extern uint64_t open_files_limit;
164
extern uint64_t max_binlog_size;
165
extern uint64_t max_relay_log_size;
166
extern uint64_t opt_binlog_rows_event_max_size;
167
extern uint64_t thread_pool_size;
168
extern uint32_t back_log;
169
extern pid_t current_pid;
170
extern uint64_t expire_logs_days;
171
extern uint64_t sync_binlog_period;
172
extern uint64_t tc_log_max_pages_used;
173
extern uint64_t tc_log_page_size;
174
extern uint64_t opt_tc_log_size;
175
extern uint64_t tc_log_page_waits;
377
extern ulong what_to_log,flush_time;
378
extern ulong binlog_cache_size, max_binlog_cache_size, open_files_limit;
379
extern ulong max_binlog_size, max_relay_log_size;
380
extern ulong opt_binlog_rows_event_max_size;
381
extern ulong rpl_recovery_rank, thread_cache_size, thread_pool_size;
382
extern ulong back_log;
383
extern ulong current_pid;
384
extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter;
385
extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size;
386
extern ulong tc_log_page_waits;
176
387
extern bool relay_log_purge;
177
388
extern bool opt_innodb_safe_binlog, opt_innodb;
178
389
extern uint32_t test_flags,select_errors,ha_open_options;