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(tianmu): support unsigned zerofill #1716 #1813

Conversation

hustjieke
Copy link
Collaborator

@hustjieke hustjieke commented May 23, 2023

Summary about this PR

Issue Number: close #1716

Tests Check List

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

Changelog

  • New Feature
  • Bug Fix
  • Performance Improvement
  • Build/Testing/CI/CD
  • Documentation
  • Not for changelog (changelog entry is not required)

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features

hustjieke added 3 commits May 22, 2023 06:03
[summary]
1. delete unsigned/zerofill limit.
2. zerofill is deprecated and will be removed in a future release, Use the LPAD function to zero-pad numbers, or store the formatted numbers in a CHAR column.
[summary]
In non-strict sql_mode, insert sucess with warning.
in strict sql_mode, crashed in function `Sql_cmd_insert_values::execute_inner(THD *thd)` in file `sql/sql_insert.cc`:
```
      if (write_record(thd, insert_table, &info, &update)) {
        has_error = true;
        break;
      }
      thd->get_stmt_da()->inc_current_row_for_condition();
    }
  }  // Statement plan is available within these braces

  assert(has_error == thd->get_stmt_da()->is_error());
```

here `has_error` = false, `thd->get_stmt_da()->is_error()` = true, that
caused crashed.

When insert data out of range, `tianmu` engine push a warning into mysql,  but in strict sql_mode, the
`Sql_condition::SL_WARNING` will be changed to `Sql_condition::SL_ERROR` in function:

```
/**
  Implementation of STRICT mode.
  Upgrades a set of given conditions from warning to error.
*/
bool Strict_error_handler::handle_condition(
...
...
switch (sql_errno) {
    ...
    case ER_WARN_DATA_OUT_OF_RANGE:
    case ER_WARN_DATA_OUT_OF_RANGE_FUNCTIONAL_INDEX:
      if ((*level == Sql_condition::SL_WARNING) &&
          (!thd->get_transaction()->cannot_safely_rollback(
               Transaction_ctx::STMT) ||
           (thd->variables.sql_mode & MODE_STRICT_ALL_TABLES))) {
        (*level) = Sql_condition::SL_ERROR;
      }
      break;
    default:
      break;
  }
  return false;
```

So, `write_record(thd, insert_table, &info, &update)` should return error and then set ` has_error = true;`, after debug, I found `ret` value not set `1` when execption get in function:

```
int Engine::InsertRow(const std::string &table_path, [[maybe_unused]] Transaction *trans_, TABLE *table,
                      std::shared_ptr<TableShare> &share) {
  int ret = 0;
  try {
    ret = rct->Insert(table);
    return ret;
  } catch (...) {
    TIANMU_LOG(LogCtl_Level::ERROR, "delayed inserting failed.");
  }

  return ret;
}
```

we should set `ret` = 1 in strict sql_mode in catch block.
@mergify
Copy link
Contributor

mergify bot commented May 23, 2023

This pull request's title should follow requirements next. @hustjieke please check it 👇.

Valid format:

fix(vc): fix sth..... (#3306)
  ^         ^---------^  ^----^
  |         |            |
  |         +            +-> you issue id.
  |         |
  |         +-> Summary in present tense.
  |
  +-------> Type: feat, fix, docs, workflow, style, refactor, test, website, chore

Valid types:

  • feat: new feature for stonedb
  • fix: bug fix for stonedb
  • docs: changes to the documentation
  • workflow: ci/cd in .github
  • perf: Changes to improve code performance
  • refactor: refactoring production code, eg. renaming a variable
  • style: formatting, missing semi colons, etc; no production code change
  • test: adding missing tests, refactoring tests; no production code change
  • website
  • chore: updating grunt tasks etc; no production code change

@mergify
Copy link
Contributor

mergify bot commented May 23, 2023

Thanks for the contribution!
I have applied any labels matching special text in your PR Changelog.

Please review the labels and make any necessary changes.

@hustjieke hustjieke changed the title Feat support unsigned zerofill issue1716 feat(tianmu): support unsigned zerofill #1716 May 23, 2023
@mergify mergify bot added the PR-feature feature for pull request label May 23, 2023
Copy link
Collaborator

@chenshengjiang chenshengjiang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@Double0101 Double0101 left a comment

Choose a reason for hiding this comment

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

LGTM

@mergify mergify bot merged commit d5c1051 into stoneatom:stonedb-8.0-dev May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-feature feature for pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants