Read an out-array as callee-allocated only where the callee can allocate it - #133
Merged
estebanzimanyi merged 1 commit intoSep 3, 2026
Conversation
…ate it An `outputArrays` entry says the callee allocates an array and writes its address through the parameter, so a binding passes one pointer's worth of storage and reads the array back from it. The inference admitted every non-const `**` parameter beside a by-pointer count, and eight of the twenty-two it admitted are the other contract: `json_each`, `json_each_text`, `jsonb_each`, `jsonb_each_text` and their four `pg_` twins fill an array the CALLER allocates. A binding projecting them hands MEOS eight bytes for `count` pointers and then reads the first pointer MEOS writes as the address of the array. The element type is what separates the two, and the signatures already state it. The callee writes `*p = <the array>`, an array of `E` is spelled `E *`, so a callee-allocated parameter is spelled `E **`: `TimestampTz **bins` over the by-value element `TimestampTz`, `SpanSet ***periods` over the element pointer `SpanSet *`. Stripping both levels off `Jsonb **values` leaves `Jsonb`, a value MEOS holds by reference and never by value in an array, so no array of that element exists for MEOS to have made. The predicate now strips the two levels and admits the parameter when what remains is a pointer or one of the by-value scalars the module already names for input arrays. Fourteen entries keep the classification; the eight that fill a caller's array carry none, so a binding meets them as the plain `**` argument they are. The suite states both contracts against the pair that spells the same element two ways, `jsonb_each` beside `tdwithin_tgeoarr_tgeoarr`, and the test that reads an out-array apart from an input one takes `temporal_time_split` as its subject.
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.
An
outputArraysentry says the callee allocates an array and writes itsaddress through the parameter, so a binding passes one pointer's worth of
storage and reads the array back from it. The inference admitted every non-const
**parameter beside a by-pointer count, and eight of the twenty-two itadmitted are the other contract:
json_each,json_each_text,jsonb_each,jsonb_each_textand their fourpg_twins fill an array the CALLER allocates.A binding projecting them hands MEOS eight bytes for
countpointers and thenreads the first pointer MEOS writes as the address of the array.
The element type is what separates the two, and the signatures already state it.
The callee writes
*p = <the array>, an array ofEis spelledE *, so acallee-allocated parameter is spelled
E **:TimestampTz **binsover theby-value element
TimestampTz,SpanSet ***periodsover the element pointerSpanSet *. Stripping both levels offJsonb **valuesleavesJsonb, a valueMEOS holds by reference and never by value in an array, so no array of that
element exists for MEOS to have made. The predicate now strips the two levels
and admits the parameter when what remains is a pointer or one of the by-value
scalars the module already names for input arrays.
Fourteen entries keep the classification; the eight that fill a caller's array
carry none, so a binding meets them as the plain
**argument they are. Thesuite states both contracts against the pair that spells the same element two
ways,
jsonb_eachbesidetdwithin_tgeoarr_tgeoarr, and the test that reads anout-array apart from an input one takes
temporal_time_splitas its subject.