-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
backport: support unsigned/zerofill #1716
Comments
assigned me! |
crash happend when insert data out of range:
|
Root cause:
here When insert data out of range,
So,
we should set |
[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.
[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.
Is your feature request related to a problem? Please describe.
working issue: #1013, ##1218
commit id: b44a51c
limit unsigned range: 38d7eb4
revert auto_increment mtr test: e3cfea3
bug: 71a27c4
Describe the solution you'd like
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: