[Commits] Rev 3215: MDEV-4823: Server crashes in Item_func_not::fix_fields on creating a table with a virtual column using NOT in file:///home/bell/maria/bzr/work-maria-5.2-MDEV-4823/

sanja at montyprogram.com sanja at montyprogram.com
Thu Aug 1 09:25:52 EEST 2013


At file:///home/bell/maria/bzr/work-maria-5.2-MDEV-4823/

------------------------------------------------------------
revno: 3215
revision-id: sanja at montyprogram.com-20130801062550-tv9tkgbk3zh42ug1
parent: wlad at montyprogram.com-20130709202457-6n9syq59jdd2sy3b
committer: sanja at montyprogram.com
branch nick: work-maria-5.2-MDEV-4823
timestamp: Thu 2013-08-01 09:25:50 +0300
message:
  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).
-------------- next part --------------
=== modified file 'mysql-test/suite/vcol/r/vcol_misc.result'
--- a/mysql-test/suite/vcol/r/vcol_misc.result	2013-01-20 07:40:53 +0000
+++ b/mysql-test/suite/vcol/r/vcol_misc.result	2013-08-01 06:25:50 +0000
@@ -193,3 +193,10 @@ SELECT COUNT(*) FROM t1;
 COUNT(*)
 2
 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

=== modified file 'mysql-test/suite/vcol/t/vcol_misc.test'
--- a/mysql-test/suite/vcol/t/vcol_misc.test	2013-01-20 07:40:53 +0000
+++ b/mysql-test/suite/vcol/t/vcol_misc.test	2013-08-01 06:25:50 +0000
@@ -198,3 +198,11 @@ SELECT COUNT(*) FROM 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

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2013-01-16 00:46:27 +0000
+++ b/sql/table.cc	2013-08-01 06:25:50 +0000
@@ -1812,7 +1812,7 @@ bool fix_vcol_expr(THD *thd,
   bool result= TRUE;
   TABLE_LIST tables;
   TABLE_LIST *save_table_list, *save_first_table, *save_last_table;
-  int error;
+  int error= 0;
   Name_resolution_context *context;
   const char *save_where;
   char* db_name;
@@ -1860,7 +1860,13 @@ bool fix_vcol_expr(THD *thd,
   save_use_only_table_context= thd->lex->use_only_table_context;
   thd->lex->use_only_table_context= TRUE;
   /* 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*/
   thd->lex->use_only_table_context= save_use_only_table_context;
   context->table_list= save_table_list;



More information about the commits mailing list