summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2005-07-30 08:19:57 +0000
committerunknown <sergefp@mysql.com>2005-07-30 08:19:57 +0000
commit11abe15eab3f444b600200e965cf18539af55392 (patch)
treec86ed0f51c03242ad2f553a26b62cff6613ac535 /mysql-test/r
parent482cf550f9cb1bf060aba73ef64d85edee791118 (diff)
downloadmariadb-git-11abe15eab3f444b600200e965cf18539af55392.tar.gz
Added Non-prelocked SP execution: Now a PROCEDURE doesn't enter/leave prelocked mode for
its body, but lets each statement to get/release its own locks. This allows a broader set of statements to be executed inside PROCEDUREs (but breaks replication) This patch should fix BUG#8072, BUG#8766, BUG#9563, BUG#11126 mysql-test/r/sp-security.result: Drop tables this test attempts to create mysql-test/r/sp-threads.result: Update test results mysql-test/r/sp.result: Disabled a test that triggers BUG#11986, cleanup used tables when tests start. mysql-test/r/view.result: Enabled a test case that now works with prelocking-free SPs mysql-test/t/sp-security.test: Drop tables this test attempts to create mysql-test/t/sp.test: Disabled a test that triggers BUG#11986, cleanup used tables when tests start. mysql-test/t/view.test: Enabled a test case that now works with prelocking-free SPs sql/handler.cc: Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt sql/item_func.cc: Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt sql/sp.cc: Non-prelocked SP execution: Added support for skipping prelocking of procedure body for "CALL proc(...)" statements. sql/sp.h: Non-prelocked SP execution: Added support for skipping prelocking of procedure body for "CALL proc(...)" statements. sql/sp_cache.h: Added comments sql/sp_head.cc: Non-prelocked SP execution: * Try to unlock tables after PROCEDURE arguments have been evaluated. * Make sp_lex_keeper be able to execute in 2 modes: A) when already in prelocked mode B) when its statement enters/leaves prelocked mode itself. sql/sp_head.h: Non-prelocked SP execution: Make sp_lex_keeper to additionally keep list of tables it needs to prelock when its statement enters/leaves prelocked mode on its own. sql/sql_base.cc: Non-prelocked SP execution: Make open_tables() to * detect 'CALL proc(...)' and not to do prelocking for procedure body statements. * Make lex->query_tables_last to point precisely to a boundary in lex->query_tables list where 'own' tables and views' tables end and added-for-prelocking tables begin. (it was not true before - view's tables could end up after query_tables_own_last) sql/sql_class.cc: Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt sql/sql_class.h: Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt sql/sql_lex.cc: Non-prelocked SP execution: More rigourous cleanup in st_lex::cleanup_after_one_table_open() sql/sql_parse.cc: Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt, remove outdated comments sql/sql_trigger.h: Rename: thd->transaction.in_sub_stmt -> thd->in_sub_stmt
Diffstat (limited to 'mysql-test/r')
-rw-r--r--mysql-test/r/sp-prelocking.result219
-rw-r--r--mysql-test/r/sp-security.result2
-rw-r--r--mysql-test/r/sp-threads.result2
-rw-r--r--mysql-test/r/sp.result29
-rw-r--r--mysql-test/r/view.result5
5 files changed, 227 insertions, 30 deletions
diff --git a/mysql-test/r/sp-prelocking.result b/mysql-test/r/sp-prelocking.result
new file mode 100644
index 00000000000..da5c95cc2dd
--- /dev/null
+++ b/mysql-test/r/sp-prelocking.result
@@ -0,0 +1,219 @@
+drop database if exists testdb;
+drop table if exists t1, t2, t3, t4;
+drop procedure if exists sp1;
+drop procedure if exists sp2;
+drop procedure if exists sp3;
+drop procedure if exists sp4;
+drop function if exists f1;
+drop function if exists f2;
+drop function if exists f3;
+create database testdb;
+use testdb//
+create procedure sp1 ()
+begin
+drop table if exists t1;
+select 1 as "my-col";
+end;
+//
+select database();
+database()
+testdb
+call sp1();
+my-col
+1
+Warnings:
+Note 1051 Unknown table 't1'
+select database();
+database()
+testdb
+use test;
+select database();
+database()
+test
+call testdb.sp1();
+my-col
+1
+Warnings:
+Note 1051 Unknown table 't1'
+select database();
+database()
+test
+drop procedure testdb.sp1;
+drop database testdb;
+create procedure sp1()
+begin
+create table t1 (a int);
+insert into t1 values (10);
+end//
+create procedure sp2()
+begin
+create table t2(a int);
+insert into t2 values(1);
+call sp1();
+end//
+create function f1() returns int
+begin
+return (select max(a) from t1);
+end//
+create procedure sp3()
+begin
+call sp1();
+select 'func', f1();
+end//
+call sp1();
+select 't1',a from t1;
+t1 a
+t1 10
+drop table t1;
+call sp2();
+select 't1',a from t1;
+t1 a
+t1 10
+select 't2',a from t2;
+t2 a
+t2 1
+drop table t1, t2;
+call sp3();
+func f1()
+func 10
+select 't1',a from t1;
+t1 a
+t1 10
+drop table t1;
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop function f1;
+create procedure sp1()
+begin
+create temporary table t2(a int);
+insert into t2 select * from t1;
+end//
+create procedure sp2()
+begin
+create temporary table t1 (a int);
+insert into t1 values(1);
+call sp1();
+select 't1', a from t1;
+select 't2', b from t2;
+drop table t1;
+drop table t2;
+end//
+call sp2();
+t1 a
+t1 1
+drop procedure sp1;
+drop procedure sp2;
+create table t1 (a int);
+insert into t1 values(1),(2);
+create table t2 as select * from t1;
+create table t3 as select * from t1;
+create table t4 as select * from t1;
+create procedure sp1(a int)
+begin
+select a;
+end //
+create function f1() returns int
+begin
+return (select max(a) from t1);
+end //
+CALL sp1(f1());
+a
+2
+create procedure sp2(a int)
+begin
+select * from t3;
+select a;
+end //
+create procedure sp3()
+begin
+select * from t1;
+call sp2(5);
+end //
+create procedure sp4()
+begin
+select * from t2;
+call sp3();
+end //
+call sp4();
+a
+1
+1
+1
+2
+a
+1
+1
+2
+a
+1
+1
+2
+a
+5
+drop temporary table t1;
+drop temporary table t2;
+drop procedure sp1;
+drop procedure sp2;
+drop procedure sp3;
+drop procedure sp4;
+drop function f1;
+drop view if exists v1;
+create function f1(ab int) returns int
+begin
+declare i int;
+set i= (select max(a) from t1 where a < ab) ;
+return i;
+end //
+create function f2(ab int) returns int
+begin
+declare i int;
+set i= (select max(a) from t2 where a < ab) ;
+return i;
+end //
+create view v1 as
+select t3.a as x, t4.a as y, f2(3) as z
+from t3, t4 where t3.a = t4.a //
+create procedure sp1()
+begin
+declare a int;
+set a= (select f1(4) + count(*) A from t1, v1);
+end //
+create function f3() returns int
+begin
+call sp1();
+return 1;
+end //
+call sp1() //
+select f3() //
+f3()
+1
+select f3() //
+f3()
+1
+call sp1() //
+drop procedure sp1//
+drop function f3//
+create procedure sp1()
+begin
+declare x int;
+declare c cursor for select f1(3) + count(*) from v1;
+open c;
+fetch c into x;
+end;//
+create function f3() returns int
+begin
+call sp1();
+return 1;
+end //
+call sp1() //
+call sp1() //
+select f3() //
+f3()
+1
+call sp1() //
+drop table t1,t2,t3;
+drop function f1;
+drop function f2;
+drop function f3;
+drop procedure sp1;
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index 184978e4a0d..75ae19eed91 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -1,7 +1,7 @@
use test;
grant usage on *.* to user1@localhost;
flush privileges;
-drop table if exists t1;
+drop table if exists t1,t2;
drop database if exists db1_secret;
create database db1_secret;
create procedure db1_secret.dummy() begin end;
diff --git a/mysql-test/r/sp-threads.result b/mysql-test/r/sp-threads.result
index e6b8128c336..2f7e8021aa7 100644
--- a/mysql-test/r/sp-threads.result
+++ b/mysql-test/r/sp-threads.result
@@ -35,7 +35,7 @@ lock tables t2 write;
show processlist;
Id User Host db Command Time State Info
# root localhost test Sleep # NULL
-# root localhost test Query # Locked call bug9486()
+# root localhost test Query # Locked update t1, t2 set val= 1 where id1=id2
# root localhost test Query # NULL show processlist
unlock tables;
drop procedure bug9486;
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index fd63204e32f..1d5cd689676 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -1,10 +1,9 @@
use test;
-drop table if exists t1;
+drop table if exists t1,t2,t3,t4;
create table t1 (
id char(16) not null default '',
data int not null
);
-drop table if exists t2;
create table t2 (
s char(16),
i int,
@@ -3042,32 +3041,6 @@ drop procedure bug11529|
drop procedure if exists bug6063|
drop procedure if exists bug7088_1|
drop procedure if exists bug7088_2|
-create procedure bug6063()
-lâbel: begin end|
-call bug6063()|
-show create procedure bug6063|
-Procedure sql_mode Create Procedure
-bug6063 CREATE PROCEDURE `test`.`bug6063`()
-l?bel: begin end
-set character set utf8|
-create procedure bug7088_1()
-label1: begin end label1|
-create procedure bug7088_2()
-läbel1: begin end|
-call bug7088_1()|
-call bug7088_2()|
-set character set default|
-show create procedure bug7088_1|
-Procedure sql_mode Create Procedure
-bug7088_1 CREATE PROCEDURE `test`.`bug7088_1`()
-label1: begin end label1
-show create procedure bug7088_2|
-Procedure sql_mode Create Procedure
-bug7088_2 CREATE PROCEDURE `test`.`bug7088_2`()
-läbel1: begin end
-drop procedure bug6063|
-drop procedure bug7088_1|
-drop procedure bug7088_2|
drop procedure if exists bug9565_sub|
drop procedure if exists bug9565|
create procedure bug9565_sub()
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index c8078a0604e..4445756d37a 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -581,6 +581,11 @@ ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function
drop view v1;
create view v1 (a,a) as select 'a','a';
ERROR 42S21: Duplicate column name 'a'
+drop procedure if exists p1;
+create procedure p1 () begin declare v int; create view v1 as select v; end;//
+call p1();
+ERROR HY000: View's SELECT contains a variable or parameter
+drop procedure p1;
create table t1 (col1 int,col2 char(22));
insert into t1 values(5,'Hello, world of views');
create view v1 as select * from t1;