Skip to content

Commit

Permalink
Allow empty column lists in with clause and views
Browse files Browse the repository at this point in the history
  • Loading branch information
katzyn committed Jan 28, 2024
1 parent d07f3a0 commit 4505de3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions h2/src/docsrc/html/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ <h1>Change Log</h1>

<h2>Next Version (unreleased)</h2>
<ul>
<li>Issue #3987: Allow empty &lt;with column list&gt;
</li>
<li>Issue #822: WITH clauses' column aliases are not maintained correctly when selecting from CTE from within a derived
table
</li>
Expand Down
8 changes: 5 additions & 3 deletions h2/src/main/org/h2/command/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1135,9 +1135,11 @@ private int parseSortType() {

private String[] parseColumnList() {
ArrayList<String> columns = Utils.newSmallArrayList();
do {
columns.add(readIdentifier());
} while (readIfMore());
if (!readIf(CLOSE_PAREN)) {
do {
columns.add(readIdentifier());
} while (readIfMore());
}
return columns.toArray(new String[0]);
}

Expand Down
12 changes: 12 additions & 0 deletions h2/src/test/org/h2/test/scripts/ddl/createView.sql
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,15 @@ SELECT * FROM TEST_VIEW;

DROP TABLE TEST CASCADE;
> ok

CREATE VIEW V() AS SELECT;
> ok

TABLE V;
>
>
>
> rows: 1

DROP VIEW V;
> ok
13 changes: 13 additions & 0 deletions h2/src/test/org/h2/test/scripts/dml/with.sql
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,16 @@ SELECT A1.F1, A1.F2 FROM (SELECT * FROM T1) A1;
> -- --
> 1 2
> rows: 1

CREATE VIEW V AS
WITH A AS (SELECT) TABLE A;
> ok

TABLE V;
>
>
>
> rows: 1

DROP VIEW V;
> ok

0 comments on commit 4505de3

Please sign in to comment.