Commit 95ca5495 authored by mleich@five.local.lan's avatar mleich@five.local.lan

Add tests + modifications according to review

parent 9e371dd2
...@@ -35,6 +35,7 @@ Part 3: NOTHING -> VIEW transitions ...@@ -35,6 +35,7 @@ Part 3: NOTHING -> VIEW transitions
===================================================================== =====================================================================
Part 4: TABLE -> NOTHING transitions Part 4: TABLE -> NOTHING transitions
===================================================================== =====================================================================
# Test 4-a: select ... from <table>
create table t1 (a int); create table t1 (a int);
prepare stmt from "select * from t1"; prepare stmt from "select * from t1";
execute stmt; execute stmt;
...@@ -59,6 +60,32 @@ call p_verify_reprepare_count(0); ...@@ -59,6 +60,32 @@ call p_verify_reprepare_count(0);
SUCCESS SUCCESS
deallocate prepare stmt; deallocate prepare stmt;
# Test 4-b: TABLE -> NOTHING by renaming the table
create table t1 (a int);
prepare stmt from "select * from t1";
execute stmt;
a
call p_verify_reprepare_count(0);
SUCCESS
execute stmt;
a
call p_verify_reprepare_count(0);
SUCCESS
rename table t1 to t2;
execute stmt;
ERROR 42S02: Table 'test.t1' doesn't exist
call p_verify_reprepare_count(0);
SUCCESS
execute stmt;
ERROR 42S02: Table 'test.t1' doesn't exist
call p_verify_reprepare_count(0);
SUCCESS
deallocate prepare stmt;
drop table t2;
===================================================================== =====================================================================
Part 5: TABLE -> TABLE (DDL) transitions Part 5: TABLE -> TABLE (DDL) transitions
===================================================================== =====================================================================
...@@ -445,6 +472,7 @@ deallocate prepare stmt; ...@@ -445,6 +472,7 @@ deallocate prepare stmt;
===================================================================== =====================================================================
Part 8: TABLE -> TEMPORARY TABLE transitions Part 8: TABLE -> TEMPORARY TABLE transitions
===================================================================== =====================================================================
# Test 8-a: base table used recreated as temporary table
create table t1 (a int); create table t1 (a int);
prepare stmt from "select * from t1"; prepare stmt from "select * from t1";
execute stmt; execute stmt;
...@@ -463,6 +491,37 @@ SUCCESS ...@@ -463,6 +491,37 @@ SUCCESS
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
# Test 8-b: temporary table has precedence over base table with same name
create table t1 (a int);
prepare stmt from 'select count(*) from t1';
execute stmt;
count(*)
0
call p_verify_reprepare_count(0);
SUCCESS
execute stmt;
count(*)
0
call p_verify_reprepare_count(0);
SUCCESS
create temporary table t1 AS SELECT 1;
execute stmt;
count(*)
1
call p_verify_reprepare_count(1);
SUCCESS
execute stmt;
count(*)
1
call p_verify_reprepare_count(0);
SUCCESS
deallocate prepare stmt;
drop temporary table t1;
drop table t1;
===================================================================== =====================================================================
Part 9: TABLE -> VIEW transitions Part 9: TABLE -> VIEW transitions
===================================================================== =====================================================================
...@@ -504,6 +563,7 @@ deallocate prepare stmt; ...@@ -504,6 +563,7 @@ deallocate prepare stmt;
===================================================================== =====================================================================
Part 11: TEMPORARY TABLE -> TABLE transitions Part 11: TEMPORARY TABLE -> TABLE transitions
===================================================================== =====================================================================
# Test 11-a: temporary table replaced by base table
create table t1 (a int); create table t1 (a int);
insert into t1 (a) value (1); insert into t1 (a) value (1);
create temporary table t1 (a int); create temporary table t1 (a int);
...@@ -525,6 +585,38 @@ a ...@@ -525,6 +585,38 @@ a
1 1
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
# Test 11-b: temporary table has precedence over base table with same name
# temporary table disappears
create table t1 (a int);
create temporary table t1 as select 1 as a;
prepare stmt from "select count(*) from t1";
execute stmt;
count(*)
1
call p_verify_reprepare_count(0);
SUCCESS
execute stmt;
count(*)
1
call p_verify_reprepare_count(0);
SUCCESS
drop temporary table t1;
execute stmt;
count(*)
0
call p_verify_reprepare_count(1);
SUCCESS
execute stmt;
count(*)
0
call p_verify_reprepare_count(0);
SUCCESS
deallocate prepare stmt;
drop table t1;
===================================================================== =====================================================================
Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions
===================================================================== =====================================================================
...@@ -1505,11 +1597,11 @@ deallocate prepare stmt_sp; ...@@ -1505,11 +1597,11 @@ deallocate prepare stmt_sp;
Ensure that metadata validation is performed for every type of Ensure that metadata validation is performed for every type of
SQL statement where it is needed. SQL statement where it is needed.
===================================================================== =====================================================================
drop table if exists t1;
create table t1 (a int);
# #
# SQLCOM_SELECT # SQLCOM_SELECT
# #
drop table if exists t1;
create table t1 (a int);
prepare stmt from "select 1 as res from dual where (1) in (select * from t1)"; prepare stmt from "select 1 as res from dual where (1) in (select * from t1)";
drop table t1; drop table t1;
create table t1 (x int); create table t1 (x int);
...@@ -1568,6 +1660,18 @@ call p_verify_reprepare_count(0); ...@@ -1568,6 +1660,18 @@ call p_verify_reprepare_count(0);
SUCCESS SUCCESS
drop table t2; drop table t2;
create view t2 as select 1;
execute stmt;
Got one of the listed errors
call p_verify_reprepare_count(1);
SUCCESS
execute stmt;
Got one of the listed errors
call p_verify_reprepare_count(0);
SUCCESS
drop view t2;
drop table t1; drop table t1;
create table t1 (x varchar(20)); create table t1 (x varchar(20));
execute stmt; execute stmt;
...@@ -1582,6 +1686,18 @@ call p_verify_reprepare_count(0); ...@@ -1582,6 +1686,18 @@ call p_verify_reprepare_count(0);
SUCCESS SUCCESS
drop table t2; drop table t2;
alter table t1 add column y decimal(10,3);
execute stmt;
call p_verify_reprepare_count(1);
SUCCESS
select * from t2;
x y
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
SUCCESS
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
# XXX: no validation of the first table in case of # XXX: no validation of the first table in case of
...@@ -1636,6 +1752,56 @@ Note 1050 Table 't2' already exists ...@@ -1636,6 +1752,56 @@ Note 1050 Table 't2' already exists
call p_verify_reprepare_count(0); call p_verify_reprepare_count(0);
SUCCESS SUCCESS
drop table t1;
drop temporary table t2;
drop table t2;
deallocate prepare stmt;
create table t1 (a int);
prepare stmt from "create table t2 like t1";
execute stmt;
call p_verify_reprepare_count(0);
SUCCESS
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
SUCCESS
drop table t2;
drop table t1;
execute stmt;
ERROR 42S02: Table 'test.t1' doesn't exist
call p_verify_reprepare_count(0);
SUCCESS
execute stmt;
ERROR 42S02: Table 'test.t1' doesn't exist
call p_verify_reprepare_count(0);
SUCCESS
create table t1 (x char(17));
execute stmt;
call p_verify_reprepare_count(1);
SUCCESS
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
SUCCESS
drop table t2;
alter table t1 add column y time;
execute stmt;
call p_verify_reprepare_count(1);
SUCCESS
select * from t2;
x y
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
SUCCESS
drop table t1; drop table t1;
drop table t2; drop table t2;
deallocate prepare stmt; deallocate prepare stmt;
......
This diff is collapsed.
...@@ -104,6 +104,7 @@ prepare stmt from "select * from t1"; ...@@ -104,6 +104,7 @@ prepare stmt from "select * from t1";
--echo Part 4: TABLE -> NOTHING transitions --echo Part 4: TABLE -> NOTHING transitions
--echo ===================================================================== --echo =====================================================================
--echo # Test 4-a: select ... from <table>
create table t1 (a int); create table t1 (a int);
prepare stmt from "select * from t1"; prepare stmt from "select * from t1";
...@@ -121,6 +122,25 @@ execute stmt; ...@@ -121,6 +122,25 @@ execute stmt;
call p_verify_reprepare_count(0); call p_verify_reprepare_count(0);
deallocate prepare stmt; deallocate prepare stmt;
--echo # Test 4-b: TABLE -> NOTHING by renaming the table
create table t1 (a int);
prepare stmt from "select * from t1";
execute stmt;
call p_verify_reprepare_count(0);
execute stmt;
call p_verify_reprepare_count(0);
rename table t1 to t2;
--error ER_NO_SUCH_TABLE
execute stmt;
call p_verify_reprepare_count(0);
--error ER_NO_SUCH_TABLE
execute stmt;
call p_verify_reprepare_count(0);
deallocate prepare stmt;
drop table t2;
--echo ===================================================================== --echo =====================================================================
--echo Part 5: TABLE -> TABLE (DDL) transitions --echo Part 5: TABLE -> TABLE (DDL) transitions
--echo ===================================================================== --echo =====================================================================
...@@ -143,11 +163,11 @@ call p_verify_reprepare_count(0); ...@@ -143,11 +163,11 @@ call p_verify_reprepare_count(0);
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
--echo ===================================================================== --echo =====================================================================
--echo Part 6: TABLE -> TABLE (TRIGGER) transitions --echo Part 6: TABLE -> TABLE (TRIGGER) transitions
--echo ===================================================================== --echo =====================================================================
--echo # Test 6-a: adding a relevant trigger --echo # Test 6-a: adding a relevant trigger
create table t1 (a int); create table t1 (a int);
...@@ -414,6 +434,7 @@ deallocate prepare stmt; ...@@ -414,6 +434,7 @@ deallocate prepare stmt;
--echo Part 8: TABLE -> TEMPORARY TABLE transitions --echo Part 8: TABLE -> TEMPORARY TABLE transitions
--echo ===================================================================== --echo =====================================================================
--echo # Test 8-a: base table used recreated as temporary table
create table t1 (a int); create table t1 (a int);
prepare stmt from "select * from t1"; prepare stmt from "select * from t1";
...@@ -430,6 +451,25 @@ call p_verify_reprepare_count(0); ...@@ -430,6 +451,25 @@ call p_verify_reprepare_count(0);
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
--echo # Test 8-b: temporary table has precedence over base table with same name
create table t1 (a int);
prepare stmt from 'select count(*) from t1';
execute stmt;
call p_verify_reprepare_count(0);
execute stmt;
call p_verify_reprepare_count(0);
create temporary table t1 AS SELECT 1;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
deallocate prepare stmt;
drop temporary table t1;
drop table t1;
--echo ===================================================================== --echo =====================================================================
--echo Part 9: TABLE -> VIEW transitions --echo Part 9: TABLE -> VIEW transitions
--echo ===================================================================== --echo =====================================================================
...@@ -471,6 +511,7 @@ deallocate prepare stmt; ...@@ -471,6 +511,7 @@ deallocate prepare stmt;
--echo Part 11: TEMPORARY TABLE -> TABLE transitions --echo Part 11: TEMPORARY TABLE -> TABLE transitions
--echo ===================================================================== --echo =====================================================================
--echo # Test 11-a: temporary table replaced by base table
create table t1 (a int); create table t1 (a int);
insert into t1 (a) value (1); insert into t1 (a) value (1);
create temporary table t1 (a int); create temporary table t1 (a int);
...@@ -488,6 +529,27 @@ select * from t1; ...@@ -488,6 +529,27 @@ select * from t1;
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
--echo # Test 11-b: temporary table has precedence over base table with same name
--echo # temporary table disappears
create table t1 (a int);
create temporary table t1 as select 1 as a;
prepare stmt from "select count(*) from t1";
execute stmt;
call p_verify_reprepare_count(0);
execute stmt;
call p_verify_reprepare_count(0);
drop temporary table t1;
execute stmt;
call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
deallocate prepare stmt;
drop table t1;
--echo ===================================================================== --echo =====================================================================
--echo Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions --echo Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions
--echo ===================================================================== --echo =====================================================================
...@@ -1354,13 +1416,15 @@ deallocate prepare stmt_sp; ...@@ -1354,13 +1416,15 @@ deallocate prepare stmt_sp;
--echo Ensure that metadata validation is performed for every type of --echo Ensure that metadata validation is performed for every type of
--echo SQL statement where it is needed. --echo SQL statement where it is needed.
--echo ===================================================================== --echo =====================================================================
--echo #
--echo # SQLCOM_SELECT
--echo #
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
create table t1 (a int); create table t1 (a int);
--echo #
--echo # SQLCOM_SELECT
--echo #
prepare stmt from "select 1 as res from dual where (1) in (select * from t1)"; prepare stmt from "select 1 as res from dual where (1) in (select * from t1)";
drop table t1; drop table t1;
create table t1 (x int); create table t1 (x int);
...@@ -1368,16 +1432,16 @@ execute stmt; ...@@ -1368,16 +1432,16 @@ execute stmt;
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
call p_verify_reprepare_count(1); call p_verify_reprepare_count(1);
--echo # --echo #
--echo # SQLCOM_CREATE_TABLE --echo # SQLCOM_CREATE_TABLE
--echo # --echo #
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
drop table if exists t2; drop table if exists t2;
--enable_warnings --enable_warnings
create table t1 (a int); create table t1 (a int);
prepare stmt from 'create table t2 as select * from t1'; prepare stmt from 'create table t2 as select * from t1';
execute stmt; execute stmt;
drop table t2; drop table t2;
...@@ -1385,6 +1449,7 @@ execute stmt; ...@@ -1385,6 +1449,7 @@ execute stmt;
drop table t2; drop table t2;
execute stmt; execute stmt;
call p_verify_reprepare_count(0); call p_verify_reprepare_count(0);
# Base table with name of table to be created exists
--error ER_TABLE_EXISTS_ERROR --error ER_TABLE_EXISTS_ERROR
execute stmt; execute stmt;
call p_verify_reprepare_count(1); call p_verify_reprepare_count(1);
...@@ -1392,6 +1457,7 @@ call p_verify_reprepare_count(1); ...@@ -1392,6 +1457,7 @@ call p_verify_reprepare_count(1);
execute stmt; execute stmt;
call p_verify_reprepare_count(0); call p_verify_reprepare_count(0);
drop table t2; drop table t2;
# Temporary table with name of table to be created exists
create temporary table t2 (a int); create temporary table t2 (a int);
--error ER_TABLE_EXISTS_ERROR --error ER_TABLE_EXISTS_ERROR
execute stmt; execute stmt;
...@@ -1406,7 +1472,23 @@ drop table t2; ...@@ -1406,7 +1472,23 @@ drop table t2;
execute stmt; execute stmt;
call p_verify_reprepare_count(0); call p_verify_reprepare_count(0);
drop table t2; drop table t2;
# View with name of table to be created exists
# Attention:
# We cannot print the error message because it contains a random filename.
# Example: 1050: Table '<some_path>/var/tmp/#sql_6979_0' already exists
# Therefore we mangle it via
# "--error ER_TABLE_EXISTS_ERROR,9999" (9999 is currently not used)
# to "Got one of the listed errors".
create view t2 as select 1;
--error ER_TABLE_EXISTS_ERROR,9999
execute stmt;
call p_verify_reprepare_count(1);
--error ER_TABLE_EXISTS_ERROR,9999
execute stmt;
call p_verify_reprepare_count(0);
drop view t2;
drop table t1; drop table t1;
# Table to be used recreated (drop,create) with different layout
create table t1 (x varchar(20)); create table t1 (x varchar(20));
execute stmt; execute stmt;
call p_verify_reprepare_count(1); call p_verify_reprepare_count(1);
...@@ -1415,6 +1497,14 @@ drop table t2; ...@@ -1415,6 +1497,14 @@ drop table t2;
execute stmt; execute stmt;
call p_verify_reprepare_count(0); call p_verify_reprepare_count(0);
drop table t2; drop table t2;
# Table to be used has a modified (alter table) layout
alter table t1 add column y decimal(10,3);
execute stmt;
call p_verify_reprepare_count(1);
select * from t2;
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
drop table t1; drop table t1;
deallocate prepare stmt; deallocate prepare stmt;
--echo # XXX: no validation of the first table in case of --echo # XXX: no validation of the first table in case of
...@@ -1445,9 +1535,47 @@ call p_verify_reprepare_count(1); ...@@ -1445,9 +1535,47 @@ call p_verify_reprepare_count(1);
execute stmt; execute stmt;
call p_verify_reprepare_count(0); call p_verify_reprepare_count(0);
drop table t1; drop table t1;
drop temporary table t2;
drop table t2; drop table t2;
deallocate prepare stmt; deallocate prepare stmt;
create table t1 (a int);
prepare stmt from "create table t2 like t1";
execute stmt;
call p_verify_reprepare_count(0);
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
drop table t2;
# Table to be used does not exist
drop table t1;
--error ER_NO_SUCH_TABLE
execute stmt;
call p_verify_reprepare_count(0);
--error ER_NO_SUCH_TABLE
execute stmt;
call p_verify_reprepare_count(0);
# Table to be used recreated (drop,create) with different layout
create table t1 (x char(17));
execute stmt;
call p_verify_reprepare_count(1);
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
drop table t2;
# Table to be used has a modified (alter table) layout
alter table t1 add column y time;
execute stmt;
call p_verify_reprepare_count(1);
select * from t2;
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
drop table t1;
drop table t2;
deallocate prepare stmt;
--echo # --echo #
--echo # SQLCOM_UPDATE --echo # SQLCOM_UPDATE
--echo # --echo #
......
This diff is collapsed.
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