Skip to content

State the arguments a forwarding SQL function passes twice - #152

Open
estebanzimanyi wants to merge 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/repeated-args
Open

estebanzimanyi wants to merge 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/repeated-args

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

A SQL function with no C symbol whose body forwards its arguments to one
C-backed signature, repeating one of them or passing a literal in place of
one, is a signature of the wrapper behind the signature it calls.
spaceSplit(tgeompoint, xsize, sorigin, bitmatrix, borderInc) is the body
SELECT spaceSplit($1, $2, $2, $2, $3, $4, $5): it is a signature of
Tgeo_space_split, and tgeo_space_split states it with
repeatedArgs: {ysize: xsize, zsize: xsize}, keyed by the C parameter the
repeat fills and valued by the C parameter the first occurrence fills, as
boundArgs keys a literal. stops(tgeompoint, minduration) is
SELECT stops($1, 0.0, $2), stated with boundArgs: {maxdist: 0.0} on its own
signature.

The signature called is the one of that name whose argument count admits
the call, defaults included, and whose argument at each position a $k fills
has the type of argument k, float8 meeting float. The arguments of a
signature fill in order the C parameters that are neither out-parameters nor
bound by the wrapper, so the argument passed at position i fills the i-th of
them. A call two signatures fit, or a function whose inputs do not line up
with the arguments of its signature, stops the catalog. A body computing an
argument, a cast or a call, is a composition and adds no signature.

Why. A binding registers one function per SQL signature and calls MEOS from
the arguments it receives. The forwarding functions are the forms a user
calls with one size for a cubic grid, and the catalog stated none of them:
their CREATE FUNCTION names no C symbol.

Measured. Over MobilityDB 8a23781e4c, 13 functions gain 39 signatures: 32
repeat an argument (spaceSplit, spaceTimeSplit, spaceBoxes, spaceTimeBoxes,
spaceTiles, spaceTimeTiles, getSpaceTile, getSpaceTimeTile), stating 48
repeatedArgs entries, and 7 pass a literal (stops, translate, scale), taking
the bound literals from 1826 to 1833. The sqlArity of 12 of them drops by
the sizes the one- and two-size forms omit. The 16 forwards over tpose and
tpcpoint call a signature that is itself a composition and add none. The
catalog is otherwise identical to the one derived without the change, and
its OpenAPI projection validates.

Witness. tests/test_sqlfn_forward.py reads a repeat and a literal as a
forward and a cast, a call, a reordering, a dropped or an unchanged argument
as none, attaches a forward to the wrapper of the signature it calls through
the type spellings, adds none for a forward calling a composition, stops on
a call two signatures fit and on inputs not lining up, and states
repeatedArgs and the forward's own boundArgs through merge_boundargs. The
suite floor goes from 337 to 352.

A SQL function with no C symbol whose body forwards its arguments to one
C-backed signature, repeating one of them or passing a literal in place of
one, is a signature of the wrapper behind the signature it calls.
spaceSplit(tgeompoint, xsize, sorigin, bitmatrix, borderInc) is the body
SELECT spaceSplit($1, $2, $2, $2, $3, $4, $5): it is a signature of
Tgeo_space_split, and tgeo_space_split states it with
repeatedArgs: {ysize: xsize, zsize: xsize}, keyed by the C parameter the
repeat fills and valued by the C parameter the first occurrence fills, as
boundArgs keys a literal. stops(tgeompoint, minduration) is
SELECT stops($1, 0.0, $2), stated with boundArgs: {maxdist: 0.0} on its own
signature.

The signature called is the one of that name whose argument count admits
the call, defaults included, and whose argument at each position a $k fills
has the type of argument k, float8 meeting float. The arguments of a
signature fill in order the C parameters that are neither out-parameters nor
bound by the wrapper, so the argument passed at position i fills the i-th of
them. A call two signatures fit, or a function whose inputs do not line up
with the arguments of its signature, stops the catalog. A body computing an
argument, a cast or a call, is a composition and adds no signature.

Why. A binding registers one function per SQL signature and calls MEOS from
the arguments it receives. The forwarding functions are the forms a user
calls with one size for a cubic grid, and the catalog stated none of them:
their CREATE FUNCTION names no C symbol.

Measured. Over MobilityDB 8a23781e4c, 13 functions gain 39 signatures: 32
repeat an argument (spaceSplit, spaceTimeSplit, spaceBoxes, spaceTimeBoxes,
spaceTiles, spaceTimeTiles, getSpaceTile, getSpaceTimeTile), stating 48
repeatedArgs entries, and 7 pass a literal (stops, translate, scale), taking
the bound literals from 1826 to 1833. The sqlArity of 12 of them drops by
the sizes the one- and two-size forms omit. The 16 forwards over tpose and
tpcpoint call a signature that is itself a composition and add none. The
catalog is otherwise identical to the one derived without the change, and
its OpenAPI projection validates.

Witness. tests/test_sqlfn_forward.py reads a repeat and a literal as a
forward and a cast, a call, a reordering, a dropped or an unchanged argument
as none, attaches a forward to the wrapper of the signature it calls through
the type spellings, adds none for a forward calling a composition, stops on
a call two signatures fit and on inputs not lining up, and states
repeatedArgs and the forward's own boundArgs through merge_boundargs. The
suite floor goes from 337 to 352.
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