mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
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.
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user