feat(tianmu): support unsigned zerofill #1716#1813
Merged
mergify[bot] merged 3 commits intoMay 24, 2023
Merged
Conversation
[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.
Contributor
|
This pull request's title should follow requirements next. @hustjieke please check it 👇. Valid format: Valid types:
|
Contributor
|
Thanks for the contribution! Please review the labels and make any necessary changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary about this PR
Issue Number: close #1716
Tests Check List
Changelog
Documentation