summaryrefslogtreecommitdiff
path: root/storage/innobase/dict
diff options
context:
space:
mode:
authorunknown <tsmith@ramayana.hindu.god>2007-08-24 19:14:52 -0600
committerunknown <tsmith@ramayana.hindu.god>2007-08-24 19:14:52 -0600
commit6d4b3c58000a65c35f08057468ae915e23c98a58 (patch)
treee7dc4baeab6840de38f72589ea58600df2658c05 /storage/innobase/dict
parent2bdfe4d7b0215fe47d24db7aa839da1649304dd7 (diff)
downloadmariadb-git-6d4b3c58000a65c35f08057468ae915e23c98a58.tar.gz
Apply InnoDB snapshot innodb-5.1-ss1726.
Bug #16979: AUTO_INC lock in InnoDB works a table level lock - this is a major change in InnoDB auto-inc handling. Bug #27950: Duplicate entry error in auto-inc after mysqld restart - Init AUTOINC from delete_row(). Bug #28781: InnoDB increments auto-increment value incorrectly with ON DUPLICATE KEY UPDATE - Use value specified by MySQL, in update_row(). mysql-test/r/innodb.result: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1655: Fix the innodb.test failure mentioned in r1654. storage/innobase/dict/dict0dict.c: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. Revision r1719: Merge r1264 from branches/zip: Avoid memory fragmentation when adding column definitions to tables. dict_mem_table_add_col(): Add the parameter "heap" for temporary memory allocation. Allow it and "name" to be NULL. These parameters are NULL when creating dummy indexes. dict_add_col_name(): Remove calls to ut_malloc() and ut_free(). dict_table_get_col_name(): Allow table->col_names to be NULL. dict_table_add_system_columns(), dict_table_add_to_cache(): Add the parameter "heap". --- Additional changes that had to be merged from branches/zip: dict_table_add_system_columns(): New function, factored out from dict_table_add_to_cache(). mlog_parse_index(): Add some consistency checks, and make use of dict_table_add_system_columns(). storage/innobase/dict/dict0mem.c: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. Revision r1719: Merge r1264 from branches/zip: Avoid memory fragmentation when adding column definitions to tables. dict_mem_table_add_col(): Add the parameter "heap" for temporary memory allocation. Allow it and "name" to be NULL. These parameters are NULL when creating dummy indexes. dict_add_col_name(): Remove calls to ut_malloc() and ut_free(). dict_table_get_col_name(): Allow table->col_names to be NULL. dict_table_add_system_columns(), dict_table_add_to_cache(): Add the parameter "heap". --- Additional changes that had to be merged from branches/zip: dict_table_add_system_columns(): New function, factored out from dict_table_add_to_cache(). mlog_parse_index(): Add some consistency checks, and make use of dict_table_add_system_columns(). storage/innobase/handler/ha_innodb.cc: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. Revision r1718: Replace mysql_byte with uchar and remove the #define mysql_byte from ha_innodb.cc. This cleanup was made possible as of r1550: Revision r1658: check_trx_exists(): Remove a redundant function call and assignment that was added by someone at MySQL. Revision r1656: Revision r1719: Merge r1264 from branches/zip: Avoid memory fragmentation when adding column definitions to tables. dict_mem_table_add_col(): Add the parameter "heap" for temporary memory allocation. Allow it and "name" to be NULL. These parameters are NULL when creating dummy indexes. dict_add_col_name(): Remove calls to ut_malloc() and ut_free(). dict_table_get_col_name(): Allow table->col_names to be NULL. dict_table_add_system_columns(), dict_table_add_to_cache(): Add the parameter "heap". --- Additional changes that had to be merged from branches/zip: dict_table_add_system_columns(): New function, factored out from dict_table_add_to_cache(). mlog_parse_index(): Add some consistency checks, and make use of dict_table_add_system_columns(). Revision r1654: One test case in innodb.test fails because of auto-increment changes in r1562:1653: $diff innodb.result innodb.reject 504c504 < 3 test2 this will work --- > 4 test2 this will work storage/innobase/handler/ha_innodb.h: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. Revision r1654: One test case in innodb.test fails because of auto-increment changes in r1562:1653: $diff innodb.result innodb.reject 504c504 < 3 test2 this will work --- > 4 test2 this will work storage/innobase/ibuf/ibuf0ibuf.c: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1715: ibuf0ibuf.c: Remove the unused prototype for dict_index_print_low() that was inadvertently added in r832. Revision r1719: Merge r1264 from branches/zip: Avoid memory fragmentation when adding column definitions to tables. dict_mem_table_add_col(): Add the parameter "heap" for temporary memory allocation. Allow it and "name" to be NULL. These parameters are NULL when creating dummy indexes. dict_add_col_name(): Remove calls to ut_malloc() and ut_free(). dict_table_get_col_name(): Allow table->col_names to be NULL. dict_table_add_system_columns(), dict_table_add_to_cache(): Add the parameter "heap". --- Additional changes that had to be merged from branches/zip: dict_table_add_system_columns(): New function, factored out from dict_table_add_to_cache(). mlog_parse_index(): Add some consistency checks, and make use of dict_table_add_system_columns(). storage/innobase/include/dict0dict.h: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. Revision r1719: Merge r1264 from branches/zip: Avoid memory fragmentation when adding column definitions to tables. dict_mem_table_add_col(): Add the parameter "heap" for temporary memory allocation. Allow it and "name" to be NULL. These parameters are NULL when creating dummy indexes. dict_add_col_name(): Remove calls to ut_malloc() and ut_free(). dict_table_get_col_name(): Allow table->col_names to be NULL. dict_table_add_system_columns(), dict_table_add_to_cache(): Add the parameter "heap". --- Additional changes that had to be merged from branches/zip: dict_table_add_system_columns(): New function, factored out from dict_table_add_to_cache(). mlog_parse_index(): Add some consistency checks, and make use of dict_table_add_system_columns(). storage/innobase/include/dict0mem.h: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. Revision r1719: Merge r1264 from branches/zip: Avoid memory fragmentation when adding column definitions to tables. dict_mem_table_add_col(): Add the parameter "heap" for temporary memory allocation. Allow it and "name" to be NULL. These parameters are NULL when creating dummy indexes. dict_add_col_name(): Remove calls to ut_malloc() and ut_free(). dict_table_get_col_name(): Allow table->col_names to be NULL. dict_table_add_system_columns(), dict_table_add_to_cache(): Add the parameter "heap". --- Additional changes that had to be merged from branches/zip: dict_table_add_system_columns(): New function, factored out from dict_table_add_to_cache(). mlog_parse_index(): Add some consistency checks, and make use of dict_table_add_system_columns(). storage/innobase/include/lock0lock.h: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1664: lock_number_of_rows_locked(): Fix a typo in comment, and make the comments in lock0lock.c and lock0lock.h identical. The typo was incorrectly fixed in r1623. storage/innobase/include/row0mysql.h: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. storage/innobase/include/row0sel.h: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. storage/innobase/include/trx0trx.h: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. storage/innobase/include/ut0mem.h: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1713: Fix typo in comment. storage/innobase/log/log0recv.c: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1657: recv_init_crash_recovery(): remove trailing white space storage/innobase/row/row0mysql.c: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. storage/innobase/row/row0sel.c: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB. storage/innobase/trx/trx0trx.c: Apply InnoDB snapshot innodb-5.1-ss1726. Revision r1645: Fix for bug# 16979, this is a major change in InnoDB auto-inc handling. There is one test that fails as of this commit. The updated test case should be part of the snapshot from MySQL shortly. Fix for bug# 27950 - Init AUTOINC from delete_row(). Fix for bug# 28781 - Use value specified by MySQL, in update_row(). Summary of structural changes: ============================== InnoDB needs to hold a table level lock for AUTOINC allocations to overcome the non-determinism inherent in MySQL SBR for INSERT ... SELECT. In this fix for simple INSERT statements (including multi-value inserts), we try and avoid acquiring the special AUTOINC table level lock unless another transaction has already reserved the AUTOINC table level lock, in which case we fall back to the old behavior of acquiring the AUTOINC table level lock. The max AUTOINC value is now read directly using the low level interface of InnoDB.
Diffstat (limited to 'storage/innobase/dict')
-rw-r--r--storage/innobase/dict/dict0dict.c163
-rw-r--r--storage/innobase/dict/dict0mem.c76
2 files changed, 100 insertions, 139 deletions
diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c
index e2a9535dc8b..595dfb06ee5 100644
--- a/storage/innobase/dict/dict0dict.c
+++ b/storage/innobase/dict/dict0dict.c
@@ -410,14 +410,27 @@ dict_table_get_col_name(
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
s = table->col_names;
-
- for (i = 0; i < col_nr; i++) {
- s += strlen(s) + 1;
+ if (s) {
+ for (i = 0; i < col_nr; i++) {
+ s += strlen(s) + 1;
+ }
}
return(s);
}
+
+/************************************************************************
+Acquire the autoinc lock.*/
+
+void
+dict_table_autoinc_lock(
+/*====================*/
+ dict_table_t* table)
+{
+ mutex_enter(&table->autoinc_mutex);
+}
+
/************************************************************************
Initializes the autoinc counter. It is not an error to initialize an already
initialized counter. */
@@ -428,54 +441,8 @@ dict_table_autoinc_initialize(
dict_table_t* table, /* in: table */
ib_longlong value) /* in: next value to assign to a row */
{
- mutex_enter(&(table->autoinc_mutex));
-
table->autoinc_inited = TRUE;
table->autoinc = value;
-
- mutex_exit(&(table->autoinc_mutex));
-}
-
-/************************************************************************
-Gets the next autoinc value (== autoinc counter value), 0 if not yet
-initialized. If initialized, increments the counter by 1. */
-
-ib_longlong
-dict_table_autoinc_get(
-/*===================*/
- /* out: value for a new row, or 0 */
- dict_table_t* table) /* in: table */
-{
- ib_longlong value;
-
- mutex_enter(&(table->autoinc_mutex));
-
- if (!table->autoinc_inited) {
-
- value = 0;
- } else {
- value = table->autoinc;
- table->autoinc = table->autoinc + 1;
- }
-
- mutex_exit(&(table->autoinc_mutex));
-
- return(value);
-}
-
-/************************************************************************
-Decrements the autoinc counter value by 1. */
-
-void
-dict_table_autoinc_decrement(
-/*=========================*/
- dict_table_t* table) /* in: table */
-{
- mutex_enter(&(table->autoinc_mutex));
-
- table->autoinc = table->autoinc - 1;
-
- mutex_exit(&(table->autoinc_mutex));
}
/************************************************************************
@@ -490,32 +457,6 @@ dict_table_autoinc_read(
{
ib_longlong value;
- mutex_enter(&(table->autoinc_mutex));
-
- if (!table->autoinc_inited) {
-
- value = 0;
- } else {
- value = table->autoinc;
- }
-
- mutex_exit(&(table->autoinc_mutex));
-
- return(value);
-}
-
-/************************************************************************
-Peeks the autoinc counter value, 0 if not yet initialized. Does not
-increment the counter. The read not protected by any mutex! */
-
-ib_longlong
-dict_table_autoinc_peek(
-/*====================*/
- /* out: value of the counter */
- dict_table_t* table) /* in: table */
-{
- ib_longlong value;
-
if (!table->autoinc_inited) {
value = 0;
@@ -527,7 +468,7 @@ dict_table_autoinc_peek(
}
/************************************************************************
-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. */
void
@@ -537,15 +478,21 @@ dict_table_autoinc_update(
dict_table_t* table, /* in: table */
ib_longlong value) /* in: value which was assigned to a row */
{
- mutex_enter(&(table->autoinc_mutex));
+ if (table->autoinc_inited && value > table->autoinc) {
- if (table->autoinc_inited) {
- if (value >= table->autoinc) {
- table->autoinc = value + 1;
- }
+ table->autoinc = value;
}
+}
- mutex_exit(&(table->autoinc_mutex));
+/************************************************************************
+Release the autoinc lock.*/
+
+void
+dict_table_autoinc_unlock(
+/*======================*/
+ dict_table_t* table) /* in: release autoinc lock for this table */
+{
+ mutex_exit(&table->autoinc_mutex);
}
/************************************************************************
@@ -842,28 +789,18 @@ dict_table_get(
}
/**************************************************************************
-Adds a table object to the dictionary cache. */
+Adds system columns to a table object. */
void
-dict_table_add_to_cache(
-/*====================*/
- dict_table_t* table) /* in: table */
+dict_table_add_system_columns(
+/*==========================*/
+ dict_table_t* table, /* in/out: table */
+ mem_heap_t* heap) /* in: temporary heap */
{
- ulint fold;
- ulint id_fold;
- ulint i;
- ulint row_len;
-
ut_ad(table);
- ut_ad(mutex_own(&(dict_sys->mutex)));
ut_ad(table->n_def == table->n_cols - DATA_N_SYS_COLS);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
- ut_ad(table->cached == FALSE);
-
- fold = ut_fold_string(table->name);
- id_fold = ut_fold_dulint(table->id);
-
- table->cached = TRUE;
+ ut_ad(!table->cached);
/* NOTE: the system columns MUST be added in the following order
(so that they can be indexed by the numerical value of DATA_ROW_ID,
@@ -871,19 +808,19 @@ dict_table_add_to_cache(
The clustered index will not always physically contain all
system columns. */
- dict_mem_table_add_col(table, "DB_ROW_ID", DATA_SYS,
+ dict_mem_table_add_col(table, heap, "DB_ROW_ID", DATA_SYS,
DATA_ROW_ID | DATA_NOT_NULL,
DATA_ROW_ID_LEN);
#if DATA_ROW_ID != 0
#error "DATA_ROW_ID != 0"
#endif
- dict_mem_table_add_col(table, "DB_TRX_ID", DATA_SYS,
+ dict_mem_table_add_col(table, heap, "DB_TRX_ID", DATA_SYS,
DATA_TRX_ID | DATA_NOT_NULL,
DATA_TRX_ID_LEN);
#if DATA_TRX_ID != 1
#error "DATA_TRX_ID != 1"
#endif
- dict_mem_table_add_col(table, "DB_ROLL_PTR", DATA_SYS,
+ dict_mem_table_add_col(table, heap, "DB_ROLL_PTR", DATA_SYS,
DATA_ROLL_PTR | DATA_NOT_NULL,
DATA_ROLL_PTR_LEN);
#if DATA_ROLL_PTR != 2
@@ -895,10 +832,34 @@ dict_table_add_to_cache(
#if DATA_N_SYS_COLS != 3
#error "DATA_N_SYS_COLS != 3"
#endif
+}
+
+/**************************************************************************
+Adds a table object to the dictionary cache. */
+
+void
+dict_table_add_to_cache(
+/*====================*/
+ dict_table_t* table, /* in: table */
+ mem_heap_t* heap) /* in: temporary heap */
+{
+ ulint fold;
+ ulint id_fold;
+ ulint i;
+ ulint row_len;
/* The lower limit for what we consider a "big" row */
#define BIG_ROW_SIZE 1024
+ ut_ad(mutex_own(&(dict_sys->mutex)));
+
+ dict_table_add_system_columns(table, heap);
+
+ table->cached = TRUE;
+
+ fold = ut_fold_string(table->name);
+ id_fold = ut_fold_dulint(table->id);
+
row_len = 0;
for (i = 0; i < table->n_def; i++) {
ulint col_len = dict_col_get_max_size(
diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c
index 9aa49dee745..e0b8bf15dd7 100644
--- a/storage/innobase/dict/dict0mem.c
+++ b/storage/innobase/dict/dict0mem.c
@@ -90,6 +90,11 @@ dict_mem_table_create(
mutex_create(&table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
table->autoinc_inited = FALSE;
+
+ /* The actual increment value will be set by MySQL, we simply
+ default to 1 here.*/
+ table->autoinc_increment = 1;
+
#ifdef UNIV_DEBUG
table->magic_n = DICT_TABLE_MAGIC_N;
#endif /* UNIV_DEBUG */
@@ -108,18 +113,11 @@ dict_mem_table_free(
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
mutex_free(&(table->autoinc_mutex));
-
- if (table->col_names && (table->n_def < table->n_cols)) {
- ut_free((void*)table->col_names);
- }
-
mem_heap_free(table->heap);
}
/********************************************************************
-Add 'name' to end of the col_names array (see dict_table_t::col_names). Call
-ut_free on col_names (if not NULL), allocate new array (if heap, from it,
-otherwise with ut_malloc), and copy col_names + name to it. */
+Append 'name' to 'col_names' (@see dict_table_t::col_names). */
static
const char*
dict_add_col_name(
@@ -129,21 +127,19 @@ dict_add_col_name(
NULL */
ulint cols, /* in: number of existing columns */
const char* name, /* in: new column name */
- mem_heap_t* heap) /* in: heap, or NULL */
+ mem_heap_t* heap) /* in: heap */
{
- ulint i;
- ulint old_len;
- ulint new_len;
- ulint total_len;
- const char* s;
- char* res;
+ ulint old_len;
+ ulint new_len;
+ ulint total_len;
+ char* res;
- ut_a(((cols == 0) && !col_names) || ((cols > 0) && col_names));
- ut_a(*name);
+ ut_ad(!cols == !col_names);
/* Find out length of existing array. */
if (col_names) {
- s = col_names;
+ const char* s = col_names;
+ ulint i;
for (i = 0; i < cols; i++) {
s += strlen(s) + 1;
@@ -157,11 +153,7 @@ dict_add_col_name(
new_len = strlen(name) + 1;
total_len = old_len + new_len;
- if (heap) {
- res = mem_heap_alloc(heap, total_len);
- } else {
- res = ut_malloc(total_len);
- }
+ res = mem_heap_alloc(heap, total_len);
if (old_len > 0) {
memcpy(res, col_names, old_len);
@@ -169,10 +161,6 @@ dict_add_col_name(
memcpy(res + old_len, name, new_len);
- if (col_names) {
- ut_free((char*)col_names);
- }
-
return(res);
}
@@ -183,7 +171,8 @@ void
dict_mem_table_add_col(
/*===================*/
dict_table_t* table, /* in: table */
- const char* name, /* in: column name */
+ mem_heap_t* heap, /* in: temporary memory heap, or NULL */
+ const char* name, /* in: column name, or NULL */
ulint mtype, /* in: main datatype */
ulint prtype, /* in: precise type */
ulint len) /* in: precision */
@@ -191,21 +180,32 @@ dict_mem_table_add_col(
dict_col_t* col;
ulint mbminlen;
ulint mbmaxlen;
- mem_heap_t* heap;
+ ulint i;
- ut_ad(table && name);
+ ut_ad(table);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
+ ut_ad(!heap == !name);
- table->n_def++;
+ i = table->n_def++;
- heap = table->n_def < table->n_cols ? NULL : table->heap;
- table->col_names = dict_add_col_name(table->col_names,
- table->n_def - 1,
- name, heap);
+ if (name) {
+ if (UNIV_UNLIKELY(table->n_def == table->n_cols)) {
+ heap = table->heap;
+ }
+ if (UNIV_LIKELY(i) && UNIV_UNLIKELY(!table->col_names)) {
+ /* All preceding column names are empty. */
+ char* s = mem_heap_alloc(heap, table->n_def);
+ memset(s, 0, table->n_def);
+ table->col_names = s;
+ }
+
+ table->col_names = dict_add_col_name(table->col_names,
+ i, name, heap);
+ }
- col = (dict_col_t*) dict_table_get_nth_col(table, table->n_def - 1);
+ col = (dict_col_t*) dict_table_get_nth_col(table, i);
- col->ind = table->n_def - 1;
+ col->ind = i;
col->ord_part = 0;
col->mtype = (unsigned int) mtype;
@@ -318,7 +318,7 @@ dict_mem_index_add_field(
{
dict_field_t* field;
- ut_ad(index && name);
+ ut_ad(index);
ut_ad(index->magic_n == DICT_INDEX_MAGIC_N);
index->n_def++;