summaryrefslogtreecommitdiff
path: root/sql/handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/handler.cc')
-rw-r--r--sql/handler.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 0b080310c6b..c7ea86412fc 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -1478,7 +1478,19 @@ next_insert_id(ulonglong nr,struct system_variables *variables)
/*
- Updates columns with type NEXT_NUMBER if:
+ Update the auto_increment field if necessary
+
+ SYNOPSIS
+ update_auto_increment()
+
+ RETURN
+ 0 ok
+ 1 get_auto_increment() was called and returned ~(ulonglong) 0
+
+
+ IMPLEMENTATION
+
+ Updates columns with type NEXT_NUMBER if:
- If column value is set to NULL (in which case
auto_increment_field_not_null is 0)
@@ -1517,12 +1529,13 @@ next_insert_id(ulonglong nr,struct system_variables *variables)
thd->next_insert_id is cleared after it's been used for a statement.
*/
-void handler::update_auto_increment()
+bool handler::update_auto_increment()
{
ulonglong nr;
THD *thd= table->in_use;
struct system_variables *variables= &thd->variables;
bool auto_increment_field_not_null;
+ bool result= 0;
DBUG_ENTER("handler::update_auto_increment");
/*
@@ -1551,11 +1564,13 @@ void handler::update_auto_increment()
thd->next_insert_id= nr;
DBUG_PRINT("info",("next_insert_id: %lu", (ulong) nr));
}
- DBUG_VOID_RETURN;
+ DBUG_RETURN(0);
}
if (!(nr= thd->next_insert_id))
{
- nr= get_auto_increment();
+ if ((nr= get_auto_increment()) == ~(ulonglong) 0)
+ result= 1; // Mark failure
+
if (variables->auto_increment_increment != 1)
nr= next_insert_id(nr-1, variables);
/*
@@ -1595,7 +1610,7 @@ void handler::update_auto_increment()
/* Mark that we generated a new value */
auto_increment_column_changed=1;
- DBUG_VOID_RETURN;
+ DBUG_RETURN(result);
}
/*