49
49
/* Routines for dropping, repairing, checking schema tables */
50
50
#include <drizzled/sql_table.h>
54
bool drizzle_rename_tables(Session *session, TableList *table_list, bool silent);
55
bool do_rename(Session *session, TableList *ren_table, char *new_db,
56
char *new_table_name, char *new_table_alias,
60
void mysql_parse(Session *session, const char *inBuf, uint32_t length,
61
const char ** semicolon);
63
bool mysql_test_parse_for_slave(Session *session,char *inBuf,uint32_t length);
66
bool is_update_query(enum enum_sql_command command);
68
bool alloc_query(Session *session, const char *packet, uint32_t packet_length);
70
void mysql_reset_session_for_next_command(Session *session);
72
void create_select_for_variable(const char *var_name);
74
void mysql_init_multi_delete(LEX *lex);
76
bool multi_delete_set_locks_and_link_aux_tables(LEX *lex);
78
void init_update_queries(void);
80
bool do_command(Session *session);
82
bool dispatch_command(enum enum_server_command command, Session *session,
83
char* packet, uint32_t packet_length);
85
void log_slow_statement(Session *session);
87
bool append_file_to_dir(Session *session, const char **filename_ptr,
88
const char *table_name);
90
bool reload_cache(Session *session, ulong options, TableList *tables, bool *write_to_binlog);
92
bool check_simple_select();
94
void mysql_init_select(LEX *lex);
95
bool mysql_new_select(LEX *lex, bool move_down);
98
void table_cache_free(void);
99
bool table_cache_init(void);
100
bool table_def_init(void);
101
void table_def_free(void);
102
void assign_new_table_id(TABLE_SHARE *share);
103
uint32_t cached_open_tables(void);
104
uint32_t cached_table_definitions(void);
107
void kill_drizzle(void);
108
void close_connection(Session *session, uint32_t errcode, bool lock);
111
Table *create_virtual_tmp_table(Session *session, List<Create_field> &field_list);
114
bool mysql_xa_recover(Session *session);
116
SORT_FIELD * make_unireg_sortorder(order_st *order, uint32_t *length,
117
SORT_FIELD *sortorder);
118
int setup_order(Session *session, Item **ref_pointer_array, TableList *tables,
119
List<Item> &fields, List <Item> &all_fields, order_st *order);
120
int setup_group(Session *session, Item **ref_pointer_array, TableList *tables,
121
List<Item> &fields, List<Item> &all_fields, order_st *order,
122
bool *hidden_group_fields);
123
bool fix_inner_refs(Session *session, List<Item> &all_fields, SELECT_LEX *select,
124
Item **ref_pointer_array);
126
bool handle_select(Session *session, LEX *lex, select_result *result,
127
ulong setup_tables_done_option);
128
bool mysql_select(Session *session, Item ***rref_pointer_array,
129
TableList *tables, uint32_t wild_num, List<Item> &list,
130
COND *conds, uint32_t og_num, order_st *order, order_st *group,
131
Item *having, order_st *proc_param, uint64_t select_type,
132
select_result *result, SELECT_LEX_UNIT *unit,
133
SELECT_LEX *select_lex);
134
void free_underlaid_joins(Session *session, SELECT_LEX *select);
135
bool mysql_explain_union(Session *session, SELECT_LEX_UNIT *unit,
136
select_result *result);
137
int mysql_explain_select(Session *session, SELECT_LEX *sl, char const *type,
138
select_result *result);
139
bool mysql_union(Session *session, LEX *lex, select_result *result,
140
SELECT_LEX_UNIT *unit, ulong setup_tables_done_option);
141
bool mysql_handle_derived(LEX *lex, bool (*processor)(Session *session,
144
bool mysql_derived_prepare(Session *session, LEX *lex, TableList *t);
145
bool mysql_derived_filling(Session *session, LEX *lex, TableList *t);
146
Field *create_tmp_field(Session *session, Table *table,Item *item, Item::Type type,
147
Item ***copy_func, Field **from_field,
149
bool group, bool modify_item,
150
bool table_cant_handle_bit_fields,
151
bool make_copy_field,
152
uint32_t convert_blob_length);
153
void sp_prepare_create_field(Session *session, Create_field *sql_field);
154
int prepare_create_field(Create_field *sql_field,
155
uint32_t *blob_columns,
156
int *timestamps, int *timestamps_with_niladic,
157
int64_t table_flags);
158
bool mysql_create_table(Session *session,const char *db, const char *table_name,
159
HA_CREATE_INFO *create_info,
160
Alter_info *alter_info,
161
bool tmp_table, uint32_t select_field_count);
162
bool mysql_create_table_no_lock(Session *session, const char *db,
163
const char *table_name,
164
HA_CREATE_INFO *create_info,
165
Alter_info *alter_info,
166
bool tmp_table, uint32_t select_field_count,
167
bool lock_open_lock);
169
bool mysql_alter_table(Session *session, char *new_db, char *new_name,
170
HA_CREATE_INFO *create_info,
171
TableList *table_list,
172
Alter_info *alter_info,
173
uint32_t order_num, order_st *order, bool ignore);
174
bool mysql_recreate_table(Session *session, TableList *table_list);
175
bool mysql_create_like_table(Session *session, TableList *table,
176
TableList *src_table,
177
HA_CREATE_INFO *create_info);
178
bool mysql_rename_table(handlerton *base, const char *old_db,
179
const char * old_name, const char *new_db,
180
const char * new_name, uint32_t flags);
181
bool mysql_prepare_update(Session *session, TableList *table_list,
182
Item **conds, uint32_t order_num, order_st *order);
183
int mysql_update(Session *session,TableList *tables,List<Item> &fields,
184
List<Item> &values,COND *conds,
185
uint32_t order_num, order_st *order, ha_rows limit,
186
enum enum_duplicates handle_duplicates, bool ignore);
187
bool mysql_multi_update(Session *session, TableList *table_list,
188
List<Item> *fields, List<Item> *values,
189
COND *conds, uint64_t options,
190
enum enum_duplicates handle_duplicates, bool ignore,
191
SELECT_LEX_UNIT *unit, SELECT_LEX *select_lex);
192
bool mysql_prepare_insert(Session *session, TableList *table_list, Table *table,
193
List<Item> &fields, List_item *values,
194
List<Item> &update_fields,
195
List<Item> &update_values, enum_duplicates duplic,
196
COND **where, bool select_insert,
197
bool check_fields, bool abort_on_warning);
198
bool mysql_insert(Session *session,TableList *table,List<Item> &fields,
199
List<List_item> &values, List<Item> &update_fields,
200
List<Item> &update_values, enum_duplicates flag,
202
int check_that_all_fields_are_given_values(Session *session, Table *entry,
203
TableList *table_list);
204
void prepare_triggers_for_insert_stmt(Table *table);
205
int mysql_prepare_delete(Session *session, TableList *table_list, Item **conds);
206
bool mysql_delete(Session *session, TableList *table_list, COND *conds,
207
SQL_LIST *order, ha_rows rows, uint64_t options,
208
bool reset_auto_increment);
209
bool mysql_truncate(Session *session, TableList *table_list, bool dont_send_ok);
210
uint32_t create_table_def_key(Session *session, char *key, TableList *table_list,
212
TABLE_SHARE *get_table_share(Session *session, TableList *table_list, char *key,
213
uint32_t key_length, uint32_t db_flags, int *error);
214
void release_table_share(TABLE_SHARE *share, enum release_type type);
215
TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name);
216
Table *open_ltable(Session *session, TableList *table_list, thr_lock_type update,
217
uint32_t lock_flags);
218
Table *open_table(Session *session, TableList *table_list, bool *refresh, uint32_t flags);
219
bool name_lock_locked_table(Session *session, TableList *tables);
220
bool reopen_name_locked_table(Session* session, TableList* table_list, bool link_in);
221
Table *table_cache_insert_placeholder(Session *session, const char *key,
222
uint32_t key_length);
223
bool lock_table_name_if_not_cached(Session *session, const char *db,
224
const char *table_name, Table **table);
225
Table *find_locked_table(Session *session, const char *db,const char *table_name);
226
void detach_merge_children(Table *table, bool clear_refs);
227
bool fix_merge_after_open(TableList *old_child_list, TableList **old_last,
228
TableList *new_child_list, TableList **new_last);
229
bool reopen_table(Table *table);
230
bool reopen_tables(Session *session,bool get_locks,bool in_refresh);
231
void close_data_files_and_morph_locks(Session *session, const char *db,
232
const char *table_name);
233
void close_handle_and_leave_table_as_lock(Table *table);
234
bool open_new_frm(Session *session, TABLE_SHARE *share, const char *alias,
235
uint32_t db_stat, uint32_t prgflag,
236
uint32_t ha_open_flags, Table *outparam,
237
TableList *table_desc, MEM_ROOT *mem_root);
238
bool wait_for_tables(Session *session);
239
bool table_is_used(Table *table, bool wait_for_name_lock);
240
Table *drop_locked_tables(Session *session,const char *db, const char *table_name);
241
void abort_locked_tables(Session *session,const char *db, const char *table_name);
242
void execute_init_command(Session *session, sys_var_str *init_command_var,
243
rw_lock_t *var_mutex);
244
extern Field *not_found_field;
245
extern Field *view_ref_found;
247
enum find_item_error_report_type {REPORT_ALL_ERRORS, REPORT_EXCEPT_NOT_FOUND,
248
IGNORE_ERRORS, REPORT_EXCEPT_NON_UNIQUE,
249
IGNORE_EXCEPT_NON_UNIQUE};
251
find_field_in_tables(Session *session, Item_ident *item,
252
TableList *first_table, TableList *last_table,
253
Item **ref, find_item_error_report_type report_error,
254
bool check_privileges, bool register_tree_change);
256
find_field_in_table_ref(Session *session, TableList *table_list,
257
const char *name, uint32_t length,
258
const char *item_name, const char *db_name,
259
const char *table_name, Item **ref,
260
bool check_privileges, bool allow_rowid,
261
uint32_t *cached_field_index_ptr,
262
bool register_tree_change, TableList **actual_table);
264
find_field_in_table(Session *session, Table *table, const char *name, uint32_t length,
265
bool allow_rowid, uint32_t *cached_field_index_ptr);
267
find_field_in_table_sef(Table *table, const char *name);
268
int update_virtual_fields_marked_for_write(Table *table,
269
bool ignore_stored=true);
272
bool mysql_do(Session *session, List<Item> &values);
275
bool append_escaped(String *to_str, String *from_str);
277
#include <drizzled/show.h>
279
52
/* information schema */
280
extern LEX_STRING INFORMATION_SCHEMA_NAME;
282
extern LEX_STRING DRIZZLE_SCHEMA_NAME;
283
extern LEX_STRING GENERAL_LOG_NAME;
284
extern LEX_STRING SLOW_LOG_NAME;
53
static const std::string INFORMATION_SCHEMA_NAME("information_schema");
286
extern const LEX_STRING partition_keywords[];
287
ST_SCHEMA_TABLE *find_schema_table(Session *session, const char* table_name);
288
ST_SCHEMA_TABLE *get_schema_table(enum enum_schema_tables schema_table_idx);
289
int prepare_schema_table(Session *session, LEX *lex, Table_ident *table_ident,
290
enum enum_schema_tables schema_table_idx);
291
int make_schema_select(Session *session, SELECT_LEX *sel,
292
enum enum_schema_tables schema_table_idx);
293
int mysql_schema_table(Session *session, LEX *lex, TableList *table_list);
294
bool get_schema_tables_result(JOIN *join,
295
enum enum_schema_table_state executed_place);
296
enum enum_schema_tables get_schema_table_idx(ST_SCHEMA_TABLE *schema_table);
298
56
#define is_schema_db(X) \
299
57
!my_strcasecmp(system_charset_info, INFORMATION_SCHEMA_NAME.str, (X))