summaryrefslogtreecommitdiff
path: root/sql/create_options.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-09-25 19:42:22 +0200
committerSergei Golubchik <sergii@pisem.net>2013-09-25 19:42:22 +0200
commit20031c62735f9b52420b54e2c66c7eeeccd7044f (patch)
treefcbcfec1f7baffe0e4a581ba1f0a1141c5a90434 /sql/create_options.cc
parentfd5530625487471f0c238a0b5a4c187ae20961e8 (diff)
downloadmariadb-git-20031c62735f9b52420b54e2c66c7eeeccd7044f.tar.gz
Enable TokuDB online ALTER
sql/create_options.cc: an utility function to compare two filled-in engine_option structures sql/sql_table.cc: * two keys are different if their option_struct's differ (for ALTER TABLE DROP key, ADD key) * engines doing inplace alter must see the new frm image
Diffstat (limited to 'sql/create_options.cc')
-rw-r--r--sql/create_options.cc36
1 files changed, 29 insertions, 7 deletions
diff --git a/sql/create_options.cc b/sql/create_options.cc
index 774d739f153..d9b1d31fd62 100644
--- a/sql/create_options.cc
+++ b/sql/create_options.cc
@@ -115,6 +115,8 @@ static bool report_unknown_option(THD *thd, engine_option_value *val,
DBUG_RETURN(FALSE);
}
+#define value_ptr(STRUCT,OPT) ((char*)(STRUCT) + (OPT)->offset)
+
static bool set_one_value(ha_create_table_option *opt,
THD *thd, const LEX_STRING *value, void *base,
bool suppress_warning,
@@ -131,7 +133,7 @@ static bool set_one_value(ha_create_table_option *opt,
DBUG_ASSERT(0); // HA_OPTION_TYPE_SYSVAR's are replaced in resolve_sysvars()
case HA_OPTION_TYPE_ULL:
{
- ulonglong *val= (ulonglong*)((char*)base + opt->offset);
+ ulonglong *val= (ulonglong*)value_ptr(base, opt);
if (!value->str)
{
*val= opt->def_value;
@@ -155,7 +157,7 @@ static bool set_one_value(ha_create_table_option *opt,
}
case HA_OPTION_TYPE_STRING:
{
- char **val= (char **)((char *)base + opt->offset);
+ char **val= (char **)value_ptr(base, opt);
if (!value->str)
{
*val= 0;
@@ -168,7 +170,7 @@ static bool set_one_value(ha_create_table_option *opt,
}
case HA_OPTION_TYPE_ENUM:
{
- uint *val= (uint *)((char *)base + opt->offset), num;
+ uint *val= (uint *)value_ptr(base, opt), num;
*val= (uint) opt->def_value;
if (!value->str)
@@ -200,7 +202,7 @@ static bool set_one_value(ha_create_table_option *opt,
}
case HA_OPTION_TYPE_BOOL:
{
- bool *val= (bool *)((char *)base + opt->offset);
+ bool *val= (bool *)value_ptr(base, opt);
*val= opt->def_value;
if (!value->str)
@@ -284,7 +286,7 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
*option_struct= alloc_root(root, option_struct_size);
}
- for (opt= rules; opt && opt->name; opt++)
+ for (opt= rules; rules && opt->name; opt++)
{
bool seen=false;
for (val= *option_list; val; val= val->next)
@@ -362,7 +364,7 @@ bool parse_option_list(THD* thd, handlerton *hton, void *option_struct_arg,
*/
static bool resolve_sysvars(handlerton *hton, ha_create_table_option *rules)
{
- for (ha_create_table_option *opt= rules; opt && opt->name; opt++)
+ for (ha_create_table_option *opt= rules; rules && opt->name; opt++)
{
if (opt->type == HA_OPTION_TYPE_SYSVAR)
{
@@ -428,7 +430,7 @@ bool resolve_sysvar_table_options(handlerton *hton)
*/
static void free_sysvars(handlerton *hton, ha_create_table_option *rules)
{
- for (ha_create_table_option *opt= rules; opt && opt->name; opt++)
+ for (ha_create_table_option *opt= rules; rules && opt->name; opt++)
{
if (opt->var)
{
@@ -491,6 +493,26 @@ bool parse_engine_table_options(THD *thd, handlerton *ht, TABLE_SHARE *share)
}
+bool engine_options_differ(void *old_struct, void *new_struct,
+ ha_create_table_option *rules)
+{
+ ha_create_table_option *opt;
+ for (opt= rules; rules && opt->name; opt++)
+ {
+ char **old_val= (char**)value_ptr(old_struct, opt);
+ char **new_val= (char**)value_ptr(new_struct, opt);
+ int neq;
+ if (opt->type == HA_OPTION_TYPE_STRING)
+ neq= (*old_val && *new_val) ? strcmp(*old_val, *new_val) : *old_val != *new_val;
+ else
+ neq= memcmp(old_val, new_val, ha_option_type_sizeof[opt->type]);
+ if (neq)
+ return true;
+ }
+ return false;
+}
+
+
/**
Returns representation length of key and value in the frm file
*/