49
49
/* Routines for dropping, repairing, checking schema tables */
50
50
#include <drizzled/sql_table.h>
53
int mysql_create_db(Session *session, char *db, HA_CREATE_INFO *create, bool silent);
54
bool mysql_alter_db(Session *session, const char *db, HA_CREATE_INFO *create);
55
bool mysql_rm_db(Session *session,char *db,bool if_exists, bool silent);
56
bool mysql_change_db(Session *session, const LEX_STRING *new_db_name,
58
bool mysql_opt_change_db(Session *session,
59
const LEX_STRING *new_db_name,
60
LEX_STRING *saved_db_name,
62
bool *cur_db_changed);
65
void write_bin_log(Session *session, bool clear_error,
66
char const *query, ulong query_length);
67
void mysql_binlog_send(Session* session, char* log_ident, my_off_t pos, uint16_t flags);
68
void mysql_client_binlog_statement(Session *session);
71
bool drizzle_rename_tables(Session *session, TableList *table_list, bool silent);
72
bool do_rename(Session *session, TableList *ren_table, char *new_db,
73
char *new_table_name, char *new_table_alias,
77
void mysql_parse(Session *session, const char *inBuf, uint32_t length,
78
const char ** semicolon);
80
bool mysql_test_parse_for_slave(Session *session,char *inBuf,uint32_t length);
83
bool is_update_query(enum enum_sql_command command);
85
bool alloc_query(Session *session, const char *packet, uint32_t packet_length);
87
void mysql_reset_session_for_next_command(Session *session);
89
void create_select_for_variable(const char *var_name);
91
void mysql_init_multi_delete(LEX *lex);
93
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
95
void init_update_queries(void);
97
bool do_command(Session *session);
99
bool dispatch_command(enum enum_server_command command, Session *session,
100
char* packet, uint32_t packet_length);
102
void log_slow_statement(Session *session);
104
bool append_file_to_dir(Session *session, const char **filename_ptr,
105
const char *table_name);
107
bool reload_cache(Session *session, 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);
115
void table_cache_free(void);
116
bool table_cache_init(void);
117
bool table_def_init(void);
118
void table_def_free(void);
119
void assign_new_table_id(TABLE_SHARE *share);
120
uint32_t cached_open_tables(void);
121
uint32_t cached_table_definitions(void);
124
void kill_mysql(void);
125
void close_connection(Session *session, uint32_t errcode, bool lock);
128
Table *create_virtual_tmp_table(Session *session, List<Create_field> &field_list);
131
bool mysql_xa_recover(Session *session);
133
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
134
SORT_FIELD *sortorder);
135
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
136
List<Item> &fields, List <Item> &all_fields, order_st *order);
137
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
138
List<Item> &fields, List<Item> &all_fields, order_st *order,
139
bool *hidden_group_fields);
140
bool fix_inner_refs(Session *session, List<Item> &all_fields, SELECT_LEX *select,
141
Item **ref_pointer_array);
143
bool handle_select(Session *session, LEX *lex, select_result *result,
144
ulong setup_tables_done_option);
145
bool mysql_select(Session *session, Item ***rref_pointer_array,
146
TableList *tables, uint32_t wild_num, List<Item> &list,
147
COND *conds, uint32_t og_num, order_st *order, order_st *group,
148
Item *having, order_st *proc_param, uint64_t select_type,
149
select_result *result, SELECT_LEX_UNIT *unit,
150
SELECT_LEX *select_lex);
151
void free_underlaid_joins(Session *session, SELECT_LEX *select);
152
bool mysql_explain_union(Session *session, SELECT_LEX_UNIT *unit,
153
select_result *result);
154
int mysql_explain_select(Session *session, SELECT_LEX *sl, char const *type,
155
select_result *result);
156
bool mysql_union(Session *session, LEX *lex, select_result *result,
157
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
158
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
161
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
162
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
163
Field *create_tmp_field(Session *session, Table *table,Item *item, Item::Type type,
164
Item ***copy_func, Field **from_field,
166
bool group, bool modify_item,
167
bool table_cant_handle_bit_fields,
168
bool make_copy_field,
169
uint32_t convert_blob_length);
170
void sp_prepare_create_field(Session *session, Create_field *sql_field);
171
int prepare_create_field(Create_field *sql_field,
172
uint32_t *blob_columns,
173
int *timestamps, int *timestamps_with_niladic,
174
int64_t table_flags);
175
bool mysql_create_table(Session *session,const char *db, const char *table_name,
176
HA_CREATE_INFO *create_info,
177
Alter_info *alter_info,
178
bool tmp_table, uint32_t select_field_count);
179
bool mysql_create_table_no_lock(Session *session, const char *db,
180
const char *table_name,
181
HA_CREATE_INFO *create_info,
182
Alter_info *alter_info,
183
bool tmp_table, uint32_t select_field_count,
184
bool lock_open_lock);
186
bool mysql_alter_table(Session *session, char *new_db, char *new_name,
187
HA_CREATE_INFO *create_info,
188
TableList *table_list,
189
Alter_info *alter_info,
190
uint32_t order_num, order_st *order, bool ignore);
191
bool mysql_recreate_table(Session *session, TableList *table_list);
192
bool mysql_create_like_table(Session *session, TableList *table,
193
TableList *src_table,
194
HA_CREATE_INFO *create_info);
195
bool mysql_rename_table(handlerton *base, const char *old_db,
196
const char * old_name, const char *new_db,
197
const char * new_name, uint32_t flags);
198
bool mysql_prepare_update(Session *session, TableList *table_list,
199
Item **conds, uint32_t order_num, order_st *order);
200
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
201
List<Item> &values,COND *conds,
202
uint32_t order_num, order_st *order, ha_rows limit,
203
enum enum_duplicates handle_duplicates, bool ignore);
204
bool mysql_multi_update(Session *session, TableList *table_list,
205
List<Item> *fields, List<Item> *values,
206
COND *conds, uint64_t options,
207
enum enum_duplicates handle_duplicates, bool ignore,
208
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
209
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
210
List<Item> &fields, List_item *values,
211
List<Item> &update_fields,
212
List<Item> &update_values, enum_duplicates duplic,
213
COND **where, bool select_insert,
214
bool check_fields, bool abort_on_warning);
215
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
216
List<List_item> &values, List<Item> &update_fields,
217
List<Item> &update_values, enum_duplicates flag,
219
int check_that_all_fields_are_given_values(Session *session, Table *entry,
220
TableList *table_list);
221
void prepare_triggers_for_insert_stmt(Table *table);
222
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
223
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
224
SQL_LIST *order, ha_rows rows, uint64_t options,
225
bool reset_auto_increment);
226
bool mysql_truncate(Session *session, TableList *table_list, bool dont_send_ok);
227
uint32_t create_table_def_key(Session *session, char *key, TableList *table_list,
229
TABLE_SHARE *get_table_share(Session *session, TableList *table_list, char *key,
230
uint32_t key_length, uint32_t db_flags, int *error);
231
void release_table_share(TABLE_SHARE *share, enum release_type type);
232
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
233
Table *open_ltable(Session *session, TableList *table_list, thr_lock_type update,
234
uint32_t lock_flags);
235
Table *open_table(Session *session, TableList *table_list, bool *refresh, uint32_t flags);
236
bool name_lock_locked_table(Session *session, TableList *tables);
237
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in);
238
Table *table_cache_insert_placeholder(Session *session, const char *key,
239
uint32_t key_length);
240
bool lock_table_name_if_not_cached(Session *session, const char *db,
241
const char *table_name, Table **table);
242
Table *find_locked_table(Session *session, 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);
247
bool reopen_tables(Session *session,bool get_locks,bool in_refresh);
248
void close_data_files_and_morph_locks(Session *session, const char *db,
249
const char *table_name);
250
void close_handle_and_leave_table_as_lock(Table *table);
251
bool open_new_frm(Session *session, 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);
255
bool wait_for_tables(Session *session);
256
bool table_is_used(Table *table, bool wait_for_name_lock);
257
Table *drop_locked_tables(Session *session,const char *db, const char *table_name);
258
void abort_locked_tables(Session *session,const char *db, const char *table_name);
259
void execute_init_command(Session *session, sys_var_str *init_command_var,
260
rw_lock_t *var_mutex);
261
extern Field *not_found_field;
262
extern Field *view_ref_found;
264
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
265
IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
266
IGNORE_EXCEPT_NON_UNIQUE};
268
find_field_in_tables(Session *session, Item_ident *item,
269
TableList *first_table, TableList *last_table,
270
Item **ref, find_item_error_report_type report_error,
271
bool check_privileges, bool register_tree_change);
273
find_field_in_table_ref(Session *session, TableList *table_list,
274
const char *name, uint32_t length,
275
const char *item_name, const char *db_name,
276
const char *table_name, Item **ref,
277
bool check_privileges, bool allow_rowid,
278
uint32_t *cached_field_index_ptr,
279
bool register_tree_change, TableList **actual_table);
281
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length,
282
bool allow_rowid, uint32_t *cached_field_index_ptr);
284
find_field_in_table_sef(Table *table, const char *name);
285
int update_virtual_fields_marked_for_write(Table *table,
286
bool ignore_stored=true);
289
bool mysql_do(Session *session, List<Item> &values);
292
bool append_escaped(String *to_str, String *from_str);
294
#include <drizzled/show.h>
296
52
/* information schema */
297
extern LEX_STRING INFORMATION_SCHEMA_NAME;
299
extern LEX_STRING DRIZZLE_SCHEMA_NAME;
300
extern LEX_STRING GENERAL_LOG_NAME;
301
extern LEX_STRING SLOW_LOG_NAME;
53
static const std::string INFORMATION_SCHEMA_NAME("information_schema");
303
extern const LEX_STRING partition_keywords[];
304
ST_SCHEMA_TABLE *find_schema_table(Session *session, const char* table_name);
305
ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
306
int prepare_schema_table(Session *session, LEX *lex, Table_ident *table_ident,
307
enum enum_schema_tables schema_table_idx);
308
int make_schema_select(Session *session, SELECT_LEX *sel,
309
enum enum_schema_tables schema_table_idx);
310
int mysql_schema_table(Session *session, LEX *lex, TableList *table_list);
311
bool get_schema_tables_result(JOIN *join,
312
enum enum_schema_table_state executed_place);
313
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
315
56
#define is_schema_db(X) \
316
57
!my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))