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
=====================================================================
Part 4: TABLE -> NOTHING transitions
=====================================================================
# Test 4-a: select ... from <table>
create table t1 (a int);
prepare stmt from "select * from t1";
execute stmt;
......@@ -59,6 +60,32 @@ call p_verify_reprepare_count(0);
SUCCESS
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
=====================================================================
......@@ -445,6 +472,7 @@ deallocate prepare stmt;
=====================================================================
Part 8: TABLE -> TEMPORARY TABLE transitions
=====================================================================
# Test 8-a: base table used recreated as temporary table
create table t1 (a int);
prepare stmt from "select * from t1";
execute stmt;
......@@ -463,6 +491,37 @@ SUCCESS
drop table t1;
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
=====================================================================
......@@ -504,6 +563,7 @@ deallocate prepare stmt;
=====================================================================
Part 11: TEMPORARY TABLE -> TABLE transitions
=====================================================================
# Test 11-a: temporary table replaced by base table
create table t1 (a int);
insert into t1 (a) value (1);
create temporary table t1 (a int);
......@@ -525,6 +585,38 @@ a
1
drop table t1;
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
=====================================================================
......@@ -1505,11 +1597,11 @@ deallocate prepare stmt_sp;
Ensure that metadata validation is performed for every type of
SQL statement where it is needed.
=====================================================================
drop table if exists t1;
create table t1 (a int);
#
# 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)";
drop table t1;
create table t1 (x int);
......@@ -1568,6 +1660,18 @@ call p_verify_reprepare_count(0);
SUCCESS
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;
create table t1 (x varchar(20));
execute stmt;
......@@ -1582,6 +1686,18 @@ call p_verify_reprepare_count(0);
SUCCESS
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;
deallocate prepare stmt;
# XXX: no validation of the first table in case of
......@@ -1636,6 +1752,56 @@ Note 1050 Table 't2' already exists
call p_verify_reprepare_count(0);
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 t2;
deallocate prepare stmt;
......
This diff is collapsed.
......@@ -104,6 +104,7 @@ prepare stmt from "select * from t1";
--echo Part 4: TABLE -> NOTHING transitions
--echo =====================================================================
--echo # Test 4-a: select ... from <table>
create table t1 (a int);
prepare stmt from "select * from t1";
......@@ -121,6 +122,25 @@ execute stmt;
call p_verify_reprepare_count(0);
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 Part 5: TABLE -> TABLE (DDL) transitions
--echo =====================================================================
......@@ -143,11 +163,11 @@ call p_verify_reprepare_count(0);
drop table t1;
deallocate prepare stmt;
--echo =====================================================================
--echo Part 6: TABLE -> TABLE (TRIGGER) transitions
--echo =====================================================================
--echo # Test 6-a: adding a relevant trigger
create table t1 (a int);
......@@ -414,6 +434,7 @@ deallocate prepare stmt;
--echo Part 8: TABLE -> TEMPORARY TABLE transitions
--echo =====================================================================
--echo # Test 8-a: base table used recreated as temporary table
create table t1 (a int);
prepare stmt from "select * from t1";
......@@ -430,6 +451,25 @@ call p_verify_reprepare_count(0);
drop table t1;
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 Part 9: TABLE -> VIEW transitions
--echo =====================================================================
......@@ -471,6 +511,7 @@ deallocate prepare stmt;
--echo Part 11: TEMPORARY TABLE -> TABLE transitions
--echo =====================================================================
--echo # Test 11-a: temporary table replaced by base table
create table t1 (a int);
insert into t1 (a) value (1);
create temporary table t1 (a int);
......@@ -488,6 +529,27 @@ select * from t1;
drop table t1;
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 Part 12: TEMPORARY TABLE -> TEMPORARY TABLE (DDL) transitions
--echo =====================================================================
......@@ -1354,13 +1416,15 @@ deallocate prepare stmt_sp;
--echo Ensure that metadata validation is performed for every type of
--echo SQL statement where it is needed.
--echo =====================================================================
--echo #
--echo # SQLCOM_SELECT
--echo #
--disable_warnings
drop table if exists t1;
--enable_warnings
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)";
drop table t1;
create table t1 (x int);
......@@ -1368,16 +1432,16 @@ execute stmt;
drop table t1;
deallocate prepare stmt;
call p_verify_reprepare_count(1);
--echo #
--echo # SQLCOM_CREATE_TABLE
--echo #
--disable_warnings
drop table if exists t1;
drop table if exists t2;
--enable_warnings
create table t1 (a int);
prepare stmt from 'create table t2 as select * from t1';
execute stmt;
drop table t2;
......@@ -1385,6 +1449,7 @@ execute stmt;
drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
# Base table with name of table to be created exists
--error ER_TABLE_EXISTS_ERROR
execute stmt;
call p_verify_reprepare_count(1);
......@@ -1392,6 +1457,7 @@ call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
drop table t2;
# Temporary table with name of table to be created exists
create temporary table t2 (a int);
--error ER_TABLE_EXISTS_ERROR
execute stmt;
......@@ -1406,7 +1472,23 @@ drop table t2;
execute stmt;
call p_verify_reprepare_count(0);
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;
# Table to be used recreated (drop,create) with different layout
create table t1 (x varchar(20));
execute stmt;
call p_verify_reprepare_count(1);
......@@ -1415,6 +1497,14 @@ 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 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;
deallocate prepare stmt;
--echo # XXX: no validation of the first table in case of
......@@ -1445,9 +1535,47 @@ call p_verify_reprepare_count(1);
execute stmt;
call p_verify_reprepare_count(0);
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);
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 # SQLCOM_UPDATE
--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