Commit 1cda2aa1 authored by Dmitry Shulga's avatar Dmitry Shulga Committed by Sergei Golubchik

MDEV-5816: Stored programs: validation of stored program statements

Fix of existing mtr tests.
parent 0b0188c5
......@@ -1544,9 +1544,9 @@ f
DROP TABLE t;
CREATE TABLE t (i INT);
CALL p;
ERROR 42S22: Unknown column 't1.f' in 'field list'
ERROR 42S22: Unknown column 'f' in 'from clause'
CALL p;
ERROR 42S22: Unknown column 't1.f' in 'field list'
ERROR 42S22: Unknown column 'f' in 'from clause'
DROP PROCEDURE p;
DROP TABLE t;
CREATE TABLE t1 (a INT, b INT);
......
......@@ -320,8 +320,8 @@ create table t3 (a int unique);
create view v1 as select a from t2;
create trigger t1_ai after insert on t1 for each row
insert into v1 (a) values (new.a);
# Demonstrate that the same bug is present
# without prepared statements
# Demonstrate that this bug is fixed by MDEV-5816
# both for regular and prepared statements
insert into t1 (a) values (5);
select * from t2;
a
......@@ -331,15 +331,15 @@ a
drop view v1;
create view v1 as select a from t3;
insert into t1 (a) values (6);
ERROR 42S02: Table 'test.t2' doesn't exist
flush table t1;
insert into t1 (a) values (6);
insert into t1 (a) values (60);
select * from t2;
a
5
select * from t3;
a
6
60
prepare stmt from "insert into t1 (a) values (?)";
set @var=7;
execute stmt using @var;
......@@ -350,6 +350,7 @@ select * from t3;
a
6
7
60
select * from t2;
a
5
......@@ -364,23 +365,26 @@ set @var=8;
# but repreparation of the main statement doesn't cause repreparation
# of trigger statements.
#
# The following EXECUTE results in ER_NO_SUCH_TABLE (t3) error, because
# pre-locking list of the prepared statement has been changed
# Prior MDEV-5816, the following EXECUTE resulted in
# ER_NO_SUCH_TABLE (t3) error, because pre-locking list of the prepared
# statement has been changed
# (the prepared statement has noticed the meta-data change),
# but the trigger still tries to deal with 't3', which is not opened.
# That's why '8' is not inserted neither into 't2', nor into 't3'.
# After the task MDEV-5816 be implemented this issue does't exist.
execute stmt using @var;
ERROR 42S02: Table 'test.t3' doesn't exist
call p_verify_reprepare_count(1);
SUCCESS
select * from t2;
a
5
8
select * from t3;
a
6
7
60
flush table t1;
set @var=9;
execute stmt using @var;
......@@ -390,11 +394,13 @@ SUCCESS
select * from t2;
a
5
8
9
select * from t3;
a
6
7
60
drop view v1;
drop table t1,t2,t3;
# Test 7-d: dependent TABLE has changed
......
......@@ -334,17 +334,18 @@ create view v1 as select a from t2;
create trigger t1_ai after insert on t1 for each row
insert into v1 (a) values (new.a);
--echo # Demonstrate that the same bug is present
--echo # without prepared statements
--echo # Demonstrate that this bug is fixed by MDEV-5816
--echo # both for regular and prepared statements
insert into t1 (a) values (5);
select * from t2;
select * from t3;
drop view v1;
create view v1 as select a from t3;
--error ER_NO_SUCH_TABLE
# Before MDEV-5816 the following statement would fail
# with the error ER_NO_SUCH_TABLE
insert into t1 (a) values (6);
flush table t1;
insert into t1 (a) values (6);
insert into t1 (a) values (60);
select * from t2;
select * from t3;
......@@ -365,12 +366,13 @@ set @var=8;
--echo # but repreparation of the main statement doesn't cause repreparation
--echo # of trigger statements.
--echo #
--echo # The following EXECUTE results in ER_NO_SUCH_TABLE (t3) error, because
--echo # pre-locking list of the prepared statement has been changed
--echo # Prior MDEV-5816, the following EXECUTE resulted in
--echo # ER_NO_SUCH_TABLE (t3) error, because pre-locking list of the prepared
--echo # statement has been changed
--echo # (the prepared statement has noticed the meta-data change),
--echo # but the trigger still tries to deal with 't3', which is not opened.
--echo # That's why '8' is not inserted neither into 't2', nor into 't3'.
--error ER_NO_SUCH_TABLE
--echo # After the task MDEV-5816 be implemented this issue does't exist.
execute stmt using @var;
call p_verify_reprepare_count(1);
select * from t2;
......
......@@ -6775,7 +6775,7 @@ call p1$
a
alter table t1 add b integer$
call p1$
a
a b
drop table t1;
drop procedure p1;
# ------------------------------------------------------------------
......@@ -7240,12 +7240,12 @@ create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5);
#
# Do we correctly resolve identifiers in LIMIT?
# Since DROP and CREATE did not invalidate
# the SP cache, we can't test until
# we drop and re-create the procedure.
# DROP and CREATE results in SP statement recompilation
# so second execution of the procedure p1() doesn't lead
# to issuing an error
#
call p1();
ERROR 42S22: Unknown column 'test.t1.c1' in 'field list'
a
#
# Drop and recreate the procedure, then repeat
#
......
......@@ -8700,11 +8700,10 @@ create table t1 (a int);
insert into t1 (a) values (1), (2), (3), (4), (5);
--echo #
--echo # Do we correctly resolve identifiers in LIMIT?
--echo # Since DROP and CREATE did not invalidate
--echo # the SP cache, we can't test until
--echo # we drop and re-create the procedure.
--echo # DROP and CREATE results in SP statement recompilation
--echo # so second execution of the procedure p1() doesn't lead
--echo # to issuing an error
--echo #
--error ER_BAD_FIELD_ERROR
call p1();
--echo #
--echo # Drop and recreate the procedure, then repeat
......
......@@ -1221,7 +1221,6 @@ CREATE PROCEDURE p1 () BEGIN SELECT f1 FROM t1 WHERE f1 IN (SELECT f1 FROM t2);
delimiter ;|
CALL p1;
ALTER TABLE t2 CHANGE COLUMN f1 my_column INT;
--error ER_BAD_FIELD_ERROR
CALL p1;
DROP PROCEDURE p1;
DROP TABLE t1, t2;
......
......@@ -1472,7 +1472,7 @@ CALL p1;
f1
ALTER TABLE t2 CHANGE COLUMN f1 my_column INT;
CALL p1;
ERROR 42S22: Unknown column 'f1' in 'where clause'
f1
DROP PROCEDURE p1;
DROP TABLE t1, t2;
#
......
......@@ -1475,7 +1475,7 @@ CALL p1;
f1
ALTER TABLE t2 CHANGE COLUMN f1 my_column INT;
CALL p1;
ERROR 42S22: Unknown column 'f1' in 'where clause'
f1
DROP PROCEDURE p1;
DROP TABLE t1, t2;
#
......
......@@ -41,8 +41,7 @@ end |
call pr(1);
b
call pr(2);
ERROR 42S22: Unknown column 'test.t1.b' in 'field list'
drop table t1;
a
set global stored_program_cache=0;
call pr(1);
b
......
......@@ -33,9 +33,11 @@ create procedure pr(i int) begin
end |
--delimiter ;
call pr(1);
--error ER_BAD_FIELD_ERROR
#--error ER_BAD_FIELD_ERROR
# MDEV-5816 added support for recompilation of statements
# inside a stored routine so the error ER_BAD_FIELD_ERROR is
# no more expcted
call pr(2);
drop table t1;
set global stored_program_cache=0;
call pr(1);
......
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