Skip to content

feat: allow SELECT without target expressions for PostgreSQL - #2841

Merged
manticore-projects merged 3 commits into
JSQLParser:masterfrom
princejain756:pg-empty-select
Oct 22, 2026
Merged

manticore-projects merged 3 commits into
JSQLParser:masterfrom
princejain756:pg-empty-select

Conversation

@princejain756

Copy link
Copy Markdown
Contributor

Resolves #2784.

PostgreSQL permits a SELECT with no target expressions, e.g.

SELECT FROM t
SELECT count(*) FROM (SELECT FROM (VALUES (1, 'a'), (2, 'b')) AS t(id, label)) AS q

which fails with a parse error because SelectItemsList requires at least one SelectItem.

With this change PlainSelect accepts an absent select-item list when the POSTGRESQL dialect is active and FROM follows SELECT directly. The parsed model exposes an empty select-items list rather than an UNSPECIFIC node, and both the toString path and SelectDeParser avoid emitting a doubled space in SELECT FROM when the list is empty. Other dialects and all existing SELECT forms are unchanged.

10,733 tests, 0 failures, 25 skipped.

Making the select-items group optional for the target-less PostgreSQL
SELECT let JavaCC see K_AS in the follow set of the optional AS
STRUCT/VALUE qualifier block, producing a choice conflict at the block.
Guard it with an explicit lookahead so AS only opens the qualifier when
STRUCT or VALUE comes next.
@manticore-projects

Copy link
Copy Markdown
Contributor

Cursed grammar, but since you got it working with only small changes and its Postgres, I will merge it.
Thank you!

@manticore-projects
manticore-projects merged commit 28ad7d2 into JSQLParser:master Oct 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] JSQLParser : PostgreSQL : SELECT without target expressions fails to parse

2 participants