Give each function the signatures of the types it serves - #81
Merged
estebanzimanyi merged 1 commit intoAug 13, 2026
Merged
Conversation
A PG wrapper commonly backs a whole per-type family: Set_values is the body behind getValues(intset), getValues(cbufferset) and fourteen more, and every one of those MEOS functions names that wrapper in its @csqlfn. The wrapper's signature list is therefore the union over its claimants, and attaching it whole told a binding that intset_values serves cbufferset. Of 1675 wrappers, 231 are claimed by more than one public function. Each function now keeps only the signatures its TYPE SCOPE covers, read from what MEOS itself states: its VALIDATE_* macro, the MeosType literals in its body, a class predicate it calls, or its C parameter types resolved through the catalog's base-type relations. The macros are read from their DEFINITIONS, so a class macro resolves too — VALIDATE_TGEO is written over ensure_tgeo_type_all, and a name-shaped reading would see only the single-type macros. Scopes are compared in both spellings, since SQL says integer where meostype_name says int4. Of the claimants, 720 resolve through a VALIDATE_* macro, 105 through C parameters and 82 through MeosType literals. The 27 that state nothing are declared in meta/type-scope.json with the reason each is unstated, and require_scopes fails generation on any claimant that is neither derived nor declared: guessing keeps the wrong signatures or drops real ones, and both are invisible downstream. A filtered function keeps its OWN overload, which carries its own SQL name (bigintset_in) rather than the representative the @sqlfn tag names (intset_in), so the single-name shortcut no longer drops it. Measured against the same MobilityDB commit: 5513 functions before and after, none gains a signature, 868 shrink to the types they serve. 20 keep none, each a wrapper whose overloads the claimant genuinely does not serve — the jsonb comparisons MEOS exports without a SQL declaration, and functions whose @csqlfn names a wrapper of another type.
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.
A PG wrapper commonly backs a whole per-type family.
Set_valuesis the body behindgetValues(intset),getValues(cbufferset)and fourteen more, and every one of those MEOS functions names that wrapper in its@csqlfn. A wrapper's signature list is therefore the union over its claimants, and attaching it whole saysintset_valuesservescbufferset. Of 1675 wrappers, 231 are claimed by more than one public function; a binding that trustssqlSignaturesas the type authority registers one function's body under every sibling's type.Each function keeps only the signatures its TYPE SCOPE covers, read from what MEOS states rather than from the function's name:
VALIDATE_*macro,MeosTypeliterals in its body,tnumber_type,tspatial_type, …),The macros are read from their definitions, so a class macro resolves as well:
VALIDATE_TGEOis written overensure_tgeo_type_all, and a name-shaped reading sees only the single-type macros and misses every class. Scopes match in both spellings, since a SQL signature saysintegerwheremeostype_namesaysint4.Of the claimants, 720 resolve through a
VALIDATE_*macro, 105 through C parameters and 82 throughMeosTypeliterals. The 27 that state nothing are declared inmeta/type-scope.jsonwith the reason each is unstated, andrequire_scopesfails generation on any claimant that is neither derived nor declared. Guessing is what the mechanism exists to avoid: assuming "all" keeps the wrong signatures, assuming "none" drops real registrations, and both are invisible downstream.A filtered function keeps its OWN overload, which carries its own SQL name (
bigintset_in) rather than the representative the@sqlfntag names (intset_in), so the single-name shortcut preserves exactly the signature the scope proves belongs to it.Measured against one MobilityDB commit, before and after: 5513 functions both sides, none gains a signature, 868 shrink to the types they serve (
intset_values16 → 1,cbufferset_values16 → 1), andtgeo_stboxeskeeps all 6 of the types its single C entry point genuinely serves. 20 keep none: each is a wrapper whose overloads the claimant does not serve — the jsonb comparisons MEOS exports without any SQL declaration, and functions whose@csqlfnnames a wrapper belonging to another type.tests/test_typescope.pycovers the filter, the generic case, the empty case, return-type placement, and the SQL spelling map.