Commit ed0fd2f6 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime

into  mockturtle.local:/home/dlenev/src/mysql-5.1-symlink

parents d5990c28 d017acee
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -47,1629 +47,1082 @@ ...@@ -47,1629 +47,1082 @@
# - Part 20: Special tables (log tables) # - Part 20: Special tables (log tables)
# - Part 21: Special tables (system tables) # - Part 21: Special tables (system tables)
# - Part 22: Special tables (views temp tables) # - Part 22: Special tables (views temp tables)
# - Part 23: Special tables (internal join tables) # - Part 23: Special statements
# - Part 24: Special statements # - Part 24: Testing the strength of TABLE_SHARE version
# - Part 25: Testing the strength of TABLE_SHARE version --disable_warnings
drop temporary table if exists t1, t2, t3;
let $base_count = SELECT VARIABLE_VALUE from drop table if exists t1, t2, t3;
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' drop procedure if exists p_verify_reprepare_count;
into @base_count ; drop procedure if exists p1;
drop function if exists f1;
let $check = SELECT CASE (VARIABLE_VALUE - @base_count - @expected) drop view if exists v1, v2;
WHEN 0 THEN "PASSED" --enable_warnings
ELSE "FAILED"
END delimiter |;
AS `CHECK`, create procedure p_verify_reprepare_count(expected int)
(VARIABLE_VALUE - @base_count - @expected) AS `OFFSET` begin
from INFORMATION_SCHEMA.SESSION_STATUS declare old_reprepare_count int default @reprepare_count;
where variable_name='COM_STMT_REPREPARE' ;
select variable_value from
eval $base_count; information_schema.session_status where
set @expected = 0; variable_name='com_stmt_reprepare'
into @reprepare_count;
# Maintainer:
# When not expecting a re-prepare, write the test like this: if old_reprepare_count + expected <> @reprepare_count then
# execute stmt; select concat("Expected: ", expected,
# eval $check; ", actual: ", @reprepare_count - old_reprepare_count)
# as "ERROR";
# When expecting a re-prepare, write the test like this: else
# set @expected = @expected + 1; select '' as "SUCCESS";
# execute stmt; end if;
# eval $check; end|
# delimiter ;|
set @reprepare_count= 0;
flush status;
--echo ===================================================================== --echo =====================================================================
--echo Testing 1: NOTHING -> TABLE transitions --echo Part 1: NOTHING -> TABLE transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings
drop table if exists t1;
--enable_warnings
# can not be tested since prepare failed # can not be tested since prepare failed
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
prepare stmt from 'select * from t1'; prepare stmt from "select * from t1";
--echo ===================================================================== --echo =====================================================================
--echo Testing 2: NOTHING -> TEMPORARY TABLE transitions --echo Part 2: NOTHING -> TEMPORARY TABLE transitions
--echo ===================================================================== --echo =====================================================================
# can not be tested # can not be tested
--echo ===================================================================== --echo =====================================================================
--echo Testing 3: NOTHING -> VIEW transitions --echo Part 3: NOTHING -> VIEW transitions
--echo ===================================================================== --echo =====================================================================
# can not be tested # can not be tested
--echo ===================================================================== --echo =====================================================================
--echo Testing 4: TABLE -> NOTHING transitions --echo Part 4: TABLE -> NOTHING transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t1 (a int);
drop table if exists t4;
--enable_warnings
create table t4(a int); prepare stmt from "select * from t1";
prepare stmt from 'select * from t4';
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t4; drop table t1;
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 5: TABLE -> TABLE (DDL) transitions --echo Part 5: TABLE -> TABLE (DDL) transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t1 (a int);
drop table if exists t5;
--enable_warnings
create table t5(a int);
prepare stmt from 'select a from t5'; prepare stmt from "select a from t1";
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
alter table t5 add column (b int); alter table t1 add column (b int);
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t5; drop table t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 6: TABLE -> TABLE (TRIGGER) transitions --echo Part 6: TABLE -> TABLE (TRIGGER) transitions
--echo ===================================================================== --echo =====================================================================
#
# Test 6-a: adding a relevant trigger
# Test 6-b: adding an irrelevant trigger
# Test 6-c: changing a relevant trigger
# Test 6-d: changing an irrelevant trigger
# Test 6-e: removing a relevant trigger
# Test 6-f: removing an irrelevant trigger
#
--disable_warnings --echo # Test 6-a: adding a relevant trigger
drop table if exists t6;
--enable_warnings
create table t6(a int); create table t1 (a int);
prepare stmt from 'insert into t6(a) value (?)'; prepare stmt from "insert into t1 (a) value (?)";
set @val=1; set @val=1;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
set @val=2;
execute stmt using @val;
eval $check;
# Relevant trigger: execute should reprepare # Relevant trigger: execute should reprepare
delimiter $$; create trigger t1_bi before insert on t1 for each row
create trigger t6_bi before insert on t6 for each row set @message= new.a;
begin
set @message= "t6_bi"; set @val=2;
end execute stmt using @val;
$$ call p_verify_reprepare_count(1);
delimiter ;$$ select @message;
set @message="none";
set @val=3; set @val=3;
set @expected = @expected + 1;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
select @message; select @message;
prepare stmt from "insert into t1 (a) value (?)";
set @val=4; set @val=4;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
select @message; select @message;
prepare stmt from 'insert into t6(a) value (?)'; --echo # Test 6-b: adding an irrelevant trigger
set @message="none";
# Unrelated trigger: reprepare may or may not happen, implementation dependent
create trigger t1_bd before delete on t1 for each row
set @message= old.a;
set @val=5; set @val=5;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(1);
select @message; select @message;
set @message="none";
set @val=6; set @val=6;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
select @message; select @message;
# Unrelated trigger: execute can pass of fail, implementation dependent prepare stmt from "insert into t1 (a) value (?)";
delimiter $$;
create trigger t6_bd before delete on t6 for each row
begin
set @message= "t6_bd";
end
$$
delimiter ;$$
set @message="none";
set @val=7; set @val=7;
set @expected = @expected + 1;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
select @message;
set @message="none";
set @val=8;
execute stmt using @val;
eval $check;
select @message; select @message;
prepare stmt from 'insert into t6(a) value (?)'; --echo # Test 6-c: changing a relevant trigger
set @message="none";
set @val=9;
execute stmt using @val;
eval $check;
select @message;
set @message="none";
set @val=10;
execute stmt using @val;
eval $check;
select @message;
# Relevant trigger: execute should reprepare # Relevant trigger: execute should reprepare
drop trigger t6_bi; drop trigger t1_bi;
delimiter $$; create trigger t1_bi before insert on t1 for each row
create trigger t6_bi before insert on t6 for each row set @message= concat("new trigger: ", new.a);
begin
set @message= "t6_bi (2)";
end
$$
delimiter ;$$
set @message="none";
set @val=11;
set @expected = @expected + 1;
execute stmt using @val;
eval $check;
select @message;
set @val=12;
execute stmt using @val;
eval $check;
select @message;
prepare stmt from 'insert into t6(a) value (?)'; set @val=8;
set @message="none";
set @val=13;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(1);
select @message; select @message;
set @message="none"; set @val=9;
set @val=14;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
select @message; select @message;
# Unrelated trigger: execute can pass of fail, implementation dependent prepare stmt from "insert into t1 (a) value (?)";
drop trigger t6_bd; set @val=10;
delimiter $$;
create trigger t6_bd before delete on t6 for each row
begin
set @message= "t6_bd (2)";
end
$$
delimiter ;$$
set @message="none";
set @val=15;
set @expected = @expected + 1;
execute stmt using @val;
eval $check;
select @message;
set @message="none";
set @val=16;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
select @message; select @message;
prepare stmt from 'insert into t6(a) value (?)'; --echo # Test 6-d: changing an irrelevant trigger
set @message="none";
set @val=17;
execute stmt using @val;
eval $check;
select @message;
set @message="none";
set @val=18;
execute stmt using @val;
eval $check;
select @message;
drop trigger t6_bi; # Unrelated trigger: reprepare may or may not happen, implementation dependent
drop trigger t1_bd;
set @message="none"; set @val=11;
set @val=19;
set @expected = @expected + 1;
execute stmt using @val;
eval $check;
select @message;
set @val=20;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(1);
select @message; select @message;
prepare stmt from 'insert into t6(a) value (?)'; --ehco Test 6-e: removing a relevant trigger
set @message="none";
set @val=21; drop trigger t1_bi;
set @val=12;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(1);
select @message; select @message;
set @val=22; set @val=13;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
select @message; select @message;
drop trigger t6_bd; prepare stmt from "insert into t1 (a) value (?)";
set @val=14;
set @val=23;
set @expected = @expected + 1;
execute stmt using @val;
eval $check;
select @message;
set @val=24;
execute stmt using @val; execute stmt using @val;
eval $check; call p_verify_reprepare_count(0);
select @message; select @message;
select * from t6 order by a; select * from t1 order by a;
drop table t6; drop table t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 7: TABLE -> TABLE (TRIGGER dependencies) transitions --echo Part 7: TABLE -> TABLE (TRIGGER dependencies) transitions
--echo ===================================================================== --echo =====================================================================
# --echo # Test 7-a: dependent PROCEDURE has changed
# Test 7-a: dependent PROCEDURE has changed --echo #
# Test 7-b: dependent FUNCTION has changed --echo # Note, this scenario is not supported, subject of Bug#12093
# Test 7-c: dependent VIEW has changed --echo #
# Test 7-d: dependent TABLE has changed
# Test 7-e: dependent TABLE TRIGGER has changed create table t1 (a int);
# create trigger t1_ai after insert on t1 for each row
call p1(new.a);
--disable_warnings create procedure p1(a int) begin end;
drop table if exists t7_proc; prepare stmt from "insert into t1 (a) values (?)";
drop table if exists t7_func; set @var= 1;
drop table if exists t7_view; execute stmt using @var;
drop table if exists t7_table; drop procedure p1;
drop table if exists t7_dependent_table; create procedure p1 (a int) begin end;
drop table if exists t7_table_trigger; set @var= 2;
drop table if exists t7_audit; --error ER_SP_DOES_NOT_EXIST
drop procedure if exists audit_proc; execute stmt using @var;
drop function if exists audit_func; --echo # Cleanup
drop view if exists audit_view; drop procedure p1;
--enable_warnings call p_verify_reprepare_count(0);
create table t7_proc(a int); --echo # Test 7-b: dependent FUNCTION has changed
create table t7_func(a int); --echo #
create table t7_view(a int); --echo # Note, this scenario is not supported, subject of Bug#12093
create table t7_table(a int); --echo #
create table t7_table_trigger(a int); drop trigger t1_ai;
create trigger t1_ai after insert on t1 for each row
create table t7_audit(old_a int, new_a int, reason varchar(50)); select f1(new.a+1) into @var;
create table t7_dependent_table(old_a int, new_a int, reason varchar(50)); create function f1 (a int) returns int return a;
prepare stmt from "insert into t1(a) values (?)";
create procedure audit_proc(a int) set @var=3;
insert into t7_audit values (NULL, a, "proc v1"); execute stmt using @var;
select @var;
drop function f1;
create function f1 (a int) returns int return 0;
--error ER_SP_DOES_NOT_EXIST
execute stmt using @var;
call p_verify_reprepare_count(0);
drop function f1;
deallocate prepare stmt;
create function audit_func() returns varchar(50) --echo # Test 7-c: dependent VIEW has changed
return "func v1"; --echo #
--echo # Note, this scenario is not functioning correctly, see
create view audit_view as select "view v1" as reason from dual; --echo # Bug#33255 Trigger using views and view ddl : corrupted triggers
--echo # and Bug #33000 Triggers do not detect changes in meta-data.
create trigger t7_proc_bi before insert on t7_proc for each row --echo #
call audit_proc(NEW.a); drop trigger t1_ai;
create table t2 (a int unique);
create trigger t7_func_bi before insert on t7_func for each row create table t3 (a int unique);
insert into t7_audit values (NULL, NEW.a, audit_func()); create view v1 as select a from t2;
create trigger t1_ai after insert on t1 for each row
create trigger t7_view_bi before insert on t7_view for each row insert into v1 (a) values (new.a);
insert into t7_audit values (NULL, NEW.a, (select reason from audit_view));
--echo # Demonstrate that the same bug is present
create trigger t7_table_bi before insert on t7_table for each row --echo # without prepared statements
insert into t7_dependent_table values (NULL, NEW.a, "dependent table"); insert into t1 (a) values (5);
select * from t2;
create trigger t7_table_trigger_bi before insert on t7_dependent_table select * from t3;
for each row set NEW.reason="trigger v1"; drop view v1;
create view v1 as select a from t3;
prepare stmt_proc from 'insert into t7_proc(a) value (?)'; --error ER_NO_SUCH_TABLE
set @val=101; insert into t1 (a) values (6);
execute stmt_proc using @val; flush table t1;
eval $check; insert into t1 (a) values (6);
set @val=102; select * from t2;
execute stmt_proc using @val; select * from t3;
eval $check;
prepare stmt from "insert into t1 (a) values (?)";
drop procedure audit_proc; set @var=7;
execute stmt using @var;
create procedure audit_proc(a int) call p_verify_reprepare_count(0);
insert into t7_audit values (NULL, a, "proc v2"); select * from t3;
select * from t2;
set @val=103; drop view v1;
set @expected = @expected + 1; create view v1 as select a from t2;
execute stmt_proc using @val; set @var=8;
eval $check; execute stmt using @var;
set @val=104; call p_verify_reprepare_count(0);
execute stmt_proc using @val; --echo #
eval $check; --echo # Sic: the insert went into t3, even though the view now
--echo # points at t2. This is because neither the merged view
--echo # nor its prelocking list are affected by view DDL
prepare stmt_func from 'insert into t7_func(a) value (?)'; --echo # The binary log is of course wrong, since it is not
set @val=201; --echo # using prepared statements
execute stmt_func using @val; --echo #
eval $check; select * from t2;
set @val=202; select * from t3;
execute stmt_func using @val; flush table t1;
eval $check; set @var=9;
execute stmt using @var;
drop function audit_func; call p_verify_reprepare_count(1);
select * from t2;
create function audit_func() returns varchar(50) select * from t3;
return "func v2"; drop view v1;
drop table t1,t2,t3;
set @val=203;
set @expected = @expected + 1; --echo # Test 7-d: dependent TABLE has changed
execute stmt_func using @val; create table t1 (a int);
eval $check; create trigger t1_ai after insert on t1 for each row
set @val=204; insert into t2 (a) values (new.a);
execute stmt_func using @val; create table t2 (a int);
eval $check;
prepare stmt from "insert into t1 (a) values (?)";
prepare stmt_view from 'insert into t7_view(a) value (?)'; set @var=1;
set @val=301; execute stmt using @var;
execute stmt_view using @val; alter table t2 add column comment varchar(255);
eval $check; set @var=2;
set @val=302; --echo # Since the dependent table is tracked in the prelocked
execute stmt_view using @val; --echo # list of the prepared statement, invalidation happens
eval $check; --echo # and the statement is re-prepared. This is an unnecessary
--echo # side effect, since the statement that *is* dependent
drop view audit_view; --echo # on t2 definition is inside the trigger, and it is currently
--echo # not reprepared (see the previous test case).
create view audit_view as select "view v2" as reason from dual; execute stmt using @var;
call p_verify_reprepare_count(1);
# Because of Bug#33255, the wrong result is still produced for cases select * from t1;
# 303 and 304, even after re-preparing the statement. select * from t2;
# This is because the table trigger is cached and is not invalidated. drop table t1,t2;
set @val=303; --echo # Test 7-e: dependent TABLE TRIGGER has changed
set @expected = @expected + 1; create table t1 (a int);
execute stmt_view using @val; create trigger t1_ai after insert on t1 for each row
eval $check; insert into t2 (a) values (new.a);
set @val=304; create table t2 (a int unique);
execute stmt_view using @val; create trigger t2_ai after insert on t2 for each row
eval $check; insert into t3 (a) values (new.a);
create table t3 (a int unique);
create table t4 (a int unique);
prepare stmt_table from 'insert into t7_table(a) value (?)';
set @val=401; insert into t1 (a) values (1);
execute stmt_table using @val; select * from t1 join t2 on (t1.a=t2.a) join t3 on (t2.a=t3.a);
eval $check; drop trigger t2_ai;
set @val=402; create trigger t2_ai after insert on t2 for each row
execute stmt_table using @val; insert into t4 (a) values (new.a);
eval $check; insert into t1 (a) values (2);
select * from t1 join t2 on (t1.a=t2.a) join t4 on (t2.a=t4.a);
alter table t7_dependent_table add column comments varchar(100) default NULL;
prepare stmt from "insert into t1 (a) values (?)";
set @val=403; set @var=3;
set @expected = @expected + 1; execute stmt using @var;
--error ER_WRONG_VALUE_COUNT_ON_ROW select * from t1 join t2 on (t1.a=t2.a) join t4 on (t2.a=t4.a);
execute stmt_table using @val; drop trigger t2_ai;
eval $check; create trigger t2_ai after insert on t2 for each row
set @val=404; insert into t3 (a) values (new.a);
set @expected = @expected + 1; set @var=4;
--error ER_WRONG_VALUE_COUNT_ON_ROW execute stmt using @var;
execute stmt_table using @val; call p_verify_reprepare_count(1);
eval $check; select * from t1 join t2 on (t1.a=t2.a) join t3 on (t2.a=t3.a);
select * from t1 join t2 on (t1.a=t2.a) join t4 on (t2.a=t4.a);
alter table t7_dependent_table drop column comments;
drop table t1, t2, t3, t4;
set @val=405; deallocate prepare stmt;
set @expected = @expected + 1;
execute stmt_table using @val;
eval $check;
set @val=406;
execute stmt_table using @val;
eval $check;
prepare stmt_table_trigger from 'insert into t7_table(a) value (?)';
set @val=501;
execute stmt_table_trigger using @val;
eval $check;
set @val=502;
execute stmt_table_trigger using @val;
eval $check;
drop trigger t7_table_trigger_bi;
create trigger t7_table_trigger_bi before insert on t7_dependent_table
for each row set NEW.reason="trigger v2";
set @val=503;
set @expected = @expected + 1;
execute stmt_table_trigger using @val;
eval $check;
set @val=504;
execute stmt_table_trigger using @val;
eval $check;
select * from t7_audit order by new_a;
select * from t7_dependent_table order by new_a;
drop table t7_proc;
drop table t7_func;
drop table t7_view;
drop table t7_table;
drop table t7_dependent_table;
drop table t7_table_trigger;
drop table t7_audit;
drop procedure audit_proc;
drop function audit_func;
drop view audit_view;
--echo ===================================================================== --echo =====================================================================
--echo Testing 8: TABLE -> TEMPORARY TABLE transitions --echo Part 8: TABLE -> TEMPORARY TABLE transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t1 (a int);
drop table if exists t8;
--enable_warnings
create table t8(a int);
prepare stmt from 'select * from t8'; prepare stmt from "select * from t1";
execute stmt; execute stmt;
eval $check;
execute stmt;
eval $check;
drop table t8; drop table t1;
create temporary table t8(a int); create temporary table t1 (a int);
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t8; drop table t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 9: TABLE -> VIEW transitions --echo Part 9: TABLE -> VIEW transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t1 (a int);
drop table if exists t9;
drop table if exists t9_b;
--enable_warnings
create table t9(a int);
create table t9_b(a int);
prepare stmt from 'select * from t9'; prepare stmt from "select * from t1";
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
execute stmt;
eval $check;
drop table t9; drop table t1;
create view t9 as select * from t9_b; create table t2 (a int);
create view t1 as select * from t2;
set @expected = @expected + 1;
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
drop view t9; drop view t1;
drop table t9_b; drop table t2;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 10: TEMPORARY TABLE -> NOTHING transitions --echo Part 10: TEMPORARY TABLE -> NOTHING transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create temporary table t1 (a int);
drop temporary table if exists t10;
--enable_warnings
create temporary table t10(a int);
prepare stmt from 'select * from t10'; prepare stmt from "select * from t1";
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop temporary table t10; drop temporary table t1;
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
--error ER_NO_SUCH_TABLE deallocate prepare stmt;
execute stmt;
eval $check;
--echo ===================================================================== --echo =====================================================================
--echo Testing 11: TEMPORARY TABLE -> TABLE transitions --echo Part 11: TEMPORARY TABLE -> TABLE transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t1 (a int);
drop table if exists t11; insert into t1 (a) value (1);
drop temporary table if exists t11; create temporary table t1 (a int);
--enable_warnings
create table t11(a int);
insert into t11(a) value (1);
create temporary table t11(a int);
prepare stmt from 'select * from t11'; prepare stmt from "select * from t1";
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop temporary table t11; drop temporary table t1;
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt;
eval $check;
select * from t11; select * from t1;
drop table t11; drop table t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions --echo Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create temporary table t1 (a int);
drop temporary table if exists t12;
--enable_warnings
create temporary table t12(a int);
prepare stmt from 'select a from t12'; prepare stmt from "select a from t1";
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop temporary table t12; drop temporary table t1;
create temporary table t12(a int, b int); create temporary table t1 (a int, b int);
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt;
eval $check;
select * from t12; select * from t1;
drop table t12; drop temporary table t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 13: TEMPORARY TABLE -> VIEW transitions --echo Part 13: TEMPORARY TABLE -> VIEW transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create temporary table t1 (a int);
drop temporary table if exists t13; create table t2 (a int);
drop table if exists t13_b;
--enable_warnings
create temporary table t13(a int); prepare stmt from "select * from t1";
create table t13_b(a int);
prepare stmt from 'select * from t13';
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop temporary table t13; drop temporary table t1;
create view t13 as select * from t13_b; create view t1 as select * from t2;
set @expected = @expected + 1;
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
drop view t13; drop view t1;
drop table t13_b; drop table t2;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 14: VIEW -> NOTHING transitions --echo Part 14: VIEW -> NOTHING transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t2 (a int);
drop view if exists t14; create view t1 as select * from t2;
drop table if exists t14_b;
--enable_warnings
create table t14_b(a int);
create view t14 as select * from t14_b;
prepare stmt from 'select * from t14'; prepare stmt from "select * from t1";
execute stmt; execute stmt;
eval $check; drop view t1;
execute stmt;
eval $check;
drop view t14;
set @expected = @expected + 1;
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
set @expected = @expected + 1;
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t14_b; drop table t2;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 15: VIEW -> TABLE transitions --echo Part 15: VIEW -> TABLE transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t2 (a int);
drop view if exists t15; create view t1 as select * from t2;
drop table if exists t15_b;
--enable_warnings
create table t15_b(a int); prepare stmt from "select * from t1";
create view t15 as select * from t15_b;
prepare stmt from 'select * from t15';
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop view t15; drop view t1;
create table t15(a int); create table t1 (a int);
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt;
eval $check;
drop table t15_b; drop table t2;
drop table t15; drop table t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 16: VIEW -> TEMPORARY TABLE transitions --echo Part 16: VIEW -> TEMPORARY TABLE transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t2 (a int);
drop view if exists t16; insert into t2 (a) values (1);
drop table if exists t16_b; create view t1 as select * from t2;
--enable_warnings
create table t16_b(a int);
create view t16 as select * from t16_b;
prepare stmt from 'select * from t16'; prepare stmt from "select * from t1";
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
execute stmt;
eval $check;
drop view t16;
create temporary table t16(a int);
set @expected = @expected + 1; create temporary table t1 (a int);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
drop view t1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t16_b; drop table t2;
drop temporary table t16; drop temporary table t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 17: VIEW -> VIEW (DDL) transitions --echo Part 17: VIEW -> VIEW (DDL) transitions
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t2 (a int);
drop view if exists t17; insert into t2 values (10), (20), (30);
drop table if exists t17_b;
--enable_warnings
create table t17_b(a int); create view t1 as select a, 2*a as b, 3*a as c from t2;
insert into t17_b values (10), (20), (30); select * from t1;
create view t17 as select a, 2*a as b, 3*a as c from t17_b; prepare stmt from "select * from t1";
select * from t17;
prepare stmt from 'select * from t17';
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check;
drop view t17; drop view t1;
create view t17 as select a, 2*a as b, 5*a as c from t17_b; create view t1 as select a, 2*a as b, 5*a as c from t2;
select * from t17; select * from t1;
set @expected = @expected + 1; --echo # Currently a different result from conventional statements.
--echo # A view is inlined once at prepare, later on view DDL
--echo # does not affect prepared statement and it is not re-prepared.
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
flush table t2;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
drop table t17_b; drop table t2;
drop view t17; drop view t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 18: VIEW -> VIEW (VIEW dependencies) transitions --echo Part 18: VIEW -> VIEW (VIEW dependencies) transitions
--echo ===================================================================== --echo =====================================================================
# --echo # Part 18a: dependent function has changed
# Test 18-a: dependent PROCEDURE has changed (via a trigger) create table t1 (a int);
# Test 18-b: dependent FUNCTION has changed insert into t1 (a) values (1), (2), (3);
# Test 18-c: dependent VIEW has changed create function f1() returns int return (select max(a) from t1);
# Test 18-d: dependent TABLE has changed create view v1 as select f1();
# Test 18-e: dependent TABLE TRIGGER has changed prepare stmt from "select * from v1";
# execute stmt;
execute stmt;
--disable_warnings call p_verify_reprepare_count(0);
drop table if exists t18; drop function f1;
drop table if exists t18_dependent_table; create function f1() returns int return 2;
drop view if exists t18_func; --echo # XXX: Bug#12093. We only get a different error
drop view if exists t18_view; --echo # message because the non-existing procedure error is masked
drop view if exists t18_table; --echo # by the view.
drop function if exists view_func; --error ER_VIEW_INVALID
drop view if exists view_view; execute stmt;
--enable_warnings --error ER_VIEW_INVALID
execute stmt;
# TODO: insertable view -> trigger call p_verify_reprepare_count(0);
# TODO: insertable view -> trigger -> proc ?
create table t18(a int);
insert into t18 values (1), (2), (3);
create function view_func(x int) returns int
return x+1;
create view view_view as select "view v1" as reason from dual;
create table t18_dependent_table(a int);
create view t18_func as select a, view_func(a) as b from t18;
create view t18_view as select a, reason as b from t18, view_view;
create view t18_table as select * from t18;
prepare stmt_func from 'select * from t18_func'; --echo # Part 18b: dependent procedure has changed (referred to via a function)
execute stmt_func;
eval $check;
execute stmt_func;
eval $check;
drop function view_func; create table t2 (a int);
create function view_func(x int) returns int insert into t2 (a) values (4), (5), (6);
return x*x;
set @expected = @expected + 1; drop function f1;
execute stmt_func; delimiter |;
eval $check; create function f1() returns int
execute stmt_func; begin
eval $check; declare x int;
call p1(x);
return x;
end|
delimiter ;|
create procedure p1(out x int) select max(a) from t1 into x;
prepare stmt_view from 'select * from t18_view'; prepare stmt from "select * from v1";
execute stmt_view; execute stmt;
eval $check; execute stmt;
execute stmt_view; call p_verify_reprepare_count(0);
eval $check; drop procedure p1;
create procedure p1(out x int) select max(a) from t2 into x;
--echo # XXX: bug. The prelocked list is not invalidated
--echo # and we keep opening table t1, whereas the procedure
--ehco # is now referring to table t2
--error ER_VIEW_INVALID
execute stmt;
call p_verify_reprepare_count(0);
flush table t1;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
drop view view_view; --echo # Test 18-c: dependent VIEW has changed
create view view_view as select "view v2" as reason from dual;
set @expected = @expected + 1; drop view v1;
execute stmt_view; create view v2 as select a from t1;
eval $check; create view v1 as select * from v2;
execute stmt_view; prepare stmt from "select * from v1";
eval $check; execute stmt;
execute stmt;
call p_verify_reprepare_count(0);
drop view v2;
create view v2 as select a from t2;
execute stmt;
execute stmt;
call p_verify_reprepare_count(0);
flush table t1;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
--echo # Test 18-d: dependent TABLE has changed
drop view v2;
create table v2 as select * from t1;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
drop table v2;
create table v2 (a int unique) as select * from t2;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
prepare stmt_table from 'select * from t18_table'; --echo # Test 18-e: dependent TABLE trigger has changed
execute stmt_table;
eval $check;
execute stmt_table;
eval $check;
alter table t18 add column comments varchar(50) default NULL; prepare stmt from "insert into v1 (a) values (?)";
set @var= 7;
execute stmt using @var;
call p_verify_reprepare_count(0);
create trigger v2_bi before insert on v2 for each row set @message="v2_bi";
set @var=8;
execute stmt using @var;
call p_verify_reprepare_count(1);
select @message;
drop trigger v2_bi;
set @message=null;
set @var=9;
execute stmt using @var;
call p_verify_reprepare_count(1);
select @message;
create trigger v2_bi after insert on v2 for each row set @message="v2_ai";
set @var= 10;
execute stmt using @var;
call p_verify_reprepare_count(1);
select @message;
select * from v1;
set @expected = @expected + 1; --echo # Cleanup
execute stmt_table;
eval $check;
execute stmt_table;
eval $check;
drop table t18; --disable_warnings
drop table t18_dependent_table; drop table if exists t1, t2, v1, v2;
drop view t18_func; drop view if exists v1, v2;
drop view t18_view; drop function f1;
drop view t18_table; drop procedure p1;
drop function view_func; --enable_warnings
drop view view_view; deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 19: Special tables (INFORMATION_SCHEMA) --echo Part 19: Special tables (INFORMATION_SCHEMA)
--echo ===================================================================== --echo =====================================================================
--disable_warnings
drop procedure if exists proc_19;
--enable_warnings
# Using a temporary table internally should not confuse the prepared # Using a temporary table internally should not confuse the prepared
# statement code, and should not raise ER_PS_INVALIDATED errors # statement code, and should not raise ER_PS_INVALIDATED errors
prepare stmt from prepare stmt from
'select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE "select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE
from INFORMATION_SCHEMA.ROUTINES where from INFORMATION_SCHEMA.ROUTINES where
routine_name=\'proc_19\''; routine_name='p1'";
create procedure proc_19() select "hi there"; create procedure p1() select "hi there";
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check;
drop procedure proc_19; drop procedure p1;
create procedure proc_19() select "hi there, again"; create procedure p1() select "hi there, again";
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop procedure proc_19; drop procedure p1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 20: Special tables (log tables) --echo Part 20: Special tables (log tables)
--echo ===================================================================== --echo =====================================================================
prepare stmt from prepare stmt from
'select * from mysql.general_log where argument=\'IMPOSSIBLE QUERY STRING\''; "select * from mysql.general_log where argument='IMPOSSIBLE QUERY STRING'";
--disable_result_log
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; --enable_result_log
call p_verify_reprepare_count(0);
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 21: Special tables (system tables) --echo Part 21: Special tables (system tables)
--echo ===================================================================== --echo =====================================================================
--disable_warnings
drop procedure if exists proc_21;
--enable_warnings
prepare stmt from prepare stmt from
'select type, db, name from mysql.proc where name=\'proc_21\''; "select type, db, name from mysql.proc where name='p1'";
create procedure proc_21() select "hi there"; create procedure p1() select "hi there";
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check;
drop procedure proc_21; drop procedure p1;
create procedure proc_21() select "hi there, again"; create procedure p1() select "hi there, again";
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop procedure proc_21; drop procedure p1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 22: Special tables (views temp tables) --echo Part 22: Special tables (views temp tables)
--echo ===================================================================== --echo =====================================================================
--disable_warnings create table t1 (a int);
drop table if exists t22_b;
drop view if exists t22;
--enable_warnings
create table t22_b(a int);
create algorithm=temptable view t22 as select a*a as a2 from t22_b; create algorithm=temptable view v1 as select a*a as a2 from t1;
# Using a temporary table internally should not confuse the prepared --echo # Using a temporary table internally should not confuse the prepared
# statement code, and should not raise ER_PS_INVALIDATED errors --echo # statement code, and should not raise ER_PS_INVALIDATED errors
show create view t22; show create view v1;
prepare stmt from 'select * from t22'; prepare stmt from "select * from v1";
insert into t22_b values (1), (2), (3); insert into t1 values (1), (2), (3);
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check;
insert into t22_b values (4), (5), (6); insert into t1 values (4), (5), (6);
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t22_b; drop table t1;
drop view t22; drop view v1;
--echo ===================================================================== --echo =====================================================================
--echo Testing 23: Special tables (internal join tables) --echo Part 23: Special statements
--echo ===================================================================== --echo =====================================================================
--disable_warnings --echo # SQLCOM_ALTER_TABLE:
drop table if exists t23_a;
drop table if exists t23_b;
--enable_warnings
create table t23_a(a int);
create table t23_b(b int);
# Using a temporary table internally should not confuse the prepared create table t1 (a int);
# statement code, and should not raise ER_PS_INVALIDATED errors
prepare stmt from 'select * from t23_a join t23_b';
insert into t23_a values (1), (2), (3);
insert into t23_b values (10), (20), (30);
execute stmt;
eval $check;
execute stmt;
eval $check;
insert into t23_a values (4); prepare stmt from "alter table t1 add column b int";
insert into t23_b values (40);
execute stmt; execute stmt;
eval $check;
execute stmt;
eval $check;
drop table t23_a;
drop table t23_b;
--echo ===================================================================== drop table t1;
--echo Testing 24: Special statements create table t1 (a1 int, a2 int);
--echo =====================================================================
# SQLCOM_ALTER_TABLE: --echo # t1 has changed, and it's does not lead to reprepare
--disable_warnings
drop table if exists t24_alter;
--enable_warnings
create table t24_alter(a int);
prepare stmt from 'alter table t24_alter add column b int';
execute stmt; execute stmt;
eval $check;
drop table t24_alter; alter table t1 drop column b;
create table t24_alter(a1 int, a2 int);
# t24_alter has changed, and it's not a problem
execute stmt; execute stmt;
eval $check;
alter table t24_alter drop column b; alter table t1 drop column b;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
alter table t24_alter drop column b; drop table t1;
execute stmt;
eval $check;
drop table t24_alter; --echo # SQLCOM_REPAIR:
# SQLCOM_REPAIR: create table t1 (a int);
--disable_warnings insert into t1 values (1), (2), (3);
drop table if exists t24_repair;
--enable_warnings
create table t24_repair(a int); prepare stmt from "repair table t1";
insert into t24_repair values (1), (2), (3);
prepare stmt from 'repair table t24_repair';
execute stmt; execute stmt;
eval $check; execute stmt;
drop table t24_repair; drop table t1;
create table t24_repair(a1 int, a2 int); create table t1 (a1 int, a2 int);
insert into t24_repair values (1, 10), (2, 20), (3, 30); insert into t1 values (1, 10), (2, 20), (3, 30);
# t24_repair has changed, and it's not a problem --echo # t1 has changed, and it's does not lead to reprepare
execute stmt; execute stmt;
eval $check;
alter table t24_repair add column b varchar(50) default NULL; alter table t1 add column b varchar(50) default NULL;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
alter table t24_repair drop column b; alter table t1 drop column b;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t24_repair; --echo # SQLCOM_ANALYZE:
# SQLCOM_ANALYZE: prepare stmt from "analyze table t1";
--disable_warnings
drop table if exists t24_analyze;
--enable_warnings
create table t24_analyze(a int);
insert into t24_analyze values (1), (2), (3);
prepare stmt from 'analyze table t24_analyze';
execute stmt; execute stmt;
eval $check;
drop table t24_analyze;
create table t24_analyze(a1 int, a2 int);
insert into t24_analyze values (1, 10), (2, 20), (3, 30);
# t24_analyze has changed, and it's not a problem drop table t1;
create table t1 (a1 int, a2 int);
insert into t1 values (1, 10), (2, 20), (3, 30);
--echo # t1 has changed, and it's not a problem
execute stmt; execute stmt;
eval $check;
alter table t24_analyze add column b varchar(50) default NULL; alter table t1 add column b varchar(50) default NULL;
execute stmt; execute stmt;
eval $check;
alter table t24_analyze drop column b; alter table t1 drop column b;
execute stmt; execute stmt;
eval $check;
drop table t24_analyze; call p_verify_reprepare_count(0);
# SQLCOM_OPTIMIZE: --echo # SQLCOM_OPTIMIZE:
--disable_warnings prepare stmt from "optimize table t1";
drop table if exists t24_optimize;
--enable_warnings
create table t24_optimize(a int);
insert into t24_optimize values (1), (2), (3);
prepare stmt from 'optimize table t24_optimize';
execute stmt; execute stmt;
eval $check;
drop table t24_optimize; drop table t1;
create table t24_optimize(a1 int, a2 int); create table t1 (a1 int, a2 int);
insert into t24_optimize values (1, 10), (2, 20), (3, 30); insert into t1 values (1, 10), (2, 20), (3, 30);
# t24_optimize has changed, and it's not a problem --echo # t1 has changed, and it's not a problem
execute stmt; execute stmt;
eval $check;
alter table t24_optimize add column b varchar(50) default NULL; alter table t1 add column b varchar(50) default NULL;
execute stmt; execute stmt;
eval $check;
alter table t24_optimize drop column b; alter table t1 drop column b;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t24_optimize; drop table t1;
# SQLCOM_SHOW_CREATE_PROC: --echo # SQLCOM_SHOW_CREATE_PROC:
--disable_warnings
drop procedure if exists changing_proc;
--enable_warnings
prepare stmt from 'show create procedure changing_proc'; prepare stmt from "show create procedure p1";
--error ER_SP_DOES_NOT_EXIST --error ER_SP_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
--error ER_SP_DOES_NOT_EXIST --error ER_SP_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
create procedure changing_proc() begin end; create procedure p1() begin end;
# changing_proc has changed, and it's not a problem --disable_result_log
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; --enable_result_log
drop procedure changing_proc; drop procedure p1;
create procedure changing_proc(x int, y int) begin end; create procedure p1(x int, y int) begin end;
--disable_result_log
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; --enable_result_log
drop procedure changing_proc; drop procedure p1;
--error ER_SP_DOES_NOT_EXIST --error ER_SP_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
--error ER_SP_DOES_NOT_EXIST --error ER_SP_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
# SQLCOM_SHOW_CREATE_FUNC: --echo # SQLCOM_SHOW_CREATE_FUNC:
--disable_warnings prepare stmt from "show create function f1";
drop function if exists changing_func;
--enable_warnings
prepare stmt from 'show create function changing_func';
--error ER_SP_DOES_NOT_EXIST --error ER_SP_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
--error ER_SP_DOES_NOT_EXIST --error ER_SP_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
create function changing_func() returns int return 0; create function f1() returns int return 0;
# changing_proc has changed, and it's not a problem --disable_result_log
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; --enable_result_log
drop function changing_func; drop function f1;
create function changing_func(x int, y int) returns int return x+y; create function f1(x int, y int) returns int return x+y;
--disable_result_log
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; --enable_result_log
drop function changing_func; drop function f1;
--error ER_SP_DOES_NOT_EXIST --error ER_SP_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
--error ER_SP_DOES_NOT_EXIST --error ER_SP_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
# SQLCOM_SHOW_CREATE_TRIGGER: --echo # SQLCOM_SHOW_CREATE_TRIGGER:
--disable_warnings create table t1 (a int);
drop table if exists t24_trigger;
--enable_warnings
create table t24_trigger(a int);
prepare stmt from 'show create trigger t24_bi;'; prepare stmt from "show create trigger t1_bi";
--error ER_TRG_DOES_NOT_EXIST --error ER_TRG_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
--error ER_TRG_DOES_NOT_EXIST --error ER_TRG_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
delimiter $$; create trigger t1_bi before insert on t1 for each row set @message= "t1_bi";
create trigger t24_bi before insert on t24_trigger for each row
begin
set @message= "t24_bi";
end
$$
delimiter ;$$
# t24_bi has changed, and it's not a problem --disable_result_log
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; --enable_result_log
drop trigger t1_bi;
drop trigger t24_bi; create trigger t1_bi before insert on t1 for each row set @message= "t1_bi (2)";
delimiter $$;
create trigger t24_bi before insert on t24_trigger for each row
begin
set @message= "t24_bi (2)";
end
$$
delimiter ;$$
# t24_bi has changed, and it's not a problem --disable_result_log
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; --enable_result_log
drop trigger t24_bi; drop trigger t1_bi;
--error ER_TRG_DOES_NOT_EXIST --error ER_TRG_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check;
--error ER_TRG_DOES_NOT_EXIST --error ER_TRG_DOES_NOT_EXIST
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t24_trigger; drop table t1;
deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Testing 25: Testing the strength of TABLE_SHARE version --echo Part 24: Testing the strength of TABLE_SHARE version
--echo ===================================================================== --echo =====================================================================
# Test 25-a: number of columns --echo # Test 24-a: number of columns
--disable_warnings
drop table if exists t25_num_col;
--enable_warnings
create table t25_num_col(a int);
prepare stmt from 'select a from t25_num_col';
execute stmt;
eval $check;
execute stmt;
eval $check;
alter table t25_num_col add column b varchar(50) default NULL; create table t1 (a int);
set @expected = @expected + 1; prepare stmt from "select a from t1";
execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t25_num_col;
# Test 25-b: column name
--disable_warnings
drop table if exists t25_col_name;
--enable_warnings
create table t25_col_name(a int); alter table t1 add column b varchar(50) default NULL;
prepare stmt from 'select * from t25_col_name';
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
alter table t25_col_name change a b int; --echo # Test 24-b: column name
set @expected = @expected + 1; alter table t1 change b c int;
--error ER_PS_REBIND
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t25_col_name; --echo # Test 24-c: column type
# Test 25-c: column type alter table t1 change a a varchar(10);
--disable_warnings
drop table if exists t25_col_type;
--enable_warnings
create table t25_col_type(a int);
prepare stmt from 'select * from t25_col_type';
execute stmt;
eval $check;
execute stmt;
eval $check;
alter table t25_col_type change a a varchar(10);
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t25_col_type;
# Test 25-d: column type length --echo # Test 24-d: column type length
--disable_warnings alter table t1 change a a varchar(20);
drop table if exists t25_col_type_length;
--enable_warnings
create table t25_col_type_length(a varchar(10));
prepare stmt from 'select * from t25_col_type_length';
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
alter table t25_col_type_length change a a varchar(20); --echo # Test 24-e: column NULL property
set @expected = @expected + 1; alter table t1 change a a varchar(20) NOT NULL;
--error ER_PS_REBIND
execute stmt;
eval $check;
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt;
eval $check;
drop table t25_col_type_length;
# Test 25-e: column NULL property
--disable_warnings
drop table if exists t25_col_null;
--enable_warnings
create table t25_col_null(a varchar(10));
prepare stmt from 'select * from t25_col_null';
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
alter table t25_col_null change a a varchar(10) NOT NULL;
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt;
eval $check;
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt;
eval $check;
drop table t25_col_null;
# Test 25-f: column DEFAULT
--disable_warnings
drop table if exists t25_col_default;
--enable_warnings
create table t25_col_default(a int, b int DEFAULT 10);
prepare stmt from 'insert into t25_col_default(a) values (?)';
set @val=1;
execute stmt using @val;
eval $check;
set @val=2;
execute stmt using @val;
eval $check;
alter table t25_col_default change b b int DEFAULT 20;
set @val=3;
# Must insert the correct default value for b
set @expected = @expected + 1;
execute stmt using @val;
eval $check;
set @val=4;
# Must insert the correct default value for b
execute stmt using @val;
eval $check;
select * from t25_col_default;
drop table t25_col_default; --echo # Test 24-f: column DEFAULT
# Test 25-g: number of keys alter table t1 change c c int DEFAULT 20;
--disable_warnings
drop table if exists t25_index;
--enable_warnings
create table t25_index(a varchar(10));
prepare stmt from 'select * from t25_index';
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
create index i1 on t25_index(a); --echo # Test 24-g: number of keys
create unique index t1_a_idx on t1 (a);
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
drop table t25_index;
# Test 25-h: changing index uniqueness --echo # Test 24-h: changing index uniqueness
--disable_warnings drop index t1_a_idx on t1;
drop table if exists t25_index_unique; create index t1_a_idx on t1 (a);
--enable_warnings
create table t25_index_unique(a varchar(10), b varchar(10));
create index i1 on t25_index_unique(a, b);
show create table t25_index_unique;
prepare stmt from 'select * from t25_index_unique';
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
alter table t25_index_unique drop index i1; --echo # Cleanup
create unique index i1 on t25_index_unique(a, b); drop table t1;
show create table t25_index_unique; deallocate prepare stmt;
set @expected = @expected + 1;
execute stmt;
eval $check;
execute stmt;
eval $check;
drop table t25_index_unique;
--echo ===================================================================== --echo =====================================================================
--echo Testing reported bugs --echo Testing reported bugs
--echo ===================================================================== --echo =====================================================================
# --echo #
# Bug#12093 (SP not found on second PS execution if another thread drops --echo # Bug#27420 A combination of PS and view operations cause
# other SP in between) --echo # error + assertion on shutdown
# --echo #
--disable_warnings
drop table if exists table_12093;
drop function if exists func_12093;
drop function if exists func_12093_unrelated;
drop procedure if exists proc_12093;
--enable_warnings
connect (con1,localhost,root,,);
connection default;
create table table_12093(a int);
delimiter //;
create function func_12093()
returns int
begin
return (select count(*) from table_12093);
end//
create procedure proc_12093(a int)
begin
select * from table_12093;
end//
delimiter ;//
create function func_12093_unrelated() returns int return 2;
create procedure proc_12093_unrelated() begin end;
prepare stmt_sf from 'select func_12093();';
prepare stmt_sp from 'call proc_12093(func_12093())';
execute stmt_sf;
eval $check;
execute stmt_sp;
eval $check;
connection con1;
drop function func_12093_unrelated;
drop procedure proc_12093_unrelated;
connection default;
# previously, failed with --error 1305
execute stmt_sf;
eval $check;
# previously, failed with --error 1305
execute stmt_sp;
eval $check;
# previously, failed with --error 1305
execute stmt_sf;
eval $check;
# previously, failed with --error 1305
execute stmt_sp;
eval $check;
deallocate prepare stmt_sf;
deallocate prepare stmt_sp;
disconnect con1;
drop table table_12093;
drop function func_12093;
drop procedure proc_12093;
#
# Bug#21294 (executing a prepared statement that executes a stored function
# which was recreat)
#
--disable_warnings
drop function if exists func_21294;
--enable_warnings
create function func_21294() returns int return 10;
prepare stmt from "select func_21294()";
execute stmt;
eval $check;
drop function func_21294;
create function func_21294() returns int return 10;
# might pass or fail, implementation dependent
execute stmt;
eval $check;
drop function func_21294;
create function func_21294() returns int return 20;
set @expected = @expected + 1;
execute stmt;
eval $check;
deallocate prepare stmt;
drop function func_21294;
#
# Bug#27420 (A combination of PS and view operations cause error + assertion
# on shutdown)
#
--disable_warnings --disable_warnings
drop table if exists t_27420_100; drop table if exists t_27420_100;
...@@ -1677,10 +1130,6 @@ drop table if exists t_27420_101; ...@@ -1677,10 +1130,6 @@ drop table if exists t_27420_101;
drop view if exists v_27420; drop view if exists v_27420;
--enable_warnings --enable_warnings
connect (con1,localhost,root,,);
connection default;
create table t_27420_100(a int); create table t_27420_100(a int);
insert into t_27420_100 values (1), (2); insert into t_27420_100 values (1), (2);
...@@ -1691,46 +1140,33 @@ create view v_27420 as select t_27420_100.a X, t_27420_101.a Y ...@@ -1691,46 +1140,33 @@ create view v_27420 as select t_27420_100.a X, t_27420_101.a Y
from t_27420_100, t_27420_101 from t_27420_100, t_27420_101
where t_27420_100.a=t_27420_101.a; where t_27420_100.a=t_27420_101.a;
prepare stmt from 'select * from v_27420'; prepare stmt from "select * from v_27420";
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
connection con1;
drop view v_27420; drop view v_27420;
create table v_27420(X int, Y int); create table v_27420(X int, Y int);
connection default;
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
connection con1;
drop table v_27420; drop table v_27420;
# passes in 5.0, fails in 5.1, should pass # passes in 5.0, fails in 5.1, should pass
create table v_27420 (a int, b int, filler char(200)); create table v_27420 (a int, b int, filler char(200));
connection default;
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
disconnect con1;
deallocate prepare stmt;
drop table t_27420_100; drop table t_27420_100;
drop table t_27420_101; drop table t_27420_101;
drop table v_27420; drop table v_27420;
deallocate prepare stmt;
# --echo #
# Bug#27430 (Crash in subquery code when in PS and table DDL changed after --echo # Bug#27430 Crash in subquery code when in PS and table DDL changed
# PREPARE) --echo # after PREPARE
# --echo #
--disable_warnings --disable_warnings
drop table if exists t_27430_1; drop table if exists t_27430_1;
...@@ -1753,12 +1189,10 @@ insert into t_27430_2 values ...@@ -1753,12 +1189,10 @@ insert into t_27430_2 values
(1234, 4); (1234, 4);
prepare stmt from prepare stmt from
'select oref, a, a in (select a from t_27430_1 where oref=t_27430_2.oref) Z from t_27430_2'; "select oref, a, a in (select a from t_27430_1 where oref=t_27430_2.oref) Z from t_27430_2";
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
execute stmt;
eval $check;
drop table t_27430_1, t_27430_2; drop table t_27430_1, t_27430_2;
...@@ -1777,23 +1211,17 @@ insert into t_27430_2 values ...@@ -1777,23 +1211,17 @@ insert into t_27430_2 values
(NULL, 3), (NULL, 3),
(NULL, 4); (NULL, 4);
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt;
eval $check;
set @expected = @expected + 1;
--error ER_PS_REBIND
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
deallocate prepare stmt;
drop table t_27430_1; drop table t_27430_1;
drop table t_27430_2; drop table t_27430_2;
deallocate prepare stmt;
# --echo #
# Bug#27690 (Re-execution of prepared statement after table was replaced --echo # Bug#27690 Re-execution of prepared statement after table
# with a view crashes) --echo # was replaced with a view crashes
# --echo #
--disable_warnings --disable_warnings
drop table if exists t_27690_1; drop table if exists t_27690_1;
...@@ -1807,33 +1235,125 @@ insert into t_27690_1 values (1,1),(2,2); ...@@ -1807,33 +1235,125 @@ insert into t_27690_1 values (1,1),(2,2);
create table v_27690_1 as select * from t_27690_1; create table v_27690_1 as select * from t_27690_1;
create table v_27690_2 as select * from t_27690_1; create table v_27690_2 as select * from t_27690_1;
prepare stmt from 'select * from v_27690_1, v_27690_2'; prepare stmt from "select * from v_27690_1, v_27690_2";
execute stmt; execute stmt;
eval $check;
execute stmt; execute stmt;
eval $check;
drop table v_27690_1; drop table v_27690_1;
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
execute stmt; execute stmt;
eval $check;
--error ER_NO_SUCH_TABLE --error ER_NO_SUCH_TABLE
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
create view v_27690_1 as select A.a, A.b from t_27690_1 A, t_27690_1 B; create view v_27690_1 as select A.a, A.b from t_27690_1 A, t_27690_1 B;
set @expected = @expected + 1;
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(1);
execute stmt; execute stmt;
eval $check; call p_verify_reprepare_count(0);
deallocate prepare stmt;
drop table t_27690_1; drop table t_27690_1;
drop view v_27690_1; drop view v_27690_1;
drop table v_27690_2; drop table v_27690_2;
deallocate prepare stmt;
--echo #=====================================================================
--echo # TODO: fix the below two bugs and modify their tests
--echo #
--echo # Bug#21294 Executing a prepared statement that executes
--echo # a stored function which was recreat
--echo #
create function f1() returns int return 10;
prepare stmt from "select f1()";
execute stmt;
drop function f1;
create function f1() returns int return 10;
# might pass or fail, implementation dependent
--error ER_SP_DOES_NOT_EXIST
execute stmt;
drop function f1;
create function f1() returns int return 20;
--error ER_SP_DOES_NOT_EXIST
execute stmt;
call p_verify_reprepare_count(0);
drop function f1;
deallocate prepare stmt;
--echo #
--echo # Bug#12093 SP not found on second PS execution if another thread drops
--echo # other SP in between
--echo #
--disable_warnings
drop table if exists t_12093;
drop function if exists f_12093;
drop function if exists f_12093_unrelated;
drop procedure if exists p_12093;
--enable_warnings
create table t_12093 (a int);
create function f_12093() returns int return (select count(*) from t_12093);
create procedure p_12093(a int) select * from t_12093;
create function f_12093_unrelated() returns int return 2;
create procedure p_12093_unrelated() begin end;
prepare stmt_sf from 'select f_12093();';
prepare stmt_sp from 'call p_12093(f_12093())';
execute stmt_sf;
execute stmt_sp;
connect (con1,localhost,root,,);
connection con1;
drop function f_12093_unrelated;
drop procedure p_12093_unrelated;
connection default;
--echo # XXX: bug
--error ER_SP_DOES_NOT_EXIST
execute stmt_sf;
--echo # XXX: bug
--error ER_SP_DOES_NOT_EXIST
execute stmt_sp;
--echo # XXX: bug
--error ER_SP_DOES_NOT_EXIST
execute stmt_sf;
--echo # XXX: bug
--error ER_SP_DOES_NOT_EXIST
execute stmt_sp;
call p_verify_reprepare_count(0);
disconnect con1;
drop table t_12093;
drop function f_12093;
drop procedure p_12093;
deallocate prepare stmt_sf;
deallocate prepare stmt_sp;
--echo # Cleanup
--echo #
--disable_warnings
drop temporary table if exists t1, t2, t3;
drop table if exists t1, t2, t3, v1, v2;
drop procedure if exists p_verify_reprepare_count;
drop procedure if exists p1;
drop function if exists f1;
drop view if exists v1, v2;
--enable_warnings
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