Skip to content

PostgreSQL: Support FETCH with an omitted direction, FROM/IN or row count sign - #1

Open
icecrasher321 wants to merge 2 commits into
mainfrom
postgres-fetch-optional
Open

icecrasher321 wants to merge 2 commits into
mainfrom
postgres-fetch-optional

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Postgres accepts FETCH [direction] [FROM | IN] cursor, where the direction and FROM/IN are both optional and counts may be signed. The parser required {FROM | IN} and an unsigned count, so valid statements failed to parse:

FETCH 1 c;          -- Expected FROM or IN
FETCH c;            -- Expected FROM or IN
FETCH -1 FROM c;    -- fails: the count must be an unsigned number

This makes FROM/IN optional, treats a missing direction as NEXT, lets FORWARD/BACKWARD omit the count, and accepts signed counts. There are no AST changes.

Made with Cursor

@icecrasher321
icecrasher321 force-pushed the postgres-fetch-optional branch from 270d3ff to e57009e Compare November 24, 2026 22:52
Co-authored-by: Cursor <cursoragent@cursor.com>
@icecrasher321
icecrasher321 force-pushed the postgres-fetch-optional branch from e57009e to 33cdac8 Compare November 25, 2026 19:46
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant