Skip to content

sql: Constant-fold parameterized top-level LIMIT#37853

Open
def- wants to merge 1 commit into
MaterializeInc:mainfrom
def-:pr-sql-476
Open

sql: Constant-fold parameterized top-level LIMIT#37853
def- wants to merge 1 commit into
MaterializeInc:mainfrom
def-:pr-sql-476

Conversation

@def-

@def- def- commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Executing a prepared statement with a parameterized LIMIT failed with "Top-level LIMIT must be a constant expression, got integer_to_bigint(3)" whenever the bound parameter type was not bigint, because parameter binding wraps the value in a cast that the bare-literal check did not fold. Evaluate the expression to a literal instead, matching how OFFSET is handled. A negative LIMIT now reports "LIMIT must not be negative" instead of soft-panicking, and a non-constant LIMIT reports "Invalid LIMIT clause: ...".

Closes: SQL-476

@def-
def- requested a review from ggevay July 24, 2026 08:29
@def-
def- requested review from a team as code owners July 24, 2026 08:29
Executing a prepared statement with a parameterized LIMIT failed with
"Top-level LIMIT must be a constant expression, got integer_to_bigint(3)"
whenever the bound parameter type was not bigint, because parameter
binding wraps the value in a cast that the bare-literal check did not
fold. Evaluate the expression to a literal instead, matching how OFFSET
is handled. A negative LIMIT now reports "LIMIT must not be negative"
instead of soft-panicking, and a non-constant LIMIT reports
"Invalid LIMIT clause: ...".

Closes: SQL-476

Co-Authored-By: Claude Fable 5 <noreply@anthropic.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