GeezerVison is showing github.com — fix(#12082): read SQL integer literals with a leading 0 as octal by shaunpatterson · Pull Request #12093 · ArcadeData/arcadedb
Conversation
Fixes #12082
Summary
sql-syntax.adoc (section Numbers) documents octal integer literals (010 is 8, -065 is -53, 010L is 8) and the SQL lexer has an OCTAL_LITERAL rule, but the parser read every non-hex INTEGER_LITERAL in base 10.
Measured with the repro script over HTTP, one fresh database, on main a7304ab2aa and on a container running this branch's engine jar:
| statement |
documented |
main a7304ab2aa |
this branch |
SELECT 010 AS a |
8 |
10 |
8 |
SELECT -065 AS b |
-53 |
-65 |
-53 |
SELECT 010L AS c |
8 |
10 |
8 |
SELECT 0x10 AS hex |
16 |
16 |
16 |
The other sections of the repro script (other issues) answer the same on both.
Cause
SQLASTBuilder.parseIntegerLiteral(String) picked radix 16 for a 0x prefix and radix 10 for everything else. The JavaCC-era PInteger.radix() read a leading 0 as base 8.
Fix
parseIntegerLiteral picks radix 8 for a leading 0 followed by more digits. 0 stays 0, 0x stays hex, the L suffix and the int-then-long widening are unchanged. Every octal token is valid base 8: the lexer's OCTAL_LITERAL is '0' [0-7]*, so 08 was never one token. It is the reader of every numeric literal: expressions, values written by INSERT and UPDATE, LIMIT, SKIP, MAXDEPTH, TOP/MIN_COUNT and FACETS bounds.
- New
parseNegatedLongLiteral: the Long.MIN_VALUE fold of a negated literal whose magnitude overflows a long, now also for the octal spelling (-01000000000000000000000). Hexadecimal stays as it was (not folded). The parser, the FACETS bounds and the literal parameterization of Design: parameterize literals before the SQL/Cypher statement-cache lookup (split from #8286) #8307 all use it, so the statement cache and the parser agree: SELECT 10 AS v and SELECT 010 AS v share one cached statement shape and answer 10 and 8.
- The bounds of the integer range tokens (
[1..3], [1...3], lexed as one token) read octal too (parseRangeBound), so they agree with [1 .. 3], which goes through the expression parser. Hexadecimal and the L suffix are still refused there.
Positions that name something with a number are not numeric literals and stay decimal, as they always were: the DDL counts and sizes (BUCKETS, PAGESIZE, SHARDS, RETENTION, COMPACTION, REFRESH EVERY, RETRY/WAIT, COMMIT RETRY), the bucket ids (bucket:N, DROP/TRUNCATE BUCKET, CHECK DATABASE BUCKET, bucketIdentifier) and the $N parameters. BUCKETS 010 is ten buckets and bucket:010 is bucket 10, like #10:0 and the parts of a RID (#12:010 is #12:10, as new RID("#12:010") reads it): one bucket number addresses one bucket whatever its spelling, and no hexadecimal or L suffix is newly accepted in those positions (the maintainers kept them decimal-only on #9122).
Before changing behaviour I searched the test sources of every module and the asciidoc manual for SQL with a bare leading-zero integer literal (outside quotes, also bucket:0N, #N:0N, ranges and $0N): no test or documented statement depends on the decimal reading. [INFERENCE] A user statement that writes a zero-padded number unquoted (SET code = 007, LIMIT 010) changes value, also when kept as text and parsed again later (a stored view or trigger definition, a saved query); one with an 8 or 9 after the leading 0 (0089) never lexed as one number.
Tests
New Issue12082SqlOctalLiteralTest (engine, com.arcadedb.query.sql.antlr), 8 tests:
- expressions:
010 = 8 (Integer), -065 = -53, 010L = 8L (Long), 0 = 0, 07 = 7, 01 = 1, 0x10 = 16, 10 = 10
- long bounds:
0777777777777777777777 = Long.MAX_VALUE, -01000000000000000000000 (with and without L) = Long.MIN_VALUE, 020000000000 widens to 2147483648L, one more than the magnitude of Long.MIN_VALUE is still an overflow
- values written by INSERT and UPDATE (
n = 010 reads 8, m = -065 reads -53, k = 011 reads 9, WHERE n = 010 matches)
LIMIT 010 returns 8 rows, SKIP 010 skips 8, l[01..010], l[01...010] and their spaced forms slice 1..7 and 1..8, l[010] is l[8]; hexadecimal and L in the range token are still refused, [08..10] and [1..09] are still syntax errors
- decimal positions:
BUCKETS 010 creates 10 buckets, BUCKETS 0x10 and BUCKETS 10L are still refused, #NN:010 is #NN:10; on the parsed statement (independent of the bucket ids a database holds) bucket:010, DROP BUCKET 010 and TRUNCATE BUCKET 010 name the bucket 10, #010:010 is bucket 10 position 10, and DROP BUCKET 0x10 / TRUNCATE BUCKET 0x10 are still refused
parseNegatedLongLiteral directly: the magnitude of Long.MIN_VALUE in decimal and octal, with and without L, one more is an overflow, a hexadecimal magnitude is refused
- statement cache:
SELECT 10 AS v, SELECT 010 AS v, SELECT 10 AS v answer 10, 8, 10; WHERE n = 10 and WHERE n = 010 match different records; a negated octal (-010, -010L, -0) and the Long.MIN_VALUE fold in a WHERE match as the parser reads them
Failing-first: with engine/src/main from origin/main the octal tests fail (expected: 8 but was: 10, CommandSQLParsingException: Invalid integer: 0777777777777777777777); the tests of the decimal positions pass on main as well, they pin the decision.
SQL packages (com.arcadedb.query.sql.**) of the engine module: 4903 tests, 0 failures, 0 errors, 8 skipped.
Summary by CodeRabbit
- New Features
- SQL integer literals now support decimal, hexadecimal, and octal formats, including values larger than the standard integer range.
- Negative integer literals can represent the minimum long value across supported formats.
- Bug Fixes
- Record ID components continue to be interpreted as decimal, regardless of the integer formats supported elsewhere.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…octal
sql-syntax.adoc documents 010 = 8 and -065 = -53, and the SQL lexer has an
OCTAL_LITERAL rule, but SQLASTBuilder.parseIntegerLiteral read every
non-hex INTEGER_LITERAL in base 10 (the JavaCC-era PInteger.radix() read
it in base 8).
parseIntegerLiteral now picks radix 8 for a leading 0 followed by more
digits. Every other place that turned an INTEGER_LITERAL into a number
with Integer.parseInt/Long.parseLong (bucket ids and bucket:N, BUCKETS,
PAGESIZE, SHARDS, RETENTION, COMPACTION, downsampling tiers, RETRY/WAIT,
REFRESH EVERY, COMPACTION THRESHOLD, $N, integer ranges) goes through the
same reading, as does the Long.MIN_VALUE fold of a negated literal (also in
FACETS bounds and the literal parameterizer). RID parts stay decimal, as
the RID's own text form is.
coderabbitai
Bot
commented
Nov 16, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Walkthrough
-
The SQL AST builder now parses integer literals as decimal, hexadecimal, or octal, and uses shared radix-aware parsers across integer-consuming SQL paths. Directly negated long magnitudes can produce Long.MIN_VALUE. RID components remain decimal.
Changes: SQL integer literal parsing
| Layer / File(s) |
Summary |
Radix-aware parsing and boundary handling engine/src/main/java/com/arcadedb/query/sql/antlr/SQLASTBuilder.java, engine/src/main/java/com/arcadedb/query/sql/antlr/SQLLiteralParameterizer.java |
Shared helpers parse decimal, hexadecimal, and octal values as signed ints or longs. Directly negated long magnitudes support Long.MIN_VALUE; the FACETS and parameterizer paths use the negated-long helper. |
SQL AST integer consumers engine/src/main/java/com/arcadedb/query/sql/antlr/SQLASTBuilder.java, engine/src/test/java/com/arcadedb/query/sql/antlr/Issue12082SqlOctalLiteralTest.java |
Integer-consuming SQL paths use the shared parsers. RID components remain decimal. Tests cover octal interpretation across expressions, data operations, bucket addressing, ranges, boundaries, and cached queries. |
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Low
Possibly related PRs
- ArcadeData/arcadedb#9122: It defines leading-zero integer literals as decimal, while this change interprets them as octal.
- ArcadeData/arcadedb#9611: It adds literal parameterization before statement and plan cache lookup, which interacts with the integer value conversion changed here.
Suggested labels: sql
Suggested reviewers: lvca, robfrank
Merge Risk: Low · up to 58fe2
-
The change adds octal SQL literals as intended. It also lets hexadecimal values through in some DDL count and size positions that previously rejected them. This is low impact, and the fix is to keep those positions decimal-only.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the main change: SQL integer literals with a leading 0 are now read as octal, and it references issue #12082. It is short, specific, and matches the objectives and the file changes in … |
| Linked Issues check |
 |
[#12082] The issue requests that SQL integer literals with a leading zero be read as octal (as sql-syntax.adoc documents and the lexer's OCTAL_LITERAL rule recognises), or that the docs drop the octal… |
| Out of Scope Changes check |
 |
[#12082] The changes are the octal parsing rule, its shared helpers, and the routing of SQL INTEGER_LITERAL conversions through those helpers (bucket IDs, BUCKETS/PAGESIZE, SHARDS, RETENTION, downsamp… |
| Description check |
 |
The description follows the repository template. It has a summary, a cause, a fix, tests, and a failing-first note. It names issue #12082 in a 'Fixes' line. It does not use the template headings (What… |
Full details: Title check
-
Explanation
The title names the main change: SQL integer literals with a leading 0 are now read as octal, and it references issue #12082. It is short, specific, and matches the objectives and the file changes in SQLASTBuilder, SQLLiteralParameterizer, and the new octal test.
Full details: Linked Issues check
-
Explanation
[#12082] The issue requests that SQL integer literals with a leading zero be read as octal (as sql-syntax.adoc documents and the lexer's OCTAL_LITERAL rule recognises), or that the docs drop the octal form. The PR takes the parser-change path. Per the PR description and raw summary, parseIntegerLiteral now selects radix 8 for a leading 0 followed by more digits, while 0, 0x hex, the L suffix and int-to-long widening are unchanged. Shared helpers (parseIntLiteral, parseLongLiteral, parseNegatedLongLiteral) route the other INTEGER_LITERAL conversions through the same rule. SQLLiteralParameterizer uses parseNegatedLongLiteral, so the cached-statement shape keeps 10 and 010 distinct. The new Issue12082SqlOctalLiteralTest (6 tests) covers the documented values (010=8, -065=-53, 010L=8L) and bounds, INSERT/UPDATE, LIMIT/SKIP, ranges, bucket IDs and statement caching. The PR reports that all six tests fail on origin/main. RID parts stay decimal, which the issue does not require to change because a RID is not a numeric literal. Evidence limits: the head file read was truncated at 16000 bytes, so I confirmed the helper changes from the PR description and raw summary, not from the full source. I did not run the tests.
Full details: Out of Scope Changes check
-
Explanation
[#12082] The changes are the octal parsing rule, its shared helpers, and the routing of SQL INTEGER_LITERAL conversions through those helpers (bucket IDs, BUCKETS/PAGESIZE, SHARDS, RETENTION, downsampling tiers, RETRY/WAIT, positional parameters, ranges, and similar). Each of these consumes an SQL integer literal, so applying one value rule to all of them follows the issue's scope. The statement parameterizer change keeps the literal cache consistent with the new value. The RID decision (RID parts stay decimal) is an explicit, documented exception and not an unrelated change. The new test class supports the stated behaviour. No change is shown to be unrelated to SQL integer-literal parsing. The engine test failures reported in the PR are attributed to tests that fail on origin/main or pass when run alone, and they are not in the SQL parser. I did not verify these attributions by running the tests.
Full details: Description check
-
Explanation
The description follows the repository template. It has a summary, a cause, a fix, tests, and a failing-first note. It names issue #12082 in a 'Fixes' line. It does not use the template headings (What does this PR do?, Motivation, Related issues, Additional Notes, Checklist). The Checklist is missing, so the author does not state whether the build ran with mvn clean package. The description gives test results for the SQL packages (4903 tests, 0 failures) and explains the motivation and scope in detail. The description is mostly complete, but the template structure is not followed.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
-
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
mergify
Bot
commented
Nov 16, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
This pull request is merged.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Up to standards ✅
🟢 Issues 0 issues
Results:
0 new issues
View in Codacy
🟢 Metrics 0 complexity
| Metric |
Results |
| Complexity |
0 |
View in Codacy
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
|
Triage: triage:lgtm · severity:minor · areas: sql, engine · has-issue
The change makes SQL integer literals with a leading 0 octal, as sql-syntax.adoc documents and the lexer's OCTAL_LITERAL rule already allows. I found no security issue and no unrelated change.
What I checked
parseIntegerLiteral now picks its radix through integerLiteralRadix. 0 stays 0 and 0x stays hex. A leading 0 followed by more digits is read as octal. The L suffix and the int-to-long widening are unchanged.
parseIntLiteral, parseLongLiteral and parseNegatedLongLiteral replace about 30 raw Integer.parseInt / Long.parseLong calls on INTEGER_LITERAL tokens, so a literal has one value wherever it is written. The helpers only parse short strings and allocate nothing extra on the hot path.
SQLLiteralParameterizer now builds its values through the same helper, so SELECT 10 and SELECT 010 share a cached statement shape but get different values. A regression test covers this.
tryFoldLongMinValueLiteral previously skipped non-decimal literals. It now folds -0x8000000000000000 and the octal Long.MIN_VALUE as well, which is consistent. The code removed there was not dead.
- The new
Issue12082SqlOctalLiteralTest covers expressions, long bounds, INSERT/UPDATE, LIMIT/SKIP, ranges, BUCKETS and bucket:N, RIDs, and the statement cache. It uses the assertThat style CLAUDE.md asks for, and it has no wall-clock assertions or hard-coded ports.
Notes for the maintainers (not blockers)
- This is a behaviour change. An unquoted zero-padded number such as
SET code = 010 or bucket:010 now changes value. The PR documents this and found no test or manual example that depends on the old reading. It deserves a release-note mention.
- Keeping RID parts decimal (
#12:010 is #12:10) is a reasonable choice. The visitInteger javadoc now says so, and the test covers it. A maintainer should confirm that this is the wanted semantics.
- Positional parameters (
$010) now go through the octal reading as well. This is consistent, but it is an odd spelling that nobody is likely to use. Nothing needs to change.
The PR also does not touch the documentation, which already describes octal, so none is needed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Triage: triage:lgtm · severity:minor · areas: sql, engine · has-issue
Summary: The PR makes the SQL parser read an integer literal with a leading 0 as octal, as sql-syntax.adoc documents and the lexer's OCTAL_LITERAL rule spells it. The radix choice sits in one place, integerLiteralRadix. All the other Integer.parseInt and Long.parseLong sites that read an INTEGER_LITERAL now go through the new helpers. I found no security hazard: the change only touches parsing, adds no dependencies, and has no I/O or reflection. Judging by the diff alone, I have no blocking findings.
What looks right
parseIntegerLiteral keeps 0 as 0, keeps 0x as hex, keeps the L suffix, and keeps the int-then-long widening.
parseNegatedLongLiteral is shared by SQLASTBuilder and SQLLiteralParameterizer. The Long.MIN_VALUE fold now works in every radix, and the previous copy-pasted logic is gone.
parseIntLiteral rejects values that don't fit an int, rather than truncating them silently.
tryFoldLongMinValueLiteral no longer bails out on hex or octal-shaped text, so those literals now fold too.
Issue12082SqlOctalLiteralTest covers expressions, the long bounds, INSERT and UPDATE, LIMIT, SKIP, ranges, BUCKETS, bucket:N, and statement-cache sharing. It uses the assertThat style CLAUDE.md asks for. The PR description says the class fails 6 of 6 against main.
Notes for the maintainers (non-blocking)
- This is a user-visible behaviour change. An unquoted zero-padded literal such as
SET code = 007 or LIMIT 010 changes value. That follows the documented behaviour, and the author states that no existing test or doc depends on the old reading. It should still go in the release notes.
- RID parts deliberately stay decimal (
#12:010 is #12:10). The PR flags this for the reviewer and documents it in the visitInteger javadoc. Maintainers should confirm they want that split between SQL literals and RIDs.
- The
Invalid integer: error in tryFoldLongMinValueLiteral now reports the text after the L suffix is stripped. Before, it reported the original text. This is cosmetic, but confirm that no test or doc asserts the old message.
- Optional: the repeated
parseIntLiteral(termNode.getText()) blocks for BUCKETS and PAGESIZE across the document, vertex and edge type visitors could be factored out later. That is not needed for this PR.
I did not run the build or the tests. The PR reports no failures in com.arcadedb.query.sql.**, and it names the failures elsewhere in the engine module as pre-existing or flaky.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…, bucket ids and RID parts stay decimal
The first commit routed about 30 DDL and identifier positions (BUCKETS, PAGESIZE, SHARDS, RETENTION, REFRESH EVERY, RETRY/WAIT, bucket:N, DROP/TRUNCATE BUCKET, CHECK DATABASE BUCKET, $N parameters) through the numeric literal reader. That newly accepted hexadecimal and the L suffix there (BUCKETS 0x10, PAGESIZE 10L were refused before), which the maintainers kept out of scope for those positions on ArcadeData#9122, and it made bucket:010 and DROP/TRUNCATE BUCKET 010 address bucket 8 while ArcadeData#10:0 and the parts of a RID stay decimal, so one bucket number named different buckets depending on its spelling (a silent retarget for the destructive statements).
Those positions read plain decimal digits again, as they always did. A literal with a leading 0 is octal where a number is read: expressions, LIMIT/SKIP, MAXDEPTH/TOP/MIN_COUNT, facet bounds, the statement cache values (SQLLiteralParameterizer), and the bounds of the [a..b] and [a...b] range tokens, which now agree with the spaced form that goes through the expression parser. The range token still refuses hexadecimal and the L suffix, and the Long.MIN_VALUE fold of a negated literal is octal and decimal only: no new accepted syntax.
The test pins the decision: BUCKETS 010 is ten buckets, BUCKETS 0x10 and 10L are still refused, bucket:0NN is bucket NN, #NN:010 is #NN:10, [0x1..0x3] and [1L..3L] are still refused. 5 of its 6 tests fail on main's engine code, the sixth guards the decimal positions.
|
Pushed c3f367e on top of the original commit, narrowing the fix to what the issue documents: a numeric literal.
- Octal (leading 0 followed by digits) is read wherever a number is read: expressions, LIMIT/SKIP, MAXDEPTH/TOP/MIN_COUNT, facet bounds, the literal-parameterized statement cache, and the bounds of the [a..b] and [a...b] range tokens (now the same as the spaced form).
- The DDL and identifier positions (BUCKETS, PAGESIZE, SHARDS, RETENTION, COMPACTION, REFRESH EVERY, RETRY/WAIT, bucket:N, DROP/TRUNCATE BUCKET, CHECK DATABASE BUCKET, $N parameters) read plain decimal digits again, as before. In the first commit they went through the numeric reader, which newly accepted hexadecimal and the L suffix there and made bucket:010 mean bucket 8 while Bump netty-all from 4.1.60.Final to 4.1.67.Final #10:0 stays decimal: one bucket number addressing different buckets by spelling, with DROP/TRUNCATE BUCKET and DELETE FROM bucket:N silently retargeted.
- The range token and the Long.MIN_VALUE fold stay octal and decimal only: no hexadecimal or L suffix is newly accepted anywhere.
The test now pins both sides: octal in expressions, long bounds, records, LIMIT/SKIP, ranges and the statement cache; BUCKETS 010 is ten buckets, BUCKETS 0x10 and 10L are still refused, bucket:0NN is bucket NN, #NN:010 is #NN:10. Five of its six tests fail on main's engine code. The whole com.arcadedb.query.sql package passes (4903 tests, 0 failures).
User-visible change for the release notes: an unquoted zero-padded integer in an expression or LIMIT/SKIP (SET code = 007, LIMIT 010) now has its octal value; the same text kept in a stored definition (view, trigger, saved query) is re-parsed with the new value.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Triage: triage:needs-changes · severity:minor · areas: sql, engine · has-issue
Thanks for the fix and the thorough test class. Octal parsing in parseIntegerLiteral looks right, and the Long.MIN_VALUE folding and the parameterizer reuse are sensible. A few things need fixing before this can merge.
1. The PR description does not match the diff.
- The body says about 30 places now go through new helpers
parseIntLiteral, parseLongLiteral and parseNegatedLongLiteral. It lists bucket ids, BUCKETS/PAGESIZE, SHARDS, $N and others, and says CREATE DOCUMENT TYPE T BUCKETS 010 creates 8 buckets.
- The diff contains only
parseNegatedLongLiteral, integerLiteralRadix and parseRangeBound. The new Javadoc on parseIntegerLiteral and the test both say BUCKETS 010 stays decimal and creates 10 buckets. The test also keeps bucket:0NN decimal.
- The body says
bucket:0NN uses the octal spelling, while the test says it is decimal.
- Please correct the body to describe what the code does. If the 30-call-site change was meant to be here, it is missing. The CodeRabbit summary repeats the wrong claim.
2. Inconsistent semantics to confirm. After this change LIMIT 010 is 8, but BUCKETS 010 and bucket:010 are 10. That is defensible, but it should be stated as an explicit maintainer decision. It is also a behavior change for existing statements such as SET code = 007, which may deserve a release note.
3. Possible regression in parseRangeBound (SQLASTBuilder). A range token like [08..10] or [009..12] previously parsed as decimal. It now calls Integer.parseInt("08", 8) and throws NumberFormatException. The PR text says the lexer never produces such a token as an octal literal. The range token is matched by a different rule, though. Please either verify the lexer rejects these, or handle non-octal digits explicitly, and add a test for it.
4. Test gaps.
- There is no test for
[08..10], which is the regression risk in point 3.
- There is no test for
-0 or for a negated octal in the parameterized (cached) path with L.
isOctalSpelled may leave the orElseThrow() in bucketCountsBucketIdsAndRidPartsStayDecimal fragile, because it depends on file ids from the new type's buckets.
5. Minor. tryFoldLongMinValueLiteral computes radix only to test fit, then calls parseNegatedLongLiteral(originalText). That is fine, but a short comment on the originalText versus text distinction would help.
No security concerns found.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…the negated octal in the statement cache and a robust bucket id
A range such as [08..10] or [1..09] is a syntax error on main already (the lexer reads 0 and then 8..10), so it never reaches the range bound parser: now pinned. The statement cache path is covered for a negated octal with and without the L suffix, -0 and the Long.MIN_VALUE fold. The bucket id used to show that bucket:0NN stays decimal no longer depends on the file ids of one type: single-bucket types are created until one has an id spelled with octal digits only.
|
Triage: triage:needs-changes · severity:minor · areas: sql, engine · has-issue
Thanks for the fix. Reading 010 as octal, as sql-syntax.adoc documents, is the right direction. The core change looks sound: integerLiteralRadix, parseIntegerLiteral, the Long.MIN_VALUE fold and the parameterizer all agree. I found no security concerns.
The PR description does not match the diff. This needs to be resolved before merge.
- The body says about 30
Integer.parseInt/Long.parseLong call sites were moved onto new parseIntLiteral and parseLongLiteral helpers. It says this covers bucket ids, BUCKETS, PAGESIZE, SHARDS, $N and others, and that BUCKETS 010 creates 8 buckets.
- The diff has no
parseIntLiteral or parseLongLiteral. Those call sites are untouched.
- The Javadoc and the test say the opposite of the body: counts, bucket ids and RID parts stay decimal, and
BUCKETS 010 gives 10 buckets (bucketCountsBucketIdsAndRidPartsStayDecimal).
- Please update the body and the release-note text to describe what the code does. If the body was the intended design, the code is incomplete.
The decimal-versus-octal split is a user-visible inconsistency.
SELECT 010 gives 8, but LIMIT 010 gives 8 while BUCKETS 010, bucket:010 and $010 stay decimal.
- The body's stated goal, "one value wherever it is written", is not met.
- If the decimal reading is deliberate, document it in
sql-syntax.adoc so it is not a surprise.
- Please also have a maintainer confirm that
LIMIT/SKIP and [a..b] become octal. This is a breaking change for any user who zero-pads numbers, for example SET code = 007 or LIMIT 010.
Minor points
SQLLiteralParameterizer now calls the package-private static SQLASTBuilder.parseNegatedLongLiteral. This is fine, but add a direct unit test for parseNegatedLongLiteral with a hex input and with a plain decimal Long.MIN_VALUE. Its Javadoc says a hex input is refused.
- The test
bucketIdWhoseOctalReadingDiffers creates up to 200 types and depends on the file-id layout. It could fail with AssertionError on a different fixture. Consider building the target bucket id deterministically.
- Per
CLAUDE.md, state in the PR how the change was verified. The body does this well. Please keep the body consistent with the final code.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…statement, and parseNegatedLongLiteral directly
The bucket id of a statement (bucket:010, DROP BUCKET 010, TRUNCATE BUCKET 010) and the parts of a RID (ArcadeData#10:010) are asserted on the parsed statement, so the test no longer depends on which file ids a database holds, and hexadecimal is still refused for a bucket id. parseNegatedLongLiteral is tested directly: the magnitude of Long.MIN_VALUE in decimal and octal, with and without the L suffix, one more is an overflow, and a hexadecimal magnitude is refused.
|
Triage: triage:lgtm · severity:minor · areas: sql, engine · has-issue
Thanks for the fix for #12082. I read the diff and the surrounding code, and I could not run anything, so the points below come from reading only.
What it does
parseIntegerLiteral now reads a leading 0 followed by more digits as octal. 0 stays 0, 0x stays hex, and the L suffix and int-to-long widening are unchanged. This matches sql-syntax.adoc and the lexer's OCTAL_LITERAL rule.
- The new
parseNegatedLongLiteral and the shared integerLiteralRadix are used by the parser (tryFoldLongMinValueLiteral), the FACETS bound and SQLLiteralParameterizer. That keeps the statement cache and the parser in agreement, so SELECT 10 and SELECT 010 share one cached shape and still answer 10 and 8.
- The
[01..010] range token now agrees with the spaced form [01 .. 010].
visitInteger still uses Integer.parseInt, so the parts of a RID and bucket ids stay decimal, as the PR describes.
- The test class follows the project conventions. It uses
TestHelper and the assertThat(...) style, adds no System.out, and covers expressions, long bounds, INSERT/UPDATE, LIMIT/SKIP, ranges, decimal-only positions, direct parseNegatedLongLiteral calls and the statement cache.
- The change is small and has no security impact. It adds no dependencies and no performance cost on hot paths.
Points for the maintainers
- This is a deliberate behaviour change. A zero-padded unquoted number such as
007 or LIMIT 010 changes value, including in stored views, triggers and saved queries. The PR body says so, and the documentation already promises octal, so I think it is acceptable. A line in the release notes would help.
visitPInteger now reads octal through parseIntegerLiteral. It is used for TRAVERSE MAXDEPTH and the FACETS TOP and MIN_COUNT bounds. That matches the PR's claims. Please confirm in the test that every DDL position the PR says stays decimal (PAGESIZE, SHARDS, RETENTION, etc.) really bypasses it, because the test only pins BUCKETS, bucket: and DROP/TRUNCATE BUCKET. Lines 662 and 683 (interval and precision) also go through parseIntegerLiteral, so they are octal now. Both are numeric values, so this is probably intended, but an assertion for each would be good.
- Nit:
parseRangeBound strips a leading - before choosing the radix. That works, but a short comment on why -010 is octal would help.
Overall this looks fine to merge, subject to a quick confirmation of point 2.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
lvca
lvca left review comments
Uh oh!
There was an error while loading. Please reload this page.
Labels
engine
Core engine: document/schema API
has-issue
The PR links an issue it resolves
pr_approved
review-pr: CI LGTM + clean triage + green sandbox tests on the reviewed head
severity:minor
Cosmetic, documentation, edge case, or a workaround exists
sql
triage:lgtm
PR triage: nothing blocking, ready for a maintainer
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.
|