summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2007-10-09 19:16:39 +0500
committerunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2007-10-09 19:16:39 +0500
commit492f0e3f315fe155d022d62edc9f00f8af4c46a5 (patch)
treec448012ac6951fe6ea62bbb0865cd44493e13145 /sql/sql_partition.cc
parent4374631593eedccdbfb52c9858cf87b4e517f959 (diff)
downloadmariadb-git-492f0e3f315fe155d022d62edc9f00f8af4c46a5.tar.gz
Fix for bug #29444: crash with partition refering to table in create-select
Problem: creating a partitioned table during name resolution for the partition function we search for column names in all parts of the CREATE TABLE query. It is superfluous (and wrong) sometimes. Fix: launch name resolution for the partition function against the table we're creating. mysql-test/r/partition.result: Fix for bug #29444: crash with partition refering to table in create-select - test result. mysql-test/t/partition.test: Fix for bug #29444: crash with partition refering to table in create-select - test result. sql/item.cc: Fix for bug #29444: crash with partition refering to table in create-select - LEX::use_only_table_context introduced, which is used in the Item_field::fix_fields() to resolve names only against context->first_name_resolution_table/last_name_resolution_table. sql/sql_lex.cc: Fix for bug #29444: crash with partition refering to table in create-select - LEX::use_only_table_context introduced, which is used in the Item_field::fix_fields() to resolve names only against context->first_name_resolution_table/last_name_resolution_table. sql/sql_lex.h: Fix for bug #29444: crash with partition refering to table in create-select - LEX::use_only_table_context introduced, which is used in the Item_field::fix_fields() to resolve names only against context->first_name_resolution_table/last_name_resolution_table. sql/sql_partition.cc: Fix for bug #29444: crash with partition refering to table in create-select - set the lex->use_only_table_context before the func_expr->fix_fields() call to ensure we're resolving names against the table we're creating; then restore it back after the call.
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 8a8a03cb4e4..0cc2cac2a1a 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;