Repository navigation
fix: read PostgreSQL 16's 0x/0o/0b integers and digit separators - #184
Merged
Merged
Conversation
Integer bounds and elements threw on text PostgreSQL 16 and 18 read: `[0x1F,)` and
`{1_000,0o17,0b101}`. Every integer ParseValue (Int32Range, Int64Range, Int16Set, Int32Set,
Int64Set, and through them the multiranges and wrapper arities) now goes through IntegerLiteral,
measured on PostgreSQL 16 and 18: a prefix in either case, one underscore after it or between
digits, the magnitude checked before the sign so the minimum is reachable in every base, and an
OverflowException past the type as before. `0x`, `0x1__F`, `0x1F_`, `_1`, `00x1` and `0o8` still
throw, and the provider never reaches the grammar.
IntegerLiteralGrammarTests holds the measured table for int2/int4/int8 (36 of 61 rows fail with the
fix reverted; the other 25 are refusals). LiteralCorpusProbeTests gains the edge cases; its 20 #127
candidates are removed as fixed, and the hex spelling of (,max] joins the #132 candidates.
Closes #127
Found-By: OT
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 #127
Problem
Integer bounds and elements threw
FormatExceptionon text PostgreSQL 16 and later reads. Examples:Int32Range.Parse("[0x1F,)")andInt32Set.Parse("{1_000,0o17,0b101}"). This hitInt32Range,Int64Range, their multiranges,Int16Set,Int32Set,Int64Setand the wrapper sets.Change
New
src/CodoMetis.ValueRanges/Internals/IntegerLiteral.csholds PostgreSQL 16'sint2/int4/int8grammar, measured on 16 and 18, which agree:0x/0o/0bin either case followed by digits in that base;_between digits, or directly after the prefix (0x_1F);-0x80000000isint.MinValue;OverflowException, asint.Parsedid.It rejects
0x,0x1__F,0x1F_,_1,1_,00x1,0x-1,0o8,0x 1Fand1e3, as PostgreSQL does. LikeDecimalLiteral, it ignores the provider. Decimal text without separators still takes the BCL fast path.All five integer
ParseValuemethods go through it. The multiranges, the wrapper arities, JSON, theTypeConverterand the EF bridge all reach it through those methods.Docs: one paragraph in
docs/serialization.md#parse-a-literal, claim J39. The CHANGELOG entry is under 10.0.0 → Fixed.Tests
IntegerLiteralGrammarTests(core): 61 rows taken frompg_input_is_validand::int8::texton PostgreSQL 16 and 18, checked through all fiveParseValuemethods, plus the forms in range, multirange and set literals, plus overflow. With the fix reverted, 36 fail. The 25 that still pass are rows PostgreSQL also rejects, which guard against loosening too far.LiteralCorpusProbeTests(live PostgreSQL 17) has new edge-case families: either-case prefix, signed hex, underscore after the prefix, hex extremes, and the malformed forms. Its 20 Integer literals refuse the 0x/0o/0b and digit-separator forms PostgreSQL 16+ reads #127 candidates now report "candidate fixed" and are removed.(,0x7FFFFFFF]hits the existing Document (,max] at the discrete domain boundary: PostgreSQL raises integer out of range #132 divergence ((,max]needs max + 1). I registered the hex spellings for Int32 and Int64 as Document (,max] at the discrete domain boundary: PostgreSQL raises integer out of range #132 candidates beside the decimal ones; this PR doesn't fix Document (,max] at the discrete domain boundary: PostgreSQL raises integer out of range #132.Note: the JSON writer for an integer wrapper still checks the element's own text with
long.TryParse. A wrapper that formats itself as0x1Fis rejected there, while the literal and the EF bridge now read it as 31. Both sides fail loudly or agree on the value, so I left it as is.🤖 Generated with Claude Code