Repository navigation
fix: refuse a ragged nest of empty arrays in value set literals - #240
Merged
Merged
Conversation
Value sets read {{{},{}},{{}}} and {{{}},{{},{}}} as {}, though PostgreSQL 16, 17 and 18 all
refuse them: IsNestOfEmptyArrays compared only the depth of siblings. PostgreSQL 17 and 18 read a
nest only when it is rectangular, every sibling the same shape at every level, which is now what
the walk compares (a shape signature per sub-array). Measured on 16, 17 and 18.
SetDimensionDecorationTests, LiteralGrammarParityTests' nested-empty test and the corpus probe
gain the ragged rows (refused) and the rectangular ones (read as {} on 17+, refused by 16). With the
depth-only walk restored: 5 unit rows fail, and 29 live tests on 16 and on 18.
Closes #231
Found-By: CA
Defect-Class: LIT
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Closes #231
Problem
Value sets read a ragged nest of empty arrays as
{}:Int32Set.Parse("{{{},{}},{{}}}")and"{{{}},{{},{}}}"both returned{}. PostgreSQL 16, 17 and 18 all reject them.SetFormat.IsNestOfEmptyArrayschecked only that siblings reached the same depth. This hit every value set type and every entry point throughSetFormat, including JSON and the TypeConverter. The behaviour is new in 10.0.0 (#128), so nothing shipped with it.Change
The walk now builds a shape signature for each sub-array:
0for{}, andn,childfor n siblings that all have the same shape. A sibling whose shape differs ends the walk. This matches what PostgreSQL 17 and 18 read: a nest only when it is rectangular.Measured with
pg_input_is_valid(…, 'int4[]'):{{{},{}},{{},{}}},{{{{}}},{{{}}}},{{{},{}},{{},{}},{{},{}}},{{{{}},{{}}},{{{}},{{}}}}{}{}{{{},{}},{{}}},{{{}},{{},{}}},{{{},{},{}},{{},{}}},{{{{}},{{}}},{{{}},{{},{}}}},{{{{}},{{}}},{{{}}}}{}before)Tests
SetDimensionDecorationTestsgains the rectangular rows (accepted) and the ragged rows (rejected).NestedEmptyArrays_ReadAsPostgres17AndLaterReadThem_AndPostgres16Rejectsand the corpus probe gain both kinds too; the probe's 16/17 split set includes the new rectangular rows.ragged-nest-read-as-empty.patch(the depth-only walk).oracles.cs seeds ragged-nestreports it CAUGHT byLiteralCorpusProbeTests(28 of 49) andLiteralGrammarParityTests.No changelog line: the 10.0.0 entry for #128 still says what reads, and this behaviour never shipped.
🤖 Generated with Claude Code