Skip to content

PostgreSQL: Support optional FROM/IN and direction in FETCH - #3096

Open
icecrasher321 wants to merge 6 commits into
apache:mainfrom
formalco:upstream/postgres-fetch-optional
Open

icecrasher321 wants to merge 6 commits into
apache:mainfrom
formalco:upstream/postgres-fetch-optional

Conversation

@icecrasher321

@icecrasher321 icecrasher321 commented Dec 3, 2026 •

Copy link
Copy Markdown

Dialects: PostgreSQL

Closes #3050

PostgreSQL's FETCH accepts an optional direction, optional FROM/IN, and signed counts, which currently fail to parse:

FETCH c;                -- Expected: a concrete value, found: c
FETCH 1 c;              -- Expected FROM or IN
FETCH FORWARD FROM c;   -- Expected: a concrete value, found: FROM
FETCH -1 FROM c;        -- Expected: a value, found: -

Makes FROM/IN optional, defaults an omitted direction to NEXT, makes the FORWARD/BACKWARD count optional, and parses signed counts (no AST changes). Tested all these forms of the query.

AI-assisted.

icecrasher321 and others added 6 commits November 25, 2026 11:44
Co-authored-by: Cursor <cursoragent@cursor.com>
…ch-optional

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	tests/sqlparser_postgres.rs
Co-authored-by: Cursor <cursoragent@cursor.com>
…ch-optional

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	tests/sqlparser_postgres.rs
@icecrasher321

Copy link
Copy Markdown
Author

@LucaCappelletti94 re-opened this with your requested changes!

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.

PostgreSqlDialect rejects FETCH statements with omitted direction, FROM/IN, or signed counts

1 participant