List:Commits« Previous MessageNext Message »
From:Evgeny Potemkin Date:December 3 2009 8:16am
Subject:bzr push into mysql-pe branch (epotemkin:3735 to 3736)
View as plain text  
 3736 Evgeny Potemkin	2009-12-03 [merge]
      Auto-merged.

    modified:
      mysql-test/r/ps.result
      mysql-test/t/ps.test
      sql/item_cmpfunc.cc
      sql/sql_base.cc
      sql/sql_class.h
 3735 Alexander Barkov	2009-12-02 [merge]
      Merging Bug#48766 from 5.1.

    modified:
      mysql-test/r/sp-ucs2.result
      mysql-test/t/sp-ucs2.test
      sql/sp.cc
=== modified file 'mysql-test/r/ps.result'
--- a/mysql-test/r/ps.result	2009-10-23 06:47:02 +0000
+++ b/mysql-test/r/ps.result	2009-12-03 08:09:18 +0000
@@ -1917,6 +1917,29 @@ execute stmt using @arg;
 ?
 -12345.5432100000
 deallocate prepare stmt;
+#
+# Bug#48508: Crash on prepared statement re-execution.
+#
+create table t1(b int);
+insert into t1 values (0);
+create view v1 AS select 1 as a from t1 where b;
+prepare stmt from "select * from v1 where a";
+execute stmt;
+a
+execute stmt;
+a
+drop table t1;
+drop view v1;
+create table t1(a bigint);
+create table t2(b tinyint);
+insert into t2 values (null);
+prepare stmt from "select 1 from t1 join  t2 on a xor b where b > 1  and a =1";
+execute stmt;
+1
+execute stmt;
+1
+drop table t1,t2;
+#
 End of 5.0 tests.
 create procedure proc_1() reset query cache;
 call proc_1();

=== modified file 'mysql-test/t/ps.test'
--- a/mysql-test/t/ps.test	2009-10-23 06:47:02 +0000
+++ b/mysql-test/t/ps.test	2009-12-03 08:09:18 +0000
@@ -1991,6 +1991,27 @@ select @arg;
 execute stmt using @arg;
 deallocate prepare stmt;
 
+--echo #
+--echo # Bug#48508: Crash on prepared statement re-execution.
+--echo #
+create table t1(b int);
+insert into t1 values (0);
+create view v1 AS select 1 as a from t1 where b;
+prepare stmt from "select * from v1 where a";
+execute stmt;
+execute stmt;
+drop table t1;
+drop view v1;
+
+create table t1(a bigint);
+create table t2(b tinyint);
+insert into t2 values (null);
+prepare stmt from "select 1 from t1 join  t2 on a xor b where b > 1  and a =1";
+execute stmt;
+execute stmt;
+drop table t1,t2;
+--echo #
+
 --echo End of 5.0 tests.
 
 #

=== modified file 'sql/item_cmpfunc.cc'
--- a/sql/item_cmpfunc.cc	2009-11-27 14:56:49 +0000
+++ b/sql/item_cmpfunc.cc	2009-12-03 08:09:18 +0000
@@ -4394,7 +4394,7 @@ Item *Item_cond::compile(Item_analyzer a
     uchar *arg_v= *arg_p;
     Item *new_item= item->compile(analyzer, &arg_v, transformer, arg_t);
     if (new_item && new_item != item)
-      li.replace(new_item);
+      current_thd->change_item_tree(li.ref(), new_item);
   }
   return Item_func::transform(transformer, arg_t);
 }

=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc	2009-11-27 14:56:49 +0000
+++ b/sql/sql_base.cc	2009-12-03 08:09:18 +0000
@@ -5477,7 +5477,8 @@ find_field_in_view(THD *thd, TABLE_LIST 
     if (!my_strcasecmp(system_charset_info, field_it.name(), name))
     {
       // in PS use own arena or data will be freed after prepare
-      if (register_tree_change && thd->stmt_arena->is_stmt_prepare_or_first_sp_execute())
+      if (register_tree_change &&
+          thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())
         arena= thd->activate_stmt_arena_if_needed(&backup);
       /*
         create_item() may, or may not create a new Item, depending on

=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h	2009-11-27 14:56:49 +0000
+++ b/sql/sql_class.h	2009-12-03 08:09:18 +0000
@@ -605,6 +605,8 @@ public:
   { return state == INITIALIZED_FOR_SP; }
   inline bool is_stmt_prepare_or_first_sp_execute() const
   { return (int)state < (int)PREPARED; }
+  inline bool is_stmt_prepare_or_first_stmt_execute() const
+  { return (int)state <= (int)PREPARED; }
   inline bool is_first_stmt_execute() const { return state == PREPARED; }
   inline bool is_stmt_execute() const
   { return state == PREPARED || state == EXECUTED; }


Attachment: [text/bzr-bundle] bzr/epotemkin@mysql.com-20091203080918-pn8zh8w7fbs4wc8w.bundle
Thread
bzr push into mysql-pe branch (epotemkin:3735 to 3736)Evgeny Potemkin3 Dec