Skip to content

Capture wrapper-bound literals as shape.boundArgs#60

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/boundargs-wrapper-literals
Jul 16, 2026
Merged

Capture wrapper-bound literals as shape.boundArgs#60
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/boundargs-wrapper-literals

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

A MEOS function's C signature can be wider than the SQL surface a binding
exposes. The MobilityDB PostgreSQL wrapper reads some arguments from the caller
(PG_GETARG_*) and binds the remaining scalar inputs to fixed literals. For
example valueAtTimestamp(temp, t) is 2-arg in SQL, yet the wrapper
Temporal_value_at_timestamptz calls
temporal_value_at_timestamptz(temp, t, true, &result)strict is bound to
true and result is an out-param.

shape.outParams already folds the trailing out-param. This adds the input-side
sibling shape.boundArgs ({param_name: literal}): a new parser pass reads each
wrapper body and records, per MEOS function, the literal bound to any argument
not sourced from PG_GETARG_* (a PG_GETARG call, or a local so-assigned, is a
caller argument; &name is an out-param; only a genuine literal — true/false,
a number, NULL, or an UPPERCASE enum/macro — is recorded). A binding generated
from the catalog emits the bound literal for those params
(fn(temp, t, /*strict*/true, &out)) while the SQL signature stays narrow,
instead of hand-writing the constant.

Across the current catalog this captures 27 accessors, including
temporal_value_at_timestamptz ({strict: true}), the *_out decimal-digit
defaults, the *_as_wkb variant, the *_shift_scale* flags,
temporal_append_tinstant ({maxdist, maxt, expand}), and
union_{s,t}box_{s,t}box ({strict: true}).

The pass mirrors parser/outparam.py and slots into run.py after the
@sqlfn wrapper map is attached (it needs mdbC). tests/test_boundargs.py
covers the hidden-literal capture, caller-arg exclusion, transform-local
exclusion, and multi-literal (NULL/number/bool) cases.

A MobilityDB PG wrapper can bind a MEOS input to a fixed literal instead of
exposing it as a SQL argument: valueAtTimestamp is 2-arg in SQL, yet the wrapper
calls temporal_value_at_timestamptz(temp, t, true, &result), hiding strict=true.
A binding generated purely from the catalog cannot form that call without the
constant.

Add a parser pass that reads each PG wrapper body and records, per MEOS
function, the literal bound to any argument that is not sourced from PG_GETARG,
as shape.boundArgs — the input-side sibling of shape.outParams. A generator
emits the bound literal for those params while the SQL signature stays narrow.
@estebanzimanyi
estebanzimanyi merged commit 970823a into MobilityDB:master Jul 16, 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