Skip to content

Capture the full per-overload SQL signature from CREATE FUNCTION#39

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/sql-signatures
Jul 9, 2026
Merged

Capture the full per-overload SQL signature from CREATE FUNCTION#39
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/sql-signatures

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

The catalog carried only fragments of each function's SQL-facing signature — sqlArity (a count) and sqlReturnType (the return only). Without the concrete argument types, a binding generator cannot know which types a function is actually registered for, so it falls back to type-scope heuristics and over-registers. Example: minInstant/maxInstant are CREATE FUNCTION'd only for the ordered base types {tint,tbigint,tfloat,ttext}, but a generic "register over all temporal types" loop wrongly adds them for tbool and the geo types.

Change

Parse each CREATE FUNCTION statement statement-bounded (to its terminating ;) and attach, per @sqlfn name, the exact list of overload signatures:

sqlSignatures: [{args: [type, ...], ret: type}, ...]

A binding then emits one registration per signature over the concrete arg types — no type-scope heuristic. minInstant lands on exactly its four overloads; endInstant on all eighteen.

  • Argument types are resolved mechanically, no hardcoded type list: a type vocabulary is gathered from the unambiguous positions (single-token bare args + every RETURNS clause), then each argument's type is the longest trailing run of tokens in that vocabulary — so a named argument (dist float, lowerInc boolean) yields its type, not its name.
  • Statement-bounding also fixes return-type extraction: a LANGUAGE SQL default-arg overload (whose own AS 'SELECT ...' has no C symbol) could bleed its RETURNS across the ; into the next C-backed statement, corrupting 16 wrappers' sqlReturnType with fragments. That drops to 0.

Compatibility

sqlArity, sqlArityMax, sqlReturnType, sqlReturnTypeAll keep their existing meaning (now derived from the per-overload list), so current consumers are unaffected.

Verification

  • minInstant/maxInstant[tint,tbigint,tfloat,ttext]; endInstant → all 18 types; tintInst[tint].
  • 0 garbage in sqlSignatures and sqlReturnTypeAll (was 16).
  • Full test suite green (156 passed, 8 skipped); regen clean against MobilityDB master 04398301c.

The catalog carried only fragments of each function's SQL-facing signature:
sqlArity (a count) and sqlReturnType (the return only). Without the concrete
argument types, a binding generator cannot know which types a function is
actually registered for, so it falls back to type-scope heuristics — and
over-registers. For example minInstant/maxInstant are CREATE FUNCTION'd only
for the ordered base types {tint,tbigint,tfloat,ttext}, but a generic
"register over all temporal types" loop wrongly adds them for tbool and the
geo types.

Parse each CREATE FUNCTION statement statement-bounded (to its terminating ';')
and attach, per @sqlfn name, the exact list of overload signatures as
sqlSignatures: [{args, ret}]. A binding then emits one registration per
signature over the concrete arg types, with no type-scope heuristic:
minInstant lands on exactly its four overloads, endInstant on all eighteen.

Argument types are resolved mechanically, with no hardcoded type list: a type
vocabulary is gathered from the unambiguous positions (single-token bare args
and every RETURNS clause), then each argument's type is the longest trailing
run of tokens in that vocabulary, so a named argument (dist float,
lowerInc boolean) yields its type, not its name.

Bounding to the statement also fixes the return-type extraction: a LANGUAGE SQL
default-arg overload (whose own AS 'SELECT ...' has no C symbol) could bleed its
RETURNS across the ';' into the next C-backed statement, corrupting sixteen
wrappers' sqlReturnType with fragments. That drops to zero.

sqlArity, sqlArityMax, sqlReturnType and sqlReturnTypeAll keep their existing
meaning (now derived from the per-overload list), so current consumers are
unaffected.
@estebanzimanyi estebanzimanyi merged commit af0264b into MobilityDB:master Jul 9, 2026
2 checks passed
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