diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2021-10-20 14:53:01 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2021-10-26 00:29:27 +0400 |
commit | efedf3da68aa0c0a70e0686d9b92c9d0924df098 (patch) | |
tree | a6772efd4a6f8901993d9c10020b7b251f3523e6 /sql/sys_vars.cc | |
parent | d627d00b13ab2f2c0954ea7b77202470cb102944 (diff) | |
download | mariadb-git-efedf3da68aa0c0a70e0686d9b92c9d0924df098.tar.gz |
MDEV-22711 Assertion `nr != 0' failed in handler::update_auto_increment.bb-10.2-mdev-22711-hf
DBUG_ASSERT removed as the AUTO INCREMENT can actually be 0 when the
SET insert_id= 0; was done.
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r-- | sql/sys_vars.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index f231f49a667..bd4b2fbb062 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4064,12 +4064,16 @@ static Sys_var_session_special Sys_identity( */ static bool update_insert_id(THD *thd, set_var *var) { - if (!var->value) - { - my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); - return true; - } - thd->force_one_auto_inc_interval(var->save_result.ulonglong_value); + /* + If we set the insert_id to the DEFAULT or 0 + it means we 'reset' it so it's value doesn't + affect the INSERT. + */ + if (!var->value || + var->save_result.ulonglong_value == 0) + thd->auto_inc_intervals_forced.empty(); + else + thd->force_one_auto_inc_interval(var->save_result.ulonglong_value); return false; } @@ -4077,6 +4081,8 @@ static ulonglong read_insert_id(THD *thd) { return thd->auto_inc_intervals_forced.minimum(); } + + static Sys_var_session_special Sys_insert_id( "insert_id", "The value to be used by the following INSERT " "or ALTER TABLE statement when inserting an AUTO_INCREMENT value", |