Commit f3c6e06e authored by sunny's avatar sunny

branches/zip:

Merge revisions 2852:2854 from branches/5.1:

  ------------------------------------------------------------------------
  r2854 | sunny | 2008-10-23 08:30:32 +0300 (Thu, 23 Oct 2008) | 13 lines
  Changed paths:
     M /branches/5.1/dict/dict0dict.c
     M /branches/5.1/dict/dict0mem.c
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/handler/ha_innodb.h
     M /branches/5.1/include/dict0dict.h
     M /branches/5.1/include/dict0mem.h
     M /branches/5.1/row/row0mysql.c
  
  branches/5.1: Backport changes from branches/zip r2725
  
  Simplify the autoinc initialization code. This removes the
  non-determinism related to reading the table's autoinc value for the first
  time. This change has also reduced the sizeof dict_table_t by sizeof(ibool)
  bytes because we don't need the dict_table_t::autoinc_inited field anymore.
  
  Bug#39830 Table autoinc value not updated on first insert.
  Bug#35498 Cannot get table test/table1 auto-inccounter value in ::info
  Bug#36411 Failed to read auto-increment value from storage engine" in 5.1.24 auto-inc
  rb://16
  
  
  ------------------------------------------------------------------------
parent d7655cbc
...@@ -317,7 +317,7 @@ dict_table_autoinc_read( ...@@ -317,7 +317,7 @@ dict_table_autoinc_read(
/************************************************************************ /************************************************************************
Updates the autoinc counter if the value supplied is greater than the Updates the autoinc counter if the value supplied is greater than the
current value. If not inited, does nothing. */ current value. */
UNIV_INTERN UNIV_INTERN
void void
dict_table_autoinc_update_if_greater( dict_table_autoinc_update_if_greater(
...@@ -329,6 +329,7 @@ dict_table_autoinc_update_if_greater( ...@@ -329,6 +329,7 @@ dict_table_autoinc_update_if_greater(
ut_ad(mutex_own(&table->autoinc_mutex)); ut_ad(mutex_own(&table->autoinc_mutex));
if (value > table->autoinc) { if (value > table->autoinc) {
table->autoinc = value; table->autoinc = value;
} }
} }
......
...@@ -62,6 +62,12 @@ dict_mem_table_create( ...@@ -62,6 +62,12 @@ dict_mem_table_create(
mutex_create(&table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX); mutex_create(&table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
table->autoinc = 0;
/* The number of transactions that are either waiting on the
AUTOINC lock or have been granted the lock. */
table->n_waiting_or_granted_auto_inc_locks = 0;
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
table->magic_n = DICT_TABLE_MAGIC_N; table->magic_n = DICT_TABLE_MAGIC_N;
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
......
...@@ -1136,7 +1136,7 @@ innobase_next_autoinc( ...@@ -1136,7 +1136,7 @@ innobase_next_autoinc(
/* Should never be 0. */ /* Should never be 0. */
ut_a(increment > 0); ut_a(increment > 0);
if (current >= max_value) { if (max_value <= current) {
next_value = max_value; next_value = max_value;
} else if (offset <= 1) { } else if (offset <= 1) {
/* Offset 0 and 1 are the same, because there must be at /* Offset 0 and 1 are the same, because there must be at
...@@ -1163,6 +1163,8 @@ innobase_next_autoinc( ...@@ -1163,6 +1163,8 @@ innobase_next_autoinc(
} else { } else {
next_value *= increment; next_value *= increment;
ut_a(max_value >= next_value);
/* Check for overflow. */ /* Check for overflow. */
if (max_value - next_value <= offset) { if (max_value - next_value <= offset) {
next_value = max_value; next_value = max_value;
...@@ -2834,7 +2836,7 @@ ha_innobase::innobase_initialize_autoinc() ...@@ -2834,7 +2836,7 @@ ha_innobase::innobase_initialize_autoinc()
"index (%s).\n", error, col_name, index->name); "index (%s).\n", error, col_name, index->name);
} }
return(ulong(error)); return(error);
} }
/********************************************************************* /*********************************************************************
......
...@@ -81,7 +81,7 @@ class ha_innobase: public handler ...@@ -81,7 +81,7 @@ class ha_innobase: public handler
ulint innobase_update_autoinc(ulonglong auto_inc); ulint innobase_update_autoinc(ulonglong auto_inc);
ulint innobase_initialize_autoinc(); ulint innobase_initialize_autoinc();
dict_index_t* innobase_get_index(uint keynr); dict_index_t* innobase_get_index(uint keynr);
ulonglong innobase_get_int_col_max_value(const Field* field); ulonglong innobase_get_int_col_max_value(const Field* field);
/* Init values for the class: */ /* Init values for the class: */
public: public:
......
...@@ -189,8 +189,8 @@ dict_table_autoinc_read( ...@@ -189,8 +189,8 @@ dict_table_autoinc_read(
/* out: value for a new row, or 0 */ /* out: value for a new row, or 0 */
const dict_table_t* table); /* in: table */ const dict_table_t* table); /* in: table */
/************************************************************************ /************************************************************************
Updates the autoinc counter if the value supplied is equal or bigger than the Updates the autoinc counter if the value supplied is greater than the
current value. If not inited, does nothing. */ current value. */
UNIV_INTERN UNIV_INTERN
void void
dict_table_autoinc_update_if_greater( dict_table_autoinc_update_if_greater(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment