Below is the list of changes that have just been committed into a local
5.0 repository of andrey. When andrey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.1962 05/09/08 21:30:05 andrey@lmy004. +3 -0
fix for bug #12651 (item of a prepared query allocated on non-permanent
are thus dangling later)
sql/sql_base.cc
1.297 05/09/08 21:29:52 andrey@lmy004. +17 -0
if there is tree transformation then backup the current arena
and use permanent one (for PS) otherwise the data will be deallocated
after the prepare process is finished.
this bug was introduced with the recent natural join patch
mysql-test/t/ps.test
1.54 05/09/08 21:29:52 andrey@lmy004. +15 -0
test for bug #12651
(data allocated on thd's arena but not on permanent arena)
mysql-test/r/ps.result
1.53 05/09/08 21:29:51 andrey@lmy004. +8 -0
test for bug #12651
(data allocated on thd's arena but not on permanent arena)
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: andrey
# Host: lmy004.
# Root: /work/mysql-5.0-bug12651
--- 1.296/sql/sql_base.cc 2005-09-02 16:06:09 +02:00
+++ 1.297/sql/sql_base.cc 2005-09-08 21:29:52 +02:00
@@ -2612,6 +2612,8 @@
table_list->alias, name, item_name, (ulong) ref));
Field_iterator_view field_it;
field_it.set(table_list);
+ Query_arena *arena, backup;
+
DBUG_ASSERT(table_list->schema_table_reformed ||
(ref != 0 && table_list->view != 0));
for (; !field_it.end_of_fields(); field_it.next())
@@ -2633,7 +2635,13 @@
name, length))
DBUG_RETURN(WRONG_GRANT);
#endif
+ // in PS use own arena or data will be freed after prepare
+ if (register_tree_change)
+ arena= thd->activate_stmt_arena_if_needed(&backup);
Item *item= field_it.create_item(thd);
+ if (register_tree_change && arena)
+ thd->restore_active_arena(arena, &backup);
+
if (!item)
DBUG_RETURN(0);
/*
@@ -2695,6 +2703,8 @@
field_it(*(table_ref->join_columns));
Natural_join_column *nj_col;
Field *found_field;
+ Query_arena *arena, backup;
+
DBUG_ENTER("find_field_in_natural_join");
DBUG_PRINT("enter", ("field name: '%s', ref 0x%lx",
name, (ulong) ref));
@@ -2723,7 +2733,14 @@
The found field is a view field, we do as in find_field_in_view()
and return a pointer to pointer to the Item of that field.
*/
+ if (register_tree_change)
+ arena= thd->activate_stmt_arena_if_needed(&backup);
+
Item *item= nj_col->create_item(thd);
+
+ if (register_tree_change && arena)
+ thd->restore_active_arena(arena, &backup);
+
if (!item)
DBUG_RETURN(NULL);
DBUG_ASSERT(nj_col->table_field == NULL);
--- 1.52/mysql-test/r/ps.result 2005-09-06 19:51:07 +02:00
+++ 1.53/mysql-test/r/ps.result 2005-09-08 21:29:51 +02:00
@@ -773,6 +773,14 @@
select ? from t1;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '? from t1' at line 1
drop table t1;
+CREATE TABLE b12651_T1(a int) ENGINE=MYISAM;
+CREATE TABLE b12651_T2(b int) ENGINE=MYISAM;
+CREATE VIEW b12651_V1 as SELECT b FROM b12651_T2;
+PREPARE b12651 FROM 'SELECT 1 FROM b12651_T1 WHERE a IN (SELECT b FROM b12651_V1)';
+EXECUTE b12651;
+1
+DROP VIEW b12651_V1;
+DROP TABLE b12651_T1, b12651_T2;
prepare stmt from "select @@time_zone";
execute stmt;
@@time_zone
--- 1.53/mysql-test/t/ps.test 2005-09-06 19:51:07 +02:00
+++ 1.54/mysql-test/t/ps.test 2005-09-08 21:29:52 +02:00
@@ -809,6 +809,21 @@
select ? from t1;
--enable_ps_protocol
drop table t1;
+
+#
+# Bug#12651
+# (Crash on a PS including a subquery which is a select from a simple view)
+#
+CREATE TABLE b12651_T1(a int) ENGINE=MYISAM;
+CREATE TABLE b12651_T2(b int) ENGINE=MYISAM;
+CREATE VIEW b12651_V1 as SELECT b FROM b12651_T2;
+
+PREPARE b12651 FROM 'SELECT 1 FROM b12651_T1 WHERE a IN (SELECT b FROM b12651_V1)';
+EXECUTE b12651;
+
+DROP VIEW b12651_V1;
+DROP TABLE b12651_T1, b12651_T2;
+
#
# Bug#9359 "Prepared statements take snapshot of system vars at PREPARE
# time"
| Thread |
|---|
| • bk commit into 5.0 tree (andrey:1.1962) BUG#12651 | ahristov | 8 Sep |