Convert array columns inside rows to PHP arrays#19
Merged
Conversation
An array-typed column used to cross into PHP as its literal text form
("{a,b}") everywhere a whole row converts: $_TD['new']/['old'] in
triggers, rows from spi_fetch_row/spi_fetchrow/spi_each, and the
fields of composite-type arguments. Route those column values through
the same conversion arguments already get, so they arrive as real PHP
arrays -- and, since the reverse path (plphp_zval_get_cstring with
do_array) already renders PHP arrays back into array literals,
assigning an array works too, e.g. modifying $_TD['new']['tags']
before returning MODIFY.
This matches PL/Perl, which converts row fields recursively. It is a
behavior change for code that string-parsed the literal form, noted in
the CHANGELOG. Composite-typed columns inside rows still arrive as
text (converting those needs a record parser; possible follow-up).
New cases in the arrays test cover SPI rows, cursor rows, triggers
(read + append + MODIFY round trip), and composite argument fields.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Stacked on #18 (which stacks on #17); retarget as they merge. Full suite green on PG 11–18 (+
jsonb_plphp) in the pre-CI sweep.The last big ergonomic wart: an array-typed column crossed into PHP as its literal text form (
{a,b}) everywhere a whole row converts —$_TD['new']/['old']in triggers, rows fromspi_fetch_row/spi_fetchrow/spi_each, and composite arguments' fields. Column values now route through the same conversion arguments already get:The reverse path already rendered PHP arrays into array literals (via the #13 rewrite), so read-modify-write round trips work — the new tests pin SPI rows, cursor rows, the trigger append+MODIFY round trip, and composite argument fields.
Matches PL/Perl's recursive row conversion. Behavior change (CHANGELOG'd): code that string-parsed the literal form should use the array directly. Composite-typed columns inside rows still arrive as text — converting those needs a record parser, a possible follow-up.
🤖 Generated with Claude Code