16 #ifndef SQL_TABLE_INCLUDED
17 #define SQL_TABLE_INCLUDED
19 #include "my_global.h"
20 #include "my_pthread.h"
22 #include "mysql_com.h"
39 enum ddl_log_entry_code
52 DDL_LOG_EXECUTE_CODE =
'e',
53 DDL_LOG_ENTRY_CODE =
'l',
54 DDL_IGNORE_LOG_ENTRY_CODE =
'i'
57 enum ddl_log_action_code
72 DDL_LOG_DELETE_ACTION =
'd',
73 DDL_LOG_RENAME_ACTION =
'r',
74 DDL_LOG_REPLACE_ACTION =
's',
75 DDL_LOG_EXCHANGE_ACTION =
'e'
78 enum enum_ddl_log_exchange_phase {
79 EXCH_PHASE_NAME_TO_TEMP= 0,
80 EXCH_PHASE_FROM_TO_NAME= 1,
81 EXCH_PHASE_TEMP_TO_FROM= 2
88 const char *from_name;
89 const char *handler_name;
93 enum ddl_log_entry_code entry_type;
94 enum ddl_log_action_code action_type;
113 enum enum_explain_filename_mode
115 EXPLAIN_ALL_VERBOSE= 0,
116 EXPLAIN_PARTITIONS_VERBOSE,
117 EXPLAIN_PARTITIONS_AS_COMMENT
121 #define EXPLAIN_FILENAME_MAX_EXTRA_LENGTH 63
123 #define MYSQL50_TABLE_NAME_PREFIX "#mysql50#"
124 #define MYSQL50_TABLE_NAME_PREFIX_LENGTH 9
126 #define WFRM_WRITE_SHADOW 1
127 #define WFRM_INSTALL_SHADOW 2
128 #define WFRM_PACK_FRM 4
129 #define WFRM_KEEP_SHARE 8
132 static const uint FN_FROM_IS_TMP= 1 << 0;
133 static const uint FN_TO_IS_TMP= 1 << 1;
134 static const uint FN_IS_TMP= FN_FROM_IS_TMP | FN_TO_IS_TMP;
135 static const uint NO_FRM_RENAME= 1 << 2;
136 static const uint FRM_ONLY= 1 << 3;
138 static const uint NO_HA_TABLE= 1 << 4;
140 static const uint SKIP_SYMDIR_ACCESS= 1 << 5;
142 static const uint NO_FK_CHECKS= 1 << 6;
144 uint filename_to_tablename(
const char *from,
char *
to, uint to_length
146 ,
bool stay_quiet =
false
149 uint tablename_to_filename(
const char *from,
char *
to, uint to_length);
150 uint check_n_cut_mysql50_prefix(
const char *from,
char *
to, uint to_length);
151 bool check_mysql50_prefix(
const char *
name);
152 uint build_table_filename(
char *buff,
size_t bufflen,
const char *db,
153 const char *
table,
const char *ext,
154 uint
flags,
bool *was_truncated);
156 uint
inline build_table_filename(
char *buff,
size_t bufflen,
const char *db,
157 const char *
table,
const char *ext, uint
flags)
159 bool truncated_not_used;
160 return build_table_filename(buff, bufflen, db, table, ext, flags,
161 &truncated_not_used);
163 uint build_table_shadow_filename(
char *buff,
size_t bufflen,
165 uint build_tmptable_filename(THD* thd,
char *buff,
size_t bufflen);
169 bool mysql_create_table_no_lock(THD *thd,
const char *db,
173 uint select_field_count,
175 int mysql_discard_or_import_tablespace(THD *thd,
178 bool mysql_prepare_alter_table(THD *thd,
TABLE *
table,
182 bool mysql_trans_prepare_alter_copy_data(THD *thd);
183 bool mysql_trans_commit_alter_copy_data(THD *thd);
184 bool mysql_alter_table(THD *thd,
char *new_db,
char *new_name,
188 uint order_num,
ORDER *order,
bool ignore);
192 bool *metadata_equal);
193 bool mysql_recreate_table(THD *thd,
TABLE_LIST *table_list);
197 bool mysql_rename_table(
handlerton *base,
const char *old_db,
198 const char * old_name,
const char *new_db,
199 const char * new_name, uint
flags);
201 bool mysql_backup_table(THD* thd,
TABLE_LIST* table_list);
202 bool mysql_restore_table(THD* thd,
TABLE_LIST* table_list);
204 bool mysql_checksum_table(THD* thd,
TABLE_LIST* table_list,
206 bool mysql_rm_table(THD *thd,
TABLE_LIST *tables, my_bool if_exists,
207 my_bool drop_temporary);
208 int mysql_rm_table_no_locks(THD *thd,
TABLE_LIST *tables,
bool if_exists,
209 bool drop_temporary,
bool drop_view,
211 bool quick_rm_table(THD *thd,
handlerton *base,
const char *db,
213 void close_cached_table(THD *thd,
TABLE *
table);
214 bool fill_field_definition(THD *thd,
216 enum enum_field_types field_type,
220 longlong table_flags);
224 int write_bin_log(THD *thd,
bool clear_error,
225 char const *
query, ulong query_length,
226 bool is_trans= FALSE);
229 bool write_execute_ddl_log_entry(uint first_entry,
232 bool deactivate_ddl_log_entry(uint entry_no);
235 void release_ddl_log();
236 void execute_ddl_log_recovery();
237 bool execute_ddl_log_entry(THD *thd, uint first_entry);
238 bool validate_comment_length(THD *thd,
const char *comment_str,
239 size_t *comment_len, uint max_len,
240 uint err_code,
const char *comment_name);
242 template<
typename T>
class List;
248 uint explain_filename(THD* thd,
const char *from,
char *
to, uint to_length,
249 enum_explain_filename_mode explain_mode);
252 extern MYSQL_PLUGIN_IMPORT
const char *primary_key_name;