patch 4.0
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -77,4 +77,19 @@ ERROR 42S02: Table doesn't exist
|
||||
with cte(n) AS (select 1 from dual UNION ALL select n+1 from cte where n < 3 order by n ) select * from cte;
|
||||
ERROR 42S02: Table doesn't exist
|
||||
|
||||
with RECURSIVE cte(n) as (select 1 union all select (select n+1 from cte where n < 1) ) select n from cte;
|
||||
ERROR HY000: recursive WITH clause must reference itself directly in one of the UNION ALL branches
|
||||
|
||||
with RECURSIVE cte(n) as (select 1 from dual union all select 1 + (select n+1 from cte where n < 1) from dual) select n from cte;
|
||||
ERROR HY000: recursive WITH clause must reference itself directly in one of the UNION ALL branches
|
||||
|
||||
with RECURSIVE cte(n) as (select 1 from dual union all select -(select n+1 from cte where n < 1) from dual) select n from cte;
|
||||
ERROR HY000: recursive WITH clause must reference itself directly in one of the UNION ALL branches
|
||||
|
||||
with RECURSIVE cte(n) as (select 1 from dual union all select 2 as c1 from dual where c1 in (select n + 1 from cte where n < 10)) select n from cte;
|
||||
ERROR HY000: recursive WITH clause must reference itself directly in one of the UNION ALL branches
|
||||
|
||||
with RECURSIVE cte(n) as (select 1 from dual union all select 2 from dual where EXISTS(select n + 1 from cte where n < 10)) select n from cte;
|
||||
ERROR HY000: recursive WITH clause must reference itself directly in one of the UNION ALL branches
|
||||
|
||||
drop database cte_st;
|
||||
|
||||
@ -215,16 +215,16 @@ CREATE TABLE numbers
|
||||
)
|
||||
SELECT * FROM my_cte;
|
||||
SELECT * FROM numbers;
|
||||
+------+
|
||||
| n |
|
||||
+------+
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
+------+
|
||||
+---+
|
||||
| n |
|
||||
+---+
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
+---+
|
||||
|
||||
INSERT INTO numbers
|
||||
WITH RECURSIVE my_cte(n) AS
|
||||
@ -236,22 +236,22 @@ WITH RECURSIVE my_cte(n) AS
|
||||
SELECT * FROM my_cte;
|
||||
|
||||
SELECT * FROM numbers;
|
||||
+------+
|
||||
| n |
|
||||
+------+
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
+------+
|
||||
+---+
|
||||
| n |
|
||||
+---+
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
+---+
|
||||
|
||||
DELETE FROM numbers
|
||||
WHERE numbers.n >
|
||||
@ -265,12 +265,12 @@ WHERE numbers.n >
|
||||
SELECT AVG(n)/2 FROM my_cte
|
||||
);
|
||||
SELECT * FROM numbers;
|
||||
+------+
|
||||
| n |
|
||||
+------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
+------+
|
||||
+---+
|
||||
| n |
|
||||
+---+
|
||||
| 1 |
|
||||
| 1 |
|
||||
+---+
|
||||
|
||||
################################################################################################
|
||||
### PART 2 generating series
|
||||
|
||||
@ -845,11 +845,11 @@ with RECURSIVE
|
||||
| 3 | 3 |
|
||||
| 4 | 4 |
|
||||
| 5 | 5 |
|
||||
| 7 | NULL |
|
||||
| 10 | NULL |
|
||||
| 8 | NULL |
|
||||
| 6 | NULL |
|
||||
| 9 | NULL |
|
||||
| 10 | NULL |
|
||||
| 7 | NULL |
|
||||
+------+------+
|
||||
|
||||
with RECURSIVE
|
||||
@ -1105,6 +1105,15 @@ with RECURSIVE outermost(x) AS (
|
||||
UNION SELECT * FROM innermost)
|
||||
)
|
||||
SELECT * FROM outermost ORDER BY 1;
|
||||
ERROR HY000: UNION ALL operation in recursive WITH clause must have only two branches
|
||||
|
||||
with RECURSIVE outermost(x) AS (
|
||||
SELECT 1 FROM DUAL
|
||||
UNION (with RECURSIVE innermost as (SELECT 2 FROM DUAL)
|
||||
SELECT * FROM outermost
|
||||
)
|
||||
)
|
||||
SELECT * FROM outermost ORDER BY 1;
|
||||
ERROR HY000: recursive WITH clause must have column alias list
|
||||
|
||||
drop database cte_st;
|
||||
|
||||
@ -387,9 +387,9 @@ select qn.a from qn, t1 t2;
|
||||
| a |
|
||||
+------+
|
||||
| NULL |
|
||||
| 2 |
|
||||
| NULL |
|
||||
| 2 |
|
||||
| 2 |
|
||||
+------+
|
||||
|
||||
# Merge hint
|
||||
@ -411,9 +411,9 @@ select /*+ merge(qn) no_merge(qn2) */ qn2.a from qn, qn qn2;
|
||||
| a |
|
||||
+------+
|
||||
| NULL |
|
||||
| 2 |
|
||||
| NULL |
|
||||
| 2 |
|
||||
| 2 |
|
||||
+------+
|
||||
|
||||
# FD detection
|
||||
@ -528,7 +528,7 @@ create view v1 as
|
||||
with RECURSIVE qn (foo, bar) as (select 1,1 from dual) select * from qn;
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE VIEW `v1` AS WITH RECURSIVE`qn`(foo, bar) as (select 1 AS `foo`,1 AS `bar`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from qn utf8mb4 utf8mb4_general_ci
|
||||
v1 CREATE VIEW `v1` AS WITH RECURSIVE`qn`(foo, bar) as (select 1 AS `foo`,1 AS `bar`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_general_ci
|
||||
|
||||
select * from v1;
|
||||
+-----+-----+
|
||||
@ -541,7 +541,7 @@ create view v1 as
|
||||
with RECURSIVE qn (foo, bar) as (select 1,1 from t1) select * from qn;
|
||||
show create view v1;
|
||||
View Create View character_set_client collation_connection
|
||||
v1 CREATE VIEW `v1` AS WITH RECURSIVE`qn`(foo, bar) as (select 1 AS `foo`,1 AS `bar` from `cte_st`.`t1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from qn utf8mb4 utf8mb4_general_ci
|
||||
v1 CREATE VIEW `v1` AS WITH RECURSIVE`qn`(foo, bar) as (select 1 AS `foo`,1 AS `bar` from `cte_st`.`t1`) select `qn`.`foo` AS `foo`,`qn`.`bar` AS `bar` from `qn` utf8mb4 utf8mb4_general_ci
|
||||
select * from v1;
|
||||
+-----+-----+
|
||||
| foo | bar |
|
||||
@ -588,7 +588,7 @@ select (with RECURSIVE qn as (select 'with RECURSIVE' from dual) select * from q
|
||||
from dual;
|
||||
show create view v;
|
||||
View Create View character_set_client collation_connection
|
||||
v CREATE VIEW `v` AS select (WITH RECURSIVE`qn` as (select 'with RECURSIVE' AS `with RECURSIVE`) select `qn`.`with RECURSIVE` from qn) AS `scal_subq` utf8mb4 utf8mb4_general_ci
|
||||
v CREATE VIEW `v` AS select (WITH RECURSIVE`qn` as (select 'with RECURSIVE' AS `with RECURSIVE`) select `qn`.`with RECURSIVE` from `qn`) AS `scal_subq` utf8mb4 utf8mb4_general_ci
|
||||
select * from v;
|
||||
+----------------+
|
||||
| scal_subq |
|
||||
@ -599,7 +599,7 @@ drop view v;
|
||||
create view v as select * from (with RECURSIVE qn as (select 'with RECURSIVE' from dual) select * from qn) dt;
|
||||
show create view v;
|
||||
View Create View character_set_client collation_connection
|
||||
v CREATE VIEW `v` AS select `dt`.`with RECURSIVE` AS `with RECURSIVE` from (WITH RECURSIVE`qn` as (select 'with RECURSIVE' AS `with RECURSIVE`) select `qn`.`with RECURSIVE` AS `with RECURSIVE` from qn) dt utf8mb4 utf8mb4_general_ci
|
||||
v CREATE VIEW `v` AS select `dt`.`with RECURSIVE` AS `with RECURSIVE` from (WITH RECURSIVE`qn` as (select 'with RECURSIVE' AS `with RECURSIVE`) select `qn`.`with RECURSIVE` AS `with RECURSIVE` from `qn`) dt utf8mb4 utf8mb4_general_ci
|
||||
select * from v;
|
||||
+----------------+
|
||||
| with RECURSIVE |
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,110 +0,0 @@
|
||||
drop database if exists cte_st;
|
||||
create database cte_st;
|
||||
use cte_st;
|
||||
## bugfix: https://work.aone.alibaba-inc.com/issue/37502128
|
||||
result_format: 4
|
||||
with cte1(c1, c2) as
|
||||
(select 1, '0' from dual
|
||||
union all select 2, '1' from dual
|
||||
),
|
||||
cte2(c1, c2) as
|
||||
(select '0', 1 from dual
|
||||
union all select cte1.c2, cte1.c1 from cte2, cte1 where 10 = cte2.c1)
|
||||
select * from cte2;
|
||||
ERROR 42S02: Table doesn't exist
|
||||
|
||||
WITH my_cte AS (SELECT 1 AS n UNION ALL SELECT 1+n FROM my_cte WHERE n<10 ) SELECT * FROM my_cte;
|
||||
ERROR 42S02: Table doesn't exist
|
||||
|
||||
WITH recursive my_cte AS (SELECT 1 AS n UNION ALL SELECT 1+n FROM my_cte WHERE n<10 ) SELECT * FROM my_cte;
|
||||
+------+
|
||||
| n |
|
||||
+------+
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
| 4 |
|
||||
| 5 |
|
||||
| 6 |
|
||||
| 7 |
|
||||
| 8 |
|
||||
| 9 |
|
||||
| 10 |
|
||||
+------+
|
||||
WITH recursive my_cte AS (SELECT 1+n FROM my_cte WHERE n<10 UNION ALL SELECT 1 AS n) SELECT * FROM my_cte;
|
||||
ERROR HY000: Recursive Common Table Expression should have one or more non-recursive query blocks followed by one or more recursive ones
|
||||
WITH my_cte AS (SELECT 1+n FROM my_cte WHERE n<10 UNION ALL SELECT 1 AS n) SELECT * FROM my_cte;
|
||||
ERROR 42S02: Table doesn't exist
|
||||
|
||||
|
||||
##bugfix: https://work.aone.alibaba-inc.com/issue/37501730
|
||||
create table t1(deptno number, loc varchar(100));
|
||||
CREATE TABLE t2(EMPNO DECIMAL(4) UNIQUE,ENAME VARCHAR(10) NOT NULL,JOB VARCHAR(9),MGR DECIMAL(4),HIREDATE DATE,SAL DECIMAL(7,2),COMM DECIMAL(7,2),DEPTNO INT);
|
||||
WITH
|
||||
temp AS (SELECT e.deptno,e.loc FROM t1 e WHERE e.loc IN ('New York','ChiCaGo') ORDER BY e.deptno),
|
||||
temp AS (SELECT p.deptno,p.job FROM t2 p WHERE p.job NOT IN ('CLERK','ANALYST') ORDER BY p.deptno)
|
||||
SELECT e.deptno,e.loc,p.job FROM temp e,temp p WHERE e.deptno = p.deptno ORDER BY 1,2,3;
|
||||
ERROR 42000: Not unique table/alias: 'temp'
|
||||
|
||||
##bugfix: https://work.aone.alibaba-inc.com/issue/37715234
|
||||
CREATE TABLE employees (
|
||||
id INT PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
manager_id INT NULL,
|
||||
INDEX (manager_id)
|
||||
);
|
||||
INSERT INTO employees VALUES(333, 'Yasmina', NULL);
|
||||
INSERT INTO employees VALUES(198, 'John', 333);
|
||||
INSERT INTO employees VALUES(692, 'Tarek', 333);
|
||||
INSERT INTO employees VALUES(29, 'Pedro', 198);
|
||||
INSERT INTO employees VALUES(4610, 'Sarah', 29);
|
||||
INSERT INTO employees VALUES(72, 'Pierre', 29);
|
||||
INSERT INTO employees VALUES(123, 'Adil', 692);
|
||||
|
||||
## result not correct. https://aone.alibaba-inc.com/task/35657687
|
||||
WITH RECURSIVE employee_paths (id, name, path) AS
|
||||
(
|
||||
SELECT id, name, 1
|
||||
FROM employees
|
||||
WHERE manager_id IS NULL
|
||||
UNION ALL
|
||||
SELECT e.id, e.name, CONCAT(ep.path, ',', e.id)
|
||||
FROM employee_paths ep JOIN employees e
|
||||
ON ep.id = e.manager_id
|
||||
)
|
||||
SELECT * FROM employee_paths ORDER BY name;
|
||||
+------+---------+------+
|
||||
| id | name | path |
|
||||
+------+---------+------+
|
||||
| 123 | Adil | 1 |
|
||||
| 198 | John | 1 |
|
||||
| 29 | Pedro | 1 |
|
||||
| 72 | Pierre | 1 |
|
||||
| 4610 | Sarah | 1 |
|
||||
| 692 | Tarek | 1 |
|
||||
| 333 | Yasmina | 1 |
|
||||
+------+---------+------+
|
||||
|
||||
WITH RECURSIVE employee_paths (id, name, path) AS
|
||||
(
|
||||
SELECT id, name, CAST(id AS CHAR(200))
|
||||
FROM employees
|
||||
WHERE manager_id IS NULL
|
||||
UNION ALL
|
||||
SELECT e.id, e.name, CONCAT(ep.path, ',', e.id)
|
||||
FROM employee_paths AS ep JOIN employees AS e
|
||||
ON ep.id = e.manager_id
|
||||
)
|
||||
SELECT * FROM employee_paths ORDER BY name;
|
||||
+------+---------+-----------------+
|
||||
| id | name | path |
|
||||
+------+---------+-----------------+
|
||||
| 123 | Adil | 333,692,123 |
|
||||
| 198 | John | 333,198 |
|
||||
| 29 | Pedro | 333,198,29 |
|
||||
| 72 | Pierre | 333,198,29,72 |
|
||||
| 4610 | Sarah | 333,198,29,4610 |
|
||||
| 692 | Tarek | 333,692 |
|
||||
| 333 | Yasmina | 333 |
|
||||
+------+---------+-----------------+
|
||||
drop database cte_st;
|
||||
@ -223,33 +223,33 @@ FROM rw;
|
||||
| MILLER | 7934 | 7782 |
|
||||
| ALLEN | 7499 | 7698 |
|
||||
| FORD | 7902 | 7566 |
|
||||
| WARD | 7521 | 7698 |
|
||||
| MARTIN | 7654 | 7698 |
|
||||
| MARTIN | 7654 | 7698 |
|
||||
| TURNER | 7844 | 7698 |
|
||||
| JAMES | 7900 | 7698 |
|
||||
| SCOTT | 7788 | 7566 |
|
||||
| WARD | 7521 | 7698 |
|
||||
| MARTIN | 7654 | 7698 |
|
||||
| SCOTT | 7788 | 7566 |
|
||||
| FORD | 7902 | 7566 |
|
||||
| FORD | 7902 | 7566 |
|
||||
| SCOTT | 7788 | 7566 |
|
||||
| FORD | 7902 | 7566 |
|
||||
| SCOTT | 7788 | 7566 |
|
||||
| FORD | 7902 | 7566 |
|
||||
| SCOTT | 7788 | 7566 |
|
||||
| MARTIN | 7654 | 7698 |
|
||||
| WARD | 7521 | 7698 |
|
||||
| JAMES | 7900 | 7698 |
|
||||
| TURNER | 7844 | 7698 |
|
||||
| MARTIN | 7654 | 7698 |
|
||||
| MARTIN | 7654 | 7698 |
|
||||
| WARD | 7521 | 7698 |
|
||||
| WARD | 7521 | 7698 |
|
||||
| ALLEN | 7499 | 7698 |
|
||||
| MILLER | 7934 | 7782 |
|
||||
| SMITH | 7369 | 7902 |
|
||||
| ADAMS | 7876 | 7788 |
|
||||
| ADAMS | 7876 | 7788 |
|
||||
| SMITH | 7369 | 7902 |
|
||||
| SMITH | 7369 | 7902 |
|
||||
| SMITH | 7369 | 7902 |
|
||||
| ADAMS | 7876 | 7788 |
|
||||
| SMITH | 7369 | 7902 |
|
||||
| ADAMS | 7876 | 7788 |
|
||||
| SMITH | 7369 | 7902 |
|
||||
| ADAMS | 7876 | 7788 |
|
||||
+--------+-------+------+
|
||||
|
||||
|
||||
@ -1818,42 +1818,42 @@ Query Plan
|
||||
|
||||
Outputs & filters:
|
||||
-------------------------------------
|
||||
0 - output([cte1.a], [cte1.b]), filter(nil),
|
||||
0 - output([cte1.a], [cte1.b]), filter(nil), rowset=256,
|
||||
conds([cte1.a < cte3.c]), nl_params_(nil)
|
||||
1 - output([cte3.c]), filter(nil),
|
||||
1 - output([cte3.c]), filter(nil), rowset=256,
|
||||
access([cte3.c])
|
||||
2 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil)
|
||||
3 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil)
|
||||
4 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil)
|
||||
2 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil), rowset=256
|
||||
3 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil), rowset=256
|
||||
4 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil), rowset=256
|
||||
5 - output([1], [1], [1]), filter(nil)
|
||||
values({1, 1, 1})
|
||||
6 - output([cte1.a + 1], [cte1.b + 1], [cte1.c + 1]), filter([cte1.a < 10]),
|
||||
access([cte1.a], [cte1.b], [cte1.c]), partitions(nil)
|
||||
7 - output([cte2.a + 1], [cte2.b + 1], [cte2.c + 1]), filter([cte2.a < 10]),
|
||||
access([cte2.a], [cte2.b], [cte2.c]), partitions(nil)
|
||||
8 - output([cte3.a + 1], [cte3.b + 1], [cte3.c + 1]), filter(nil),
|
||||
6 - output([cte1.a + 1], [cte1.b + 1], [cte1.c + 1]), filter([cte1.a < 10]), rowset=256,
|
||||
access([cte1.a], [cte1.b], [cte1.c]), partitions is NULL,
|
||||
7 - output([cte2.a + 1], [cte2.b + 1], [cte2.c + 1]), filter([cte2.a < 10]), rowset=256,
|
||||
access([cte2.a], [cte2.b], [cte2.c]), partitions is NULL,
|
||||
8 - output([cte3.a + 1], [cte3.b + 1], [cte3.c + 1]), filter(nil), rowset=256,
|
||||
conds([cte3.a < cte2.b]), nl_params_(nil)
|
||||
9 - output([cte3.a], [cte3.b], [cte3.c]), filter([cte3.a < 10]),
|
||||
access([cte3.a], [cte3.b], [cte3.c]), partitions(nil)
|
||||
10 - output([cte2.b]), filter(nil)
|
||||
11 - output([cte2.b]), filter([cte2.a < 3]),
|
||||
9 - output([cte3.a], [cte3.b], [cte3.c]), filter([cte3.a < 10]), rowset=256,
|
||||
access([cte3.a], [cte3.b], [cte3.c]), partitions is NULL,
|
||||
10 - output([cte2.b]), filter(nil), rowset=256
|
||||
11 - output([cte2.b]), filter([cte2.a < 3]), rowset=256,
|
||||
access([cte2.a], [cte2.b])
|
||||
12 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil)
|
||||
13 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil)
|
||||
12 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil), rowset=256
|
||||
13 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil), rowset=256
|
||||
14 - output([1], [1], [1]), filter(nil)
|
||||
values({1, 1, 1})
|
||||
15 - output([cte1.a + 1], [cte1.b + 1], [cte1.c + 1]), filter([cte1.a < 10]),
|
||||
access([cte1.a], [cte1.b], [cte1.c]), partitions(nil)
|
||||
16 - output([cte2.a + 1], [cte2.b + 1], [cte2.c + 1]), filter([cte2.a < 10]),
|
||||
access([cte2.a], [cte2.b], [cte2.c]), partitions(nil)
|
||||
17 - output([cte1.a], [cte1.b]), filter(nil)
|
||||
18 - output([cte1.a], [cte1.b]), filter(nil),
|
||||
15 - output([cte1.a + 1], [cte1.b + 1], [cte1.c + 1]), filter([cte1.a < 10]), rowset=256,
|
||||
access([cte1.a], [cte1.b], [cte1.c]), partitions is NULL,
|
||||
16 - output([cte2.a + 1], [cte2.b + 1], [cte2.c + 1]), filter([cte2.a < 10]), rowset=256,
|
||||
access([cte2.a], [cte2.b], [cte2.c]), partitions is NULL,
|
||||
17 - output([cte1.a], [cte1.b]), filter(nil), rowset=256
|
||||
18 - output([cte1.a], [cte1.b]), filter(nil), rowset=256,
|
||||
access([cte1.a], [cte1.b])
|
||||
19 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil)
|
||||
19 - output([UNION([1])], [UNION([2])], [UNION([3])]), filter(nil), rowset=256
|
||||
20 - output([1], [1], [1]), filter(nil)
|
||||
values({1, 1, 1})
|
||||
21 - output([cte1.a + 1], [cte1.b + 1], [cte1.c + 1]), filter([cte1.a < 10]),
|
||||
access([cte1.a], [cte1.b], [cte1.c]), partitions(nil)
|
||||
21 - output([cte1.a + 1], [cte1.b + 1], [cte1.c + 1]), filter([cte1.a < 10]), rowset=256,
|
||||
access([cte1.a], [cte1.b], [cte1.c]), partitions is NULL,
|
||||
|
||||
|
||||
set ob_query_timeout = 100000000;
|
||||
|
||||
@ -80,4 +80,19 @@ with cte(n) AS ( select 1 from cte) select * from cte;
|
||||
--error 1146
|
||||
with cte(n) AS (select 1 from dual UNION ALL select n+1 from cte where n < 3 order by n ) select * from cte;
|
||||
|
||||
--error 5744
|
||||
with RECURSIVE cte(n) as (select 1 union all select (select n+1 from cte where n < 1) ) select n from cte;
|
||||
|
||||
--error 5744
|
||||
with RECURSIVE cte(n) as (select 1 from dual union all select 1 + (select n+1 from cte where n < 1) from dual) select n from cte;
|
||||
|
||||
--error 5744
|
||||
with RECURSIVE cte(n) as (select 1 from dual union all select -(select n+1 from cte where n < 1) from dual) select n from cte;
|
||||
|
||||
--error 5744
|
||||
with RECURSIVE cte(n) as (select 1 from dual union all select 2 as c1 from dual where c1 in (select n + 1 from cte where n < 10)) select n from cte;
|
||||
|
||||
--error 5744
|
||||
with RECURSIVE cte(n) as (select 1 from dual union all select 2 from dual where EXISTS(select n + 1 from cte where n < 10)) select n from cte;
|
||||
|
||||
drop database cte_st;
|
||||
@ -574,7 +574,7 @@ with RECURSIVE outermost(x) AS (
|
||||
)
|
||||
SELECT * FROM outermost ORDER BY 1;
|
||||
|
||||
--error 5741
|
||||
--error 5743
|
||||
with RECURSIVE outermost(x) AS (
|
||||
SELECT 1 FROM DUAL
|
||||
UNION (with RECURSIVE innermost as (SELECT 2 FROM DUAL)
|
||||
@ -583,4 +583,13 @@ with RECURSIVE outermost(x) AS (
|
||||
)
|
||||
SELECT * FROM outermost ORDER BY 1;
|
||||
|
||||
--error 5741
|
||||
with RECURSIVE outermost(x) AS (
|
||||
SELECT 1 FROM DUAL
|
||||
UNION (with RECURSIVE innermost as (SELECT 2 FROM DUAL)
|
||||
SELECT * FROM outermost
|
||||
)
|
||||
)
|
||||
SELECT * FROM outermost ORDER BY 1;
|
||||
|
||||
drop database cte_st;
|
||||
@ -1,84 +0,0 @@
|
||||
# owner: dachuan.sdc
|
||||
# owner group: sql2
|
||||
# tags: optimizer
|
||||
|
||||
--disable_warnings
|
||||
drop database if exists cte_st;
|
||||
--enable_warnings
|
||||
create database cte_st;
|
||||
use cte_st;
|
||||
|
||||
--echo ## bugfix: https://work.aone.alibaba-inc.com/issue/37502128
|
||||
--result_format 4
|
||||
--error 1146
|
||||
with cte1(c1, c2) as
|
||||
(select 1, '0' from dual
|
||||
union all select 2, '1' from dual
|
||||
),
|
||||
cte2(c1, c2) as
|
||||
(select '0', 1 from dual
|
||||
union all select cte1.c2, cte1.c1 from cte2, cte1 where 10 = cte2.c1)
|
||||
select * from cte2;
|
||||
|
||||
--error 1146
|
||||
WITH my_cte AS (SELECT 1 AS n UNION ALL SELECT 1+n FROM my_cte WHERE n<10 ) SELECT * FROM my_cte;
|
||||
|
||||
WITH recursive my_cte AS (SELECT 1 AS n UNION ALL SELECT 1+n FROM my_cte WHERE n<10 ) SELECT * FROM my_cte;
|
||||
--error 3574
|
||||
WITH recursive my_cte AS (SELECT 1+n FROM my_cte WHERE n<10 UNION ALL SELECT 1 AS n) SELECT * FROM my_cte;
|
||||
--error 1146
|
||||
WITH my_cte AS (SELECT 1+n FROM my_cte WHERE n<10 UNION ALL SELECT 1 AS n) SELECT * FROM my_cte;
|
||||
|
||||
|
||||
|
||||
--echo ##bugfix: https://work.aone.alibaba-inc.com/issue/37501730
|
||||
create table t1(deptno number, loc varchar(100));
|
||||
CREATE TABLE t2(EMPNO DECIMAL(4) UNIQUE,ENAME VARCHAR(10) NOT NULL,JOB VARCHAR(9),MGR DECIMAL(4),HIREDATE DATE,SAL DECIMAL(7,2),COMM DECIMAL(7,2),DEPTNO INT);
|
||||
--error 1066
|
||||
WITH
|
||||
temp AS (SELECT e.deptno,e.loc FROM t1 e WHERE e.loc IN ('New York','ChiCaGo') ORDER BY e.deptno),
|
||||
temp AS (SELECT p.deptno,p.job FROM t2 p WHERE p.job NOT IN ('CLERK','ANALYST') ORDER BY p.deptno)
|
||||
SELECT e.deptno,e.loc,p.job FROM temp e,temp p WHERE e.deptno = p.deptno ORDER BY 1,2,3;
|
||||
|
||||
|
||||
--echo ##bugfix: https://work.aone.alibaba-inc.com/issue/37715234
|
||||
CREATE TABLE employees (
|
||||
id INT PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
manager_id INT NULL,
|
||||
INDEX (manager_id)
|
||||
);
|
||||
INSERT INTO employees VALUES(333, 'Yasmina', NULL);
|
||||
INSERT INTO employees VALUES(198, 'John', 333);
|
||||
INSERT INTO employees VALUES(692, 'Tarek', 333);
|
||||
INSERT INTO employees VALUES(29, 'Pedro', 198);
|
||||
INSERT INTO employees VALUES(4610, 'Sarah', 29);
|
||||
INSERT INTO employees VALUES(72, 'Pierre', 29);
|
||||
INSERT INTO employees VALUES(123, 'Adil', 692);
|
||||
|
||||
## result not correct. https://aone.alibaba-inc.com/task/35657687
|
||||
WITH RECURSIVE employee_paths (id, name, path) AS
|
||||
(
|
||||
SELECT id, name, 1
|
||||
FROM employees
|
||||
WHERE manager_id IS NULL
|
||||
UNION ALL
|
||||
SELECT e.id, e.name, CONCAT(ep.path, ',', e.id)
|
||||
FROM employee_paths ep JOIN employees e
|
||||
ON ep.id = e.manager_id
|
||||
)
|
||||
SELECT * FROM employee_paths ORDER BY name;
|
||||
|
||||
|
||||
WITH RECURSIVE employee_paths (id, name, path) AS
|
||||
(
|
||||
SELECT id, name, CAST(id AS CHAR(200))
|
||||
FROM employees
|
||||
WHERE manager_id IS NULL
|
||||
UNION ALL
|
||||
SELECT e.id, e.name, CONCAT(ep.path, ',', e.id)
|
||||
FROM employee_paths AS ep JOIN employees AS e
|
||||
ON ep.id = e.manager_id
|
||||
)
|
||||
SELECT * FROM employee_paths ORDER BY name;
|
||||
drop database cte_st;
|
||||
Reference in New Issue
Block a user