1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Manual merge

mysql-test/r/sp.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/view.test:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sp.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_trigger.h:
  Auto merged
This commit is contained in:
unknown
2005-08-03 03:47:07 +00:00
20 changed files with 731 additions and 222 deletions

View File

@ -0,0 +1,215 @@
drop database if exists mysqltest;
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 mysqltest;
use mysqltest//
create procedure sp1 ()
begin
drop table if exists t1;
select 1 as "my-col";
end;
//
select database();
database()
mysqltest
call sp1();
my-col
1
Warnings:
Note 1051 Unknown table 't1'
select database();
database()
mysqltest
use test;
select database();
database()
test
call mysqltest.sp1();
my-col
1
Warnings:
Note 1051 Unknown table 't1'
select database();
database()
test
drop procedure mysqltest.sp1;
drop database mysqltest;
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', a from t2;
drop table t1;
drop table t2;
end//
call sp2();
t1 a
t1 1
t2 a
t2 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
2
a
1
2
a
1
2
a
5
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;

View File

@ -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;

View File

@ -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,
@ -85,7 +84,6 @@ foo 1
kaka 3
delete from t1|
drop procedure setcontext|
drop table if exists t3|
create table t3 ( d date, i int, f double, s varchar(32) )|
drop procedure if exists nullset|
create procedure nullset()
@ -521,7 +519,6 @@ select data into x from test.t1 limit 1;
insert into test.t3 values ("into4", x);
end|
delete from t1|
drop table if exists t3|
create table t3 ( s char(16), d int)|
call into_test4()|
Warnings:
@ -565,13 +562,12 @@ insert into test.t1 values (x, y);
create temporary table test.t3 select * from test.t1;
insert into test.t3 values (concat(x, "2"), y+2);
end|
drop table if exists t3|
call create_select("cs", 90)|
select * from t1, t3|
id data id data
cs 90 cs 90
cs 90 cs2 92
drop table if exists t3|
drop table t3|
delete from t1|
drop procedure create_select|
drop function if exists e|
@ -702,7 +698,6 @@ id data
hndlr3 13
delete from t1|
drop procedure hndlr3|
drop table if exists t3|
create table t3 ( id char(16), data int )|
drop procedure if exists hndlr4|
create procedure hndlr4()
@ -745,7 +740,6 @@ foo 40
bar 15
zap 663
drop procedure cur1|
drop table if exists t3|
create table t3 ( s char(16), i int )|
drop procedure if exists cur2|
create procedure cur2()
@ -1309,7 +1303,6 @@ select t1max()|
t1max()
5
drop function t1max|
drop table if exists t3|
create table t3 (
v char(16) not null primary key,
c int unsigned not null
@ -1430,7 +1423,6 @@ select @1, @2|
2 NULL
drop table t70|
drop procedure bug1656|
drop table if exists t3|
create table t3(a int)|
drop procedure if exists bug1862|
create procedure bug1862()
@ -1555,7 +1547,6 @@ select @x|
42
drop procedure bug2776_1|
drop procedure bug2776_2|
drop table if exists t3|
create table t3 (s1 smallint)|
insert into t3 values (123456789012)|
Warnings:
@ -1616,7 +1607,6 @@ f1 rc t3
drop procedure bug1863|
drop temporary table temp_t1;
drop table t3, t4|
drop table if exists t3, t4|
create table t3 (
OrderID int not null,
MarketID int,
@ -1694,7 +1684,6 @@ select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
@i time
2 01-01-1970 03:16:40
drop procedure bug3426|
drop table if exists t3, t4|
create table t3 (
a int primary key,
ach char(1)
@ -1724,7 +1713,6 @@ a ach b bch
1 a 1 b
drop procedure bug3448|
drop table t3, t4|
drop table if exists t3|
create table t3 (
id int unsigned auto_increment not null primary key,
title VARCHAR(200),
@ -1873,7 +1861,6 @@ select 1+2|
1+2
3
drop procedure bug3843|
drop table if exists t3|
create table t3 ( s1 char(10) )|
insert into t3 values ('a'), ('b')|
drop procedure if exists bug3368|
@ -1889,7 +1876,6 @@ group_concat(v)
yz,yz
drop procedure bug3368|
drop table t3|
drop table if exists t3|
create table t3 (f1 int, f2 int)|
insert into t3 values (1,1)|
drop procedure if exists bug4579_1|
@ -1914,7 +1900,6 @@ Warning 1329 No data to FETCH
drop procedure bug4579_1|
drop procedure bug4579_2|
drop table t3|
drop table if exists t3|
drop procedure if exists bug2773|
create function bug2773() returns int return null|
create table t3 as select bug2773()|
@ -1936,7 +1921,6 @@ select bug3788()|
bug3788()
5
drop function bug3788|
drop table if exists t3|
create table t3 (f1 int, f2 int, f3 int)|
insert into t3 values (1,1,1)|
drop procedure if exists bug4726|
@ -2097,7 +2081,6 @@ call bug4902_2()|
Id User Host db Command Time State Info
# root localhost test Query # NULL show processlist
drop procedure bug4902_2|
drop table if exists t3|
drop procedure if exists bug4904|
create procedure bug4904()
begin
@ -2286,7 +2269,6 @@ flush status|
flush query cache|
delete from t1|
drop procedure bug3583|
drop table if exists t3|
drop procedure if exists bug4905|
create table t3 (s1 int,primary key (s1))|
drop procedure if exists bug4905|
@ -2344,7 +2326,6 @@ call bug8540()|
y z
1 1
drop procedure bug8540|
drop table if exists t3|
create table t3 (s1 int)|
drop procedure if exists bug6642|
create procedure bug6642()
@ -2427,7 +2408,6 @@ call bug7992_2()|
drop procedure bug7992_1|
drop procedure bug7992_2|
drop table t3|
drop table if exists t3|
create table t3 ( userid bigint(20) not null default 0 )|
drop procedure if exists bug8116|
create procedure bug8116(in _userid int)
@ -2588,7 +2568,6 @@ delete from t1|
drop procedure if exists bug6900|
drop procedure if exists bug9074|
drop procedure if exists bug6900_9074|
drop table if exists t3|
create table t3 (w char unique, x char)|
insert into t3 values ('a', 'b')|
create procedure bug6900()
@ -3042,32 +3021,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<EFBFBD>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<EFBFBD>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()

View File

@ -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;

View File

@ -0,0 +1,242 @@
#
# Tests of prelocking-free execution of stored procedures.
# Currently two properties of prelocking-free SP execution are checked:
# - It is possible to execute DDL statements in prelocking-free stored
# procedure
# - The same procedure can be called in prelocking-free mode and
# in prelocked mode (from within a function).
--disable_warnings
drop database if exists mysqltest;
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;
--enable_warnings
# BUG#8072
create database mysqltest;
delimiter //;
use mysqltest//
create procedure sp1 ()
begin
drop table if exists t1;
select 1 as "my-col";
end;
//
delimiter ;//
select database();
call sp1();
select database();
use test;
select database();
call mysqltest.sp1();
select database();
drop procedure mysqltest.sp1;
drop database mysqltest;
# BUG#8766
delimiter //;
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//
delimiter ;//
call sp1();
select 't1',a from t1;
drop table t1;
call sp2();
select 't1',a from t1;
select 't2',a from t2;
drop table t1, t2;
call sp3();
select 't1',a from t1;
drop table t1;
drop procedure sp1;
drop procedure sp2;
drop procedure sp3;
drop function f1;
delimiter //;
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', a from t2;
drop table t1;
drop table t2;
end//
delimiter ;//
call sp2();
drop procedure sp1;
drop procedure sp2;
# Miscelaneous tests
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;
delimiter //;
create procedure sp1(a int)
begin
select a;
end //
create function f1() returns int
begin
return (select max(a) from t1);
end //
delimiter ;//
CALL sp1(f1());
#############
delimiter //;
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 //
delimiter ;//
call sp4();
drop procedure sp1;
drop procedure sp2;
drop procedure sp3;
drop procedure sp4;
drop function f1;
# Test that prelocking state restoration works with cursors
--disable_warnings
drop view if exists v1;
--enable_warnings
delimiter //;
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() //
select f3() //
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() //
call sp1() //
delimiter ;//
drop table t1,t2,t3;
drop function f1;
drop function f2;
drop function f3;
drop procedure sp1;

View File

@ -22,15 +22,12 @@ use test;
# t3 and up are created and dropped when needed.
#
--disable_warnings
drop table if exists t1;
drop table if exists t1,t2,t3,t4;
--enable_warnings
create table t1 (
id char(16) not null default '',
data int not null
);
--disable_warnings
drop table if exists t2;
--enable_warnings
create table t2 (
s char(16),
i int,
@ -150,9 +147,6 @@ drop procedure setcontext|
# Set things to null
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( d date, i int, f double, s varchar(32) )|
--disable_warnings
@ -686,9 +680,6 @@ begin
end|
delete from t1|
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( s char(16), d int)|
call into_test4()|
select * from t3|
@ -744,14 +735,9 @@ begin
insert into test.t3 values (concat(x, "2"), y+2);
end|
--disable_warnings
drop table if exists t3|
--enable_warnings
call create_select("cs", 90)|
select * from t1, t3|
--disable_warnings
drop table if exists t3|
--enable_warnings
drop table t3|
delete from t1|
drop procedure create_select|
@ -925,9 +911,6 @@ drop procedure hndlr3|
# Variables might be uninitialized when using handlers
# (Otherwise the compiler can detect if a variable is not set, but
# not in this case.)
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( id char(16), data int )|
--disable_warnings
@ -980,9 +963,6 @@ call cur1()|
select * from t1|
drop procedure cur1|
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( s char(16), i int )|
--disable_warnings
@ -1619,9 +1599,6 @@ insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|
select t1max()|
drop function t1max|
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (
v char(16) not null primary key,
c int unsigned not null
@ -1755,9 +1732,6 @@ drop procedure bug1656|
#
# BUG#1862
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3(a int)|
--disable_warnings
@ -2018,9 +1992,6 @@ drop procedure bug2776_2|
#
# BUG#2780
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (s1 smallint)|
insert into t3 values (123456789012)|
@ -2094,9 +2065,6 @@ drop table t3, t4|
#
# BUG#2656
#
--disable_warnings
drop table if exists t3, t4|
--enable_warnings
create table t3 (
OrderID int not null,
@ -2184,8 +2152,6 @@ drop procedure bug3426|
# BUG#3448
#
--disable_warnings
drop table if exists t3, t4|
create table t3 (
a int primary key,
ach char(1)
@ -2217,9 +2183,6 @@ drop table t3, t4|
#
# BUG#3734
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (
id int unsigned auto_increment not null primary key,
title VARCHAR(200),
@ -2395,9 +2358,6 @@ drop procedure bug3843|
#
# BUG#3368
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( s1 char(10) )|
insert into t3 values ('a'), ('b')|
@ -2417,9 +2377,6 @@ drop table t3|
#
# BUG#4579
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (f1 int, f2 int)|
insert into t3 values (1,1)|
@ -2454,7 +2411,6 @@ drop table t3|
# BUG#2773: Function's data type ignored in stored procedures
#
--disable_warnings
drop table if exists t3|
drop procedure if exists bug2773|
--enable_warnings
@ -2483,10 +2439,6 @@ drop function bug3788|
#
# BUG#4726
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (f1 int, f2 int, f3 int)|
insert into t3 values (1,1,1)|
@ -2517,29 +2469,24 @@ drop table t3|
# BUG#4318
#
#QQ Don't know if HANDLER commands can work with SPs, or at all...
--disable_parsing
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (s1 int)|
insert into t3 values (3), (4)|
--disable_warnings
drop procedure if exists bug4318|
--enable_warnings
create procedure bug4318()
handler t3 read next|
handler t3 open|
# Expect no results, as tables are closed, but there shouldn't be any errors
call bug4318()|
call bug4318()|
handler t3 close|
drop procedure bug4318|
drop table t3|
--enable_parsing
#
#create table t3 (s1 int)|
#insert into t3 values (3), (4)|
#
#--disable_warnings
#drop procedure if exists bug4318|
#--enable_warnings
#create procedure bug4318()
# handler t3 read next|
#
#handler t3 open|
## Expect no results, as tables are closed, but there shouldn't be any errors
#call bug4318()|
#call bug4318()|
#handler t3 close|
#
#drop procedure bug4318|
#drop table t3|
#
# BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error
@ -2604,10 +2551,6 @@ drop procedure bug4902_2|
#
# BUG#4904
#
--disable_warnings
drop table if exists t3|
--enable_warnings
--disable_warnings
drop procedure if exists bug4904|
--enable_warnings
@ -2861,7 +2804,6 @@ drop procedure bug3583|
# BUG#4905: Stored procedure doesn't clear for "Rows affected"
#
--disable_warnings
drop table if exists t3|
drop procedure if exists bug4905|
--enable_warnings
@ -2961,9 +2903,6 @@ drop procedure bug8540|
#
# BUG#6642: Stored procedure crash if expression with set function
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (s1 int)|
--disable_warnings
@ -3051,9 +2990,6 @@ drop table t3|
# BUG#8116: calling simple stored procedure twice in a row results
# in server crash
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 ( userid bigint(20) not null default 0 )|
--disable_warnings
@ -3296,7 +3232,6 @@ delete from t1|
drop procedure if exists bug6900|
drop procedure if exists bug9074|
drop procedure if exists bug6900_9074|
drop table if exists t3|
--enable_warnings
create table t3 (w char unique, x char)|
@ -3825,26 +3760,27 @@ drop procedure if exists bug7088_1|
drop procedure if exists bug7088_2|
--enable_warnings
create procedure bug6063()
l<>bel: begin end|
call bug6063()|
# QQ Known bug: this will not show the label correctly.
show create procedure bug6063|
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|
show create procedure bug7088_2|
drop procedure bug6063|
drop procedure bug7088_1|
drop procedure bug7088_2|
# psergey: temporarily disabled until Bar fixes BUG#11986
# create procedure bug6063()
# l<>bel: begin end|
# call bug6063()|
# # QQ Known bug: this will not show the label correctly.
# show create procedure bug6063|
#
# 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|
# show create procedure bug7088_2|
#
# drop procedure bug6063|
# drop procedure bug7088_1|
# drop procedure bug7088_2|
#
# BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure

View File

@ -491,15 +491,15 @@ create view v1 (a,a) as select 'a','a';
#
# SP variables inside view test
#
# QQ This can't be tested with the new table locking for functions,
# QQ since views created in an SP can't be used within the same SP
# QQ (just as for tables). Instead it fails with error 1146.
#delimiter //;
#create procedure p1 () begin declare v int; create view v1 as select v; end;//
#delimiter ;//
#-- error 1351
#call p1();
#drop procedure p1;
--disable_warnings
drop procedure if exists p1;
--enable_warnings
delimiter //;
create procedure p1 () begin declare v int; create view v1 as select v; end;//
delimiter ;//
-- error 1351
call p1();
drop procedure p1;
#
# updatablity should be transitive