Skip to content

State a C wrapper casting an argument before its call as a composition - #180

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/cast-wrapper-compositions
Oct 8, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:catalog/cast-wrapper-compositions

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

A C wrapper that converts an argument through a public cast before it calls its MEOS function
states its signature as a composition beside those A7 reads from SQL bodies:
eIntersects(tpose, geometry), whose wrapper Eintersects_tpose_geo casts with
tpoint = tpose_to_tpoint(temp) and calls eintersects_tgeo_geo(tpoint, gs), is the composition
of operand 0 through tpose_to_tpoint and operand 1 into eintersects_tgeo_geo, and leaves that
function's sqlSignatures. Each signature is traced to the wrapper whose CREATE FUNCTION states
it and each argument of the call to the SQL argument it carries; a cast is a public catalog
function of one parameter, and a wrapper casting nothing keeps its signature where it is.

PostgreSQL keeps such a wrapper for its planner support function: an inlinable SQL body is
inlined before index matching, and PostgreSQL offers an index to a support function only
for an argument that is the indexed column itself, which the cast of the column is not.

Witness: on MobilityDB master e30ef41657 the six ever relationships of tpose over geometry and
tpose (eIntersects, eDwithin) are C wrappers calling the internal ea_intersects_tgeo_geo and
ea_dwithin_tgeo_geo, which no @csqlfn names, so the catalog states none of the six; a wrapper
calling the public eintersects_tgeo_geo with a cast argument would state eIntersects(tpose,
geometry) on that function, and a binding would pass it a tpose it refuses.

Measured: over a MobilityDB tree whose six tpose wrappers cast with tpose_to_tpoint and call the
public tgeo functions, which name them in their @csqlfn, run.py states 6 C wrapper compositions,
each operand of a tpose argument through tpose_to_tpoint and the others as they are, and none of
the six signatures on the tgeo functions; over master e30ef41657 it states none, and the
functions, compositions, aggregates and type encodings of the catalog equal those over master
without the change. The suite passes, 486 tests, 25 skipped as before, the two new tests in
tests/test_compositions.py among them.

Why: the bindings reach a relationship of a derived type through the cast and the function of
its cast target, as for the SQL compositions, while PostgreSQL answers it through a C wrapper
its index serves.

A C wrapper that converts an argument through a public cast before it calls its MEOS function
states its signature as a composition beside those A7 reads from SQL bodies:
eIntersects(tpose, geometry), whose wrapper Eintersects_tpose_geo casts with
tpoint = tpose_to_tpoint(temp) and calls eintersects_tgeo_geo(tpoint, gs), is the composition
of operand 0 through tpose_to_tpoint and operand 1 into eintersects_tgeo_geo, and leaves that
function's sqlSignatures. Each signature is traced to the wrapper whose CREATE FUNCTION states
it and each argument of the call to the SQL argument it carries; a cast is a public catalog
function of one parameter, and a wrapper casting nothing keeps its signature where it is.

PostgreSQL keeps such a wrapper for its planner support function: an inlinable SQL body is
inlined before index matching, and PostgreSQL offers an index to a support function only
for an argument that is the indexed column itself, which the cast of the column is not.

Witness: on MobilityDB master e30ef41657 the six ever relationships of tpose over geometry and
tpose (eIntersects, eDwithin) are C wrappers calling the internal ea_intersects_tgeo_geo and
ea_dwithin_tgeo_geo, which no @csqlfn names, so the catalog states none of the six; a wrapper
calling the public eintersects_tgeo_geo with a cast argument would state eIntersects(tpose,
geometry) on that function, and a binding would pass it a tpose it refuses.

Measured: over a MobilityDB tree whose six tpose wrappers cast with tpose_to_tpoint and call the
public tgeo functions, which name them in their @csqlfn, run.py states 6 C wrapper compositions,
each operand of a tpose argument through tpose_to_tpoint and the others as they are, and none of
the six signatures on the tgeo functions; over master e30ef41657 it states none, and the
functions, compositions, aggregates and type encodings of the catalog equal those over master
without the change. The suite passes, 486 tests, 25 skipped as before, the two new tests in
tests/test_compositions.py among them.

Why: the bindings reach a relationship of a derived type through the cast and the function of
its cast target, as for the SQL compositions, while PostgreSQL answers it through a C wrapper
its index serves.
@estebanzimanyi
estebanzimanyi merged commit 999cc04 into MobilityDB:master Oct 8, 2026
3 checks passed
@estebanzimanyi
estebanzimanyi deleted the catalog/cast-wrapper-compositions branch October 8, 2026 23:59
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