summaryrefslogtreecommitdiff
path: root/sql/create_options.cc
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2015-06-05 23:24:39 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2015-06-05 23:24:39 +0200
commitf8fa5fe1bc9023e0e9fac5b05515b94ed04289cb (patch)
tree44bff5f7c263003693720c2f0ba79f1ede0243c5 /sql/create_options.cc
parent9dee994d992b3930f0d29197aed82771bf910c47 (diff)
parentf7002c05ae4e4a09bc6859ccc568064cfd6bb268 (diff)
downloadmariadb-git-f8fa5fe1bc9023e0e9fac5b05515b94ed04289cb.tar.gz
Commit merge resolve
Diffstat (limited to 'sql/create_options.cc')
-rw-r--r--sql/create_options.cc65
1 files changed, 41 insertions, 24 deletions
diff --git a/sql/create_options.cc b/sql/create_options.cc
index 5800003ed49..c3796710f78 100644
--- a/sql/create_options.cc
+++ b/sql/create_options.cc
@@ -297,8 +297,7 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
(uchar*)val->name.str, val->name.length))
continue;
- seen=true;
-
+ /* skip duplicates (see engine_option_value constructor above) */
if (val->parsed && !val->value.str)
continue;
@@ -306,39 +305,58 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
*option_struct, suppress_warning || val->parsed, root))
DBUG_RETURN(TRUE);
val->parsed= true;
+ seen=true;
break;
}
- if (!seen)
+ if (!seen || (opt->var && !last->value.str))
{
LEX_STRING default_val= null_lex_str;
/*
- If it's CREATE/ALTER TABLE parsing mode (options are created in the
- transient thd->mem_root, not in the long living TABLE_SHARE::mem_root),
- and variable-backed option was not explicitly set.
-
- If it's not create, but opening of the existing frm (that was,
- probably, created with the older version of the storage engine and
- does not have this option stored), we take the *default* value of the
- sysvar, not the *current* value. Because we don't want to have
- different option values for the same table if it's opened many times.
+ Okay, here's the logic for sysvar options:
+ 1. When we parse CREATE TABLE and sysvar option was not explicitly
+ mentioned we add it to the list as if it was specified with the
+ *current* value of the underlying sysvar.
+ 2. But only if the underlying sysvar value is different from the
+ sysvar's default.
+ 3. If it's ALTER TABLE and the sysvar option was not explicitly
+ mentioned - do nothing, do not add it to the list.
+ 4. But if it was ALTER TABLE with sysvar option = DEFAULT, we
+ add it to the list (under the same condition #2).
+ 5. If we're here parsing the option list from the .frm file
+ for a normal open_table() and the sysvar option was not there -
+ do not add it to the list (makes no sense anyway) and
+ use the *default* value of the underlying sysvar. Because
+ sysvar value can change, but it should not affect existing tables.
+
+ This is how it's implemented: the current sysvar value is added
+ to the list if suppress_warning is FALSE (meaning a table is created,
+ that is CREATE TABLE or ALTER TABLE) and it's actually a CREATE TABLE
+ command or it's an ALTER TABLE and the option was seen (=DEFAULT).
+
+ Note that if the option was set explicitly (not =DEFAULT) it wouldn't
+ have passes the if() condition above.
*/
- if (root == thd->mem_root && opt->var)
+ if (!suppress_warning && opt->var &&
+ (thd->lex->sql_command == SQLCOM_CREATE_TABLE || seen))
{
// take a value from the variable and add it to the list
sys_var *sysvar= find_hton_sysvar(hton, opt->var);
DBUG_ASSERT(sysvar);
- char buf[256];
- String sbuf(buf, sizeof(buf), system_charset_info), *str;
- if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_lex_str)))
+ if (!sysvar->session_is_default(thd))
{
- LEX_STRING name= { const_cast<char*>(opt->name), opt->name_length };
- default_val.str= strmake_root(root, str->ptr(), str->length());
- default_val.length= str->length();
- val= new (root) engine_option_value(name, default_val, true,
- option_list, &last);
- val->parsed= true;
+ char buf[256];
+ String sbuf(buf, sizeof(buf), system_charset_info), *str;
+ if ((str= sysvar->val_str(&sbuf, thd, OPT_SESSION, &null_lex_str)))
+ {
+ LEX_STRING name= { const_cast<char*>(opt->name), opt->name_length };
+ default_val.str= strmake_root(root, str->ptr(), str->length());
+ default_val.length= str->length();
+ val= new (root) engine_option_value(name, default_val,
+ opt->type != HA_OPTION_TYPE_ULL, option_list, &last);
+ val->parsed= true;
+ }
}
}
set_one_value(opt, thd, &default_val, *option_struct,
@@ -762,9 +780,8 @@ engine_option_value *merge_engine_table_options(engine_option_value *first,
engine_option_value *second,
MEM_ROOT *root)
{
- engine_option_value *end, *opt;
+ engine_option_value *UNINIT_VAR(end), *opt;
DBUG_ENTER("merge_engine_table_options");
- LINT_INIT(end);
/* Create copy of first list */
for (opt= first, first= 0; opt; opt= opt->next)