DBZ-6336 MySql in debezium-parser-ddl does not support with keyword parsing

This commit is contained in:
caicancai 2023-04-15 19:02:21 +08:00 committed by Jiri Pechanec
parent 5ed3fa3e0d
commit 514afb72eb
2 changed files with 48 additions and 1 deletions

View File

@ -74,7 +74,7 @@ dmlStatement
: selectStatement | insertStatement | updateStatement
| deleteStatement | replaceStatement | callStatement
| loadDataStatement | loadXmlStatement | doStatement
| handlerStatement | valuesStatement
| handlerStatement | valuesStatement | withStatement
;
transactionStatement
@ -960,6 +960,10 @@ valuesStatement
(',' '(' expressionsWithDefaults? ')')*
;
withStatement
: WITH RECURSIVE? commonTableExpressions (',' commonTableExpressions)*
;
updateStatement
: singleUpdateStatement | multipleUpdateStatement
;

View File

@ -256,3 +256,46 @@ SELECT *
)
) AS tt;
#begin
---- From MySQL 5.7, withStatement are supported
--https://dev.mysql.com/doc/refman/8.0/en/with.html
-- Recursive CTE
WITH RECURSIVE cte (n) AS (
SELECT 1
UNION ALL
SELECT n + 1 FROM cte WHERE n < 10
)
SELECT n FROM cte;
WITH RECURSIVE cte AS (
SELECT id, name, manager_id
FROM employees
WHERE id = 1
UNION ALL
SELECT e.id, e.name, e.manager_id
FROM employees e
JOIN cte ON e.manager_id = cte.id
)
SELECT * FROM cte;
WITH RECURSIVE cte AS (
SELECT id, name, parent_id
FROM departments
WHERE id = 1
UNION ALL
SELECT d.id, d.name, d.parent_id
FROM departments d
JOIN cte ON d.parent_id = cte.id
)
SELECT * FROM cte;
#end
#begin
--Non-recursive Ctes
WITH cte1 AS (
SELECT * FROM table1 WHERE col1 = 'value'
),
cte2 AS (
SELECT * FROM table2 WHERE col2 = 'value'
)
SELECT cte1.col1, cte2.col2 FROM cte1 JOIN cte2 ON cte1.id = cte2.id;
#end