Capture the full per-overload SQL signature from CREATE FUNCTION#39
Merged
estebanzimanyi merged 1 commit intoJul 9, 2026
Merged
Conversation
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.
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.
The catalog carried only fragments of each function's SQL-facing signature —
sqlArity(a count) andsqlReturnType(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/maxInstantareCREATE FUNCTION'd only for the ordered base types{tint,tbigint,tfloat,ttext}, but a generic "register over all temporal types" loop wrongly adds them fortbooland the geo types.Change
Parse each
CREATE FUNCTIONstatement statement-bounded (to its terminating;) and attach, per@sqlfnname, the exact list of overload signatures:A binding then emits one registration per signature over the concrete arg types — no type-scope heuristic.
minInstantlands on exactly its four overloads;endInstanton all eighteen.RETURNSclause), 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.LANGUAGE SQLdefault-arg overload (whose ownAS 'SELECT ...'has no C symbol) could bleed itsRETURNSacross the;into the next C-backed statement, corrupting 16 wrappers'sqlReturnTypewith fragments. That drops to 0.Compatibility
sqlArity,sqlArityMax,sqlReturnType,sqlReturnTypeAllkeep 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].sqlSignaturesandsqlReturnTypeAll(was 16).04398301c.