summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc33
1 files changed, 28 insertions, 5 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 8a8a03cb4e4..a06ad0a4612 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -902,6 +902,7 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
const char *save_where;
char* db_name;
char db_name_string[FN_REFLEN];
+ bool save_use_only_table_context;
DBUG_ENTER("fix_fields_part_func");
if (part_info->fixed)
@@ -958,8 +959,14 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table,
This is a tricky call to prepare for since it can have a large number
of interesting side effects, both desirable and undesirable.
*/
+
+ save_use_only_table_context= thd->lex->use_only_table_context;
+ thd->lex->use_only_table_context= TRUE;
+
error= func_expr->fix_fields(thd, (Item**)0);
+ thd->lex->use_only_table_context= save_use_only_table_context;
+
context->table_list= save_table_list;
context->first_name_resolution_table= save_first_table;
context->last_name_resolution_table= save_last_table;
@@ -1849,6 +1856,20 @@ static int add_uint(File fptr, ulonglong number)
return add_string(fptr, buff);
}
+/*
+ Must escape strings in partitioned tables frm-files,
+ parsing it later with mysql_unpack_partition will fail otherwise.
+*/
+static int add_quoted_string(File fptr, const char *quotestr)
+{
+ String orgstr(quotestr, system_charset_info);
+ String escapedstr;
+ int err= add_string(fptr, "'");
+ err+= append_escaped(&escapedstr, &orgstr);
+ err+= add_string(fptr, escapedstr.c_ptr_safe());
+ return err + add_string(fptr, "'");
+}
+
static int add_keyword_string(File fptr, const char *keyword,
bool should_use_quotes,
const char *keystr)
@@ -1859,10 +1880,9 @@ static int add_keyword_string(File fptr, const char *keyword,
err+= add_equal(fptr);
err+= add_space(fptr);
if (should_use_quotes)
- err+= add_string(fptr, "'");
- err+= add_string(fptr, keystr);
- if (should_use_quotes)
- err+= add_string(fptr, "'");
+ err+= add_quoted_string(fptr, keystr);
+ else
+ err+= add_string(fptr, keystr);
return err + add_space(fptr);
}
@@ -5024,7 +5044,10 @@ the generated partition syntax in a correct manner.
*partition_changed= TRUE;
}
if (create_info->db_type == partition_hton)
- part_info->default_engine_type= table->part_info->default_engine_type;
+ {
+ if (!part_info->default_engine_type)
+ part_info->default_engine_type= table->part_info->default_engine_type;
+ }
else
part_info->default_engine_type= create_info->db_type;
if (check_native_partitioned(create_info, &is_native_partitioned,