Skip to content
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

feat: Refactor 'DataValue' length check logic; add support for varchar computations #60

Merged
merged 3 commits into from
Sep 17, 2023

Conversation

loloxwg
Copy link
Member

@loloxwg loloxwg commented Sep 16, 2023

What problem does this PR solve?

This commit revises the mechanism for checking limit conditions on variable length types such as varchar, moving the check from 'src/binder/insert.rs' to 'src/types/value.rs' to centralize the control. It also implements expression computation for the Udf8 data type. Furthermore, the now-unnecessary Nvarchar type has been removed. This overhaul enhances robustness against incorrect inputs in variable length fields and improves the computational abilities for the Utf8 data type.

Issue link:

What is changed and how it works?

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

@loloxwg loloxwg requested a review from KKould September 16, 2023 16:37
src/types/value.rs Outdated Show resolved Hide resolved
src/types/value.rs Outdated Show resolved Hide resolved
src/types/mod.rs Show resolved Hide resolved
@@ -52,6 +52,11 @@ impl<S: Storage> Binder<S> {
let cast_value = DataValue::clone(value)
.cast(columns[i].datatype())?;

// Check if the value length is too long
if Some(cast_value.to_raw().len()) > columns[i].datatype().raw_len() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataValue adds a Check method to check the upper limit of data type

src/types/mod.rs Outdated Show resolved Hide resolved
src/types/mod.rs Outdated Show resolved Hide resolved
src/types/mod.rs Outdated Show resolved Hide resolved
@loloxwg loloxwg changed the title feat: Added length restriction in types feat: Refactor 'DataValue' length check logic; add support for varchar computations Sep 16, 2023
@loloxwg loloxwg requested a review from KKould September 16, 2023 20:32
…r computations

This commit revises the mechanism for checking limit conditions on variable length types such as varchar, moving the check from 'src/binder/insert.rs' to 'src/types/value.rs' to centralize the control. It also implements expression computation for the Udf8 data type. Furthermore, the now-unnecessary `Nvarchar` type has been removed. This overhaul enhances robustness against incorrect inputs in variable length fields and improves the computational abilities for the Utf8 data type.
src/types/value.rs Show resolved Hide resolved
src/types/value.rs Outdated Show resolved Hide resolved
Copy link
Member

@KKould KKould left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@loloxwg loloxwg merged commit 1853a9b into main Sep 17, 2023
@loloxwg loloxwg deleted the feat/type branch September 17, 2023 11:35
@KKould KKould linked an issue Sep 24, 2023 that may be closed by this pull request
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.

Support type length limit
2 participants