Commit f522912d authored by tsmith@ramayana.hindu.god's avatar tsmith@ramayana.hindu.god
Browse files

Merge ramayana.hindu.god:/home/tsmith/m/bk/50

into  ramayana.hindu.god:/home/tsmith/m/bk/maint/50
parents ff483538 1c1401bb
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -1177,4 +1177,40 @@ id c1 c2
4	2	3
1	5	1
DROP TABLE t1;
CREATE TABLE t1 ( a INT, b INT );
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
c	(SELECT a FROM t1 WHERE b = c)
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1 
HAVING b = 10;
c	(SELECT a FROM t1 WHERE b = c)
SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
FROM t1 
HAVING b = 10;
ERROR 42S22: Reference 'c' not supported (reference to group function)
SET @old_sql_mode = @@sql_mode;
SET @@sql_mode='ONLY_FULL_GROUP_BY';
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
c	(SELECT a FROM t1 WHERE b = c)
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1 
HAVING b = 10;
ERROR 42000: non-grouping field 'b' is used in HAVING clause
SELECT MAX(b) c, (SELECT a FROM t1 WHERE b = c)
FROM t1 
HAVING b = 10;
ERROR 42S22: Reference 'c' not supported (reference to group function)
INSERT INTO t1 VALUES (1, 1);
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
c	(SELECT a FROM t1 WHERE b = c)
1	1
INSERT INTO t1 VALUES (2, 1);
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
End of 5.0 tests
+109 −0
Original line number Diff line number Diff line
@@ -733,4 +733,113 @@ optimizer: keep hreturn
drop table t1;
drop procedure proc_26977_broken;
drop procedure proc_26977_works;
drop procedure if exists proc_33618_h;
drop procedure if exists proc_33618_c;
create procedure proc_33618_h(num int)
begin
declare count1 int default '0';
declare vb varchar(30);
declare last_row int;
while(num>=1) do
set num=num-1;
begin
declare cur1 cursor for select `a` from t_33618;
declare continue handler for not found set last_row = 1;
set last_row:=0;
open cur1;
rep1:
repeat
begin
declare exit handler for 1062 begin end;
fetch cur1 into vb;
if (last_row = 1) then
## should generate a hpop instruction here
leave rep1;
end if;
end;
until last_row=1
end repeat;
close cur1;
end;
end while;
end//
create procedure proc_33618_c(num int)
begin
declare count1 int default '0';
declare vb varchar(30);
declare last_row int;
while(num>=1) do
set num=num-1;
begin
declare cur1 cursor for select `a` from t_33618;
declare continue handler for not found set last_row = 1;
set last_row:=0;
open cur1;
rep1:
repeat
begin
declare cur2 cursor for select `b` from t_33618;
fetch cur1 into vb;
if (last_row = 1) then
## should generate a cpop instruction here
leave rep1;
end if;
end;
until last_row=1
end repeat;
close cur1;
end;
end while;
end//
show procedure code proc_33618_h;
Pos	Instruction
0	set count1@1 _latin1'0'
1	set vb@2 NULL
2	set last_row@3 NULL
3	jump_if_not 24(24) (num@0 >= 1)
4	set num@0 (num@0 - 1)
5	cpush cur1@0
6	hpush_jump 9 4 CONTINUE
7	set last_row@3 1
8	hreturn 4
9	set last_row@3 0
10	copen cur1@0
11	hpush_jump 13 4 EXIT
12	hreturn 0 17
13	cfetch cur1@0 vb@2
14	jump_if_not 17(17) (last_row@3 = 1)
15	hpop 1
16	jump 19
17	hpop 1
18	jump_if_not 11(19) (last_row@3 = 1)
19	cclose cur1@0
20	hpop 1
21	cpop 1
22	jump 3
show procedure code proc_33618_c;
Pos	Instruction
0	set count1@1 _latin1'0'
1	set vb@2 NULL
2	set last_row@3 NULL
3	jump_if_not 23(23) (num@0 >= 1)
4	set num@0 (num@0 - 1)
5	cpush cur1@0
6	hpush_jump 9 4 CONTINUE
7	set last_row@3 1
8	hreturn 4
9	set last_row@3 0
10	copen cur1@0
11	cpush cur2@1
12	cfetch cur1@0 vb@2
13	jump_if_not 16(16) (last_row@3 = 1)
14	cpop 1
15	jump 18
16	cpop 1
17	jump_if_not 11(18) (last_row@3 = 1)
18	cclose cur1@0
19	hpop 1
20	cpop 1
21	jump 3
drop procedure proc_33618_h;
drop procedure proc_33618_c;
End of 5.0 tests.
+48 −0
Original line number Diff line number Diff line
@@ -1465,3 +1465,51 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT ..inexistent();
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.inexistent()' at line 1
USE test;
drop procedure if exists proc_33983_a;
drop procedure if exists proc_33983_b;
drop procedure if exists proc_33983_c;
drop procedure if exists proc_33983_d;
create procedure proc_33983_a()
begin
label1:
begin
label2:
begin
select 1;
end label1;
end;
end|
ERROR 42000: End-label label1 without match
create procedure proc_33983_b()
begin
label1:
repeat
label2:
repeat
select 1;
until FALSE end repeat label1;
until FALSE end repeat;
end|
ERROR 42000: End-label label1 without match
create procedure proc_33983_c()
begin
label1:
while TRUE do
label2:
while TRUE do
select 1;
end while label1;
end while;
end|
ERROR 42000: End-label label1 without match
create procedure proc_33983_d()
begin
label1:
loop
label2:
loop
select 1;
end loop label1;
end loop;
end|
ERROR 42000: End-label label1 without match
+51 −0
Original line number Diff line number Diff line
@@ -6578,6 +6578,57 @@ DROP PROCEDURE db28318_a.t1;
DROP PROCEDURE db28318_b.t2;
DROP DATABASE db28318_a;
DROP DATABASE db28318_b;
USE test;
DROP TABLE IF EXISTS t1;
DROP PROCEDURE IF EXISTS bug29770;
CREATE TABLE t1(a int);
CREATE PROCEDURE bug29770()
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '42S22' SET @state:= 'run';
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET @exception:= 'run';
SELECT x FROM t1;
END|
CALL bug29770();
SELECT @state, @exception;
@state	@exception
run	NULL
DROP TABLE t1;
DROP PROCEDURE bug29770;
use test;
drop table if exists t_33618;
drop procedure if exists proc_33618;
create table t_33618 (`a` int, unique(`a`), `b` varchar(30)) engine=myisam;
insert into t_33618 (`a`,`b`) values (1,'1'),(2,'2');
create procedure proc_33618(num int)
begin
declare count1 int default '0';
declare vb varchar(30);
declare last_row int;
while(num>=1) do
set num=num-1;
begin
declare cur1 cursor for select `a` from t_33618;
declare continue handler for not found set last_row = 1;
set last_row:=0;
open cur1;
rep1:
repeat
begin
declare exit handler for 1062 begin end;
fetch cur1 into vb;
if (last_row = 1) then
leave rep1;
end if;
end;
until last_row=1
end repeat;
close cur1;
end;
end while;
end//
call proc_33618(20);
drop table t_33618;
drop procedure proc_33618;
# ------------------------------------------------------------------
# -- End of 5.0 tests
# ------------------------------------------------------------------
+48 −0
Original line number Diff line number Diff line
@@ -4392,4 +4392,52 @@ select count(*) from t1 where f12 =
count(*)
3
drop table t1,t2;
CREATE TABLE t4 (
f7 varchar(32) collate utf8_bin NOT NULL default '',
f10 varchar(32) collate utf8_bin default NULL,
PRIMARY KEY  (f7)
);
INSERT INTO t4 VALUES(1,1), (2,null);
CREATE TABLE t2 (
f4 varchar(32) collate utf8_bin NOT NULL default '',
f2 varchar(50) collate utf8_bin default NULL,
f3 varchar(10) collate utf8_bin default NULL,
PRIMARY KEY  (f4),
UNIQUE KEY uk1 (f2)
);
INSERT INTO t2 VALUES(1,1,null), (2,2,null);
CREATE TABLE t1 (
f8 varchar(32) collate utf8_bin NOT NULL default '',
f1 varchar(10) collate utf8_bin default NULL,
f9 varchar(32) collate utf8_bin default NULL,
PRIMARY KEY  (f8)
);
INSERT INTO t1 VALUES (1,'P',1), (2,'P',1), (3,'R',2);
CREATE TABLE t3 (
f6 varchar(32) collate utf8_bin NOT NULL default '',
f5 varchar(50) collate utf8_bin default NULL,
PRIMARY KEY (f6)
);
INSERT INTO t3 VALUES (1,null), (2,null);
SELECT
IF(t1.f1 = 'R', a1.f2, t2.f2) AS a4,
IF(t1.f1 = 'R', a1.f3, t2.f3) AS f3,
SUM(
IF(
(SELECT VPC.f2
FROM t2 VPC, t4 a2, t2 a3
WHERE
VPC.f4 = a2.f10 AND a3.f2 = a4
LIMIT 1) IS NULL, 
0, 
t3.f5
)
) AS a6
FROM 
t2, t3, t1 JOIN t2 a1 ON t1.f9 = a1.f4
GROUP BY a4;
a4	f3	a6
1	NULL	NULL
2	NULL	NULL
DROP TABLE t1, t2, t3, t4;
End of 5.0 tests.
Loading