-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tianmu): crashed when insert out of range #1716
[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.
- Loading branch information
1 parent
a374a07
commit d5c1051
Showing
4 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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