Skip to content

Commit d368133

Browse files
committed
Merge 10.4 into 10.5
2 parents 996431f + 57022df commit d368133

File tree

13 files changed

+451
-16
lines changed

13 files changed

+451
-16
lines changed

mysql-test/main/cte_recursive.result

Lines changed: 163 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -691,13 +691,13 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
691691
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
692692
1 PRIMARY <derived3> ref key0 key0 5 c.h_id 2 100.00
693693
1 PRIMARY <derived3> ref key0 key0 5 c.w_id 2 100.00
694-
2 DERIVED <derived3> ALL NULL NULL NULL NULL 12 100.00 Using where
695694
3 DERIVED folks ALL NULL NULL NULL NULL 12 100.00 Using where
696695
4 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00
697696
4 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00 Using where; Using join buffer (flat, BNL join)
698697
5 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00
699698
5 RECURSIVE UNION p ALL NULL NULL NULL NULL 12 100.00 Using where; Using join buffer (flat, BNL join)
700699
NULL UNION RESULT <union3,4,5> ALL NULL NULL NULL NULL NULL NULL
700+
2 DERIVED <derived3> ALL NULL NULL NULL NULL 12 100.00 Using where
701701
Warnings:
702702
Note 1003 with recursive ancestor_couple_ids(`h_id`,`w_id`) as (/* select#2 */ select `a`.`father` AS `h_id`,`a`.`mother` AS `w_id` from `coupled_ancestors` `a` where `a`.`father` is not null and `a`.`mother` is not null), coupled_ancestors(`id`,`name`,`dob`,`father`,`mother`) as (/* select#3 */ select `test`.`folks`.`id` AS `id`,`test`.`folks`.`name` AS `name`,`test`.`folks`.`dob` AS `dob`,`test`.`folks`.`father` AS `father`,`test`.`folks`.`mother` AS `mother` from `test`.`folks` where `test`.`folks`.`name` = 'Me' union all /* select#4 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `fa` where `test`.`p`.`id` = `fa`.`h_id` union all /* select#5 */ select `test`.`p`.`id` AS `id`,`test`.`p`.`name` AS `name`,`test`.`p`.`dob` AS `dob`,`test`.`p`.`father` AS `father`,`test`.`p`.`mother` AS `mother` from `test`.`folks` `p` join `ancestor_couple_ids` `ma` where `test`.`p`.`id` = `ma`.`w_id`)/* select#1 */ select `h`.`name` AS `name`,`h`.`dob` AS `dob`,`w`.`name` AS `name`,`w`.`dob` AS `dob` from `ancestor_couple_ids` `c` join `coupled_ancestors` `h` join `coupled_ancestors` `w` where `h`.`id` = `c`.`h_id` and `w`.`id` = `c`.`w_id`
703703
# simple mutual recursion
@@ -1302,12 +1302,12 @@ id select_type table type possible_keys key key_len ref rows Extra
13021302
1 PRIMARY <derived4> ALL NULL NULL NULL NULL 24
13031303
4 DERIVED folks ALL NULL NULL NULL NULL 12 Using where
13041304
6 RECURSIVE UNION <derived3> ALL NULL NULL NULL NULL 12
1305+
5 RECURSIVE UNION <derived4> ALL NULL NULL NULL NULL 24
1306+
NULL UNION RESULT <union4,6,5> ALL NULL NULL NULL NULL NULL
13051307
3 DERIVED folks ALL NULL NULL NULL NULL 12 Using where
13061308
2 RECURSIVE UNION folks ALL PRIMARY NULL NULL NULL 12
13071309
2 RECURSIVE UNION <derived3> ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
13081310
NULL UNION RESULT <union3,2> ALL NULL NULL NULL NULL NULL
1309-
5 RECURSIVE UNION <derived4> ALL NULL NULL NULL NULL 24
1310-
NULL UNION RESULT <union4,6,5> ALL NULL NULL NULL NULL NULL
13111311
explain FORMAT=JSON
13121312
with recursive
13131313
prev_gen
@@ -3372,13 +3372,13 @@ select * from cte1, cte2;
33723372
id select_type table type possible_keys key key_len ref rows filtered Extra
33733373
1 PRIMARY <derived4> ALL NULL NULL NULL NULL 6 100.00
33743374
1 PRIMARY <derived5> ALL NULL NULL NULL NULL 6 100.00 Using join buffer (flat, BNL join)
3375+
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
3376+
3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
3377+
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
33753378
4 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
33763379
4 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
33773380
5 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
33783381
5 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
3379-
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
3380-
3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
3381-
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
33823382
Warnings:
33833383
Note 1003 with recursive rcte(`a`) as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte1`.`c1` AS `c1`,`cte2`.`c2` AS `c2` from `cte1` join `cte2`
33843384
prepare stmt from "with recursive
@@ -3437,6 +3437,65 @@ cte2 as
34373437
(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
34383438
select * from cte1, cte2 where cte1.c1 = 3;
34393439
c1 c2
3440+
with recursive
3441+
rcte(a) as
3442+
(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
3443+
cte1 as
3444+
(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
3445+
cte2 as
3446+
(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
3447+
select * from cte2, cte1;
3448+
c2 c1
3449+
1 2
3450+
explain extended with recursive
3451+
rcte(a) as
3452+
(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
3453+
cte1 as
3454+
(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
3455+
cte2 as
3456+
(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
3457+
select * from cte2, cte1;
3458+
id select_type table type possible_keys key key_len ref rows filtered Extra
3459+
1 PRIMARY <derived5> ALL NULL NULL NULL NULL 6 100.00
3460+
1 PRIMARY <derived4> ALL NULL NULL NULL NULL 6 100.00 Using join buffer (flat, BNL join)
3461+
2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
3462+
3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
3463+
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
3464+
5 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
3465+
5 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
3466+
4 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
3467+
4 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
3468+
Warnings:
3469+
Note 1003 with recursive rcte(`a`) as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte2`.`c2` AS `c2`,`cte1`.`c1` AS `c1` from `cte2` join `cte1`
3470+
prepare stmt from "with recursive
3471+
rcte(a) as
3472+
(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
3473+
cte1 as
3474+
(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
3475+
cte2 as
3476+
(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
3477+
select * from cte2, cte1";
3478+
execute stmt;
3479+
c2 c1
3480+
1 2
3481+
execute stmt;
3482+
c2 c1
3483+
1 2
3484+
drop procedure p;
3485+
drop table t2;
3486+
create table t2 (c1 int, c2 int);
3487+
create procedure p() insert into t2 with recursive
3488+
rcte(a) as
3489+
(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
3490+
cte1 as
3491+
(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
3492+
cte2 as
3493+
(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
3494+
select * from cte2, cte1;
3495+
call p();
3496+
select * from t2;
3497+
c1 c2
3498+
1 2
34403499
drop procedure p;
34413500
drop table t1,t2;
34423501
#
@@ -3843,7 +3902,104 @@ ANALYZE
38433902
}
38443903
drop function f1;
38453904
drop table t1,t2;
3846-
End of 10.2 tests
3905+
#
3906+
# MDEV-22748: two materialized CTEs using the same recursive CTE
3907+
# (see also test case for MDEV-17024)
3908+
#
3909+
CREATE TABLE t1 (YEAR int(4), d1 date , d2 date) ;
3910+
INSERT INTO t1 VALUES (2018,'2018-01-01','2018-09-20');
3911+
CREATE TABLE t2 (id int, tm date);
3912+
INSERT INTO t2 VALUES (1,'2018-08-30'),(2,'2018-08-30'),(3,'2018-08-30');
3913+
CREATE TABLE t3 (id int, tm date);
3914+
INSERT INTO t3 VALUES (1,'2018-08-30'),(2,'2018-08-30');
3915+
WITH RECURSIVE
3916+
cte AS
3917+
(SELECT YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn
3918+
FROM t1
3919+
UNION ALL
3920+
SELECT YEAR(cte.st + INTERVAL 1 MONTH),
3921+
cte.st + INTERVAL 1 MONTH, t1.d2 + INTERVAL 1 DAY
3922+
FROM cte JOIN t1
3923+
WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),
3924+
cte2 AS (SELECT YEAR, COUNT(*)
3925+
FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn),
3926+
cte3 AS (SELECT YEAR, COUNT(*)
3927+
FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn)
3928+
SELECT t1.* FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR);
3929+
YEAR d1 d2
3930+
2018 2018-01-01 2018-09-20
3931+
EXPLAIN EXTENDED WITH RECURSIVE
3932+
cte AS
3933+
(SELECT YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn
3934+
FROM t1
3935+
UNION ALL
3936+
SELECT YEAR(cte.st + INTERVAL 1 MONTH),
3937+
cte.st + INTERVAL 1 MONTH, t1.d2 + INTERVAL 1 DAY
3938+
FROM cte JOIN t1
3939+
WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),
3940+
cte2 AS (SELECT YEAR, COUNT(*)
3941+
FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn),
3942+
cte3 AS (SELECT YEAR, COUNT(*)
3943+
FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn)
3944+
SELECT t1.* FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR);
3945+
id select_type table type possible_keys key key_len ref rows filtered Extra
3946+
1 PRIMARY t1 system NULL NULL NULL NULL 1 100.00
3947+
1 PRIMARY <derived5> ref key0 key0 5 const 0 0.00
3948+
1 PRIMARY <derived4> ref key0 key0 5 const 0 0.00
3949+
2 DERIVED t1 system NULL NULL NULL NULL 1 100.00
3950+
3 RECURSIVE UNION t1 system NULL NULL NULL NULL 1 100.00
3951+
3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
3952+
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
3953+
4 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00
3954+
4 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
3955+
5 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00
3956+
5 DERIVED t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
3957+
Warnings:
3958+
Note 1003 with recursive cte as (/* select#2 */ select year(`test`.`t1`.`d1`) AS `YEAR`,`test`.`t1`.`d1` AS `st`,`test`.`t1`.`d1` + interval 1 month AS `fn` from `test`.`t1` union all /* select#3 */ select year(`cte`.`st` + interval 1 month) AS `YEAR(cte.st + INTERVAL 1 MONTH)`,`cte`.`st` + interval 1 month AS `cte.st + INTERVAL 1 MONTH`,`test`.`t1`.`d2` + interval 1 day AS `t1.d2 + INTERVAL 1 DAY` from `cte` join `test`.`t1` where `cte`.`st` + interval 1 month < `test`.`t1`.`d2`), cte2 as (/* select#4 */ select `cte`.`YEAR` AS `YEAR`,count(0) AS `COUNT(*)` from `cte` join `test`.`t2` where `test`.`t2`.`tm` between `cte`.`st` and `cte`.`fn`), cte3 as (/* select#5 */ select `cte`.`YEAR` AS `YEAR`,count(0) AS `COUNT(*)` from `cte` join `test`.`t3` where `test`.`t3`.`tm` between `cte`.`st` and `cte`.`fn`)/* select#1 */ select 2018 AS `YEAR`,'2018-01-01' AS `d1`,'2018-09-20' AS `d2` from `cte2` join `cte3` where `cte3`.`YEAR` = 2018 and `cte2`.`YEAR` = 2018
3959+
PREPARE stmt FROM "WITH RECURSIVE
3960+
cte AS
3961+
(SELECT YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn
3962+
FROM t1
3963+
UNION ALL
3964+
SELECT YEAR(cte.st + INTERVAL 1 MONTH),
3965+
cte.st + INTERVAL 1 MONTH, t1.d2 + INTERVAL 1 DAY
3966+
FROM cte JOIN t1
3967+
WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),
3968+
cte2 AS (SELECT YEAR, COUNT(*)
3969+
FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn),
3970+
cte3 AS (SELECT YEAR, COUNT(*)
3971+
FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn)
3972+
SELECT t1.* FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR)";
3973+
EXECUTE stmt;
3974+
YEAR d1 d2
3975+
2018 2018-01-01 2018-09-20
3976+
EXECUTE stmt;
3977+
YEAR d1 d2
3978+
2018 2018-01-01 2018-09-20
3979+
CREATE TABLE t4 (YEAR int(4), d1 date , d2 date);
3980+
CREATE PROCEDURE p() INSERT INTO t4 WITH RECURSIVE
3981+
cte AS
3982+
(SELECT YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn
3983+
FROM t1
3984+
UNION ALL
3985+
SELECT YEAR(cte.st + INTERVAL 1 MONTH),
3986+
cte.st + INTERVAL 1 MONTH, t1.d2 + INTERVAL 1 DAY
3987+
FROM cte JOIN t1
3988+
WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),
3989+
cte2 AS (SELECT YEAR, COUNT(*)
3990+
FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn),
3991+
cte3 AS (SELECT YEAR, COUNT(*)
3992+
FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn)
3993+
SELECT t1.* FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR);
3994+
CALL p();
3995+
SELECT * FROM t4;
3996+
YEAR d1 d2
3997+
2018 2018-01-01 2018-09-20
3998+
DROP PROCEDURE p;
3999+
DROP TABLE t1,t2,t3,t4;
4000+
#
4001+
# End of 10.2 tests
4002+
#
38474003
#
38484004
# MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
38494005
#

mysql-test/main/cte_recursive.test

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2424,6 +2424,30 @@ select * from cte1, cte2 where cte1.c1 = 3;
24242424

24252425
eval $q3;
24262426

2427+
let $q4=
2428+
with recursive
2429+
rcte(a) as
2430+
(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
2431+
cte1 as
2432+
(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
2433+
cte2 as
2434+
(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
2435+
select * from cte2, cte1;
2436+
2437+
eval $q4;
2438+
eval explain extended $q4;
2439+
eval prepare stmt from "$q4";
2440+
execute stmt;
2441+
execute stmt;
2442+
2443+
drop procedure p;
2444+
drop table t2;
2445+
2446+
create table t2 (c1 int, c2 int);
2447+
eval create procedure p() insert into t2 $q4;
2448+
call p();
2449+
select * from t2;
2450+
24272451
drop procedure p;
24282452
drop table t1,t2;
24292453

@@ -2609,7 +2633,51 @@ eval analyze format=json $q;
26092633
drop function f1;
26102634
drop table t1,t2;
26112635

2612-
--echo End of 10.2 tests
2636+
--echo #
2637+
--echo # MDEV-22748: two materialized CTEs using the same recursive CTE
2638+
--echo # (see also test case for MDEV-17024)
2639+
--echo #
2640+
2641+
CREATE TABLE t1 (YEAR int(4), d1 date , d2 date) ;
2642+
INSERT INTO t1 VALUES (2018,'2018-01-01','2018-09-20');
2643+
CREATE TABLE t2 (id int, tm date);
2644+
INSERT INTO t2 VALUES (1,'2018-08-30'),(2,'2018-08-30'),(3,'2018-08-30');
2645+
CREATE TABLE t3 (id int, tm date);
2646+
INSERT INTO t3 VALUES (1,'2018-08-30'),(2,'2018-08-30');
2647+
2648+
let $q=
2649+
WITH RECURSIVE
2650+
cte AS
2651+
(SELECT YEAR(t1.d1) AS YEAR, t1.d1 AS st, t1.d1 + INTERVAL 1 MONTH AS fn
2652+
FROM t1
2653+
UNION ALL
2654+
SELECT YEAR(cte.st + INTERVAL 1 MONTH),
2655+
cte.st + INTERVAL 1 MONTH, t1.d2 + INTERVAL 1 DAY
2656+
FROM cte JOIN t1
2657+
WHERE cte.st + INTERVAL 1 MONTH < t1.d2 ),
2658+
cte2 AS (SELECT YEAR, COUNT(*)
2659+
FROM cte JOIN t2 ON t2.tm BETWEEN cte.st AND cte.fn),
2660+
cte3 AS (SELECT YEAR, COUNT(*)
2661+
FROM cte JOIN t3 ON t3.tm BETWEEN cte.st AND cte.fn)
2662+
SELECT t1.* FROM t1 JOIN cte2 USING (YEAR) JOIN cte3 USING (YEAR);
2663+
2664+
eval $q;
2665+
eval EXPLAIN EXTENDED $q;
2666+
eval PREPARE stmt FROM "$q";
2667+
EXECUTE stmt;
2668+
EXECUTE stmt;
2669+
2670+
CREATE TABLE t4 (YEAR int(4), d1 date , d2 date);
2671+
eval CREATE PROCEDURE p() INSERT INTO t4 $q;
2672+
CALL p();
2673+
SELECT * FROM t4;
2674+
2675+
DROP PROCEDURE p;
2676+
DROP TABLE t1,t2,t3,t4;
2677+
2678+
--echo #
2679+
--echo # End of 10.2 tests
2680+
--echo #
26132681

26142682
--echo #
26152683
--echo # MDEV-14217 [db crash] Recursive CTE when SELECT includes new field

mysql-test/suite/compat/oracle/r/parser.result

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,40 @@ ERROR HY000: Unknown system variable 'password'
607607
SELECT @@GLOBAL.role;
608608
ERROR HY000: Unknown system variable 'role'
609609
#
610+
# MDEV-22822 sql_mode="oracle" cannot declare without variable errors
611+
#
612+
# It's OK to have no declarations between DECLARE and BEGIN.
613+
#
614+
BEGIN
615+
DECLARE
616+
BEGIN
617+
NULL;
618+
END;
619+
EXCEPTION
620+
WHEN OTHERS THEN
621+
NULL;
622+
END;
623+
//
624+
DECLARE
625+
BEGIN
626+
NULL;
627+
EXCEPTION
628+
WHEN OTHERS THEN
629+
NULL;
630+
END;
631+
//
632+
BEGIN
633+
<<lab>>
634+
DECLARE
635+
BEGIN
636+
NULL;
637+
END;
638+
EXCEPTION
639+
WHEN OTHERS THEN
640+
NULL;
641+
END;
642+
//
643+
#
610644
# End of 10.3 tests
611645
#
612646
#

mysql-test/suite/compat/oracle/t/parser.test

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,53 @@ SELECT @@GLOBAL.password;
409409
SELECT @@GLOBAL.role;
410410

411411

412+
--echo #
413+
--echo # MDEV-22822 sql_mode="oracle" cannot declare without variable errors
414+
--echo #
415+
--echo # It's OK to have no declarations between DECLARE and BEGIN.
416+
--echo #
417+
418+
DELIMITER //;
419+
BEGIN
420+
DECLARE
421+
BEGIN
422+
NULL;
423+
END;
424+
EXCEPTION
425+
WHEN OTHERS THEN
426+
NULL;
427+
END;
428+
//
429+
DELIMITER ;//
430+
431+
432+
DELIMITER //;
433+
DECLARE
434+
BEGIN
435+
NULL;
436+
EXCEPTION
437+
WHEN OTHERS THEN
438+
NULL;
439+
END;
440+
//
441+
DELIMITER ;//
442+
443+
444+
DELIMITER //;
445+
BEGIN
446+
<<lab>>
447+
DECLARE
448+
BEGIN
449+
NULL;
450+
END;
451+
EXCEPTION
452+
WHEN OTHERS THEN
453+
NULL;
454+
END;
455+
//
456+
DELIMITER ;//
457+
458+
412459
--echo #
413460
--echo # End of 10.3 tests
414461
--echo #

0 commit comments

Comments
 (0)