Skip to content

State the array arguments a function reads - #128

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/input-arrays
Sep 3, 2026
Merged

State the array arguments a function reads#128
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:feat/input-arrays

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

The shape says which arrays a function ANSWERS and leaves the ones it READS to
each binding to recognise, and the only thing there to recognise them by is the
length parameter's name. Those names disagree across the surface — count,
count1, size, ngeoms, keys_len, path_len, pixels_size, wkb_size
so a binding that knows some of them silently drops the rest, and
geo_cluster_kmeans, jsonb_delete_array and their kin reach no binding at
all.

shape.inputArrays states them, the sibling of arrayReturn and
outputArrays: the parameter, the parameter its length comes from, and the
element type with one pointer level off. 158 arguments across the surface.

The discriminator is the one this module already reads in the other direction.
An output array's length is passed BY POINTER, since the callee fills it in; an
input array's is passed BY VALUE, since the caller already knows it. So an
input array is a parameter that is an array of pointers or of by-value scalars
followed by a by-value integer — jsonb_each's written-back Jsonb **values
is not one, its int *count saying so.

A pointer to a MEOS VALUE type beside an integer is a value and a number, never
an array: text_left(text *txt, int n) takes one text and a character count,
jsonb_hash_extended one jsonb and a seed, interval_in one string and a
typmod. Only a pointer to a C scalar is an array of them, and char * is a
string in every binding rather than an array of characters.

Six tests hold the rule to those cases, the two that already stated an input
array is not an output one now stating what it is instead.

The shape says which arrays a function ANSWERS and leaves the ones it READS to
each binding to recognise, and the only thing there to recognise them by is the
length parameter's name. Those names disagree across the surface — `count`,
`count1`, `size`, `ngeoms`, `keys_len`, `path_len`, `pixels_size`, `wkb_size` —
so a binding that knows some of them silently drops the rest, and
`geo_cluster_kmeans`, `jsonb_delete_array` and their kin reach no binding at
all.

`shape.inputArrays` states them, the sibling of `arrayReturn` and
`outputArrays`: the parameter, the parameter its length comes from, and the
element type with one pointer level off. 158 arguments across the surface.

The discriminator is the one this module already reads in the other direction.
An output array's length is passed BY POINTER, since the callee fills it in; an
input array's is passed BY VALUE, since the caller already knows it. So an
input array is a parameter that is an array of pointers or of by-value scalars
followed by a by-value integer — `jsonb_each`'s written-back `Jsonb **values`
is not one, its `int *count` saying so.

A pointer to a MEOS VALUE type beside an integer is a value and a number, never
an array: `text_left(text *txt, int n)` takes one text and a character count,
`jsonb_hash_extended` one jsonb and a seed, `interval_in` one string and a
typmod. Only a pointer to a C scalar is an array of them, and `char *` is a
string in every binding rather than an array of characters.

Six tests hold the rule to those cases, the two that already stated an input
array is not an output one now stating what it is instead.
@estebanzimanyi
estebanzimanyi merged commit af587c6 into MobilityDB:master Sep 3, 2026
3 checks passed
@estebanzimanyi
estebanzimanyi deleted the feat/input-arrays branch September 3, 2026 01:39
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