Unverified 提交 d20a519e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov 提交者: GitHub

Merge pull request #1279 from katzyn/dml

Allow parentheses around final action in WITH
...@@ -5508,6 +5508,10 @@ public class Parser { ...@@ -5508,6 +5508,10 @@ public class Parser {
// used in setCteCleanups. // used in setCteCleanups.
Collections.reverse(viewsCreated); Collections.reverse(viewsCreated);
int parentheses = 0;
while (readIf(OPEN_PAREN)) {
parentheses++;
}
if (isToken(SELECT)) { if (isToken(SELECT)) {
Query query = parseSelectUnion(); Query query = parseSelectUnion();
query.setPrepareAlways(true); query.setPrepareAlways(true);
...@@ -5537,6 +5541,9 @@ public class Parser { ...@@ -5537,6 +5541,9 @@ public class Parser {
throw DbException.get(ErrorCode.SYNTAX_ERROR_1, throw DbException.get(ErrorCode.SYNTAX_ERROR_1,
WITH_STATEMENT_SUPPORTS_LIMITED_SUB_STATEMENTS); WITH_STATEMENT_SUPPORTS_LIMITED_SUB_STATEMENTS);
} }
for (; parentheses > 0; parentheses--) {
read(CLOSE_PAREN);
}
// Clean up temporary views starting with last to first (in case of // Clean up temporary views starting with last to first (in case of
// dependencies) - but only if they are not persistent. // dependencies) - but only if they are not persistent.
......
...@@ -82,3 +82,21 @@ SELECT * FROM SCH.R2; ...@@ -82,3 +82,21 @@ SELECT * FROM SCH.R2;
> 2 > 2
> 3 > 3
> rows: 3 > rows: 3
WITH CTE_TEST AS (SELECT 1, 2) SELECT * FROM CTE_TEST;
> 1 2
> - -
> 1 2
> rows: 1
WITH CTE_TEST AS (SELECT 1, 2) (SELECT * FROM CTE_TEST);
> 1 2
> - -
> 1 2
> rows: 1
WITH CTE_TEST AS (SELECT 1, 2) ((SELECT * FROM CTE_TEST));
> 1 2
> - -
> 1 2
> rows: 1
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论