Commit d8b447a1 authored by unknown's avatar unknown

Merge bodhi.local:/opt/local/work/tmp_merge

into  bodhi.local:/opt/local/work/mysql-5.0-runtime-merge-41


ndb/src/mgmsrv/ConfigInfo.cpp:
  Auto merged
sql/table.cc:
  Auto merged
mysql-test/r/ps.result:
  Manual merge: use local.
mysql-test/t/ps.test:
  Manual merge: remove duplicate test cases from ps.test.
sql/sql_lex.cc:
  Manual merge.
sql/sql_prepare.cc:
  Manual merge.
sql/table.h:
  Manual merge.
parents 67d53e36 4cb0659d
...@@ -490,17 +490,6 @@ execute stmt; ...@@ -490,17 +490,6 @@ execute stmt;
deallocate prepare stmt; deallocate prepare stmt;
drop table t1, t2; drop table t1, t2;
#
# Bug#6102 "Server crash with prepared statement and blank after
# function name"
# ensure that stored functions are cached when preparing a statement
# before we open tables
#
create table t1 (a varchar(20));
insert into t1 values ('foo');
--error 1305
prepare stmt FROM 'SELECT char_length (a) FROM t1';
drop table t1;
# #
# Bug #6089: FOUND_ROWS returns wrong values when no table/view is used # Bug #6089: FOUND_ROWS returns wrong values when no table/view is used
...@@ -513,86 +502,6 @@ execute stmt; ...@@ -513,86 +502,6 @@ execute stmt;
SELECT FOUND_ROWS(); SELECT FOUND_ROWS();
deallocate prepare stmt; deallocate prepare stmt;
#
# Bug#8115: equality propagation and prepared statements
#
create table t1 (a char(3) not null, b char(3) not null,
c char(3) not null, primary key (a, b, c));
create table t2 like t1;
# reduced query
prepare stmt from
"select t1.a from (t1 left outer join t2 on t2.a=1 and t1.b=t2.b)
where t1.a=1";
execute stmt;
execute stmt;
execute stmt;
# original query
prepare stmt from
"select t1.a, t1.b, t1.c, t2.a, t2.b, t2.c from
(t1 left outer join t2 on t2.a=? and t1.b=t2.b)
left outer join t2 t3 on t3.a=? where t1.a=?";
set @a:=1, @b:=1, @c:=1;
execute stmt using @a, @b, @c;
execute stmt using @a, @b, @c;
execute stmt using @a, @b, @c;
deallocate prepare stmt;
drop table t1,t2;
#
# Bug#9383: INFORMATION_SCHEMA.COLUMNS, JOIN, Crash, prepared statement
#
eval SET @aux= "SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS A,
INFORMATION_SCHEMA.COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME
AND A.COLUMN_NAME = B.COLUMN_NAME AND
A.TABLE_NAME = 'user'";
let $exec_loop_count= 3;
eval prepare my_stmt from @aux;
while ($exec_loop_count)
{
eval execute my_stmt;
dec $exec_loop_count;
}
deallocate prepare my_stmt;
# Test CALL in prepared mode
delimiter |;
--disable_warnings
drop procedure if exists p1|
drop table if exists t1|
--enable_warnings
create table t1 (id int)|
insert into t1 values(1)|
create procedure p1(a int, b int)
begin
declare c int;
select max(id)+1 into c from t1;
insert into t1 select a+b;
insert into t1 select a-b;
insert into t1 select a-c;
end|
set @a= 3, @b= 4|
prepare stmt from "call p1(?, ?)"|
execute stmt using @a, @b|
execute stmt using @a, @b|
select * from t1|
deallocate prepare stmt|
drop procedure p1|
drop table t1|
delimiter ;|
# #
# Bug#9096 "select doesn't return all matched records if prepared statements # Bug#9096 "select doesn't return all matched records if prepared statements
# is used" # is used"
...@@ -618,7 +527,6 @@ set @a=200887, @b=860; ...@@ -618,7 +527,6 @@ set @a=200887, @b=860;
# this query did not return all matching rows # this query did not return all matching rows
execute stmt using @a, @b; execute stmt using @a, @b;
deallocate prepare stmt; deallocate prepare stmt;
drop table t1; drop table t1;
# #
...@@ -667,35 +575,6 @@ select t2.id from t2, t1 where (t1.id=1 and t2.t1_id=t1.id); ...@@ -667,35 +575,6 @@ select t2.id from t2, t1 where (t1.id=1 and t2.t1_id=t1.id);
deallocate prepare stmt; deallocate prepare stmt;
drop table t1, t2; drop table t1, t2;
#
# Bug#7306 LIMIT ?, ? and also WL#1785 " Prepared statements: implement
# support for placeholders in LIMIT clause."
# Add basic test coverage for the feature.
#
create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
prepare stmt from "select * from t1 limit ?, ?";
set @offset=0, @limit=1;
execute stmt using @offset, @limit;
select * from t1 limit 0, 1;
set @offset=3, @limit=2;
execute stmt using @offset, @limit;
select * from t1 limit 3, 2;
prepare stmt from "select * from t1 limit ?";
execute stmt using @limit;
--error 1235
prepare stmt from "select * from t1 where a in (select a from t1 limit ?)";
prepare stmt from "select * from t1 union all select * from t1 limit ?, ?";
set @offset=9;
set @limit=2;
execute stmt using @offset, @limit;
prepare stmt from "(select * from t1 limit ?, ?) union all
(select * from t1 limit ?, ?) order by a limit ?";
execute stmt using @offset, @limit, @offset, @limit, @limit;
drop table t1;
deallocate prepare stmt;
# #
# Bug#11060 "Server crashes on calling stored procedure with INSERT SELECT # Bug#11060 "Server crashes on calling stored procedure with INSERT SELECT
# UNION SELECT" aka "Server crashes on re-execution of prepared INSERT ... # UNION SELECT" aka "Server crashes on re-execution of prepared INSERT ...
...@@ -707,6 +586,7 @@ execute stmt; ...@@ -707,6 +586,7 @@ execute stmt;
execute stmt; execute stmt;
deallocate prepare stmt; deallocate prepare stmt;
drop table t1; drop table t1;
# #
# Bug#11458 "Prepared statement with subselects return random data": # Bug#11458 "Prepared statement with subselects return random data":
# drop PARAM_TABLE_BIT from the list of tables used by a subquery # drop PARAM_TABLE_BIT from the list of tables used by a subquery
...@@ -775,6 +655,7 @@ execute stmt using @user_id, @id; ...@@ -775,6 +655,7 @@ execute stmt using @user_id, @id;
execute stmt using @user_id, @id; execute stmt using @user_id, @id;
deallocate prepare stmt; deallocate prepare stmt;
drop table t1, t2, t3, t4; drop table t1, t2, t3, t4;
# #
# Bug#9379: make sure that Item::collation is reset when one sets # Bug#9379: make sure that Item::collation is reset when one sets
# a parameter marker from a string variable. # a parameter marker from a string variable.
...@@ -813,22 +694,6 @@ select ??; ...@@ -813,22 +694,6 @@ 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;
DEALLOCATE PREPARE b12651;
# #
# Bug#9359 "Prepared statements take snapshot of system vars at PREPARE # Bug#9359 "Prepared statements take snapshot of system vars at PREPARE
# time" # time"
...@@ -905,6 +770,7 @@ execute stmt using @like; ...@@ -905,6 +770,7 @@ execute stmt using @like;
deallocate prepare stmt; deallocate prepare stmt;
drop table t1; drop table t1;
# #
# Bug#13134 "Length of VARCHAR() utf8 column is increasing when table is # Bug#13134 "Length of VARCHAR() utf8 column is increasing when table is
# recreated with PS/SP" # recreated with PS/SP"
...@@ -975,17 +841,17 @@ set global max_prepared_stmt_count=10000000000000000; ...@@ -975,17 +841,17 @@ set global max_prepared_stmt_count=10000000000000000;
select @@max_prepared_stmt_count; select @@max_prepared_stmt_count;
set global max_prepared_stmt_count=default; set global max_prepared_stmt_count=default;
select @@max_prepared_stmt_count; select @@max_prepared_stmt_count;
--error ER_GLOBAL_VARIABLE --error 1229 # ER_GLOBAL_VARIABLE
set @@max_prepared_stmt_count=1; set @@max_prepared_stmt_count=1;
--error ER_GLOBAL_VARIABLE --error 1229 # ER_GLOBAL_VARIABLE
set max_prepared_stmt_count=1; set max_prepared_stmt_count=1;
--error ER_GLOBAL_VARIABLE --error 1229 # ER_GLOBAL_VARIABLE
set local max_prepared_stmt_count=1; set local max_prepared_stmt_count=1;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR --error 1229 # ER_GLOBAL_VARIABLE
set local prepared_stmt_count=0; set local prepared_stmt_count=0;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR --error 1229 # ER_GLOBAL_VARIABLE
set @@prepared_stmt_count=0; set @@prepared_stmt_count=0;
--error ER_INCORRECT_GLOBAL_LOCAL_VAR --error 1232 # ER_WRONG_TYPE_FOR_VAR
set global prepared_stmt_count=1; set global prepared_stmt_count=1;
# set to a reasonable limit works # set to a reasonable limit works
set global max_prepared_stmt_count=1; set global max_prepared_stmt_count=1;
...@@ -995,13 +861,13 @@ select @@max_prepared_stmt_count; ...@@ -995,13 +861,13 @@ select @@max_prepared_stmt_count;
# #
set global max_prepared_stmt_count=0; set global max_prepared_stmt_count=0;
select @@max_prepared_stmt_count, @@prepared_stmt_count; select @@max_prepared_stmt_count, @@prepared_stmt_count;
--error ER_MAX_PREPARED_STMT_COUNT_REACHED --error 1105 # ER_UNKNOWN_ERROR
prepare stmt from "select 1"; prepare stmt from "select 1";
select @@prepared_stmt_count; select @@prepared_stmt_count;
set global max_prepared_stmt_count=1; set global max_prepared_stmt_count=1;
prepare stmt from "select 1"; prepare stmt from "select 1";
select @@prepared_stmt_count; select @@prepared_stmt_count;
--error ER_MAX_PREPARED_STMT_COUNT_REACHED --error 1105 # ER_UNKNOWN_ERROR
prepare stmt1 from "select 1"; prepare stmt1 from "select 1";
select @@prepared_stmt_count; select @@prepared_stmt_count;
deallocate prepare stmt; deallocate prepare stmt;
...@@ -1020,13 +886,13 @@ select @@prepared_stmt_count; ...@@ -1020,13 +886,13 @@ select @@prepared_stmt_count;
# #
select @@prepared_stmt_count, @@max_prepared_stmt_count; select @@prepared_stmt_count, @@max_prepared_stmt_count;
set global max_prepared_stmt_count=0; set global max_prepared_stmt_count=0;
--error ER_MAX_PREPARED_STMT_COUNT_REACHED --error 1105 # ER_UNKNOWN_ERROR
prepare stmt from "select 1"; prepare stmt from "select 1";
# Result: the old statement is deallocated, the new is not created. # Result: the old statement is deallocated, the new is not created.
--error 1243 # ER_UNKNOWN_STMT_HANDLER --error 1243 # ER_UNKNOWN_STMT_HANDLER
execute stmt; execute stmt;
select @@prepared_stmt_count; select @@prepared_stmt_count;
--error ER_MAX_PREPARED_STMT_COUNT_REACHED --error 1105 # ER_UNKNOWN_ERROR
prepare stmt from "select 1"; prepare stmt from "select 1";
select @@prepared_stmt_count; select @@prepared_stmt_count;
# #
...@@ -1040,10 +906,10 @@ connect (con1,localhost,root,,); ...@@ -1040,10 +906,10 @@ connect (con1,localhost,root,,);
connection con1; connection con1;
prepare stmt from "select 2"; prepare stmt from "select 2";
prepare stmt1 from "select 3"; prepare stmt1 from "select 3";
--error ER_MAX_PREPARED_STMT_COUNT_REACHED --error 1105 # ER_UNKNOWN_ERROR
prepare stmt2 from "select 4"; prepare stmt2 from "select 4";
connection default; connection default;
--error ER_MAX_PREPARED_STMT_COUNT_REACHED --error 1105 # ER_UNKNOWN_ERROR
prepare stmt2 from "select 4"; prepare stmt2 from "select 4";
select @@max_prepared_stmt_count, @@prepared_stmt_count; select @@max_prepared_stmt_count, @@prepared_stmt_count;
disconnect con1; disconnect con1;
...@@ -1063,7 +929,172 @@ select @@max_prepared_stmt_count, @@prepared_stmt_count; ...@@ -1063,7 +929,172 @@ select @@max_prepared_stmt_count, @@prepared_stmt_count;
set global max_prepared_stmt_count= @old_max_prepared_stmt_count; set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
--enable_ps_protocol --enable_ps_protocol
# End of 4.1 tests #
# Bug#19399 "Stored Procedures 'Lost Connection' when dropping/creating
# tables"
# Check that multi-delete tables are also cleaned up before re-execution.
#
--disable_warnings
drop table if exists t1;
create temporary table if not exists t1 (a1 int);
--enable_warnings
# exact delete syntax is essential
prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
drop temporary table t1;
create temporary table if not exists t1 (a1 int);
# the server crashed on the next statement without the fix
execute stmt;
drop temporary table t1;
create temporary table if not exists t1 (a1 int);
# the problem was in memory corruption: repeat the test just in case
execute stmt;
drop temporary table t1;
create temporary table if not exists t1 (a1 int);
execute stmt;
drop temporary table t1;
deallocate prepare stmt;
--echo End of 4.1 tests
############################# 5.0 tests start ################################
#
#
# Bug#6102 "Server crash with prepared statement and blank after
# function name"
# ensure that stored functions are cached when preparing a statement
# before we open tables
#
create table t1 (a varchar(20));
insert into t1 values ('foo');
--error 1305
prepare stmt FROM 'SELECT char_length (a) FROM t1';
drop table t1;
#
# Bug#8115: equality propagation and prepared statements
#
create table t1 (a char(3) not null, b char(3) not null,
c char(3) not null, primary key (a, b, c));
create table t2 like t1;
# reduced query
prepare stmt from
"select t1.a from (t1 left outer join t2 on t2.a=1 and t1.b=t2.b)
where t1.a=1";
execute stmt;
execute stmt;
execute stmt;
# original query
prepare stmt from
"select t1.a, t1.b, t1.c, t2.a, t2.b, t2.c from
(t1 left outer join t2 on t2.a=? and t1.b=t2.b)
left outer join t2 t3 on t3.a=? where t1.a=?";
set @a:=1, @b:=1, @c:=1;
execute stmt using @a, @b, @c;
execute stmt using @a, @b, @c;
execute stmt using @a, @b, @c;
deallocate prepare stmt;
drop table t1,t2;
#
# Bug#9383: INFORMATION_SCHEMA.COLUMNS, JOIN, Crash, prepared statement
#
eval SET @aux= "SELECT COUNT(*)
FROM INFORMATION_SCHEMA.COLUMNS A,
INFORMATION_SCHEMA.COLUMNS B
WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
AND A.TABLE_NAME = B.TABLE_NAME
AND A.COLUMN_NAME = B.COLUMN_NAME AND
A.TABLE_NAME = 'user'";
let $exec_loop_count= 3;
eval prepare my_stmt from @aux;
while ($exec_loop_count)
{
eval execute my_stmt;
dec $exec_loop_count;
}
deallocate prepare my_stmt;
# Test CALL in prepared mode
delimiter |;
--disable_warnings
drop procedure if exists p1|
drop table if exists t1|
--enable_warnings
create table t1 (id int)|
insert into t1 values(1)|
create procedure p1(a int, b int)
begin
declare c int;
select max(id)+1 into c from t1;
insert into t1 select a+b;
insert into t1 select a-b;
insert into t1 select a-c;
end|
set @a= 3, @b= 4|
prepare stmt from "call p1(?, ?)"|
execute stmt using @a, @b|
execute stmt using @a, @b|
select * from t1|
deallocate prepare stmt|
drop procedure p1|
drop table t1|
delimiter ;|
#
# Bug#7306 LIMIT ?, ? and also WL#1785 " Prepared statements: implement
# support for placeholders in LIMIT clause."
# Add basic test coverage for the feature.
#
create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
prepare stmt from "select * from t1 limit ?, ?";
set @offset=0, @limit=1;
execute stmt using @offset, @limit;
select * from t1 limit 0, 1;
set @offset=3, @limit=2;
execute stmt using @offset, @limit;
select * from t1 limit 3, 2;
prepare stmt from "select * from t1 limit ?";
execute stmt using @limit;
--error 1235
prepare stmt from "select * from t1 where a in (select a from t1 limit ?)";
prepare stmt from "select * from t1 union all select * from t1 limit ?, ?";
set @offset=9;
set @limit=2;
execute stmt using @offset, @limit;
prepare stmt from "(select * from t1 limit ?, ?) union all
(select * from t1 limit ?, ?) order by a limit ?";
execute stmt using @offset, @limit, @offset, @limit, @limit;
drop table t1;
deallocate prepare stmt;
#
# 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;
DEALLOCATE PREPARE b12651;
# #
# Bug #14956: ROW_COUNT() returns incorrect result after EXECUTE of prepared # Bug #14956: ROW_COUNT() returns incorrect result after EXECUTE of prepared
......
...@@ -126,6 +126,7 @@ void lex_start(THD *thd, uchar *buf,uint length) ...@@ -126,6 +126,7 @@ void lex_start(THD *thd, uchar *buf,uint length)
lex->param_list.empty(); lex->param_list.empty();
lex->view_list.empty(); lex->view_list.empty();
lex->prepared_stmt_params.empty(); lex->prepared_stmt_params.empty();
lex->auxilliary_table_list.empty();
lex->unit.next= lex->unit.master= lex->unit.next= lex->unit.master=
lex->unit.link_next= lex->unit.return_to= 0; lex->unit.link_next= lex->unit.return_to= 0;
lex->unit.prev= lex->unit.link_prev= 0; lex->unit.prev= lex->unit.link_prev= 0;
......
...@@ -2128,28 +2128,21 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) ...@@ -2128,28 +2128,21 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
they have their own table list). they have their own table list).
*/ */
for (TABLE_LIST *tables= lex->query_tables; for (TABLE_LIST *tables= lex->query_tables;
tables; tables;
tables= tables->next_global) tables= tables->next_global)
{ {
/* tables->reinit_before_use(thd);
Reset old pointers to TABLEs: they are not valid since the tables }
were closed in the end of previous prepare or execute call. /*
*/ Cleanup of the special case of DELETE t1, t2 FROM t1, t2, t3 ...
tables->table= 0; (multi-delete). We do a full clean up, although at the moment all we
/* Reset is_schema_table_processed value(needed for I_S tables */ need to clean in the tables of MULTI-DELETE list is 'table' member.
tables->is_schema_table_processed= FALSE; */
for (TABLE_LIST *tables= (TABLE_LIST*) lex->auxilliary_table_list.first;
TABLE_LIST *embedded; /* The table at the current level of nesting. */ tables;
TABLE_LIST *embedding= tables; /* The parent nested table reference. */ tables= tables->next)
do {
{ tables->reinit_before_use(thd);
embedded= embedding;
if (embedded->prep_on_expr)
embedded->on_expr= embedded->prep_on_expr->copy_andor_structure(thd);
embedding= embedded->embedding;
}
while (embedding &&
embedding->nested_join->join_list.head() == embedded);
} }
lex->current_select= &lex->select_lex; lex->current_select= &lex->select_lex;
......
...@@ -2985,6 +2985,23 @@ Field_iterator_table_ref::get_natural_column_ref() ...@@ -2985,6 +2985,23 @@ Field_iterator_table_ref::get_natural_column_ref()
return nj_col; return nj_col;
} }
/*
Cleanup this table for re-execution.
SYNOPSIS
st_table_list::reinit_before_use()
*/
void st_table_list::reinit_before_use(THD * /* thd */)
{
/*
Reset old pointers to TABLEs: they are not valid since the tables
were closed in the end of previous prepare or execute call.
*/
table= 0;
table_list= 0;
}
/***************************************************************************** /*****************************************************************************
** Instansiate templates ** Instansiate templates
......
...@@ -672,6 +672,11 @@ typedef struct st_table_list ...@@ -672,6 +672,11 @@ typedef struct st_table_list
private: private:
bool prep_check_option(THD *thd, uint8 check_opt_type); bool prep_check_option(THD *thd, uint8 check_opt_type);
bool prep_where(THD *thd, Item **conds, bool no_where_clause); bool prep_where(THD *thd, Item **conds, bool no_where_clause);
/*
Cleanup for re-execution in a prepared statement or a stored
procedure.
*/
void reinit_before_use(THD *thd);
} TABLE_LIST; } TABLE_LIST;
class Item; class Item;
......
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