Commit 89e95985 authored by unknown's avatar unknown

Merge ahristov@bk-internal.mysql.com:/home/bk/mysql-5.0

into lmy004.:/work/mysql-5.0-bug12651

parents 5ed7e973 d3f2e6af
...@@ -773,6 +773,14 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -773,6 +773,14 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
select ? from t1; 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 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; 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"; prepare stmt from "select @@time_zone";
execute stmt; execute stmt;
@@time_zone @@time_zone
......
...@@ -809,6 +809,21 @@ select ??; ...@@ -809,6 +809,21 @@ select ??;
select ? from t1; select ? from t1;
--enable_ps_protocol --enable_ps_protocol
drop table t1; 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 # Bug#9359 "Prepared statements take snapshot of system vars at PREPARE
# time" # time"
......
...@@ -2612,6 +2612,8 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list, ...@@ -2612,6 +2612,8 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
table_list->alias, name, item_name, (ulong) ref)); table_list->alias, name, item_name, (ulong) ref));
Field_iterator_view field_it; Field_iterator_view field_it;
field_it.set(table_list); field_it.set(table_list);
Query_arena *arena, backup;
DBUG_ASSERT(table_list->schema_table_reformed || DBUG_ASSERT(table_list->schema_table_reformed ||
(ref != 0 && table_list->view != 0)); (ref != 0 && table_list->view != 0));
for (; !field_it.end_of_fields(); field_it.next()) for (; !field_it.end_of_fields(); field_it.next())
...@@ -2633,7 +2635,13 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list, ...@@ -2633,7 +2635,13 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
name, length)) name, length))
DBUG_RETURN(WRONG_GRANT); DBUG_RETURN(WRONG_GRANT);
#endif #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); Item *item= field_it.create_item(thd);
if (register_tree_change && arena)
thd->restore_active_arena(arena, &backup);
if (!item) if (!item)
DBUG_RETURN(0); DBUG_RETURN(0);
/* /*
...@@ -2695,6 +2703,8 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, ...@@ -2695,6 +2703,8 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
field_it(*(table_ref->join_columns)); field_it(*(table_ref->join_columns));
Natural_join_column *nj_col; Natural_join_column *nj_col;
Field *found_field; Field *found_field;
Query_arena *arena, backup;
DBUG_ENTER("find_field_in_natural_join"); DBUG_ENTER("find_field_in_natural_join");
DBUG_PRINT("enter", ("field name: '%s', ref 0x%lx", DBUG_PRINT("enter", ("field name: '%s', ref 0x%lx",
name, (ulong) ref)); name, (ulong) ref));
...@@ -2723,7 +2733,14 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name, ...@@ -2723,7 +2733,14 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
The found field is a view field, we do as in find_field_in_view() 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. 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); Item *item= nj_col->create_item(thd);
if (register_tree_change && arena)
thd->restore_active_arena(arena, &backup);
if (!item) if (!item)
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
DBUG_ASSERT(nj_col->table_field == NULL); DBUG_ASSERT(nj_col->table_field == NULL);
......
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