summaryrefslogtreecommitdiff
path: root/mysql-test/t/ps_ddl.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/ps_ddl.test')
-rw-r--r--mysql-test/t/ps_ddl.test83
1 files changed, 67 insertions, 16 deletions
diff --git a/mysql-test/t/ps_ddl.test b/mysql-test/t/ps_ddl.test
index 1543c757908..3803a0daf52 100644
--- a/mysql-test/t/ps_ddl.test
+++ b/mysql-test/t/ps_ddl.test
@@ -278,8 +278,6 @@ deallocate prepare stmt;
--echo # Test 7-a: dependent PROCEDURE has changed
--echo #
---echo # Note, this scenario is not supported, subject of Bug#12093
---echo #
create table t1 (a int);
create trigger t1_ai after insert on t1 for each row
@@ -291,11 +289,10 @@ execute stmt using @var;
drop procedure p1;
create procedure p1 (a int) begin end;
set @var= 2;
---error ER_SP_DOES_NOT_EXIST
execute stmt using @var;
--echo # Cleanup
drop procedure p1;
-call p_verify_reprepare_count(0);
+call p_verify_reprepare_count(1);
--echo # Test 7-b: dependent FUNCTION has changed
--echo #
@@ -355,11 +352,13 @@ set @var=8;
--echo # XXX: bug, the SQL statement in the trigger is still
--echo # pointing at table 't3', since the view was expanded
--echo # at first statement execution.
+--echo # Since the view definition is inlined in the statement
+--echo # at prepare, changing the view definition does not cause
+--echo # repreparation.
--echo # Repreparation of the main statement doesn't cause repreparation
--echo # of trigger statements.
---error ER_NO_SUCH_TABLE
execute stmt using @var;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
--echo #
--echo # Sic: the insert went into t3, even though the view now
--echo # points at t2. This is because neither the merged view
@@ -642,6 +641,9 @@ deallocate prepare stmt;
--echo Part 16: VIEW -> TEMPORARY TABLE transitions
--echo =====================================================================
+--echo #
+--echo # Test 1: Merged view
+--echo #
create table t2 (a int);
insert into t2 (a) values (1);
create view t1 as select * from t2;
@@ -651,9 +653,39 @@ execute stmt;
call p_verify_reprepare_count(0);
create temporary table t1 (a int);
+# t1 still refers to the view - no reprepare has been done.
execute stmt;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
+
+drop view t1;
+# t1 still refers to the, now deleted, view - no reprepare has been done.
+--error ER_NO_SUCH_TABLE
+execute stmt;
+call p_verify_reprepare_count(0);
+
+drop table t2;
+drop temporary table t1;
+deallocate prepare stmt;
+
+--echo #
+--echo # Test 2: Materialized view
+--echo #
+create table t2 (a int);
+insert into t2 (a) values (1);
+create algorithm = temptable view t1 as select * from t2;
+
+prepare stmt from "select * from t1";
+execute stmt;
+call p_verify_reprepare_count(0);
+
+create temporary table t1 (a int);
+# t1 still refers to the view - no reprepare has been done.
+execute stmt;
+call p_verify_reprepare_count(0);
+
drop view t1;
+# t1 still refers to the, now deleted, view - no reprepare has been done.
+--error ER_NO_SUCH_TABLE
execute stmt;
call p_verify_reprepare_count(0);
@@ -661,6 +693,28 @@ drop table t2;
drop temporary table t1;
deallocate prepare stmt;
+--echo #
+--echo # Test 3: View referencing an Information schema table
+--echo #
+create view t1 as select table_name from information_schema.views;
+
+prepare stmt from "select * from t1";
+execute stmt;
+call p_verify_reprepare_count(0);
+
+create temporary table t1 (a int);
+# t1 has been substituted with a reference to the IS table
+execute stmt;
+call p_verify_reprepare_count(0);
+
+drop view t1;
+# Since the IS table has been substituted in, the statement still works
+execute stmt;
+call p_verify_reprepare_count(0);
+
+drop temporary table t1;
+deallocate prepare stmt;
+
--echo =====================================================================
--echo Part 17: VIEW -> VIEW (DDL) transitions
--echo =====================================================================
@@ -1447,7 +1501,7 @@ drop table t2;
create temporary table t2 (a int);
# Temporary table and base table are not in the same name space.
execute stmt;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
--error ER_TABLE_EXISTS_ERROR
execute stmt;
call p_verify_reprepare_count(1);
@@ -1457,7 +1511,7 @@ execute stmt;
call p_verify_reprepare_count(0);
drop table t2;
execute stmt;
-call p_verify_reprepare_count(1);
+call p_verify_reprepare_count(0);
drop table t2;
# View with name of table to be created exists
# Attention:
@@ -1494,27 +1548,24 @@ execute stmt;
call p_verify_reprepare_count(0);
drop table t1;
deallocate prepare stmt;
---echo # XXX: no validation of the first table in case of
---echo # CREATE TEMPORARY TABLE. This is a shortcoming of the current code,
---echo # but since validation is not strictly necessary, nothing is done
---echo # about it.
---echo # Will be fixed as part of work on Bug#21431 "Incomplete support of
---echo # temporary tables"
create table t1 (a int);
insert into t1 (a) values (1);
prepare stmt from "create temporary table if not exists t2 as select * from t1";
execute stmt;
drop table t2;
execute stmt;
+call p_verify_reprepare_count(0);
execute stmt;
+call p_verify_reprepare_count(1);
select * from t2;
execute stmt;
+call p_verify_reprepare_count(0);
select * from t2;
drop table t2;
create temporary table t2 (a varchar(10));
execute stmt;
select * from t2;
-call p_verify_reprepare_count(0);
+call p_verify_reprepare_count(1);
drop table t1;
create table t1 (x int);
execute stmt;