Commit 0a578711 authored by unknown's avatar unknown

WL#4165 (Prepared statements: validation)

Adding the tests cases alone for WL#4165, disabled


mysql-test/t/disabled.def:
  WL#4165 (Prepared statements: validation)
mysql-test/r/ps_ddl.result:
  WL#4165 (Prepared statements: validation)
mysql-test/t/ps_ddl.test:
  WL#4165 (Prepared statements: validation)
parent 4d3cd0d7
=====================================================================
Testing 1: NOTHING -> TABLE transitions
=====================================================================
drop table if exists t1;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
prepare stmt from 'select * from t1';
ERROR 42S02: Table 'test.t1' doesn't exist
=====================================================================
Testing 2: NOTHING -> TEMPORARY TABLE transitions
=====================================================================
=====================================================================
Testing 3: NOTHING -> VIEW transitions
=====================================================================
=====================================================================
Testing 4: TABLE -> NOTHING transitions
=====================================================================
drop table if exists t4;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t4(a int);
prepare stmt from 'select * from t4';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t4;
execute stmt;
ERROR 42S02: Table 'test.t4' doesn't exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR 42S02: Table 'test.t4' doesn't exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
=====================================================================
Testing 5: TABLE -> TABLE (DDL) transitions
=====================================================================
drop table if exists t5;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t5(a int);
prepare stmt from 'select * from t5';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t5 add column (b int);
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop table t5;
=====================================================================
Testing 6: TABLE -> TABLE (TRIGGER) transitions
=====================================================================
drop table if exists t6;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t6(a int);
prepare stmt from 'insert into t6(a) value (?)';
set @val=1;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
set @val=2;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
create trigger t6_bi before insert on t6 for each row
begin
set @message= "t6_bi";
end
$$
set @message="none";
set @val=3;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select @message;
@message
t6_bi
set @val=4;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select @message;
@message
t6_bi
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=5;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select @message;
@message
t6_bi
set @message="none";
set @val=6;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select @message;
@message
t6_bi
create trigger t6_bd before delete on t6 for each row
begin
set @message= "t6_bd";
end
$$
set @message="none";
set @val=7;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select @message;
@message
t6_bi
set @message="none";
set @val=8;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select @message;
@message
t6_bi
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=9;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select @message;
@message
t6_bi
set @message="none";
set @val=10;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select @message;
@message
t6_bi
drop trigger t6_bi;
create trigger t6_bi before insert on t6 for each row
begin
set @message= "t6_bi (2)";
end
$$
set @message="none";
set @val=11;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
t6_bi (2)
set @val=12;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
t6_bi (2)
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=13;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
t6_bi (2)
set @message="none";
set @val=14;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
t6_bi (2)
drop trigger t6_bd;
create trigger t6_bd before delete on t6 for each row
begin
set @message= "t6_bd (2)";
end
$$
set @message="none";
set @val=15;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
t6_bi (2)
set @message="none";
set @val=16;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
t6_bi (2)
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=17;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
t6_bi (2)
set @message="none";
set @val=18;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
t6_bi (2)
drop trigger t6_bi;
set @message="none";
set @val=19;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
none
set @val=20;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
none
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=21;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
none
set @val=22;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
none
drop trigger t6_bd;
set @val=23;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
none
set @val=24;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
select @message;
@message
none
select * from t6 order by a;
a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
drop table t6;
=====================================================================
Testing 7: TABLE -> TABLE (TRIGGER dependencies) transitions
=====================================================================
drop table if exists t7_proc;
drop table if exists t7_func;
drop table if exists t7_view;
drop table if exists t7_table;
drop table if exists t7_dependent_table;
drop table if exists t7_table_trigger;
drop table if exists t7_audit;
drop procedure if exists audit_proc;
drop function if exists audit_func;
drop view if exists audit_view;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t7_proc(a int);
create table t7_func(a int);
create table t7_view(a int);
create table t7_table(a int);
create table t7_table_trigger(a int);
create table t7_audit(old_a int, new_a int, reason varchar(50));
create table t7_dependent_table(old_a int, new_a int, reason varchar(50));
create procedure audit_proc(a int)
insert into t7_audit values (NULL, a, "proc v1");
create function audit_func() returns varchar(50)
return "func v1";
create view audit_view as select "view v1" as reason from dual;
create trigger t7_proc_bi before insert on t7_proc for each row
call audit_proc(NEW.a);
create trigger t7_func_bi before insert on t7_func for each row
insert into t7_audit values (NULL, NEW.a, audit_func());
create trigger t7_view_bi before insert on t7_view for each row
insert into t7_audit values (NULL, NEW.a, (select reason from audit_view));
create trigger t7_table_bi before insert on t7_table for each row
insert into t7_dependent_table values (NULL, NEW.a, "dependent table");
create trigger t7_table_trigger_bi before insert on t7_dependent_table
for each row set NEW.reason="trigger v1";
prepare stmt_proc from 'insert into t7_proc(a) value (?)';
set @val=101;
execute stmt_proc using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
set @val=102;
execute stmt_proc using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop procedure audit_proc;
create procedure audit_proc(a int)
insert into t7_audit values (NULL, a, "proc v2");
set @val=103;
execute stmt_proc using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
set @val=104;
execute stmt_proc using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
prepare stmt_func from 'insert into t7_func(a) value (?)';
set @val=201;
execute stmt_func using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
set @val=202;
execute stmt_func using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop function audit_func;
create function audit_func() returns varchar(50)
return "func v2";
set @val=203;
execute stmt_func using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
set @val=204;
execute stmt_func using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
prepare stmt_view from 'insert into t7_view(a) value (?)';
set @val=301;
execute stmt_view using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
set @val=302;
execute stmt_view using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop view audit_view;
create view audit_view as select "view v2" as reason from dual;
set @val=303;
execute stmt_view using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
set @val=304;
execute stmt_view using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
prepare stmt_table from 'insert into t7_table(a) value (?)';
set @val=401;
execute stmt_table using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
set @val=402;
execute stmt_table using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
alter table t7_dependent_table add column comments varchar(100) default NULL;
set @val=403;
execute stmt_table using @val;
ERROR 21S01: Column count doesn't match value count at row 1
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
set @val=404;
execute stmt_table using @val;
ERROR 21S01: Column count doesn't match value count at row 1
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
alter table t7_dependent_table drop column comments;
set @val=405;
execute stmt_table using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
3
set @val=406;
execute stmt_table using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
3
prepare stmt_table_trigger from 'insert into t7_table(a) value (?)';
set @val=501;
execute stmt_table_trigger using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
3
set @val=502;
execute stmt_table_trigger using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
3
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;
execute stmt_table_trigger using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
4
set @val=504;
execute stmt_table_trigger using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
4
select * from t7_audit order by new_a;
old_a new_a reason
NULL 101 proc v1
NULL 102 proc v1
NULL 103 proc v2
NULL 104 proc v2
NULL 201 func v1
NULL 202 func v1
NULL 203 func v2
NULL 204 func v2
NULL 301 view v1
NULL 302 view v1
NULL 303 view v1
NULL 304 view v1
select * from t7_dependent_table order by new_a;
old_a new_a reason
NULL 401 trigger v1
NULL 402 trigger v1
NULL 405 trigger v1
NULL 406 trigger v1
NULL 501 trigger v1
NULL 502 trigger v1
NULL 503 trigger v2
NULL 504 trigger v2
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;
=====================================================================
Testing 8: TABLE -> TEMPORARY TABLE transitions
=====================================================================
drop table if exists t8;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t8(a int);
prepare stmt from 'select * from t8';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t8;
create temporary table t8(a int);
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop table t8;
=====================================================================
Testing 9: TABLE -> VIEW transitions
=====================================================================
drop table if exists t9;
drop table if exists t9_b;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t9(a int);
create table t9_b(a int);
prepare stmt from 'select * from t9';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t9;
create view t9 as select * from t9_b;
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop view t9;
drop table t9_b;
=====================================================================
Testing 10: TEMPORARY TABLE -> NOTHING transitions
=====================================================================
drop temporary table if exists t10;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create temporary table t10(a int);
prepare stmt from 'select * from t10';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop temporary table t10;
execute stmt;
ERROR 42S02: Table 'test.t10' doesn't exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR 42S02: Table 'test.t10' doesn't exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
=====================================================================
Testing 11: TEMPORARY TABLE -> TABLE transitions
=====================================================================
drop table if exists t11;
drop temporary table if exists t11;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t11(a int);
insert into t11(a) value (1);
create temporary table t11(a int);
prepare stmt from 'select * from t11';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop temporary table t11;
execute stmt;
a
1
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a
1
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select * from t11;
a
1
drop table t11;
=====================================================================
Testing 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions
=====================================================================
drop temporary table if exists t12;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create temporary table t12(a int);
prepare stmt from 'select * from t12';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop temporary table t12;
create temporary table t12(a int, b int);
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
select * from t12;
a b
drop table t12;
=====================================================================
Testing 13: TEMPORARY TABLE -> VIEW transitions
=====================================================================
drop temporary table if exists t13;
drop table if exists t13_b;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create temporary table t13(a int);
create table t13_b(a int);
prepare stmt from 'select * from t13';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop temporary table t13;
create view t13 as select * from t13_b;
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop view t13;
drop table t13_b;
=====================================================================
Testing 14: VIEW -> NOTHING transitions
=====================================================================
drop view if exists t14;
drop table if exists t14_b;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t14_b(a int);
create view t14 as select * from t14_b;
prepare stmt from 'select * from t14';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop view t14;
execute stmt;
ERROR 42S02: Table 'test.t14' doesn't exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
ERROR 42S02: Table 'test.t14' doesn't exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop table t14_b;
=====================================================================
Testing 15: VIEW -> TABLE transitions
=====================================================================
drop view if exists t15;
drop table if exists t15_b;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t15_b(a int);
create view t15 as select * from t15_b;
prepare stmt from 'select * from t15';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop view t15;
create table t15(a int);
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop table t15_b;
drop table t15;
=====================================================================
Testing 16: VIEW -> TEMPORARY TABLE transitions
=====================================================================
drop view if exists t16;
drop table if exists t16_b;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t16_b(a int);
create view t16 as select * from t16_b;
prepare stmt from 'select * from t16';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop view t16;
create temporary table t16(a int);
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop table t16_b;
drop temporary table t16;
=====================================================================
Testing 17: VIEW -> VIEW (DDL) transitions
=====================================================================
drop view if exists t17;
drop table if exists t17_b;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t17_b(a int);
insert into t17_b values (10), (20), (30);
create view t17 as select a, 2*a as b, 3*a as c from t17_b;
select * from t17;
a b c
10 20 30
20 40 60
30 60 90
prepare stmt from 'select * from t17';
execute stmt;
a b c
10 20 30
20 40 60
30 60 90
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a b c
10 20 30
20 40 60
30 60 90
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop view t17;
create view t17 as select a, 2*a as b, 10*a as c from t17_b;
select * from t17;
a b c
10 20 100
20 40 200
30 60 300
execute stmt;
a b c
10 20 100
20 40 200
30 60 300
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a b c
10 20 100
20 40 200
30 60 300
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop table t17_b;
drop view t17;
=====================================================================
Testing 18: VIEW -> VIEW (VIEW dependencies) transitions
=====================================================================
drop table if exists t18;
drop table if exists t18_dependent_table;
drop view if exists t18_func;
drop view if exists t18_view;
drop view if exists t18_table;
drop function if exists view_func;
drop view if exists view_view;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
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';
execute stmt_func;
a b
1 2
2 3
3 4
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt_func;
a b
1 2
2 3
3 4
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop function view_func;
create function view_func(x int) returns int
return x*x;
execute stmt_func;
a b
1 1
2 4
3 9
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt_func;
a b
1 1
2 4
3 9
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
prepare stmt_view from 'select * from t18_view';
execute stmt_view;
a b
1 view v1
2 view v1
3 view v1
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt_view;
a b
1 view v1
2 view v1
3 view v1
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop view view_view;
create view view_view as select "view v2" as reason from dual;
execute stmt_view;
a b
1 view v2
2 view v2
3 view v2
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt_view;
a b
1 view v2
2 view v2
3 view v2
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
prepare stmt_table from 'select * from t18_table';
execute stmt_table;
a
1
2
3
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt_table;
a
1
2
3
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
alter table t18 add column comments varchar(50) default NULL;
execute stmt_table;
a
1
2
3
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
execute stmt_table;
a
1
2
3
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
drop table t18;
drop table t18_dependent_table;
drop view t18_func;
drop view t18_view;
drop view t18_table;
drop function view_func;
drop view view_view;
=====================================================================
Testing 19: Special tables (INFORMATION_SCHEMA)
=====================================================================
drop procedure if exists proc_19;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
prepare stmt from
'select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE
from INFORMATION_SCHEMA.ROUTINES where
routine_name=\'proc_19\'';
create procedure proc_19() select "hi there";
execute stmt;
ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE
test proc_19 PROCEDURE
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE
test proc_19 PROCEDURE
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop procedure proc_19;
create procedure proc_19() select "hi there, again";
execute stmt;
ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE
test proc_19 PROCEDURE
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ROUTINE_SCHEMA ROUTINE_NAME ROUTINE_TYPE
test proc_19 PROCEDURE
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop procedure proc_19;
=====================================================================
Testing 20: Special tables (log tables)
=====================================================================
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
prepare stmt from
'select * from mysql.general_log where argument=\'IMPOSSIBLE QUERY STRING\'';
execute stmt;
event_time user_host thread_id server_id command_type argument
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
event_time user_host thread_id server_id command_type argument
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
event_time user_host thread_id server_id command_type argument
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
event_time user_host thread_id server_id command_type argument
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
=====================================================================
Testing 21: Special tables (system tables)
=====================================================================
drop procedure if exists proc_21;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
prepare stmt from
'select type, db, name from mysql.proc where name=\'proc_21\'';
create procedure proc_21() select "hi there";
execute stmt;
type db name
PROCEDURE test proc_21
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
type db name
PROCEDURE test proc_21
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop procedure proc_21;
create procedure proc_21() select "hi there, again";
execute stmt;
type db name
PROCEDURE test proc_21
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
type db name
PROCEDURE test proc_21
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop procedure proc_21;
=====================================================================
Testing 22: Special tables (views temp tables)
=====================================================================
drop table if exists t22_b;
drop view if exists t22;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t22_b(a int);
create algorithm=temptable view t22 as select a*a as a2 from t22_b;
show create view t22;
View Create View character_set_client collation_connection
t22 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `t22` AS select (`t22_b`.`a` * `t22_b`.`a`) AS `a2` from `t22_b` latin1 latin1_swedish_ci
prepare stmt from 'select * from t22';
insert into t22_b values (1), (2), (3);
execute stmt;
a2
1
4
9
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a2
1
4
9
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
insert into t22_b values (4), (5), (6);
execute stmt;
a2
1
4
9
16
25
36
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a2
1
4
9
16
25
36
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t22_b;
drop view t22;
=====================================================================
Testing 23: Special tables (internal join tables)
=====================================================================
drop table if exists t23_a;
drop table if exists t23_b;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t23_a(a int);
create table t23_b(b int);
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;
a b
1 10
2 10
3 10
1 20
2 20
3 20
1 30
2 30
3 30
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a b
1 10
2 10
3 10
1 20
2 20
3 20
1 30
2 30
3 30
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
insert into t23_a values (4);
insert into t23_b values (40);
execute stmt;
a b
1 10
2 10
3 10
4 10
1 20
2 20
3 20
4 20
1 30
2 30
3 30
4 30
1 40
2 40
3 40
4 40
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a b
1 10
2 10
3 10
4 10
1 20
2 20
3 20
4 20
1 30
2 30
3 30
4 30
1 40
2 40
3 40
4 40
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t23_a;
drop table t23_b;
=====================================================================
Testing 24: Special statements
=====================================================================
drop table if exists t24_alter;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t24_alter(a int);
prepare stmt from 'alter table t24_alter add column b int';
execute stmt;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_alter;
create table t24_alter(a1 int, a2 int);
execute stmt;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t24_alter drop column b;
execute stmt;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t24_alter drop column b;
execute stmt;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_alter;
drop table if exists t24_repair;
create table t24_repair(a int);
insert into t24_repair values (1), (2), (3);
prepare stmt from 'repair table t24_repair';
execute stmt;
Table Op Msg_type Msg_text
test.t24_repair repair status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_repair;
create table t24_repair(a1 int, a2 int);
insert into t24_repair values (1, 10), (2, 20), (3, 30);
execute stmt;
Table Op Msg_type Msg_text
test.t24_repair repair status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t24_repair add column b varchar(50) default NULL;
execute stmt;
Table Op Msg_type Msg_text
test.t24_repair repair status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t24_repair drop column b;
execute stmt;
Table Op Msg_type Msg_text
test.t24_repair repair status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_repair;
drop table if exists t24_analyze;
create table t24_analyze(a int);
insert into t24_analyze values (1), (2), (3);
prepare stmt from 'analyze table t24_analyze';
execute stmt;
Table Op Msg_type Msg_text
test.t24_analyze analyze status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_analyze;
create table t24_analyze(a1 int, a2 int);
insert into t24_analyze values (1, 10), (2, 20), (3, 30);
execute stmt;
Table Op Msg_type Msg_text
test.t24_analyze analyze status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t24_analyze add column b varchar(50) default NULL;
execute stmt;
Table Op Msg_type Msg_text
test.t24_analyze analyze status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t24_analyze drop column b;
execute stmt;
Table Op Msg_type Msg_text
test.t24_analyze analyze status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_analyze;
drop table if exists t24_optimize;
create table t24_optimize(a int);
insert into t24_optimize values (1), (2), (3);
prepare stmt from 'optimize table t24_optimize';
execute stmt;
Table Op Msg_type Msg_text
test.t24_optimize optimize status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_optimize;
create table t24_optimize(a1 int, a2 int);
insert into t24_optimize values (1, 10), (2, 20), (3, 30);
execute stmt;
Table Op Msg_type Msg_text
test.t24_optimize optimize status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t24_optimize add column b varchar(50) default NULL;
execute stmt;
Table Op Msg_type Msg_text
test.t24_optimize optimize status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t24_optimize drop column b;
execute stmt;
Table Op Msg_type Msg_text
test.t24_optimize optimize status OK
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_optimize;
drop procedure if exists changing_proc;
prepare stmt from 'show create procedure changing_proc';
execute stmt;
ERROR 42000: PROCEDURE changing_proc does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR 42000: PROCEDURE changing_proc does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
create procedure changing_proc() begin end;
execute stmt;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
changing_proc CREATE DEFINER=`root`@`localhost` PROCEDURE `changing_proc`()
begin end latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
changing_proc CREATE DEFINER=`root`@`localhost` PROCEDURE `changing_proc`()
begin end latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop procedure changing_proc;
create procedure changing_proc(x int, y int) begin end;
execute stmt;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
changing_proc CREATE DEFINER=`root`@`localhost` PROCEDURE `changing_proc`(x int, y int)
begin end latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation
changing_proc CREATE DEFINER=`root`@`localhost` PROCEDURE `changing_proc`(x int, y int)
begin end latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop procedure changing_proc;
execute stmt;
ERROR 42000: PROCEDURE changing_proc does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR 42000: PROCEDURE changing_proc does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop function if exists changing_func;
prepare stmt from 'show create function changing_func';
execute stmt;
ERROR 42000: FUNCTION changing_func does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR 42000: FUNCTION changing_func does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
create function changing_func() returns int return 0;
execute stmt;
Function sql_mode Create Function character_set_client collation_connection Database Collation
changing_func CREATE DEFINER=`root`@`localhost` FUNCTION `changing_func`() RETURNS int(11)
return 0 latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
Function sql_mode Create Function character_set_client collation_connection Database Collation
changing_func CREATE DEFINER=`root`@`localhost` FUNCTION `changing_func`() RETURNS int(11)
return 0 latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop function changing_func;
create function changing_func(x int, y int) returns int return x+y;
execute stmt;
Function sql_mode Create Function character_set_client collation_connection Database Collation
changing_func CREATE DEFINER=`root`@`localhost` FUNCTION `changing_func`(x int, y int) RETURNS int(11)
return x+y latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
Function sql_mode Create Function character_set_client collation_connection Database Collation
changing_func CREATE DEFINER=`root`@`localhost` FUNCTION `changing_func`(x int, y int) RETURNS int(11)
return x+y latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop function changing_func;
execute stmt;
ERROR 42000: FUNCTION changing_func does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR 42000: FUNCTION changing_func does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table if exists t24_trigger;
create table t24_trigger(a int);
prepare stmt from 'show create trigger t24_bi;';
execute stmt;
ERROR HY000: Trigger does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR HY000: Trigger does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
create trigger t24_bi before insert on t24_trigger for each row
begin
set @message= "t24_bi";
end
$$
execute stmt;
Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
t24_bi CREATE DEFINER=`root`@`localhost` trigger t24_bi before insert on t24_trigger for each row
begin
set @message= "t24_bi";
end latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
t24_bi CREATE DEFINER=`root`@`localhost` trigger t24_bi before insert on t24_trigger for each row
begin
set @message= "t24_bi";
end latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop trigger t24_bi;
create trigger t24_bi before insert on t24_trigger for each row
begin
set @message= "t24_bi (2)";
end
$$
execute stmt;
Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
t24_bi CREATE DEFINER=`root`@`localhost` trigger t24_bi before insert on t24_trigger for each row
begin
set @message= "t24_bi (2)";
end latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation
t24_bi CREATE DEFINER=`root`@`localhost` trigger t24_bi before insert on t24_trigger for each row
begin
set @message= "t24_bi (2)";
end latin1 latin1_swedish_ci latin1_swedish_ci
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop trigger t24_bi;
execute stmt;
ERROR HY000: Trigger does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR HY000: Trigger does not exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t24_trigger;
=====================================================================
Testing 25: Testing the strength of TABLE_SHARE version
=====================================================================
drop table if exists t25_num_col;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t25_num_col(a int);
prepare stmt from 'select * from t25_num_col';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
alter table t25_num_col add column b varchar(50) default NULL;
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop table t25_num_col;
drop table if exists t25_col_name;
create table t25_col_name(a int);
prepare stmt from 'select * from t25_col_name';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
alter table t25_col_name change a b int;
execute stmt;
b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
execute stmt;
b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
drop table t25_col_name;
drop table if exists t25_col_type;
create table t25_col_type(a int);
prepare stmt from 'select * from t25_col_type';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
alter table t25_col_type change a a varchar(10);
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
3
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
3
drop table t25_col_type;
drop table if exists t25_col_type_length;
create table t25_col_type_length(a varchar(10));
prepare stmt from 'select * from t25_col_type_length';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
3
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
3
alter table t25_col_type_length change a a varchar(20);
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
4
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
4
drop table t25_col_type_length;
drop table if exists t25_col_null;
create table t25_col_null(a varchar(10));
prepare stmt from 'select * from t25_col_null';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
4
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
4
alter table t25_col_null change a a varchar(10) NOT NULL;
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
5
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
5
drop table t25_col_null;
drop table if exists t25_col_default;
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;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
5
set @val=2;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
5
alter table t25_col_default change b b int DEFAULT 20;
set @val=3;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
5
set @val=4;
execute stmt using @val;
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
5
select * from t25_col_default;
a b
1 10
2 10
3 20
4 20
drop table t25_col_default;
drop table if exists t25_index;
create table t25_index(a varchar(10));
prepare stmt from 'select * from t25_index';
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
5
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
5
create index i1 on t25_index(a);
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
6
execute stmt;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
6
drop table t25_index;
drop table if exists t25_index_unique;
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;
Table Create Table
t25_index_unique CREATE TABLE `t25_index_unique` (
`a` varchar(10) DEFAULT NULL,
`b` varchar(10) DEFAULT NULL,
KEY `i1` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
prepare stmt from 'select * from t25_index_unique';
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
6
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
6
alter table t25_index_unique drop index i1;
create unique index i1 on t25_index_unique(a, b);
show create table t25_index_unique;
Table Create Table
t25_index_unique CREATE TABLE `t25_index_unique` (
`a` varchar(10) DEFAULT NULL,
`b` varchar(10) DEFAULT NULL,
UNIQUE KEY `i1` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
7
execute stmt;
a b
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
7
drop table t25_index_unique;
=====================================================================
Testing reported bugs
=====================================================================
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;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table table_12093(a int);
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//
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;
func_12093()
0
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt_sp;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop function func_12093_unrelated;
drop procedure proc_12093_unrelated;
execute stmt_sf;
func_12093()
0
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt_sp;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt_sf;
func_12093()
0
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt_sp;
a
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
deallocate prepare stmt_sf;
deallocate prepare stmt_sp;
drop table table_12093;
drop function func_12093;
drop procedure proc_12093;
drop function if exists func_21294;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create function func_21294() returns int return 10;
prepare stmt from "select func_21294()";
execute stmt;
func_21294()
10
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop function func_21294;
create function func_21294() returns int return 10;
execute stmt;
func_21294()
10
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop function func_21294;
create function func_21294() returns int return 20;
execute stmt;
func_21294()
20
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
deallocate prepare stmt;
drop function func_21294;
drop table if exists t_27420_100;
drop table if exists t_27420_101;
drop view if exists v_27420;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t_27420_100(a int);
insert into t_27420_100 values (1), (2);
create table t_27420_101(a int);
insert into t_27420_101 values (1), (2);
create view v_27420 as select t_27420_100.a X, t_27420_101.a Y
from t_27420_100, t_27420_101
where t_27420_100.a=t_27420_101.a;
prepare stmt from 'select * from v_27420';
execute stmt;
X Y
1 1
2 2
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop view v_27420;
create table v_27420(X int, Y int);
execute stmt;
X Y
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
drop table v_27420;
create table v_27420 (a int, b int, filler char(200));
execute stmt;
a b filler
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
2
deallocate prepare stmt;
drop table t_27420_100;
drop table t_27420_101;
drop table v_27420;
drop table if exists t_27430_1;
drop table if exists t_27430_2;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t_27430_1 (a int not null, oref int not null, key(a));
insert into t_27430_1 values
(1, 1),
(1, 1234),
(2, 3),
(2, 1234),
(3, 1234);
create table t_27430_2 (a int not null, oref int not null);
insert into t_27430_2 values
(1, 1),
(2, 2),
(1234, 3),
(1234, 4);
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';
execute stmt;
oref a Z
1 1 1
2 2 0
3 1234 0
4 1234 0
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
oref a Z
1 1 1
2 2 0
3 1234 0
4 1234 0
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table t_27430_1, t_27430_2;
create table t_27430_1 (a int, oref int, key(a));
insert into t_27430_1 values
(1, 1),
(1, NULL),
(2, 3),
(2, NULL),
(3, NULL);
create table t_27430_2 (a int, oref int);
insert into t_27430_2 values
(1, 1),
(2,2),
(NULL, 3),
(NULL, 4);
execute stmt;
oref a Z
1 1 1
2 2 0
3 NULL NULL
4 NULL 0
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
oref a Z
1 1 1
2 2 0
3 NULL NULL
4 NULL 0
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
deallocate prepare stmt;
drop table t_27430_1;
drop table t_27430_2;
drop table if exists t_27690_1;
drop view if exists v_27690_1;
drop table if exists v_27690_2;
SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
create table t_27690_1 (a int, b int);
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_2 as select * from t_27690_1;
prepare stmt from 'select * from v_27690_1, v_27690_2';
execute stmt;
a b a b
1 1 1 1
2 2 1 1
1 1 2 2
2 2 2 2
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
a b a b
1 1 1 1
2 2 1 1
1 1 2 2
2 2 2 2
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
drop table v_27690_1;
execute stmt;
ERROR 42S02: Table 'test.v_27690_1' doesn't exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
execute stmt;
ERROR 42S02: Table 'test.v_27690_1' doesn't exist
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
0
create view v_27690_1 as select A.a, A.b from t_27690_1 A, t_27690_1 B;
execute stmt;
a b a b
1 1 1 1
2 2 1 1
1 1 1 1
2 2 1 1
1 1 2 2
2 2 2 2
1 1 2 2
2 2 2 2
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
execute stmt;
a b a b
1 1 1 1
2 2 1 1
1 1 1 1
2 2 1 1
1 1 2 2
2 2 2 2
1 1 2 2
2 2 2 2
SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
REPREPARED
1
deallocate prepare stmt;
drop table t_27690_1;
drop view v_27690_1;
drop table v_27690_2;
...@@ -20,6 +20,6 @@ lowercase_table3 : Bug#32667 lowercase_table3.test reports to error log ...@@ -20,6 +20,6 @@ lowercase_table3 : Bug#32667 lowercase_table3.test reports to error log
kill : Bug#29149: Test "kill" fails on Windows kill : Bug#29149: Test "kill" fails on Windows
innodb_mysql : Bug#32724: innodb_mysql.test fails randomly innodb_mysql : Bug#32724: innodb_mysql.test fails randomly
wait_timeout : Bug#32801 wait_timeout.test fails randomly wait_timeout : Bug#32801 wait_timeout.test fails randomly
kill : Bug#29149 Test "kill" fails on Windows
ctype_create : Bug#32965 main.ctype_create fails ctype_create : Bug#32965 main.ctype_create fails
status : Bug#32966 main.status fails status : Bug#32966 main.status fails
ps_ddl : Bug#12093 2007-12-14 pending WL#4165 / WL#4166
#
# Testing the behavior of 'PREPARE', 'DDL', 'EXECUTE' scenarios
#
# Background:
# In a statement like "select * from t1", t1 can be:
# - nothing (the table does not exist)
# - a real table
# - a temporary table
# - a view
#
# Changing the nature of "t1" between a PREPARE and an EXECUTE
# can invalidate the internal state of a prepared statement, so that,
# during the execute, the server should:
# - detect state changes and fail to execute a statement,
# instead of crashing the server or returning wrong results
# - "RE-PREPARE" the statement to restore a valid internal state.
#
# Also, changing the physical structure of "t1", by:
# - changing the definition of t1 itself (DDL on tables, views)
# - changing TRIGGERs associated with a table
# - changing PROCEDURE, FUNCTION referenced by a TRIGGER body,
# - changing PROCEDURE, FUNCTION referenced by a VIEW body,
# impacts the internal structure of a prepared statement, and should
# cause the same verifications at execute time to be performed.
#
# This test provided in this file cover the different state transitions
# between a PREPARE and an EXECUTE, and are organized as follows:
# - Part 1: NOTHING -> TABLE
# - Part 2: NOTHING -> TEMPORARY TABLE
# - Part 3: NOTHING -> VIEW
# - Part 4: TABLE -> NOTHING
# - Part 5: TABLE -> TABLE (DDL)
# - Part 6: TABLE -> TABLE (TRIGGER)
# - Part 7: TABLE -> TABLE (TRIGGER dependencies)
# - Part 8: TABLE -> TEMPORARY TABLE
# - Part 9: TABLE -> VIEW
# - Part 10: TEMPORARY TABLE -> NOTHING
# - Part 11: TEMPORARY TABLE -> TABLE
# - Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL)
# - Part 13: TEMPORARY TABLE -> VIEW
# - Part 14: VIEW -> NOTHING
# - Part 15: VIEW -> TABLE
# - Part 16: VIEW -> TEMPORARY TABLE
# - Part 17: VIEW -> VIEW (DDL)
# - Part 18: VIEW -> VIEW (VIEW dependencies)
# - Part 19: Special tables (INFORMATION_SCHEMA)
# - Part 20: Special tables (log tables)
# - Part 21: Special tables (system tables)
# - Part 22: Special tables (views temp tables)
# - Part 23: Special tables (internal join tables)
# - Part 24: Special statements
# - Part 25: Testing the strength of TABLE_SHARE version
let $base_count = SELECT VARIABLE_VALUE from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE'
into @base_count ;
let $reprepared = SELECT VARIABLE_VALUE - @base_count AS REPREPARED from
INFORMATION_SCHEMA.SESSION_STATUS where variable_name='COM_STMT_REPREPARE' ;
--echo =====================================================================
--echo Testing 1: NOTHING -> TABLE transitions
--echo =====================================================================
--disable_warnings
drop table if exists t1;
--enable_warnings
eval $base_count;
# can not be tested since prepare failed
--error ER_NO_SUCH_TABLE
prepare stmt from 'select * from t1';
--echo =====================================================================
--echo Testing 2: NOTHING -> TEMPORARY TABLE transitions
--echo =====================================================================
# can not be tested
--echo =====================================================================
--echo Testing 3: NOTHING -> VIEW transitions
--echo =====================================================================
# can not be tested
--echo =====================================================================
--echo Testing 4: TABLE -> NOTHING transitions
--echo =====================================================================
--disable_warnings
drop table if exists t4;
--enable_warnings
eval $base_count;
create table t4(a int);
prepare stmt from 'select * from t4';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t4;
--error ER_NO_SUCH_TABLE
execute stmt;
eval $reprepared;
--error ER_NO_SUCH_TABLE
execute stmt;
eval $reprepared;
--echo =====================================================================
--echo Testing 5: TABLE -> TABLE (DDL) transitions
--echo =====================================================================
--disable_warnings
drop table if exists t5;
--enable_warnings
eval $base_count;
create table t5(a int);
prepare stmt from 'select * from t5';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
alter table t5 add column (b int);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t5;
--echo =====================================================================
--echo Testing 6: TABLE -> TABLE (TRIGGER) transitions
--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
drop table if exists t6;
--enable_warnings
eval $base_count;
create table t6(a int);
prepare stmt from 'insert into t6(a) value (?)';
set @val=1;
execute stmt using @val;
eval $reprepared;
set @val=2;
execute stmt using @val;
eval $reprepared;
# Relevant trigger: execute should reprepare
delimiter $$;
create trigger t6_bi before insert on t6 for each row
begin
set @message= "t6_bi";
end
$$
delimiter ;$$
set @message="none";
set @val=3;
# REPREPARED +1
execute stmt using @val;
eval $reprepared;
select @message;
set @val=4;
execute stmt using @val;
eval $reprepared;
select @message;
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=5;
execute stmt using @val;
eval $reprepared;
select @message;
set @message="none";
set @val=6;
execute stmt using @val;
eval $reprepared;
select @message;
# Unrelated trigger: execute can pass of fail, implementation dependent
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;
execute stmt using @val;
eval $reprepared;
select @message;
set @message="none";
set @val=8;
execute stmt using @val;
eval $reprepared;
select @message;
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=9;
execute stmt using @val;
eval $reprepared;
select @message;
set @message="none";
set @val=10;
execute stmt using @val;
eval $reprepared;
select @message;
# Relevant trigger: execute should reprepare
drop trigger t6_bi;
delimiter $$;
create trigger t6_bi before insert on t6 for each row
begin
set @message= "t6_bi (2)";
end
$$
delimiter ;$$
set @message="none";
set @val=11;
# REPREPARED +1
execute stmt using @val;
eval $reprepared;
select @message;
set @val=12;
execute stmt using @val;
eval $reprepared;
select @message;
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=13;
execute stmt using @val;
eval $reprepared;
select @message;
set @message="none";
set @val=14;
execute stmt using @val;
eval $reprepared;
select @message;
# Unrelated trigger: execute can pass of fail, implementation dependent
drop trigger t6_bd;
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;
execute stmt using @val;
eval $reprepared;
select @message;
set @message="none";
set @val=16;
execute stmt using @val;
eval $reprepared;
select @message;
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=17;
execute stmt using @val;
eval $reprepared;
select @message;
set @message="none";
set @val=18;
execute stmt using @val;
eval $reprepared;
select @message;
drop trigger t6_bi;
set @message="none";
set @val=19;
# safe to re-execute
execute stmt using @val;
eval $reprepared;
select @message;
set @val=20;
# safe to re-execute
execute stmt using @val;
eval $reprepared;
select @message;
prepare stmt from 'insert into t6(a) value (?)';
set @message="none";
set @val=21;
execute stmt using @val;
eval $reprepared;
select @message;
set @val=22;
execute stmt using @val;
eval $reprepared;
select @message;
drop trigger t6_bd;
set @val=23;
# safe to re-execute
execute stmt using @val;
eval $reprepared;
select @message;
set @val=24;
# safe to re-execute
execute stmt using @val;
eval $reprepared;
select @message;
select * from t6 order by a;
drop table t6;
--echo =====================================================================
--echo Testing 7: TABLE -> TABLE (TRIGGER dependencies) transitions
--echo =====================================================================
#
# Test 7-a: dependent PROCEDURE has changed
# Test 7-b: dependent FUNCTION has changed
# Test 7-c: dependent VIEW has changed
# Test 7-d: dependent TABLE has changed
# Test 7-e: dependent TABLE TRIGGER has changed
#
--disable_warnings
drop table if exists t7_proc;
drop table if exists t7_func;
drop table if exists t7_view;
drop table if exists t7_table;
drop table if exists t7_dependent_table;
drop table if exists t7_table_trigger;
drop table if exists t7_audit;
drop procedure if exists audit_proc;
drop function if exists audit_func;
drop view if exists audit_view;
--enable_warnings
eval $base_count;
create table t7_proc(a int);
create table t7_func(a int);
create table t7_view(a int);
create table t7_table(a int);
create table t7_table_trigger(a int);
create table t7_audit(old_a int, new_a int, reason varchar(50));
create table t7_dependent_table(old_a int, new_a int, reason varchar(50));
create procedure audit_proc(a int)
insert into t7_audit values (NULL, a, "proc v1");
create function audit_func() returns varchar(50)
return "func v1";
create view audit_view as select "view v1" as reason from dual;
create trigger t7_proc_bi before insert on t7_proc for each row
call audit_proc(NEW.a);
create trigger t7_func_bi before insert on t7_func for each row
insert into t7_audit values (NULL, NEW.a, audit_func());
create trigger t7_view_bi before insert on t7_view for each row
insert into t7_audit values (NULL, NEW.a, (select reason from audit_view));
create trigger t7_table_bi before insert on t7_table for each row
insert into t7_dependent_table values (NULL, NEW.a, "dependent table");
create trigger t7_table_trigger_bi before insert on t7_dependent_table
for each row set NEW.reason="trigger v1";
prepare stmt_proc from 'insert into t7_proc(a) value (?)';
set @val=101;
execute stmt_proc using @val;
eval $reprepared;
set @val=102;
execute stmt_proc using @val;
eval $reprepared;
drop procedure audit_proc;
create procedure audit_proc(a int)
insert into t7_audit values (NULL, a, "proc v2");
set @val=103;
execute stmt_proc using @val;
eval $reprepared;
set @val=104;
execute stmt_proc using @val;
eval $reprepared;
prepare stmt_func from 'insert into t7_func(a) value (?)';
set @val=201;
execute stmt_func using @val;
eval $reprepared;
set @val=202;
execute stmt_func using @val;
eval $reprepared;
drop function audit_func;
create function audit_func() returns varchar(50)
return "func v2";
set @val=203;
execute stmt_func using @val;
eval $reprepared;
set @val=204;
execute stmt_func using @val;
eval $reprepared;
prepare stmt_view from 'insert into t7_view(a) value (?)';
set @val=301;
execute stmt_view using @val;
eval $reprepared;
set @val=302;
execute stmt_view using @val;
eval $reprepared;
drop view audit_view;
create view audit_view as select "view v2" as reason from dual;
# Because of Bug#33255, the wrong result is still produced for cases
# 303 and 304, even after re-preparing the statement.
# This is because the table trigger is cached and is not invalidated.
set @val=303;
# REPREPARED +1
execute stmt_view using @val;
eval $reprepared;
set @val=304;
execute stmt_view using @val;
eval $reprepared;
prepare stmt_table from 'insert into t7_table(a) value (?)';
set @val=401;
execute stmt_table using @val;
eval $reprepared;
set @val=402;
execute stmt_table using @val;
eval $reprepared;
alter table t7_dependent_table add column comments varchar(100) default NULL;
set @val=403;
# REPREPARED +1
--error ER_WRONG_VALUE_COUNT_ON_ROW
execute stmt_table using @val;
eval $reprepared;
set @val=404;
--error ER_WRONG_VALUE_COUNT_ON_ROW
execute stmt_table using @val;
eval $reprepared;
alter table t7_dependent_table drop column comments;
set @val=405;
# REPREPARED +1
execute stmt_table using @val;
eval $reprepared;
set @val=406;
execute stmt_table using @val;
eval $reprepared;
prepare stmt_table_trigger from 'insert into t7_table(a) value (?)';
set @val=501;
execute stmt_table_trigger using @val;
eval $reprepared;
set @val=502;
execute stmt_table_trigger using @val;
eval $reprepared;
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;
# REPREPARED +1
execute stmt_table_trigger using @val;
eval $reprepared;
set @val=504;
execute stmt_table_trigger using @val;
eval $reprepared;
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 Testing 8: TABLE -> TEMPORARY TABLE transitions
--echo =====================================================================
--disable_warnings
drop table if exists t8;
--enable_warnings
eval $base_count;
create table t8(a int);
prepare stmt from 'select * from t8';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t8;
create temporary table t8(a int);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t8;
--echo =====================================================================
--echo Testing 9: TABLE -> VIEW transitions
--echo =====================================================================
--disable_warnings
drop table if exists t9;
drop table if exists t9_b;
--enable_warnings
eval $base_count;
create table t9(a int);
create table t9_b(a int);
prepare stmt from 'select * from t9';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t9;
create view t9 as select * from t9_b;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop view t9;
drop table t9_b;
--echo =====================================================================
--echo Testing 10: TEMPORARY TABLE -> NOTHING transitions
--echo =====================================================================
--disable_warnings
drop temporary table if exists t10;
--enable_warnings
eval $base_count;
create temporary table t10(a int);
prepare stmt from 'select * from t10';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop temporary table t10;
--error ER_NO_SUCH_TABLE
execute stmt;
eval $reprepared;
--error ER_NO_SUCH_TABLE
execute stmt;
eval $reprepared;
--echo =====================================================================
--echo Testing 11: TEMPORARY TABLE -> TABLE transitions
--echo =====================================================================
--disable_warnings
drop table if exists t11;
drop temporary table if exists t11;
--enable_warnings
eval $base_count;
create table t11(a int);
insert into t11(a) value (1);
create temporary table t11(a int);
prepare stmt from 'select * from t11';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop temporary table t11;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
select * from t11;
drop table t11;
--echo =====================================================================
--echo Testing 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions
--echo =====================================================================
--disable_warnings
drop temporary table if exists t12;
--enable_warnings
eval $base_count;
create temporary table t12(a int);
prepare stmt from 'select * from t12';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop temporary table t12;
create temporary table t12(a int, b int);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
select * from t12;
drop table t12;
--echo =====================================================================
--echo Testing 13: TEMPORARY TABLE -> VIEW transitions
--echo =====================================================================
--disable_warnings
drop temporary table if exists t13;
drop table if exists t13_b;
--enable_warnings
eval $base_count;
create temporary table t13(a int);
create table t13_b(a int);
prepare stmt from 'select * from t13';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop temporary table t13;
create view t13 as select * from t13_b;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop view t13;
drop table t13_b;
--echo =====================================================================
--echo Testing 14: VIEW -> NOTHING transitions
--echo =====================================================================
--disable_warnings
drop view if exists t14;
drop table if exists t14_b;
--enable_warnings
eval $base_count;
create table t14_b(a int);
create view t14 as select * from t14_b;
prepare stmt from 'select * from t14';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop view t14;
# REPREPARED +1
--error ER_NO_SUCH_TABLE
execute stmt;
eval $reprepared;
--error ER_NO_SUCH_TABLE
execute stmt;
eval $reprepared;
drop table t14_b;
--echo =====================================================================
--echo Testing 15: VIEW -> TABLE transitions
--echo =====================================================================
--disable_warnings
drop view if exists t15;
drop table if exists t15_b;
--enable_warnings
eval $base_count;
create table t15_b(a int);
create view t15 as select * from t15_b;
prepare stmt from 'select * from t15';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop view t15;
create table t15(a int);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t15_b;
drop table t15;
--echo =====================================================================
--echo Testing 16: VIEW -> TEMPORARY TABLE transitions
--echo =====================================================================
--disable_warnings
drop view if exists t16;
drop table if exists t16_b;
--enable_warnings
eval $base_count;
create table t16_b(a int);
create view t16 as select * from t16_b;
prepare stmt from 'select * from t16';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop view t16;
create temporary table t16(a int);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t16_b;
drop temporary table t16;
--echo =====================================================================
--echo Testing 17: VIEW -> VIEW (DDL) transitions
--echo =====================================================================
--disable_warnings
drop view if exists t17;
drop table if exists t17_b;
--enable_warnings
eval $base_count;
create table t17_b(a int);
insert into t17_b values (10), (20), (30);
create view t17 as select a, 2*a as b, 3*a as c from t17_b;
select * from t17;
prepare stmt from 'select * from t17';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop view t17;
create view t17 as select a, 2*a as b, 10*a as c from t17_b;
select * from t17;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t17_b;
drop view t17;
--echo =====================================================================
--echo Testing 18: VIEW -> VIEW (VIEW dependencies) transitions
--echo =====================================================================
#
# Test 18-a: dependent PROCEDURE has changed (via a trigger)
# Test 18-b: dependent FUNCTION has changed
# Test 18-c: dependent VIEW has changed
# Test 18-d: dependent TABLE has changed
# Test 18-e: dependent TABLE TRIGGER has changed
#
--disable_warnings
drop table if exists t18;
drop table if exists t18_dependent_table;
drop view if exists t18_func;
drop view if exists t18_view;
drop view if exists t18_table;
drop function if exists view_func;
drop view if exists view_view;
--enable_warnings
eval $base_count;
# TODO: insertable view -> trigger
# 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';
execute stmt_func;
eval $reprepared;
execute stmt_func;
eval $reprepared;
drop function view_func;
create function view_func(x int) returns int
return x*x;
execute stmt_func;
eval $reprepared;
execute stmt_func;
eval $reprepared;
prepare stmt_view from 'select * from t18_view';
execute stmt_view;
eval $reprepared;
execute stmt_view;
eval $reprepared;
drop view view_view;
create view view_view as select "view v2" as reason from dual;
# REPREPARED +1
execute stmt_view;
eval $reprepared;
execute stmt_view;
eval $reprepared;
prepare stmt_table from 'select * from t18_table';
execute stmt_table;
eval $reprepared;
execute stmt_table;
eval $reprepared;
alter table t18 add column comments varchar(50) default NULL;
# REPREPARED +1
execute stmt_table;
eval $reprepared;
execute stmt_table;
eval $reprepared;
drop table t18;
drop table t18_dependent_table;
drop view t18_func;
drop view t18_view;
drop view t18_table;
drop function view_func;
drop view view_view;
--echo =====================================================================
--echo Testing 19: Special tables (INFORMATION_SCHEMA)
--echo =====================================================================
--disable_warnings
drop procedure if exists proc_19;
--enable_warnings
eval $base_count;
# Using a temporary table internally should not confuse the prepared
# statement code, and should not raise ER_PS_INVALIDATED errors
prepare stmt from
'select ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE
from INFORMATION_SCHEMA.ROUTINES where
routine_name=\'proc_19\'';
create procedure proc_19() select "hi there";
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop procedure proc_19;
create procedure proc_19() select "hi there, again";
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop procedure proc_19;
--echo =====================================================================
--echo Testing 20: Special tables (log tables)
--echo =====================================================================
eval $base_count;
prepare stmt from
'select * from mysql.general_log where argument=\'IMPOSSIBLE QUERY STRING\'';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
--echo =====================================================================
--echo Testing 21: Special tables (system tables)
--echo =====================================================================
--disable_warnings
drop procedure if exists proc_21;
--enable_warnings
eval $base_count;
prepare stmt from
'select type, db, name from mysql.proc where name=\'proc_21\'';
create procedure proc_21() select "hi there";
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop procedure proc_21;
create procedure proc_21() select "hi there, again";
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop procedure proc_21;
--echo =====================================================================
--echo Testing 22: Special tables (views temp tables)
--echo =====================================================================
--disable_warnings
drop table if exists t22_b;
drop view if exists t22;
--enable_warnings
eval $base_count;
create table t22_b(a int);
create algorithm=temptable view t22 as select a*a as a2 from t22_b;
# Using a temporary table internally should not confuse the prepared
# statement code, and should not raise ER_PS_INVALIDATED errors
show create view t22;
prepare stmt from 'select * from t22';
insert into t22_b values (1), (2), (3);
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
insert into t22_b values (4), (5), (6);
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t22_b;
drop view t22;
--echo =====================================================================
--echo Testing 23: Special tables (internal join tables)
--echo =====================================================================
--disable_warnings
drop table if exists t23_a;
drop table if exists t23_b;
--enable_warnings
eval $base_count;
create table t23_a(a int);
create table t23_b(b int);
# Using a temporary table internally should not confuse the prepared
# 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 $reprepared;
execute stmt;
eval $reprepared;
insert into t23_a values (4);
insert into t23_b values (40);
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t23_a;
drop table t23_b;
--echo =====================================================================
--echo Testing 24: Special statements
--echo =====================================================================
# SQLCOM_ALTER_TABLE:
--disable_warnings
drop table if exists t24_alter;
--enable_warnings
eval $base_count;
create table t24_alter(a int);
prepare stmt from 'alter table t24_alter add column b int';
execute stmt;
eval $reprepared;
drop table t24_alter;
create table t24_alter(a1 int, a2 int);
# t24_alter has changed, and it's not a problem
execute stmt;
eval $reprepared;
alter table t24_alter drop column b;
execute stmt;
eval $reprepared;
alter table t24_alter drop column b;
execute stmt;
eval $reprepared;
drop table t24_alter;
# SQLCOM_REPAIR:
--disable_warnings
drop table if exists t24_repair;
--enable_warnings
create table t24_repair(a int);
insert into t24_repair values (1), (2), (3);
prepare stmt from 'repair table t24_repair';
execute stmt;
eval $reprepared;
drop table t24_repair;
create table t24_repair(a1 int, a2 int);
insert into t24_repair values (1, 10), (2, 20), (3, 30);
# t24_repair has changed, and it's not a problem
execute stmt;
eval $reprepared;
alter table t24_repair add column b varchar(50) default NULL;
execute stmt;
eval $reprepared;
alter table t24_repair drop column b;
execute stmt;
eval $reprepared;
drop table t24_repair;
# SQLCOM_ANALYZE:
--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;
eval $reprepared;
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
execute stmt;
eval $reprepared;
alter table t24_analyze add column b varchar(50) default NULL;
execute stmt;
eval $reprepared;
alter table t24_analyze drop column b;
execute stmt;
eval $reprepared;
drop table t24_analyze;
# SQLCOM_OPTIMIZE:
--disable_warnings
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;
eval $reprepared;
drop table t24_optimize;
create table t24_optimize(a1 int, a2 int);
insert into t24_optimize values (1, 10), (2, 20), (3, 30);
# t24_optimize has changed, and it's not a problem
execute stmt;
eval $reprepared;
alter table t24_optimize add column b varchar(50) default NULL;
execute stmt;
eval $reprepared;
alter table t24_optimize drop column b;
execute stmt;
eval $reprepared;
drop table t24_optimize;
# SQLCOM_SHOW_CREATE_PROC:
--disable_warnings
drop procedure if exists changing_proc;
--enable_warnings
prepare stmt from 'show create procedure changing_proc';
--error ER_SP_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
--error ER_SP_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
create procedure changing_proc() begin end;
# changing_proc has changed, and it's not a problem
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop procedure changing_proc;
create procedure changing_proc(x int, y int) begin end;
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop procedure changing_proc;
--error ER_SP_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
--error ER_SP_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
# SQLCOM_SHOW_CREATE_FUNC:
--disable_warnings
drop function if exists changing_func;
--enable_warnings
prepare stmt from 'show create function changing_func';
--error ER_SP_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
--error ER_SP_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
create function changing_func() returns int return 0;
# changing_proc has changed, and it's not a problem
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop function changing_func;
create function changing_func(x int, y int) returns int return x+y;
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop function changing_func;
--error ER_SP_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
--error ER_SP_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
# SQLCOM_SHOW_CREATE_TRIGGER:
--disable_warnings
drop table if exists t24_trigger;
--enable_warnings
create table t24_trigger(a int);
prepare stmt from 'show create trigger t24_bi;';
--error ER_TRG_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
--error ER_TRG_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
delimiter $$;
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
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop trigger t24_bi;
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
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop trigger t24_bi;
--error ER_TRG_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
--error ER_TRG_DOES_NOT_EXIST
execute stmt;
eval $reprepared;
drop table t24_trigger;
--echo =====================================================================
--echo Testing 25: Testing the strength of TABLE_SHARE version
--echo =====================================================================
# Test 25-a: number of columns
--disable_warnings
drop table if exists t25_num_col;
--enable_warnings
eval $base_count;
create table t25_num_col(a int);
prepare stmt from 'select * from t25_num_col';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
alter table t25_num_col add column b varchar(50) default NULL;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
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);
prepare stmt from 'select * from t25_col_name';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
alter table t25_col_name change a b int;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t25_col_name;
# Test 25-c: column type
--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 $reprepared;
execute stmt;
eval $reprepared;
alter table t25_col_type change a a varchar(10);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t25_col_type;
# Test 25-d: column type length
--disable_warnings
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;
eval $reprepared;
execute stmt;
eval $reprepared;
alter table t25_col_type_length change a a varchar(20);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
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;
eval $reprepared;
execute stmt;
eval $reprepared;
alter table t25_col_null change a a varchar(10) NOT NULL;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
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 $reprepared;
set @val=2;
execute stmt using @val;
eval $reprepared;
alter table t25_col_default change b b int DEFAULT 20;
set @val=3;
# Must insert the correct default value for b
execute stmt using @val;
eval $reprepared;
set @val=4;
# Must insert the correct default value for b
execute stmt using @val;
eval $reprepared;
select * from t25_col_default;
drop table t25_col_default;
# Test 25-g: number of keys
--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;
eval $reprepared;
execute stmt;
eval $reprepared;
create index i1 on t25_index(a);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t25_index;
# Test 25-h: changing index uniqueness
--disable_warnings
drop table if exists t25_index_unique;
--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;
eval $reprepared;
execute stmt;
eval $reprepared;
alter table t25_index_unique drop index i1;
create unique index i1 on t25_index_unique(a, b);
show create table t25_index_unique;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t25_index_unique;
--echo =====================================================================
--echo Testing reported bugs
--echo =====================================================================
#
# Bug#12093 (SP not found on second PS execution if another thread drops
# other SP in between)
#
--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
eval $base_count;
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 $reprepared;
execute stmt_sp;
eval $reprepared;
connection con1;
drop function func_12093_unrelated;
drop procedure proc_12093_unrelated;
connection default;
# previously, failed with --error 1305
execute stmt_sf;
eval $reprepared;
# previously, failed with --error 1305
execute stmt_sp;
eval $reprepared;
# previously, failed with --error 1305
execute stmt_sf;
eval $reprepared;
# previously, failed with --error 1305
execute stmt_sp;
eval $reprepared;
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
eval $base_count;
create function func_21294() returns int return 10;
prepare stmt from "select func_21294()";
execute stmt;
eval $reprepared;
drop function func_21294;
create function func_21294() returns int return 10;
# might pass or fail, implementation dependent
execute stmt;
eval $reprepared;
drop function func_21294;
create function func_21294() returns int return 20;
execute stmt;
eval $reprepared;
deallocate prepare stmt;
drop function func_21294;
#
# Bug#27420 (A combination of PS and view operations cause error + assertion
# on shutdown)
#
--disable_warnings
drop table if exists t_27420_100;
drop table if exists t_27420_101;
drop view if exists v_27420;
--enable_warnings
eval $base_count;
connect (con1,localhost,root,,);
connection default;
create table t_27420_100(a int);
insert into t_27420_100 values (1), (2);
create table t_27420_101(a int);
insert into t_27420_101 values (1), (2);
create view v_27420 as select t_27420_100.a X, t_27420_101.a Y
from t_27420_100, t_27420_101
where t_27420_100.a=t_27420_101.a;
prepare stmt from 'select * from v_27420';
execute stmt;
eval $reprepared;
connection con1;
drop view v_27420;
create table v_27420(X int, Y int);
connection default;
# REPREPARED +1
execute stmt;
eval $reprepared;
connection con1;
drop table v_27420;
# passes in 5.0, fails in 5.1, should pass
create table v_27420 (a int, b int, filler char(200));
connection default;
# REPREPARED +1
execute stmt;
eval $reprepared;
disconnect con1;
deallocate prepare stmt;
drop table t_27420_100;
drop table t_27420_101;
drop table v_27420;
#
# Bug#27430 (Crash in subquery code when in PS and table DDL changed after
# PREPARE)
#
--disable_warnings
drop table if exists t_27430_1;
drop table if exists t_27430_2;
--enable_warnings
eval $base_count;
create table t_27430_1 (a int not null, oref int not null, key(a));
insert into t_27430_1 values
(1, 1),
(1, 1234),
(2, 3),
(2, 1234),
(3, 1234);
create table t_27430_2 (a int not null, oref int not null);
insert into t_27430_2 values
(1, 1),
(2, 2),
(1234, 3),
(1234, 4);
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';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table t_27430_1, t_27430_2;
create table t_27430_1 (a int, oref int, key(a));
insert into t_27430_1 values
(1, 1),
(1, NULL),
(2, 3),
(2, NULL),
(3, NULL);
create table t_27430_2 (a int, oref int);
insert into t_27430_2 values
(1, 1),
(2,2),
(NULL, 3),
(NULL, 4);
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
deallocate prepare stmt;
drop table t_27430_1;
drop table t_27430_2;
#
# Bug#27690 (Re-execution of prepared statement after table was replaced
# with a view crashes)
#
--disable_warnings
drop table if exists t_27690_1;
drop view if exists v_27690_1;
drop table if exists v_27690_2;
--enable_warnings
eval $base_count;
create table t_27690_1 (a int, b int);
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_2 as select * from t_27690_1;
prepare stmt from 'select * from v_27690_1, v_27690_2';
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
drop table v_27690_1;
--error ER_NO_SUCH_TABLE
execute stmt;
eval $reprepared;
--error ER_NO_SUCH_TABLE
execute stmt;
eval $reprepared;
create view v_27690_1 as select A.a, A.b from t_27690_1 A, t_27690_1 B;
# REPREPARED +1
execute stmt;
eval $reprepared;
execute stmt;
eval $reprepared;
deallocate prepare stmt;
drop table t_27690_1;
drop view v_27690_1;
drop table v_27690_2;
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