Skip to content

MOD-6501, MOD-4551, MOD-4856, MOD-5714: fix crash from converting u64 to i64 #1192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2024

Conversation

ephraimfeldblum
Copy link
Collaborator

@ephraimfeldblum ephraimfeldblum commented Mar 6, 2024

Description

Indexing NUMERIC fields has unchanged behavior.

  • A NUMERIC field with value greater than i64::min (-2^63), but less than i64::max (2^63 - 1) is indexed as i64. It does not lose precision. Its type is integer.
  • A NUMERIC field with value greater than i64::max (2^63 - 1), but less than u64::max (2^64 - 1) is indexed as u64. It does not lose precision. Its type is integer.
  • A NUMERIC field with value greater than u64::max (2^64 - 1), or lower than i64::min (-2^63), or containing a decimal point, is indexed as f64. Its type is number. This may implicate losing precision, but this is not a breaking change.

NUMINCRBY behavior changed to prevent crash.

  • i64 + i64 whose result is between i64::min and i64::max has unchanged behavior. Its result is stored as i64, its type is integer.
  • i64 + i64 whose result is greater than i64::max or less than i64::min explicitly wraps instead of invoking undefined behavior. Its result is stored as i64, its type is integer.
  • i64 + u64 and u64 + u64 behavior is unchanged. Its result is stored as f64, its type is number. This may implicate losing precision, but this is not a breaking change.
  • u64 + i64 used to crash. Now it behaves consistently with the prior case.
  • If either argument is f64, the result is stored as f64, with type number.

DROP of integers stored as u64 no longer crashes.

This PR only affects NUMERIC fields using vanilla JSON, not those using HDT.

Which issues this PR fixes

  1. MOD-6501
  2. MOD-4551
  3. MOD-4856
  4. MOD-5714
  5. #875
  6. #3726 (Search)

Main objects this PR modified

  1. IValue Manager
  2. JSON Node

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 76.66667% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 77.99%. Comparing base (ec06572) to head (1de5d77).

Files Patch % Lines
json_path/src/json_node.rs 64.70% 6 Missing ⚠️
redis_json/src/key_value.rs 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              2.6    #1192      +/-   ##
==========================================
- Coverage   78.06%   77.99%   -0.08%     
==========================================
  Files          15       15              
  Lines        3912     3917       +5     
==========================================
+ Hits         3054     3055       +1     
- Misses        858      862       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants