mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Change update_auto_increment to return 1 if get_auto_increment() returned ~(ulonglong)
This makes it easier to give an error in the handler if there was a problem generating an auto-increment value mysys/thr_alarm.c: Remove warning from valgrind sql/item_strfunc.cc: Fixed indentation tests/mysql_client_test.c: Removed compiler warning
This commit is contained in:
@ -85,7 +85,7 @@ void init_thr_alarm(uint max_alarms)
|
|||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
struct sigaction sact;
|
struct sigaction sact;
|
||||||
sact.sa_flags = 0;
|
bzero((char*) &sact, sizeof(sact));
|
||||||
sact.sa_handler = thread_alarm;
|
sact.sa_handler = thread_alarm;
|
||||||
sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
|
sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
|
||||||
}
|
}
|
||||||
|
@ -1376,7 +1376,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
|
- If column value is set to NULL (in which case
|
||||||
auto_increment_field_not_null is 0)
|
auto_increment_field_not_null is 0)
|
||||||
@ -1415,12 +1427,13 @@ next_insert_id(ulonglong nr,struct system_variables *variables)
|
|||||||
thd->next_insert_id is cleared after it's been used for a statement.
|
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;
|
ulonglong nr;
|
||||||
THD *thd= table->in_use;
|
THD *thd= table->in_use;
|
||||||
struct system_variables *variables= &thd->variables;
|
struct system_variables *variables= &thd->variables;
|
||||||
bool auto_increment_field_not_null;
|
bool auto_increment_field_not_null;
|
||||||
|
bool result= 0;
|
||||||
DBUG_ENTER("handler::update_auto_increment");
|
DBUG_ENTER("handler::update_auto_increment");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1449,11 +1462,13 @@ void handler::update_auto_increment()
|
|||||||
thd->next_insert_id= nr;
|
thd->next_insert_id= nr;
|
||||||
DBUG_PRINT("info",("next_insert_id: %lu", (ulong) nr));
|
DBUG_PRINT("info",("next_insert_id: %lu", (ulong) nr));
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
if (!(nr= thd->next_insert_id))
|
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)
|
if (variables->auto_increment_increment != 1)
|
||||||
nr= next_insert_id(nr-1, variables);
|
nr= next_insert_id(nr-1, variables);
|
||||||
/*
|
/*
|
||||||
@ -1493,7 +1508,7 @@ void handler::update_auto_increment()
|
|||||||
|
|
||||||
/* Mark that we generated a new value */
|
/* Mark that we generated a new value */
|
||||||
auto_increment_column_changed=1;
|
auto_increment_column_changed=1;
|
||||||
DBUG_VOID_RETURN;
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -497,7 +497,7 @@ public:
|
|||||||
{}
|
{}
|
||||||
virtual ~handler(void) { /* TODO: DBUG_ASSERT(inited == NONE); */ }
|
virtual ~handler(void) { /* TODO: DBUG_ASSERT(inited == NONE); */ }
|
||||||
int ha_open(const char *name, int mode, int test_if_locked);
|
int ha_open(const char *name, int mode, int test_if_locked);
|
||||||
void update_auto_increment();
|
bool update_auto_increment();
|
||||||
virtual void print_error(int error, myf errflag);
|
virtual void print_error(int error, myf errflag);
|
||||||
virtual bool get_error_message(int error, String *buf);
|
virtual bool get_error_message(int error, String *buf);
|
||||||
uint get_dup_key(int error);
|
uint get_dup_key(int error);
|
||||||
|
@ -2906,9 +2906,9 @@ String *Item_func_uuid::val_str(String *str)
|
|||||||
ulonglong tv=my_getsystime() + UUID_TIME_OFFSET + nanoseq;
|
ulonglong tv=my_getsystime() + UUID_TIME_OFFSET + nanoseq;
|
||||||
if (unlikely(tv < uuid_time))
|
if (unlikely(tv < uuid_time))
|
||||||
set_clock_seq_str();
|
set_clock_seq_str();
|
||||||
else
|
else if (unlikely(tv == uuid_time))
|
||||||
if (unlikely(tv == uuid_time))
|
{
|
||||||
{ /* special protection from low-res system clocks */
|
/* special protection from low-res system clocks */
|
||||||
nanoseq++;
|
nanoseq++;
|
||||||
tv++;
|
tv++;
|
||||||
}
|
}
|
||||||
|
@ -787,6 +787,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count)
|
|||||||
|
|
||||||
/* Utility function to execute a query using prepare-execute */
|
/* Utility function to execute a query using prepare-execute */
|
||||||
|
|
||||||
|
#ifndef EMBEDDED_LIBRARY
|
||||||
static void execute_prepare_query(const char *query, ulonglong exp_count)
|
static void execute_prepare_query(const char *query, ulonglong exp_count)
|
||||||
{
|
{
|
||||||
MYSQL_STMT *stmt;
|
MYSQL_STMT *stmt;
|
||||||
@ -807,7 +808,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count)
|
|||||||
DIE_UNLESS(affected_rows == exp_count);
|
DIE_UNLESS(affected_rows == exp_count);
|
||||||
mysql_stmt_close(stmt);
|
mysql_stmt_close(stmt);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Store result processing */
|
/* Store result processing */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user