summaryrefslogtreecommitdiff
path: root/sql/sql_table.h
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2021-09-09 11:58:46 +0300
committerSergei Golubchik <serg@mariadb.org>2021-10-26 17:07:46 +0200
commitb7bba721eee42af892178a747fa72a6fc2975c94 (patch)
treeb1a55eb154ed9d22815d8b45b283af349cfa8bef /sql/sql_table.h
parentf6b0e34c381c54f392222c978fb17dcf12e7cff3 (diff)
downloadmariadb-git-b7bba721eee42af892178a747fa72a6fc2975c94.tar.gz
MDEV-22166 CONVERT PARTITION: move out partition into a table
Syntax for CONVERT keyword ALTER TABLE tbl_name [alter_option [, alter_option] ...] | [partition_options] partition_option: { ... | CONVERT PARTITION partition_name TO TABLE tbl_name } Examples: ALTER TABLE t1 CONVERT PARTITION p2 TO TABLE tp2; New ALTER_PARTITION_CONVERT_OUT command for fast_alter_partition_table() is done in alter_partition_convert_out() function which basically does ha_rename_table(). Partition to extract is marked with the same flag as dropped partition: PART_TO_BE_DROPPED. Note that we cannot have multiple partitioning commands in one ALTER. For DDL logging basically the principle is the same as for other fast_alter_partition_table() commands. The only difference is that it integrates late Atomic DDL functions and introduces additional phase of WFRM_BACKUP_ORIGINAL. That is required for binlog consistency because otherwise we could not revert back after WFRM_INSTALL_SHADOW is done. And before DDL log is complete if we crash or fail the altered table will be already new but binlog will miss that ALTER command. Note that this is different from all other atomic DDL in that it rolls back until the ddl_log_complete() is done even if everything was done fully before the crash. Test cases added to: parts.alter_table \ parts.partition_debug \ versioning.partition \ atomic.alter_partition
Diffstat (limited to 'sql/sql_table.h')
-rw-r--r--sql/sql_table.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/sql/sql_table.h b/sql/sql_table.h
index aacb6c99f15..a925e32b573 100644
--- a/sql/sql_table.h
+++ b/sql/sql_table.h
@@ -20,6 +20,11 @@
#include <my_sys.h> // pthread_mutex_t
#include "m_string.h" // LEX_CUSTRING
+#define ERROR_INJECT_CRASH(code) \
+ (DBUG_IF(code) && (DBUG_SUICIDE(), false))
+#define ERROR_INJECT_ERROR(code) \
+ (DBUG_IF(code) && (my_error(ER_UNKNOWN_ERROR, MYF(0)), 1))
+
class Alter_info;
class Alter_table_ctx;
class Column_definition;
@@ -53,6 +58,9 @@ enum enum_explain_filename_mode
#define WFRM_WRITE_SHADOW 1
#define WFRM_INSTALL_SHADOW 2
#define WFRM_KEEP_SHARE 4
+#define WFRM_WRITE_CONVERTED_TO 8
+#define WFRM_BACKUP_ORIGINAL 16
+#define WFRM_DROP_BACKUP 32
/* Flags for conversion functions. */
static const uint FN_FROM_IS_TMP= 1 << 0;
@@ -77,7 +85,8 @@ bool check_mysql50_prefix(const char *name);
uint build_table_filename(char *buff, size_t bufflen, const char *db,
const char *table, const char *ext, uint flags);
uint build_table_shadow_filename(char *buff, size_t bufflen,
- ALTER_PARTITION_PARAM_TYPE *lpt);
+ ALTER_PARTITION_PARAM_TYPE *lpt,
+ bool backup= false);
void build_lower_case_table_filename(char *buff, size_t bufflen,
const LEX_CSTRING *db,
const LEX_CSTRING *table,