#At file:///export/home/x/mysql-trunk-online-alter/ based on revid:mayank.prasad@stripped
3377 Jon Olav Hauglid 2011-05-20
WL#5534 Online ALTER in 5.6*
Implementation of ALTER TABLE syntax changes:
ALTER TABLE ... algorithm concurrency
algorithm:
/* empty */
| ALGORITHM [=] DEFAULT
| ALGORITHM [=] INPLACE
| ALGORITHM [=] COPY
concurrency:
/* empty */
| LOCK [=] DEFAULT
| LOCK [=] NONE
| LOCK [=] SHARED
| LOCK [=] EXCLUSIVE
The patch updates sql_yacc.yy to add support for these two
new clauses. It also updates the Alter_info class to store
information about them for a given ALTER TABLE statement.
None of these clauses currently have any effect.
modified:
sql/share/errmsg-utf8.txt
sql/sql_lex.cc
sql/sql_lex.h
sql/sql_yacc.yy
=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt 2011-05-12 17:29:19 +0000
+++ b/sql/share/errmsg-utf8.txt 2011-05-20 12:38:10 +0000
@@ -6503,3 +6503,8 @@ ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_CR
eng "The creation of some temporary tables could not be rolled back."
ER_WARNING_NOT_COMPLETE_ROLLBACK_WITH_DROPPED_TEMP_TABLE
eng "Some temporary tables were dropped, but these operations could not be rolled back."
+
+ER_UNKNOWN_ALTER_ALGORITHM
+ eng "Unknown ALGORITHM value '%s'"
+ER_UNKNOWN_ALTER_LOCK
+ eng "Unknown LOCK value '%s'"
=== modified file 'sql/sql_lex.cc'
--- a/sql/sql_lex.cc 2011-04-01 14:04:52 +0000
+++ b/sql/sql_lex.cc 2011-05-20 12:38:10 +0000
@@ -1650,7 +1650,9 @@ Alter_info::Alter_info(const Alter_info
num_parts(rhs.num_parts),
change_level(rhs.change_level),
datetime_field(rhs.datetime_field),
- error_if_not_empty(rhs.error_if_not_empty)
+ error_if_not_empty(rhs.error_if_not_empty),
+ requested_algorithm(rhs.requested_algorithm),
+ requested_lock(rhs.requested_lock)
{
/*
Make deep copies of used objects.
@@ -1669,6 +1671,36 @@ Alter_info::Alter_info(const Alter_info
}
+bool Alter_info::set_requested_algorithm(const LEX_STRING *str)
+{
+ if (!my_strcasecmp(system_charset_info, str->str, "INPLACE"))
+ requested_algorithm= ALTER_TABLE_ALGORITHM_INPLACE;
+ else if (!my_strcasecmp(system_charset_info, str->str, "COPY"))
+ requested_algorithm= ALTER_TABLE_ALGORITHM_COPY;
+ else if (!my_strcasecmp(system_charset_info, str->str, "DEFAULT"))
+ requested_algorithm= ALTER_TABLE_ALGORITHM_DEFAULT;
+ else
+ return true;
+ return false;
+}
+
+
+bool Alter_info::set_requested_lock(const LEX_STRING *str)
+{
+ if (!my_strcasecmp(system_charset_info, str->str, "NONE"))
+ requested_lock= ALTER_TABLE_LOCK_NONE;
+ else if (!my_strcasecmp(system_charset_info, str->str, "SHARED"))
+ requested_lock= ALTER_TABLE_LOCK_SHARED;
+ else if (!my_strcasecmp(system_charset_info, str->str, "EXCLUSIVE"))
+ requested_lock= ALTER_TABLE_LOCK_EXCLUSIVE;
+ else if (!my_strcasecmp(system_charset_info, str->str, "DEFAULT"))
+ requested_lock= ALTER_TABLE_LOCK_DEFAULT;
+ else
+ return true;
+ return false;
+}
+
+
void trim_whitespace(const CHARSET_INFO *cs, LEX_STRING *str)
{
/*
=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h 2011-05-12 17:29:19 +0000
+++ b/sql/sql_lex.h 2011-05-20 12:38:10 +0000
@@ -911,6 +911,20 @@ enum enum_alter_table_change_level
ALTER_TABLE_INDEX_CHANGED= 2
};
+enum enum_alter_table_algorithm
+{
+ ALTER_TABLE_ALGORITHM_DEFAULT= 0,
+ ALTER_TABLE_ALGORITHM_INPLACE,
+ ALTER_TABLE_ALGORITHM_COPY
+};
+
+enum enum_alter_table_lock
+{
+ ALTER_TABLE_LOCK_DEFAULT= 0,
+ ALTER_TABLE_LOCK_NONE,
+ ALTER_TABLE_LOCK_SHARED,
+ ALTER_TABLE_LOCK_EXCLUSIVE
+};
/**
Temporary hack to enable a class bound forward declaration
@@ -951,6 +965,8 @@ public:
enum_alter_table_change_level change_level;
Create_field *datetime_field;
bool error_if_not_empty;
+ enum_alter_table_algorithm requested_algorithm;
+ enum_alter_table_lock requested_lock;
Alter_info() :
@@ -960,7 +976,9 @@ public:
num_parts(0),
change_level(ALTER_TABLE_METADATA_ONLY),
datetime_field(NULL),
- error_if_not_empty(FALSE)
+ error_if_not_empty(FALSE),
+ requested_algorithm(ALTER_TABLE_ALGORITHM_DEFAULT),
+ requested_lock(ALTER_TABLE_LOCK_DEFAULT)
{}
void reset()
@@ -977,8 +995,35 @@ public:
change_level= ALTER_TABLE_METADATA_ONLY;
datetime_field= 0;
error_if_not_empty= FALSE;
+ requested_algorithm= ALTER_TABLE_ALGORITHM_DEFAULT;
+ requested_lock= ALTER_TABLE_LOCK_DEFAULT;
}
Alter_info(const Alter_info &rhs, MEM_ROOT *mem_root);
+
+
+ /**
+ Parses the given string and sets requested_algorithm
+ if the string value matches a supported value.
+ Supported values: INPLACE, COPY, DEFAULT
+
+ @param str String containing the supplied value
+ @retval false Supported value found, state updated
+ @retval true Not supported value, no changes made
+ */
+ bool set_requested_algorithm(const LEX_STRING *str);
+
+
+ /**
+ Parses the given string and sets requested_lock
+ if the string value matches a supported value.
+ Supported values: NONE, SHARED, EXCLUSIVE, DEFAULT
+
+ @param str String containing the supplied value
+ @retval false Supported value found, state updated
+ @retval true Not supported value, no changes made
+ */
+
+ bool set_requested_lock(const LEX_STRING *str);
private:
Alter_info &operator=(const Alter_info &rhs); // not implemented
Alter_info(const Alter_info &rhs); // not implemented
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2011-05-12 05:52:39 +0000
+++ b/sql/sql_yacc.yy 2011-05-20 12:38:10 +0000
@@ -6871,6 +6871,24 @@ alter_list_item:
LEX *lex=Lex;
lex->alter_info.flags|= ALTER_ORDER;
}
+ | ALGORITHM_SYM opt_equal DEFAULT {}
+ | ALGORITHM_SYM opt_equal ident_or_text
+ {
+ if (Lex->alter_info.set_requested_algorithm(&$3))
+ {
+ my_error(ER_UNKNOWN_ALTER_ALGORITHM, MYF(0), $3.str);
+ MYSQL_YYABORT;
+ }
+ }
+ | LOCK_SYM opt_equal DEFAULT {}
+ | LOCK_SYM opt_equal ident_or_text
+ {
+ if (Lex->alter_info.set_requested_lock(&$3))
+ {
+ my_error(ER_UNKNOWN_ALTER_LOCK, MYF(0), $3.str);
+ MYSQL_YYABORT;
+ }
+ }
;
opt_column:
Attachment: [text/bzr-bundle] bzr/jon.hauglid@oracle.com-20110520123810-uqk8zpfiv9b8lah0.bundle
| Thread |
|---|
| • bzr commit into mysql-trunk branch (jon.hauglid:3377) WL#5534 | Jon Olav Hauglid | 20 May |