Convert composite values structurally, in both directions#25
Merged
Conversation
Completes the structural-conversion work begun with array columns: composite-typed columns in rows, the fields of composite arguments, and composites inside arrays now arrive in PHP as associative arrays, recursively (a composite containing arrays containing composites nests all the way down). The reverse direction works symmetrically: a PHP array destined for a composite-typed slot -- a return value, a return_next row's column, an OUT argument, or a trigger MODIFY field -- is rendered as a record literal, so nested structures can be built from plain PHP arrays and modified in place in triggers. The machinery is a parser for the composite output format (quote and backslash doubling, empty-field NULLs, dropped-column skipping), mirrored by a record-literal builder that always double-quotes non-null fields; the array parser and builder gained an element-type parameter so composite elements convert too. Column/field semantics match row columns (scalars stay strings); the per-argument element type replaces the old arg_is_array flag. Also accept anycompatible and anycompatiblearray as polymorphic argument/return types on PostgreSQL 13+ (an arrays_1.out variant covers 11/12, where the types do not exist). New regression cases: composite columns with nested composite and array fields (with embedded quotes, commas, and parentheses), composite arguments, composites inside array arguments, building a nested composite from associative arrays, trigger MODIFY through a nested composite field, NULL fields in both directions, and the anycompatible polymorphics. 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.
Completes the structural-conversion story begun with array columns in 2.3.0. Full suite green on PG 11–18 +
jsonb_plphpin the container sweep; CI (including the new ASAN job) validates on this PR.Forward
Composite-typed columns in rows, fields of composite arguments, and composites inside arrays now arrive as associative PHP arrays — recursively:
Reverse (symmetric)
A PHP array destined for a composite slot — return value,
return_nextcolumn, OUT argument, or triggerMODIFYfield — renders as a record literal:Implementation: a parser for the composite output format (quote/backslash doubling, empty-field NULLs, dropped columns) mirrored by an always-quoting record-literal builder; the array parser/builder gained an element-type parameter so composite elements convert too. Escaping torture cases (embedded quotes, commas, parens, backslashes) are pinned in the tests both directions.
Rider
anycompatible/anycompatiblearrayaccepted as polymorphics on PG 13+ (anarrays_1.outvariant covers 11/12 where the types don't exist).🤖 Generated with Claude Code