Emit a NULL row for return_next(null) on a composite set - #39
Open
sfc-gh-okalaci wants to merge 1 commit into
Open
Emit a NULL row for return_next(null) on a composite set#39sfc-gh-okalaci wants to merge 1 commit into
sfc-gh-okalaci wants to merge 1 commit into
Conversation
sfc-gh-okalaci
force-pushed
the
up/07-validator-and-cache
branch
from
August 18, 2026 09:15
f2d5dcd to
e7fa72b
Compare
sfc-gh-okalaci
force-pushed
the
up/08-null-rows
branch
from
August 18, 2026 09:15
b9fc8f2 to
c78b72f
Compare
sfc-gh-okalaci
force-pushed
the
up/07-validator-and-cache
branch
from
August 18, 2026 09:24
e7fa72b to
401b753
Compare
sfc-gh-okalaci
force-pushed
the
up/08-null-rows
branch
from
August 18, 2026 09:24
c78b72f to
948f5a7
Compare
return_next(null) on a set-returning function with a composite result type dropped the row silently. A caller counting rows got a different answer from the one it asked for, with nothing to indicate a row had been discarded. It now emits a row whose every column is NULL, which is what a null row means in SQL. Adds sql/pg_return_next_null_row.sql, covering a composite set with null rows interleaved with real ones.
sfc-gh-okalaci
force-pushed
the
up/07-validator-and-cache
branch
from
August 18, 2026 09:29
401b753 to
0711556
Compare
sfc-gh-okalaci
force-pushed
the
up/08-null-rows
branch
from
August 18, 2026 09:29
948f5a7 to
49c2b80
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
return_next(null)on a set-returning function with a composite result type dropped therow silently. A caller counting rows got a different answer from the one it asked for,
with nothing to indicate a row had been discarded — the failure is invisible unless you
already know the expected count.
It now emits a row whose every column is NULL, which is what a null row means in SQL.
sql/pg_return_next_null_row.sqlcovers a composite set with null rows interleaved withreal ones, so both the null and the non-null path are pinned.
Commits
Emit a NULL row for return_next(null) on a composite setWhy this is one commit rather than a group
The other null-and-undefined fixes that would naturally sit beside it — reporting SQL
NULL through
fcinfoon the composite, record and fallback paths; treating anull or undefined value as SQL NULL for an array type; converting an
undefinedjsonbarray element to
null; reading the column value out of a row object for asingle-column set — all depend on a larger rework of value conversion that is not part
of this series. Attempted separately, three of them conflict in
src/types.cand twoterminate the backend, because the null checks and the conversion dispatch they sit in
are the same piece of code.
They are held back deliberately rather than split badly, and will follow with that
rework.
The commit builds from clean and passes the full ordered suite on its own, on PostgreSQL
17, and is green on 16, 17, 18 and 19beta3 with
pljs.memory_limit=64and underAddressSanitizer.