diff options
author | unknown <dlenev@mysql.com> | 2005-11-17 03:51:14 +0300 |
---|---|---|
committer | unknown <dlenev@mysql.com> | 2005-11-17 03:51:14 +0300 |
commit | d518f7020011b685f6753b1d86e9dd7a98a9c171 (patch) | |
tree | 6ecc88603a374aba692955d3369fbbaac736f5cc /mysql-test | |
parent | 4d89977269c7faf8481439bc7d41169b5e4109b9 (diff) | |
download | mariadb-git-d518f7020011b685f6753b1d86e9dd7a98a9c171.tar.gz |
Fix for bug #13399 Crash when executing PS/SP which should activate trigger
which is now dropped" and bug #12329 "Bogus error msg when executing PS with
stored procedure after SP was re-created".
mysql-test/r/sp-error.result:
Added test for bug #12329 "Bogus error msg when executing PS with stored
procedure after SP was re-created".
mysql-test/r/trigger.result:
Added test for bug #13399 Crash when executing PS/SP which should activate
trigger which is now dropped".
mysql-test/t/sp-error.test:
Added test for bug #12329 "Bogus error msg when executing PS with stored
procedure after SP was re-created".
mysql-test/t/trigger.test:
Added test for bug #13399 Crash when executing PS/SP which should activate
trigger which is now dropped".
sql/sp_head.cc:
sp_head::add_used_tables_to_table_list():
We have to copy database/table names and alias to PS/SP memory since current
instance of sp_head object can pass away before next execution of PS/SP for
which tables are added to prelocking list.
This will be fixed by introducing of proper invalidation mechanism once new
TDC is ready.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/sp-error.result | 18 | ||||
-rw-r--r-- | mysql-test/r/trigger.result | 25 | ||||
-rw-r--r-- | mysql-test/t/sp-error.test | 22 | ||||
-rw-r--r-- | mysql-test/t/trigger.test | 39 |
4 files changed, 104 insertions, 0 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 2f4b420a2ae..26bb0fa4694 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -975,6 +975,24 @@ return 1; END | drop table t1| drop function bug_13627_f| +drop function if exists bug12329; +create table t1 as select 1 a; +create table t2 as select 1 a; +create function bug12329() returns int return (select a from t1); +prepare stmt1 from 'select bug12329()'; +execute stmt1; +bug12329() +1 +drop function bug12329; +create function bug12329() returns int return (select a+100 from t2); +select bug12329(); +bug12329() +101 +execute stmt1; +ERROR HY000: Table 't2' was not locked with LOCK TABLES +deallocate prepare stmt1; +drop function bug12329; +drop table t1, t2; create database mysqltest1; use mysqltest1; drop database mysqltest1; diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result index d3fbb56e493..af99dea58b9 100644 --- a/mysql-test/r/trigger.result +++ b/mysql-test/r/trigger.result @@ -738,3 +738,28 @@ f1 1 drop trigger t1_bi; drop tables t1, t2; +create table t1 (id int); +create table t2 (id int); +create trigger t1_bi before insert on t1 for each row insert into t2 values (new.id); +prepare stmt1 from "insert into t1 values (10)"; +create procedure p1() insert into t1 values (10); +call p1(); +drop trigger t1_bi; +execute stmt1; +call p1(); +deallocate prepare stmt1; +drop procedure p1; +create table t3 (id int); +create trigger t1_bi after insert on t1 for each row insert into t2 values (new.id); +prepare stmt1 from "insert into t1 values (10)"; +create procedure p1() insert into t1 values (10); +call p1(); +drop trigger t1_bi; +create trigger t1_bi after insert on t1 for each row insert into t3 values (new.id); +execute stmt1; +ERROR HY000: Table 't3' was not locked with LOCK TABLES +call p1(); +ERROR HY000: Table 't3' was not locked with LOCK TABLES +deallocate prepare stmt1; +drop procedure p1; +drop table t1, t2, t3; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index f16562227f3..4cc141fea4b 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -1403,6 +1403,28 @@ drop function bug_13627_f| delimiter ;| +# BUG#12329: "Bogus error msg when executing PS with stored procedure after +# SP was re-created". See also test for related bug#13399 in trigger.test +--disable_warnings +drop function if exists bug12329; +--enable_warnings +create table t1 as select 1 a; +create table t2 as select 1 a; +create function bug12329() returns int return (select a from t1); +prepare stmt1 from 'select bug12329()'; +execute stmt1; +drop function bug12329; +create function bug12329() returns int return (select a+100 from t2); +select bug12329(); +# Until we implement proper mechanism for invalidation of PS/SP when table +# or SP's are changed the following statement will fail with 'Table ... was +# not locked' error (this mechanism should be based on the new TDC). +--error 1100 +execute stmt1; +deallocate prepare stmt1; +drop function bug12329; +drop table t1, t2; + # # Bug#13514 "server crash when create a stored procedure before choose a # database" and diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index cd79eb82ace..02d994128e2 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -875,3 +875,42 @@ drop function f1; drop view v1; drop table t1, t2, t3; --enable_parsing + +# +# Test for bug #13399 "Crash when executing PS/SP which should activate +# trigger which is now dropped". See also test for similar bug for stored +# routines in sp-error.test (#12329). +create table t1 (id int); +create table t2 (id int); +create trigger t1_bi before insert on t1 for each row insert into t2 values (new.id); +prepare stmt1 from "insert into t1 values (10)"; +create procedure p1() insert into t1 values (10); +call p1(); +# Actually it is enough to do FLUSH TABLES instead of DROP TRIGGER +drop trigger t1_bi; +# Server should not crash on these two statements +execute stmt1; +call p1(); +deallocate prepare stmt1; +drop procedure p1; + +# Let us test more complex situation when we alter trigger in such way that +# it uses different set of tables (or simply add new trigger). +create table t3 (id int); +create trigger t1_bi after insert on t1 for each row insert into t2 values (new.id); +prepare stmt1 from "insert into t1 values (10)"; +create procedure p1() insert into t1 values (10); +call p1(); +# Altering trigger forcing it use different set of tables +drop trigger t1_bi; +create trigger t1_bi after insert on t1 for each row insert into t3 values (new.id); +# Until we implement proper mechanism for invalidation of PS/SP when table +# or SP's are changed these two statements will fail with 'Table ... was +# not locked' error (this mechanism should be based on the new TDC). +--error 1100 +execute stmt1; +--error 1100 +call p1(); +deallocate prepare stmt1; +drop procedure p1; +drop table t1, t2, t3; |