Skip to content

Answer an empty set-element result as NULL rather than raising - #355

Merged
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:duck/set-element-empty-result
Aug 29, 2026
Merged

Answer an empty set-element result as NULL rather than raising#355
estebanzimanyi merged 1 commit into
MobilityDB:mainfrom
estebanzimanyi:duck/set-element-empty-result

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

MEOS returns the empty set as a NULL pointer, so setMinus('{3}'::intset, 3),
setIntersection('{1}'::intset, 2) and their bigint, float, date, timestamptz
and text twins raise "Invalid Input Error: Null pointer not allowed" where the
answer is the empty set.

The generated body for a set with a scalar element marshals its result through
SetToBlobN, which carries a NULL pointer to SQL NULL. That is what PostgreSQL
answers: Setop_set_base in mobilitydb/src/temporal/set_ops.c, the shared
wrapper over intersection_set_value and minus_set_value, reads
"if (! result) PG_RETURN_NULL()". The (Set,Set) body beside it already answers
NULL for the same emptiness.

The registered surface is unchanged: duckdb_functions() reports the same 11625
rows, the emitted registration set is identical at 6065 lines, and the line
movement in the generated chunks is their split points shifting. setMinus of
{1,3,5} and 3 answers {1, 5}, setUnion of {1,3} and 9 answers {1, 3, 9}, and
setIntersection of {1,3} and 3 answers {3}.

MEOS returns the empty set as a NULL pointer, so setMinus('{3}'::intset, 3),
setIntersection('{1}'::intset, 2) and their bigint, float, date, timestamptz
and text twins raise "Invalid Input Error: Null pointer not allowed" where the
answer is the empty set.

The generated body for a set with a scalar element marshals its result through
SetToBlobN, which carries a NULL pointer to SQL NULL. That is what PostgreSQL
answers: Setop_set_base in mobilitydb/src/temporal/set_ops.c, the shared
wrapper over intersection_set_value and minus_set_value, reads
"if (! result) PG_RETURN_NULL()". The (Set,Set) body beside it already answers
NULL for the same emptiness.

The registered surface is unchanged: duckdb_functions() reports the same 11625
rows, the emitted registration set is identical at 6065 lines, and the line
movement in the generated chunks is their split points shifting. setMinus of
{1,3,5} and 3 answers {1, 5}, setUnion of {1,3} and 9 answers {1, 3, 9}, and
setIntersection of {1,3} and 3 answers {3}.
@estebanzimanyi
estebanzimanyi merged commit 075c483 into MobilityDB:main Aug 29, 2026
10 checks passed
@estebanzimanyi
estebanzimanyi deleted the duck/set-element-empty-result branch August 29, 2026 09:57
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