Skip to content

fix(rpc): run volatile set-returning functions exactly once - #107

Merged
archlemon merged 1 commit into
mainfrom
fix/volatile-rpc-once
Nov 24, 2026
Merged

archlemon merged 1 commit into
mainfrom
fix/volatile-rpc-once

Conversation

@archlemon

Copy link
Copy Markdown
Member

Closes #105

A volatile SETOF function called with count=true executed twice (page,
then total), and limit=0 on a SETOF scalar or composite one compiled to
LIMIT 0 so the function never ran, unlike SETOF <table>.

Evaluate the call once in a MATERIALIZED CTE that the page, the has_next
look-ahead and the total all read. limit=0 now runs the function once and
returns no rows for every result kind. Stable and immutable functions keep
their plan.
@archlemon
archlemon merged commit 9c0c14f into main Nov 24, 2026
4 checks passed
@archlemon
archlemon deleted the fix/volatile-rpc-once branch November 24, 2026 02:35
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.

Volatile SETOF RPCs: count=true runs the function twice; limit=0 skips scalar/composite ones

1 participant