Repository navigation
State a C wrapper casting an argument before its call as a composition - #180
Merged
estebanzimanyi merged 1 commit intoOct 8, 2026
Conversation
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.
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 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.