Repository navigation
fix: read array_in's dimension decoration and nested empty arrays in value sets - #186
Merged
Merged
Conversation
…value sets
Value set literals threw on two forms PostgreSQL reads as one-dimensional arrays: the decoration
`[lower:upper]=` (or `[upper]=`), which array_out prints whenever the lower bound is not 1, so a
column written as '[0:1]={1,2}' could not be read back; and empty arrays nested to one depth,
`{{}}` and `{{},{}}`. SetFormat.Parse now reads the decoration and drops it, as PostgreSQL 16 and 18
do (they agree): signed decimal int4 bounds with no whitespace inside the brackets, upper + 1
representable, whitespace around '=', and the element count as written, duplicates included, equal
to upper - lower + 1. A second bracket pair is a second dimension and still refused. The nested
empties read as {} as PostgreSQL 17 and 18 do; PostgreSQL 16 refuses them, which the docs say.
SetDimensionDecorationTests holds the measured table (22 accepted rows fail with the fix reverted;
the 33 refusals pass either way). LiteralCorpusProbeTests gains the edges for all 28 value set
types; its 28 #128 candidates are removed as fixed.
Closes #128
Found-By: OT
Defect-Class: LIT
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The sets read {{}} as {} as PostgreSQL 17 and 18 do, and docs/value-sets.md says 16 rejects it.
LiteralGrammarParityTests now asks each version (the suite's 17, and its own 16 and 18 containers),
so the test fails when either side of the split moves rather than the sentence going stale; a
nested array holding an element stays two-dimensional everywhere and rejected here. Claim S21
holds the sentence.
Shown to fail both ways: without the library's nested-empty reading ("Int32Set does not read {{}}
as {}"), and with the expectation moved to 16 ("PostgreSQL 16 rejects {{}}").
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # CHANGELOG.md # test/oracles/candidates.json
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 #128
Problem
Value set literals threw
FormatExceptionon two forms PostgreSQL'sarray_inreads as one-dimensional arrays:[lower:upper]=or[upper]=.array_outprints it whenever the lower bound isn't 1, so the library couldn't read back a column another tool wrote as'[0:1]={1,2}'.{{}}and{{},{}}.Change
SetFormat.Parse(src/CodoMetis.ValueRanges/Internals/SetFormat.cs) now reads the decoration and drops it, since a set has no index. Every value set type and every entry point goes through it. The rule was measured on PostgreSQL 16 and 18, which agree on every decoration row:int4, with no whitespace inside the brackets;upper + 1must not overflow, so[2147483647:2147483647]fails;=;upper - lower + 1, so[1:1]={1,1}fails and[1:2]={1,1}is{1};[1:0]={}and[1:1]={{}}fail;{}when they are regular (same depth throughout):{{}},{{},{}},{ {} },{{{}},{{}}}. Mixed depths such as{{},{{}}}fail, as on the server.docs/value-sets.md#parse-and-print-literals(claim S20). The CHANGELOG entry is under 10.0.0 → Fixed.The version split, confirmed by the 10.0.0 assessment session. PostgreSQL 16 rejects
{{}}and its variants, while 17 and 18 read them as{}. The sets follow 17 and later. This is safe because the library binds values, never this text, and the server never prints{{}}, so only input you write yourself (a literal, JSON, a query string, theTypeConverter) reaches it.docs/value-sets.mdnames both versions (claim S21).{{1}}and every other multi-dimensional form still fail. Also measured: PostgreSQL 16 rejects a vertical tab before{and 18 accepts it. The parser follows 18, as the existing whitespace rule already does.Tests
SetDimensionDecorationTests(core): 55 literals measured withpg_input_is_validon 16 and 18, plus every family. With the fix reverted, 23 fail (all 22 accepted rows and the every-family test). The 33 rejection rows pass either way; they guard against loosening too far.LiteralGrammarParityTests.NestedEmptyArrays_ReadAsPostgres17AndLaterReadThem_AndPostgres16Rejectsasks PostgreSQL 16, 17 and 18 directly; 16 and 18 run in containers of the test's own. It fails if either side of the split moves, or if a nested array holding an element stops being two-dimensional. I made it fail both ways: without the library's nested-empty reading, and with the expectation moved to 16.LiteralCorpusProbeTests(live PostgreSQL 17, all 28 value set types) gains the accepted and malformed edges. Its 28 Value set literals refuse array_in's dimension decoration ([1:1]={…}) and {{}} #128 candidates now report "candidate fixed" and are removed.LiteralGrammarParityTestsstill passes.🤖 Generated with Claude Code