Repository navigation
fix(core): check a PartiQL number's magnitude before its digit count - #1376
LeeroyHannigan wants to merge 1 commit into
Conversation
A PartiQL number with more than 38 significant digits and a magnitude out of range got the digit count text. DynamoDB answers the magnitude fault for such a number. DynamoDB was measured in us-east-1 on 23 Nov 2026, with ExecuteStatement on a table that does not exist. Each request went out twice and got the same answer both times. The number check answers before the table lookup. F is the forty digits 1234567890123456789012345678901234567890: - A parameter of F E200 gets "Number overflow. Attempting to store a number with magnitude larger than supported range". - A parameter of F E-200 gets "Number underflow. Attempting to store a number with magnitude smaller than supported range". - A parameter of F gets "Attempting to store more than 38 significant digits in a Number". - A literal gets the same texts with " under root" after them. The order is the same for 39 digits at each end of the magnitude range. It is also the same for a number in a map, a list or a set, and for INSERT, SELECT and DELETE. BatchExecuteStatement and ExecuteTransaction keep it too. check_number now checks the magnitude range before the digit count. The item operations, such as PutItem, answered the digit count for these numbers on 11 Nov 2026. The classic number check therefore keeps its order. Fixes #958.
LJMart11
left a comment
There was a problem hiding this comment.
Reviewed at 97651d0.
Docs — outside the diff
docs/manuals/07-upgrade-manual.md:385— Please add an entry under Behavior Changes by Release for the new message order. v1.1.0 (and v1.0.0, v0.1.15) carry the old order incheck_number, and on this head1234567890123456789012345678901234567890E200as a parameter or literal now getsNumber overflow...where those releases answeredAttempting to store more than 38 significant digits in a Number. The manual already records the same kind of message-only number change for #619 at line 1227, so a matching bullet would close this.
navareamol
left a comment
There was a problem hiding this comment.
I checked the new order on a server built from this head against main with 23 numbers on 20 request forms, parameters and literals, ExecuteStatement and ExecuteTransaction. Every form that gave the digit count text for F E200, F E-200 and a 39 digit number with E88 or E-169 on main gives the overflow or underflow text here, and the forms that should not change did not. The four new rows in test_partiql_numbers.py fail on main and pass here.
I think one edge is not covered. The magnitude uses all digits including trailing zeros, and the digit count does not. F (the forty digits, one trailing zero) with E86 is in range and with E87 is an overflow by that rule, and the measured boundary rows use 39 digit numbers without a trailing zero. Could you measure F E86 and F E87 on the live service, and add them to the Rust table if they match?
The wire test file has rows for E200 and E-200 only. Could one row for the boundary (39 digits with E88) be added there too, so the boundary is held on the wire?
I will approve once the trailing zero boundary is measured or the description says it was not.
What
check_numberincrates/core/src/partiql/number.rsnow checks the magnitude range of a PartiQL number before its digit count. A number with more than 38 significant digits and a magnitude out of range gets the overflow or the underflow text, as DynamoDB gives. Before, it gotAttempting to store more than 38 significant digits in a Number.check_numberis the one PartiQL number check. It reads theNvalues inParametersand the number literals in a statement, so both get the new order. The conversion check still comes first. The classic number check of the item operations does not change.The changes:
check_numbermoves the digit check after the magnitude checks. The module doc and the function doc say so.the_magnitude_range_comes_before_the_digit_countanda_literal_names_the_magnitude_before_the_digit_countinnumber/tests.rshold the measured rows.tests/test_partiql_numbers.pyhas four more rows, two for a parameter and two for a literal.Fixes #958
Why
DynamoDB was measured in us-east-1 on 23 November 2026, with ExecuteStatement on a table that does not exist. Each request went out twice and got the same answer both times. The number check answers before the table lookup: the number
1getsResourceNotFoundException.F is the forty digits
1234567890123456789012345678901234567890, which have 39 significant digits.Number overflow. Attempting to store a number with magnitude larger than supported rangeAttempting to store more than 38 significant digits in a NumberNumber underflow. Attempting to store a number with magnitude smaller than supported rangeunder rootunder rootThe same order holds in these cases, each measured twice:
under root.xorunder root[0].The literal F with the exponent 2147483647 got
InternalFailure(HTTP 500) from DynamoDB, twice. ExtendDB gives it the underflow text withunder root, as it does for the same number as a parameter.The item operations, such as PutItem, answered the digit count text for F E200 and F E-200 on 11 November 2026. So the classic number check in
crates/core/src/validation/number.rskeeps its order.Testing done
cargo test -p extenddb-core --lib --no-fail-fast: 1148 passed, 1 ignored, whichmainignores too.cargo +1.97.0 clippy -p extenddb-core --all-targets -- -D warningsandcargo +1.97.0 fmt --all -- --checkare clean.mainand kept the new tests. Both new tests failed. In the parameter table, 7 of 10 rows got the digit count text. In the literal table, 8 of 9 rows did. The rows that passed expect the digit count text in both orders. The other 18 tests of the module passed on both orders, so no earlier test held the old order.tests/test_partiql_numbers.pyagainst that build: 109 passed and 1 xfailed, the four new rows among the passes. The xfail is the mark for a server built without the MongoDB crate.Production is +12 -8, of which the code is +3 -3. The tests are +74 -5.
git merge-treeshows no conflict withmainor with #781, the one open PR that changes a file of this PR.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.