summaryrefslogtreecommitdiff
path: root/sql/sql_alter.h
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-05-07 14:54:58 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2018-05-07 14:58:11 +0530
commit85cc6b70bd7e5db2c96c4f58344bab269343cf85 (patch)
treeffa0ab7a6a75996497ce75b65fe9d5d3b02c9bd0 /sql/sql_alter.h
parenta0bc3b7eeef6a3bfd0e7eae1cceabcc73071a61a (diff)
downloadmariadb-git-85cc6b70bd7e5db2c96c4f58344bab269343cf85.tar.gz
MDEV-13134 Introduce ALTER TABLE attributes ALGORITHM=NOCOPY and ALGORITHM=INSTANT
Introduced new alter algorithm type called NOCOPY & INSTANT for inplace alter operation. NOCOPY - Algorithm refuses any alter operation that would rebuild the clustered index. It is a subset of INPLACE algorithm. INSTANT - Algorithm allow any alter operation that would modify only meta data. It is a subset of NOCOPY algorithm. Introduce new variable called alter_algorithm. The values are DEFAULT(0), COPY(1), INPLACE(2), NOCOPY(3), INSTANT(4) Message to deprecate old_alter_table variable and make it alias for alter_algorithm variable. alter_algorithm variable for slave is always set to default.
Diffstat (limited to 'sql/sql_alter.h')
-rw-r--r--sql/sql_alter.h57
1 files changed, 53 insertions, 4 deletions
diff --git a/sql/sql_alter.h b/sql/sql_alter.h
index 85a7b993e12..268dbc43abd 100644
--- a/sql/sql_alter.h
+++ b/sql/sql_alter.h
@@ -47,14 +47,24 @@ public:
*/
enum enum_alter_table_algorithm
{
- // In-place if supported, copy otherwise.
+/*
+ Use thd->variables.alter_algorithm for alter method. If this is also
+ default then use the fastest possible ALTER TABLE method
+ (INSTANT, NOCOPY, INPLACE, COPY)
+*/
ALTER_TABLE_ALGORITHM_DEFAULT,
+ // Copy if supported, error otherwise.
+ ALTER_TABLE_ALGORITHM_COPY,
+
// In-place if supported, error otherwise.
ALTER_TABLE_ALGORITHM_INPLACE,
- // Copy if supported, error otherwise.
- ALTER_TABLE_ALGORITHM_COPY
+ // No Copy will refuse any operation which does rebuild.
+ ALTER_TABLE_ALGORITHM_NOCOPY,
+
+ // Instant should allow any operation that changes metadata only.
+ ALTER_TABLE_ALGORITHM_INSTANT
};
@@ -67,7 +77,7 @@ public:
// Maximum supported level of concurency for the given operation.
ALTER_TABLE_LOCK_DEFAULT,
- // Allow concurrent reads & writes. If not supported, give erorr.
+ // Allow concurrent reads & writes. If not supported, give error.
ALTER_TABLE_LOCK_NONE,
// Allow concurrent reads only. If not supported, give error.
@@ -174,6 +184,45 @@ public:
bool set_requested_lock(const LEX_CSTRING *str);
+ /**
+ Returns the algorithm value in the format "algorithm=value"
+ */
+ const char* algorithm() const;
+
+ /**
+ Returns the lock value in the format "lock=value"
+ */
+ const char* lock() const;
+
+ /**
+ Check whether the given result can be supported
+ with the specified user alter algorithm.
+
+ @param thd Thread handle
+ @param result Operation supported for inplace alter
+ @param ha_alter_info Structure describing changes to be done
+ by ALTER TABLE and holding data during
+ in-place alter
+ @retval false Supported operation
+ @retval true Not supported value
+ */
+ bool supports_algorithm(THD *thd, enum_alter_inplace_result result,
+ const Alter_inplace_info *ha_alter_info);
+
+ /**
+ Check whether the given result can be supported
+ with the specified user lock type.
+
+ @param result Operation supported for inplace alter
+ @param ha_alter_info Structure describing changes to be done
+ by ALTER TABLE and holding data during
+ in-place alter
+ @retval false Supported lock type
+ @retval true Not supported value
+ */
+ bool supports_lock(THD *thd, enum_alter_inplace_result result,
+ const Alter_inplace_info *ha_alter_info);
+
private:
Alter_info &operator=(const Alter_info &rhs); // not implemented
Alter_info(const Alter_info &rhs); // not implemented