Commit ef342b74 authored by unknown's avatar unknown
Browse files

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
parent 2398f9d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ void init_thr_alarm(uint max_alarms)
#else
  {
    struct sigaction sact;
    sact.sa_flags = 0;
    bzero((char*) &sact, sizeof(sact));
    sact.sa_handler = thread_alarm;
    sigaction(THR_CLIENT_ALARM, &sact, (struct sigaction*) 0);
  }
+20 −5
Original line number Diff line number Diff line
@@ -1376,6 +1376,18 @@ next_insert_id(ulonglong nr,struct system_variables *variables)


/*
  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
@@ -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.
*/

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");

  /*
@@ -1449,11 +1462,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);
    /*
@@ -1493,7 +1508,7 @@ void handler::update_auto_increment()

  /* Mark that we generated a new value */
  auto_increment_column_changed=1;
  DBUG_VOID_RETURN;
  DBUG_RETURN(result);
}

/*
+1 −1
Original line number Diff line number Diff line
@@ -497,7 +497,7 @@ class handler :public Sql_alloc
    {}
  virtual ~handler(void) { /* TODO: DBUG_ASSERT(inited == NONE); */ }
  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 bool get_error_message(int error, String *buf);
  uint get_dup_key(int error);
+3 −3
Original line number Diff line number Diff line
@@ -2906,9 +2906,9 @@ String *Item_func_uuid::val_str(String *str)
  ulonglong tv=my_getsystime() + UUID_TIME_OFFSET + nanoseq;
  if (unlikely(tv < uuid_time))
    set_clock_seq_str();
  else
  if (unlikely(tv == uuid_time))
  { /* special protection from low-res system clocks */
  else if (unlikely(tv == uuid_time))
  {
    /* special protection from low-res system clocks */
    nanoseq++;
    tv++;
  }
+2 −1
Original line number Diff line number Diff line
@@ -787,6 +787,7 @@ static void verify_field_count(MYSQL_RES *result, uint exp_count)

/* Utility function to execute a query using prepare-execute */

#ifndef EMBEDDED_LIBRARY
static void execute_prepare_query(const char *query, ulonglong exp_count)
{
  MYSQL_STMT *stmt;
@@ -807,7 +808,7 @@ static void execute_prepare_query(const char *query, ulonglong exp_count)
  DIE_UNLESS(affected_rows == exp_count);
  mysql_stmt_close(stmt);
}

#endif

/* Store result processing */