summaryrefslogtreecommitdiff
path: root/sql/sql_alter.h
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2020-04-25 14:27:00 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2020-05-04 09:35:38 +0530
commitec9908b2577758ffb3cb0d1b06400f12ff47b81c (patch)
treea18426dce230626e84f752cf5d966d8e205f530b /sql/sql_alter.h
parentf98017bb6df0110aa0a359ab4378cc97f6a95473 (diff)
downloadmariadb-git-ec9908b2577758ffb3cb0d1b06400f12ff47b81c.tar.gz
MDEV-16288 ALTER TABLE…ALGORITHM=DEFAULT does not override alter_algorithm
- ALTER_ALGORITHM should be substituted when there is no mention of algorithm in alter statement. - Introduced algorithm(thd) in Alter_info. It returns the user requested algorithm. If user doesn't specify algorithm explicitly then it returns alter_algorithm variable. - changed algorithm() to get_algorithm(thd) to return algorithm name for displaying the error. - set_requested_algorithm(algo_value) to avoid direct assignment on requested_algorithm variable. - Avoid direct access of requested_algorithm to encapsulate requested_algorithm variable
Diffstat (limited to 'sql/sql_alter.h')
-rw-r--r--sql/sql_alter.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/sql/sql_alter.h b/sql/sql_alter.h
index 10aafe1ab37..53d0c8438f8 100644
--- a/sql/sql_alter.h
+++ b/sql/sql_alter.h
@@ -57,7 +57,10 @@ public:
ALTER_TABLE_ALGORITHM_NOCOPY,
// Instant should allow any operation that changes metadata only.
- ALTER_TABLE_ALGORITHM_INSTANT
+ ALTER_TABLE_ALGORITHM_INSTANT,
+
+ // When there is no specification of algorithm during alter table.
+ ALTER_TABLE_ALGORITHM_NONE
};
@@ -104,8 +107,11 @@ public:
List<const char> partition_names;
// Number of partitions.
uint num_parts;
+private:
// Type of ALTER TABLE algorithm.
enum_alter_table_algorithm requested_algorithm;
+
+public:
// Type of ALTER TABLE lock.
enum_alter_table_lock requested_lock;
@@ -114,7 +120,7 @@ public:
flags(0), partition_flags(0),
keys_onoff(LEAVE_AS_IS),
num_parts(0),
- requested_algorithm(ALTER_TABLE_ALGORITHM_DEFAULT),
+ requested_algorithm(ALTER_TABLE_ALGORITHM_NONE),
requested_lock(ALTER_TABLE_LOCK_DEFAULT)
{}
@@ -130,7 +136,7 @@ public:
keys_onoff= LEAVE_AS_IS;
num_parts= 0;
partition_names.empty();
- requested_algorithm= ALTER_TABLE_ALGORITHM_DEFAULT;
+ requested_algorithm= ALTER_TABLE_ALGORITHM_NONE;
requested_lock= ALTER_TABLE_LOCK_DEFAULT;
}
@@ -178,9 +184,15 @@ public:
bool set_requested_lock(const LEX_CSTRING *str);
/**
+ Set the requested algorithm to the given algorithm value
+ @param algo_value algorithm to be set
+ */
+ void set_requested_algorithm(enum_alter_table_algorithm algo_value);
+
+ /**
Returns the algorithm value in the format "algorithm=value"
*/
- const char* algorithm() const;
+ const char* algorithm_clause(THD *thd) const;
/**
Returns the lock value in the format "lock=value"
@@ -216,6 +228,12 @@ public:
bool supports_lock(THD *thd, enum_alter_inplace_result result,
const Alter_inplace_info *ha_alter_info);
+ /**
+ Return user requested algorithm. If user does not specify
+ algorithm then return alter_algorithm variable value.
+ */
+ enum_alter_table_algorithm algorithm(const THD *thd) const;
+
private:
Alter_info &operator=(const Alter_info &rhs); // not implemented
Alter_info(const Alter_info &rhs); // not implemented