Commit a9a7b023 authored by unknown's avatar unknown

MDEV-4823: Server crashes in Item_func_not::fix_fields on creating a table...

MDEV-4823: Server crashes in Item_func_not::fix_fields on creating a table with a virtual column using NOT

fix_field() call protocol was brocken (zero pointer passed as link to item which is possible only if you are sure that there can not be Items which transforms).
parent 5f4318b6
...@@ -193,3 +193,10 @@ SELECT COUNT(*) FROM t1; ...@@ -193,3 +193,10 @@ SELECT COUNT(*) FROM t1;
COUNT(*) COUNT(*)
2 2
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-4823 Server crashes in Item_func_not::fix_fields on
# creating a table with a virtual column using NOT
#
CREATE TABLE t1 ( f1 INT, v4 INT AS ( NOT f1 ) VIRTUAL );
drop table t1;
# end of 5.2 tests
...@@ -198,3 +198,11 @@ SELECT COUNT(*) FROM t1; ...@@ -198,3 +198,11 @@ SELECT COUNT(*) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-4823 Server crashes in Item_func_not::fix_fields on
--echo # creating a table with a virtual column using NOT
--echo #
CREATE TABLE t1 ( f1 INT, v4 INT AS ( NOT f1 ) VIRTUAL );
drop table t1;
--echo # end of 5.2 tests
...@@ -1812,7 +1812,7 @@ bool fix_vcol_expr(THD *thd, ...@@ -1812,7 +1812,7 @@ bool fix_vcol_expr(THD *thd,
bool result= TRUE; bool result= TRUE;
TABLE_LIST tables; TABLE_LIST tables;
TABLE_LIST *save_table_list, *save_first_table, *save_last_table; TABLE_LIST *save_table_list, *save_first_table, *save_last_table;
int error; int error= 0;
Name_resolution_context *context; Name_resolution_context *context;
const char *save_where; const char *save_where;
char* db_name; char* db_name;
...@@ -1860,7 +1860,13 @@ bool fix_vcol_expr(THD *thd, ...@@ -1860,7 +1860,13 @@ bool fix_vcol_expr(THD *thd,
save_use_only_table_context= thd->lex->use_only_table_context; save_use_only_table_context= thd->lex->use_only_table_context;
thd->lex->use_only_table_context= TRUE; thd->lex->use_only_table_context= TRUE;
/* Fix fields referenced to by the virtual column function */ /* Fix fields referenced to by the virtual column function */
error= func_expr->fix_fields(thd, (Item**)0); if (!func_expr->fixed)
error= func_expr->fix_fields(thd, &vcol_info->expr_item);
/* fix_fields could change the expression */
func_expr= vcol_info->expr_item;
/* Number of columns will be checked later */
/* Restore the original context*/ /* Restore the original context*/
thd->lex->use_only_table_context= save_use_only_table_context; thd->lex->use_only_table_context= save_use_only_table_context;
context->table_list= save_table_list; context->table_list= save_table_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment