Commit a4729a90 authored by pem@mysql.comhem.se's avatar pem@mysql.comhem.se

Added test cases for the following bugs that have been fixed by recent changes:

 BUG#1863: CREATE TABLE in Stored Procedure sometimes crashes on repeated calls.
 BUG#2656: select with join in stored procedure: erroneous result on 2nd call.
 BUG#3426: IF x IS NULL in stored procedure fails on second call within connection.
 BUG#3448: Stored Procedures with inner joins possible bug.
 BUG#3734: Stored procedure returns wrong rows with fulltext parameter.
 BUG#3863: Stored procedure crash when incrementing variable in a loop.

(And corrected the row count output to the client after CALL)
parent 350d8a21
......@@ -1093,6 +1093,186 @@ s1
32767
drop procedure bug2780|
drop table t3|
drop table if exists t3|
create table t3 (content varchar(10) )|
insert into t3 values ("test1")|
insert into t3 values ("test2")|
drop table if exists t4|
create table t4 (f1 int, rc int, t3 int)|
create procedure bug1863(in1 int)
begin
declare ind int default 0;
declare t1 int;
declare t2 int;
declare t3 int;
declare rc int default 0;
declare continue handler for 1065 set rc = 1;
drop table if exists temp_t1;
create temporary table temp_t1 (
f1 int auto_increment, f2 varchar(20), primary key (f1)
);
insert into temp_t1 (f2) select content from t3;
select f2 into t3 from temp_t1 where f1 = 10;
if (rc) then
insert into t4 values (1, rc, t3);
end if;
insert into t4 values (2, rc, t3);
end|
call bug1863(10)|
Warnings:
call bug1863(10)|
Warnings:
select * from t4|
f1 rc t3
2 0 NULL
2 0 NULL
drop procedure bug1863|
drop table t3, t4|
drop table if exists t3, t4|
create table t3 (
OrderID int not null,
MarketID int,
primary key (OrderID)
)|
create table t4 (
MarketID int not null,
Market varchar(60),
Status char(1),
primary key (MarketID)
)|
insert t3 (OrderID,MarketID) values (1,1)|
insert t3 (OrderID,MarketID) values (2,2)|
insert t4 (MarketID,Market,Status) values (1,"MarketID One","A")|
insert t4 (MarketID,Market,Status) values (2,"MarketID Two","A")|
create procedure bug2656_1()
begin
select
m.Market
from t4 m JOIN t3 o
ON o.MarketID != 1 and o.MarketID = m.MarketID;
end |
create procedure bug2656_2()
begin
select
m.Market
from
t4 m, t3 o
where
m.MarketID != 1 and m.MarketID = o.MarketID;
end |
call bug2656_1()|
Market
MarketID Two
call bug2656_1()|
Market
MarketID Two
call bug2656_2()|
Market
MarketID Two
call bug2656_2()|
Market
MarketID Two
drop procedure bug2656_1|
drop procedure bug2656_2|
drop table t3, t4|
create procedure bug3426(in_time int unsigned, out x int)
begin
if in_time is null then
set @stamped_time=10;
set x=1;
else
set @stamped_time=in_time;
set x=2;
end if;
end|
call bug3426(1000, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
@i time
2 01-01-1970 03:16:40
call bug3426(NULL, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
@i time
1 01-01-1970 03:00:10
alter procedure bug3426 sql security invoker|
call bug3426(NULL, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
@i time
1 01-01-1970 03:00:10
call bug3426(1000, @i)|
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)
) engine = innodb|
create table t4 (
b int primary key ,
bch char(1)
) engine = innodb|
insert into t3 values (1 , 'aCh1' ) , ('2' , 'aCh2')|
Warnings:
Warning 1265 Data truncated for column 'ach' at row 1
Warning 1265 Data truncated for column 'ach' at row 2
insert into t4 values (1 , 'bCh1' )|
Warnings:
Warning 1265 Data truncated for column 'bch' at row 1
create procedure bug3448()
select * from t3 inner join t4 on t3.a = t4.b|
select * from t3 inner join t4 on t3.a = t4.b|
a ach b bch
1 a 1 b
call bug3448()|
a ach b bch
1 a 1 b
call bug3448()|
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),
body text,
fulltext (title,body)
)|
insert into t3 (title,body) values
('MySQL Tutorial','DBMS stands for DataBase ...'),
('How To Use MySQL Well','After you went through a ...'),
('Optimizing MySQL','In this tutorial we will show ...'),
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
('MySQL vs. YourSQL','In the following database comparison ...'),
('MySQL Security','When configured properly, MySQL ...')|
create procedure bug3734 (param1 varchar(100))
select * from t3 where match (title,body) against (param1)|
call bug3734('database')|
id title body
5 MySQL vs. YourSQL In the following database comparison ...
1 MySQL Tutorial DBMS stands for DataBase ...
call bug3734('Security')|
id title body
6 MySQL Security When configured properly, MySQL ...
drop procedure bug3734|
drop table t3|
create procedure bug3863()
begin
set @a = 0;
while @a < 5 do
set @a = @a + 1;
end while;
end|
call bug3863()|
select @a|
@a
5
call bug3863()|
select @a|
@a
5
drop procedure bug3863|
drop table if exists fac|
create table fac (n int unsigned not null primary key, f bigint unsigned)|
create procedure ifac(n int unsigned)
......
......@@ -1262,6 +1262,215 @@ select * from t3|
drop procedure bug2780|
drop table t3|
#
# BUG#1863
#
--disable_warnings
drop table if exists t3|
--enable_warnings
create table t3 (content varchar(10) )|
insert into t3 values ("test1")|
insert into t3 values ("test2")|
--disable_warnings
drop table if exists t4|
--enable_warnings
create table t4 (f1 int, rc int, t3 int)|
create procedure bug1863(in1 int)
begin
declare ind int default 0;
declare t1 int;
declare t2 int;
declare t3 int;
declare rc int default 0;
declare continue handler for 1065 set rc = 1;
drop table if exists temp_t1;
create temporary table temp_t1 (
f1 int auto_increment, f2 varchar(20), primary key (f1)
);
insert into temp_t1 (f2) select content from t3;
select f2 into t3 from temp_t1 where f1 = 10;
if (rc) then
insert into t4 values (1, rc, t3);
end if;
insert into t4 values (2, rc, t3);
end|
call bug1863(10)|
call bug1863(10)|
select * from t4|
drop procedure bug1863|
drop table t3, t4|
#
# BUG#2656
#
--disable_warnings
drop table if exists t3, t4|
--enable_warnings
create table t3 (
OrderID int not null,
MarketID int,
primary key (OrderID)
)|
create table t4 (
MarketID int not null,
Market varchar(60),
Status char(1),
primary key (MarketID)
)|
insert t3 (OrderID,MarketID) values (1,1)|
insert t3 (OrderID,MarketID) values (2,2)|
insert t4 (MarketID,Market,Status) values (1,"MarketID One","A")|
insert t4 (MarketID,Market,Status) values (2,"MarketID Two","A")|
create procedure bug2656_1()
begin
select
m.Market
from t4 m JOIN t3 o
ON o.MarketID != 1 and o.MarketID = m.MarketID;
end |
create procedure bug2656_2()
begin
select
m.Market
from
t4 m, t3 o
where
m.MarketID != 1 and m.MarketID = o.MarketID;
end |
call bug2656_1()|
call bug2656_1()|
call bug2656_2()|
call bug2656_2()|
drop procedure bug2656_1|
drop procedure bug2656_2|
drop table t3, t4|
#
# BUG#3426
#
create procedure bug3426(in_time int unsigned, out x int)
begin
if in_time is null then
set @stamped_time=10;
set x=1;
else
set @stamped_time=in_time;
set x=2;
end if;
end|
call bug3426(1000, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
call bug3426(NULL, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
# Clear SP cache
alter procedure bug3426 sql security invoker|
call bug3426(NULL, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
call bug3426(1000, @i)|
select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
drop procedure bug3426|
#
# BUG#3448
#
--disable_warnings
drop table if exists t3, t4|
--enable_warnings
create table t3 (
a int primary key,
ach char(1)
) engine = innodb|
create table t4 (
b int primary key ,
bch char(1)
) engine = innodb|
insert into t3 values (1 , 'aCh1' ) , ('2' , 'aCh2')|
insert into t4 values (1 , 'bCh1' )|
create procedure bug3448()
select * from t3 inner join t4 on t3.a = t4.b|
select * from t3 inner join t4 on t3.a = t4.b|
call bug3448()|
call bug3448()|
drop procedure bug3448|
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),
body text,
fulltext (title,body)
)|
insert into t3 (title,body) values
('MySQL Tutorial','DBMS stands for DataBase ...'),
('How To Use MySQL Well','After you went through a ...'),
('Optimizing MySQL','In this tutorial we will show ...'),
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
('MySQL vs. YourSQL','In the following database comparison ...'),
('MySQL Security','When configured properly, MySQL ...')|
create procedure bug3734 (param1 varchar(100))
select * from t3 where match (title,body) against (param1)|
call bug3734('database')|
call bug3734('Security')|
drop procedure bug3734|
drop table t3|
#
# BUG#3863
#
create procedure bug3863()
begin
set @a = 0;
while @a < 5 do
set @a = @a + 1;
end while;
end|
call bug3863()|
select @a|
call bug3863()|
select @a|
drop procedure bug3863|
#
# Some "real" examples
......
......@@ -3489,7 +3489,7 @@ unsent_create_error:
}
if (res == 0)
send_ok(thd, thd->row_count_func);
send_ok(thd, (thd->row_count_func < 0 ? 0 : thd->row_count_func));
else
goto error; // Substatement should already have sent error
}
......
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