Give a function the SQL surface of every wrapper it backs - #83
Merged
estebanzimanyi merged 1 commit intoAug 14, 2026
Merged
Conversation
A MEOS function often backs several PostgreSQL wrappers, each registering its own CREATE FUNCTION overloads: the ever/always pair over one `ea_*` kernel, the shift/scale/shiftScale trio over one `*_shift_scale`, send and asBinary over one `*_as_wkb`, and the argument-commuted form of an asymmetric operation (`NAD_stbox_tgeo` beside `NAD_tgeo_stbox`, both over `nad_tgeo_stbox`). `sqlSignatures` read only the first of them, so every sibling wrapper's overloads were dropped — the always half of each ever/always pair, two thirds of each shift/scale trio, and any commuted argument order. Take the union over all of them instead, scope-filtering each wrapper on its own and de-duplicating. A wrapper is shared whenever two functions name it, in whatever position, so gather the claimants of every wrapper rather than of the first alone; that brings `Temporal_scale_time` under the scope check, and its generic claimant is declared alongside its two siblings. PostgreSQL also accepts the function attributes in any order, and `aTouches(tcbuffer, cbuffer)` writes SUPPORT before the body, which parsed as the return type `boolean SUPPORT tspatial_supportfn`. Keep only the type. Deriving from MobilityDB 071d4c80de leaves the 5537 functions unchanged and takes sqlSignatures from 8234 to 9027: 111 functions gain 793 overloads and none loses any.
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 MEOS function often backs several PostgreSQL wrappers, and each wrapper
registers its own
CREATE FUNCTIONoverloads.sqlSignaturesread only thefirst of them, so every sibling wrapper's overloads were dropped.
Four shapes of that loss:
ea_dwithin_tgeo_tgeoEdwithin_tgeo_tgeo,Adwithin_tgeo_tgeoeDwithinonlyintspan_shift_scaleNumspan_shift,Numspan_scale,Numspan_shift_scaleshiftonlyset_as_wkbSet_send,Set_as_wkb*_sendonlynad_tgeo_stboxNAD_tgeo_stbox,NAD_stbox_tgeoThe last one is why a commuted overload could not be represented at all.
nearestApproachDistance(stbox, tgeompoint)is a second wrapper over the onenad_tgeo_stbox, so even a correct@csqlfn #NAD_tgeo_stbox() #NAD_stbox_tgeo()had nowhere to land — the catalog would still have carried only the first order,
and a binding projecting
sqlSignaturescould never emit the swapped onewithout hand-writing the swap itself.
The surface is now the union over every wrapper the function claims, with each
wrapper scope-filtered on its own and the result de-duplicated.
sqlfn,sqlopand
mdbCkeep naming the primary wrapper, unchanged.Two things follow from it:
so the claimant gathering no longer stops at the first. That brings
Temporal_scale_time— claimed second by all four of its claimants — underthe scope check for the first time; it is generic over
Temporal *like thetwo siblings already declared beside it, and is declared the same way.
aTouches(tcbuffer, cbuffer)is the one place MobilityDB writesSUPPORTbefore the body rather than after it, and that parsed as the return type
boolean SUPPORT tspatial_supportfn. Only the type is kept now.Measured
Derived from MobilityDB
071d4c80de, both sides in the same run:sqlSignatures8234 → 9027: 111 functions gain 793 overloads, none loses anysqlfn,sqlop,mdbC: unchanged on every functionsqlArityMaxrises on 42 (a second wrapper's wider overload),sqlArityfallson
temporal_from_wkb(Temporal_from_wkbtakes one argument whereTemporal_recvtakes three)sqlReturnTypechanges on two:tbox_outgainsasTextbesidetbox_outand so reports both, and
atouches_tcbuffer_cbufferloses the SUPPORT clausefrom its type
tests/test_sqlfn_wrappers.pycovers the commuted pair, both halves of anever/always pair, the arity widening, the attribute-before-body return type, and
that the primary wrapper still names the function. Three of its six cases fail
against the previous parser.
Suite: 214 passed, 15 skipped. Two failures in
test_familyandtest_struct_layoutare pre-existing — they reproduce unchanged on a cataloggenerated by master's parser from the same MobilityDB commit, and come from
parsing source-tree headers (approximate struct layouts) rather than installed
ones.
Not in this change
The commuted wrappers still need MEOS to name them. 79 PostgreSQL wrappers that
carry an
@sqlfnare the argument-swap of a wrapper some MEOS function claims,yet no MEOS function claims them — 171 SQL overloads,
NAD_stbox_tgeoamongthem. Some are tag repointing (
tdisjoint_geo_tcbufferexists and tags#Tdisjoint_tcbuffer_geo()); others have no MEOS symbol at all and want theone-line swap wrapper the spatial-relationship grid already uses. Both are
MobilityDB-side; this change is what makes their result representable.