Name the C value feeding each column of a returned SQL row - #151
Merged
estebanzimanyi merged 1 commit intoSep 30, 2026
Merged
Conversation
A SQL signature returning a row lists its columns, each naming the C value
that feeds it. PostgreSQL declares the columns of a function returning
record as its OUT arguments, and those of a function returning a composite
type as the members of that type. An OUT argument is no input, so it leaves
args, argDefaults and required: eDisjointPairs(tgeometry[], tgeometry[]) is
{args: [tgeometry[], tgeometry[]], ret: record, retSet: true, columns:
[i, j]}: the two arrays are its only arguments.
attach_row_sources matches each column to its C source by type, so the SQL
column order and the C parameter order need not agree. from is return, the
value or array the function returns, or an out-parameter, with element or
field inside it: valueTimeSplit rows (number, time, tnumber) read the
out-parameters value_bins and time_bins and the returned fragments,
dynTimeWarpPath rows (i, j) the fields of each returned Match, quaternion
the four elements of the returned array. A bool returned beside
out-parameters says whether there is a row and feeds no column, and a
struct a class stands for, a TBox tile, is one value and not its fields.
meta/sql-columns.json states what only the wrapper computes: the index of a
tile numbers the rows from 1 (from: ordinal), and the …Pairs wrappers add 1
to the C indices i and j to make them SQL array positions (offset: 1). A row
with a column no C value feeds, fed alike by two, or with a C value feeding
no column stops the catalog.
Why. A binding that returns the rows of a SQL function reads them from the
C call: it has to know which C value is which column, and which argument of
a record-returning signature is passed rather than returned.
Measured. Over MobilityDB 8a23781e4c, 147 SQL signatures carried by 64
functions state their columns: 37 returning record (the …Pairs kernels) and
110 returning one of 61 composite types. Of their columns, 200 read the C
return (95 the value or array whole, 74 an element plus the declared
offset, 24 a struct field, 7 an element of a fixed array), 96 an
out-parameter, and 18 the ordinal. The 37
record signatures drop their OUT arguments from args, and the 12 …Pairs
functions their sqlArity from 4, 5 or 6 to 2 or 3. The catalog is otherwise
identical to the one derived without the change.
Witness. tests/test_sqlfn_rows.py takes the OUT arguments out of args and
the members of a composite return type as columns, matches columns by type
whatever their order, reads struct fields, fixed-array elements and a
pair's elements beside an out-parameter array, applies ordinal and offset
only where declared, stops on an unfed, doubly fed or surplus source, and
validates meta/sql-columns.json against its schema. The suite floor goes
from 317 to 337.
estebanzimanyi
force-pushed
the
catalog/row-columns
branch
from
September 30, 2026 14:49
44ad1a6 to
c4515c0
Compare
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 SQL signature returning a row lists its columns, each naming the C value
that feeds it. PostgreSQL declares the columns of a function returning
record as its OUT arguments, and those of a function returning a composite
type as the members of that type. An OUT argument is no input, so it leaves
args, argDefaults and required: eDisjointPairs(tgeometry[], tgeometry[]) is
{args: [tgeometry[], tgeometry[]], ret: record, retSet: true, columns:
[i, j]}: the two arrays are its only arguments.
attach_row_sources matches each column to its C source by type, so the SQL
column order and the C parameter order need not agree. from is return, the
value or array the function returns, or an out-parameter, with element or
field inside it: valueTimeSplit rows (number, time, tnumber) read the
out-parameters value_bins and time_bins and the returned fragments,
dynTimeWarpPath rows (i, j) the fields of each returned Match, quaternion
the four elements of the returned array. A bool returned beside
out-parameters says whether there is a row and feeds no column, and a
struct a class stands for, a TBox tile, is one value and not its fields.
meta/sql-columns.json states what only the wrapper computes: the index of a
tile numbers the rows from 1 (from: ordinal), and the …Pairs wrappers add 1
to the C indices i and j to make them SQL array positions (offset: 1). A row
with a column no C value feeds, fed alike by two, or with a C value feeding
no column stops the catalog.
Why. A binding that returns the rows of a SQL function reads them from the
C call: it has to know which C value is which column, and which argument of
a record-returning signature is passed rather than returned.
Measured. Over MobilityDB 8a23781e4c, 147 SQL signatures carried by 64
functions state their columns: 37 returning record (the …Pairs kernels) and
110 returning one of 61 composite types. Of their columns, 200 read the C
return (95 the value or array whole, 74 an element plus the declared
offset, 24 a struct field, 7 an element of a fixed array), 96 an
out-parameter, and 18 the ordinal. The 37
record signatures drop their OUT arguments from args, and the 12 …Pairs
functions their sqlArity from 4, 5 or 6 to 2 or 3. The catalog is otherwise
identical to the one derived without the change.
Witness. tests/test_sqlfn_rows.py takes the OUT arguments out of args and
the members of a composite return type as columns, matches columns by type
whatever their order, reads struct fields, fixed-array elements and a
pair's elements beside an out-parameter array, applies ordinal and offset
only where declared, stops on an unfed, doubly fed or surplus source, and
validates meta/sql-columns.json against its schema. The suite floor goes
from 317 to 337.