summaryrefslogtreecommitdiff
path: root/sql/sys_vars.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-10-28 08:48:36 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2021-10-28 08:48:36 +0300
commita8ded395578ccab9c256b9beee7e62d4ada08522 (patch)
tree3560bcda4fc05f41dd8a96df37152802d928a423 /sql/sys_vars.cc
parentf7bd369973ae56fe068302f0ff1c4e84d01bff75 (diff)
parent3a79e5fd317316c293baa459e8296fdb0744c280 (diff)
downloadmariadb-git-a8ded395578ccab9c256b9beee7e62d4ada08522.tar.gz
Merge 10.4 into 10.5
Diffstat (limited to 'sql/sys_vars.cc')
-rw-r--r--sql/sys_vars.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 565f26bcdb2..10175f41969 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4696,12 +4696,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;
}
@@ -4709,6 +4713,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",