summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorunknown <acurtis/antony@xiphis.org/ltamd64.xiphis.org>2007-09-08 11:19:35 -0700
committerunknown <acurtis/antony@xiphis.org/ltamd64.xiphis.org>2007-09-08 11:19:35 -0700
commitbec076f494ad7dd014dc7fc596beaa7e494210fe (patch)
tree17d593ba05a33afb99ac0a48c390109f871fecfb /storage
parentaff30b40cd4e8aebfe134be74c57bf6bdef6120e (diff)
downloadmariadb-git-bec076f494ad7dd014dc7fc596beaa7e494210fe.tar.gz
Bug#30907
"Regression: "--innodb_autoinc_lock_mode=0" (off) not same as older releases" Bug#28430 "Failure in replication of innodb partitioned tables on row/mixed format" Bug#30888 "Innodb table + stored procedure + row deletion = server crash" Apply Oracle patch from Sunny Include tests cases by Omer Ensure that innobase_read_and_init_auto performs table autoinc lock when lock_mode = 0 No need for "if" guard around row_unlock_table_autoinc_for_mysql() because it already performs same check. Make autoinc_lock_mode variable read-only for duration of running mysqld process. storage/innobase/handler/ha_innodb.cc: Bug30907/28430 "Regression: "--innodb_autoinc_lock_mode=0" (off) not same as older releases" "Failure in replication of innodb partitioned tables on row/mixed format" Apply Oracle patch from Sunny Ensure that innobase_read_and_init_auto performs table autoinc lock when lock_mode = 0 No need for "if" guard around row_unlock_table_autoinc_for_mysql() because it already performs same check. Make autoinc_lock_mode variable read-only for duration of running mysqld process. storage/innobase/row/row0sel.c: Bug30888 "Innodb table + stored procedure + row deletion = server crash" Remove endian-specific code. Fix function row_search_autoinc_read_column() to handle any integer size up to 8 bytes. mysql-test/suite/rpl/r/rpl_innodb_bug28430.result: New BitKeeper file ``mysql-test/suite/rpl/r/rpl_innodb_bug28430.result'' mysql-test/suite/rpl/r/rpl_innodb_bug30888.result: New BitKeeper file ``mysql-test/suite/rpl/r/rpl_innodb_bug30888.result'' mysql-test/suite/rpl/t/rpl_innodb-master.opt: New BitKeeper file ``mysql-test/suite/rpl/t/rpl_innodb-master.opt'' mysql-test/suite/rpl/t/rpl_innodb_bug28430-master.opt: New BitKeeper file ``mysql-test/suite/rpl/t/rpl_innodb_bug28430-master.opt'' mysql-test/suite/rpl/t/rpl_innodb_bug28430.test: New BitKeeper file ``mysql-test/suite/rpl/t/rpl_innodb_bug28430.test'' mysql-test/suite/rpl/t/rpl_innodb_bug30888.test: New BitKeeper file ``mysql-test/suite/rpl/t/rpl_innodb_bug30888.test''
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/handler/ha_innodb.cc99
-rw-r--r--storage/innobase/row/row0sel.c48
2 files changed, 53 insertions, 94 deletions
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index f4f24b33f53..793e0f8e070 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -1904,12 +1904,11 @@ retry:
/* We just mark the SQL statement ended and do not do a
transaction commit */
- if (trx->auto_inc_lock) {
- /* If we had reserved the auto-inc lock for some
- table in this SQL statement we release it now */
+ /* If we had reserved the auto-inc lock for some
+ table in this SQL statement we release it now */
+
+ row_unlock_table_autoinc_for_mysql(trx);
- row_unlock_table_autoinc_for_mysql(trx);
- }
/* Store the current undo_no of the transaction so that we
know where to roll back if we have to roll back the next
SQL statement */
@@ -1962,13 +1961,11 @@ innobase_rollback(
innobase_release_stat_resources(trx);
- if (trx->auto_inc_lock) {
- /* If we had reserved the auto-inc lock for some table (if
- we come here to roll back the latest SQL statement) we
- release it now before a possibly lengthy rollback */
+ /* If we had reserved the auto-inc lock for some table (if
+ we come here to roll back the latest SQL statement) we
+ release it now before a possibly lengthy rollback */
- row_unlock_table_autoinc_for_mysql(trx);
- }
+ row_unlock_table_autoinc_for_mysql(trx);
if (all
|| !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
@@ -2002,13 +1999,11 @@ innobase_rollback_trx(
innobase_release_stat_resources(trx);
- if (trx->auto_inc_lock) {
- /* If we had reserved the auto-inc lock for some table (if
- we come here to roll back the latest SQL statement) we
- release it now before a possibly lengthy rollback */
+ /* If we had reserved the auto-inc lock for some table (if
+ we come here to roll back the latest SQL statement) we
+ release it now before a possibly lengthy rollback */
- row_unlock_table_autoinc_for_mysql(trx);
- }
+ row_unlock_table_autoinc_for_mysql(trx);
error = trx_rollback_for_mysql(trx);
@@ -7135,6 +7130,7 @@ ha_innobase::innobase_read_and_init_auto_inc(
int mysql_error = 0;
dict_table_t* innodb_table = prebuilt->table;
ibool trx_was_not_started = FALSE;
+ ulint error;
ut_a(prebuilt);
ut_a(prebuilt->table);
@@ -7155,7 +7151,11 @@ ha_innobase::innobase_read_and_init_auto_inc(
trx_search_latch_release_if_reserved(prebuilt->trx);
- dict_table_autoinc_lock(prebuilt->table);
+ error = innobase_autoinc_lock();
+ if (error != DB_SUCCESS) {
+ mysql_error = 1;
+ goto err;
+ }
auto_inc = dict_table_autoinc_read(prebuilt->table);
@@ -7168,7 +7168,6 @@ ha_innobase::innobase_read_and_init_auto_inc(
if (auto_inc == 0) {
dict_index_t* index;
- ulint error = DB_SUCCESS;
const char* autoinc_col_name;
ut_a(!innodb_table->autoinc_inited);
@@ -7196,6 +7195,7 @@ ha_innobase::innobase_read_and_init_auto_inc(
dict_table_autoinc_unlock(prebuilt->table);
+err:
/* Since MySQL does not seem to call autocommit after SHOW TABLE
STATUS (even if we would register the trx here), we commit our
transaction here if it was started here. This is to eliminate a
@@ -7240,12 +7240,10 @@ ha_innobase::innobase_get_auto_increment(
trx = prebuilt->trx;
dict_table_autoinc_unlock(prebuilt->table);
- if (trx->auto_inc_lock) {
- /* If we had reserved the AUTO-INC
- lock in this SQL statement we release
- it before retrying.*/
- row_unlock_table_autoinc_for_mysql(trx);
- }
+ /* If we had reserved the AUTO-INC
+ lock in this SQL statement we release
+ it before retrying.*/
+ row_unlock_table_autoinc_for_mysql(trx);
/* Just to make sure */
ut_a(!trx->auto_inc_lock);
@@ -7287,6 +7285,7 @@ ha_innobase::get_auto_increment(
ulonglong *first_value, /* out: the autoinc value */
ulonglong *nb_reserved_values) /* out: count of reserved values */
{
+ trx_t* trx;
ulint error;
ulonglong autoinc = 0;
@@ -7313,37 +7312,29 @@ ha_innobase::get_auto_increment(
this method for the same statement results in different values which
don't make sense. Therefore we store the value the first time we are
called and count down from that as rows are written (see write_row()).
+ */
- We make one exception, if the *first_value is precomputed by MySQL
- we use that value. And set the number of reserved values to 1 if
- this is the first time we were called for the SQL statement, this
- will force MySQL to call us for the next value. If we are in the
- middle of a multi-row insert we preserve the existing counter.*/
- if (*first_value == 0) {
-
- /* Called for the first time ? */
- if (prebuilt->trx->n_autoinc_rows == 0) {
+ trx = prebuilt->trx;
- prebuilt->trx->n_autoinc_rows = (ulint) nb_desired_values;
+ /* Called for the first time ? */
+ if (trx->n_autoinc_rows == 0) {
- /* It's possible for nb_desired_values to be 0:
- e.g., INSERT INTO T1(C) SELECT C FROM T2; */
- if (nb_desired_values == 0) {
+ trx->n_autoinc_rows = nb_desired_values;
- ++prebuilt->trx->n_autoinc_rows;
- }
+ /* It's possible for nb_desired_values to be 0:
+ e.g., INSERT INTO T1(C) SELECT C FROM T2; */
+ if (nb_desired_values == 0) {
+
+ trx->n_autoinc_rows = 1;
}
-
+
+ *first_value = autoinc;
+ /* Not in the middle of a mult-row INSERT. */
+ } else if (prebuilt->last_value == 0) {
*first_value = autoinc;
-
- } else if (prebuilt->trx->n_autoinc_rows == 0) {
-
- prebuilt->trx->n_autoinc_rows = 1;
}
-
- ut_a(prebuilt->trx->n_autoinc_rows > 0);
-
- *nb_reserved_values = prebuilt->trx->n_autoinc_rows;
+
+ *nb_reserved_values = trx->n_autoinc_rows;
/* With old style AUTOINC locking we only update the table's
AUTOINC counter after attempting to insert the row. */
@@ -7670,12 +7661,10 @@ innobase_xa_prepare(
/* We just mark the SQL statement ended and do not do a
transaction prepare */
- if (trx->auto_inc_lock) {
- /* If we had reserved the auto-inc lock for some
- table in this SQL statement we release it now */
+ /* If we had reserved the auto-inc lock for some
+ table in this SQL statement we release it now */
- row_unlock_table_autoinc_for_mysql(trx);
- }
+ row_unlock_table_autoinc_for_mysql(trx);
/* Store the current undo_no of the transaction so that we
know where to roll back if we have to roll back the next
@@ -8026,7 +8015,7 @@ static MYSQL_SYSVAR_STR(data_file_path, innobase_data_file_path,
NULL, NULL, NULL);
static MYSQL_SYSVAR_LONG(autoinc_lock_mode, innobase_autoinc_lock_mode,
- PLUGIN_VAR_RQCMDARG,
+ PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
"The AUTOINC lock modes supported by InnoDB:\n"
" 0 => Old style AUTOINC locking (for backward compatibility)\n"
" 1 => New style AUTOINC locking\n"
diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c
index 9cb4e0f6f20..fdf6aa46351 100644
--- a/storage/innobase/row/row0sel.c
+++ b/storage/innobase/row/row0sel.c
@@ -4533,7 +4533,6 @@ row_search_autoinc_read_column(
ibool unsigned_type) /* in: signed or unsigned flag */
{
ulint len;
- byte* ptr;
const byte* data;
ib_longlong value;
mem_heap_t* heap = NULL;
@@ -4555,49 +4554,20 @@ row_search_autoinc_read_column(
ut_a(len != UNIV_SQL_NULL);
ut_a(len <= sizeof value);
-#ifdef WORDS_BIGENDIAN
/* Copy integer data and restore sign bit */
+ if (unsigned_type || (data[0] & 128))
+ memset(dest, 0x00, sizeof(dest));
+ else
+ memset(dest, 0xff, sizeof(dest));
- memcpy((ptr = dest), data, len);
+ memcpy(dest + (sizeof(value) - len), data, len);
- if (!unsigned_type) {
- dest[0] ^= 128;
- }
-#else
- /* Convert integer data from Innobase to a little-endian format,
- sign bit restored to normal */
-
- for (ptr = dest + len; ptr != dest; ++data) {
- --ptr;
- *ptr = *data;
- }
-
- if (!unsigned_type) {
- dest[len - 1] ^= 128;
- }
-#endif
+ if (!unsigned_type)
+ dest[sizeof(value) - len] ^= 128;
/* The assumption here is that the AUTOINC value can't be negative.*/
- switch (len) {
- case 8:
- value = *(ib_longlong*) ptr;
- break;
-
- case 4:
- value = *(ib_uint32_t*) ptr;
- break;
-
- case 2:
- value = *(uint16 *) ptr;
- break;
-
- case 1:
- value = *ptr;
- break;
-
- default:
- ut_error;
- }
+ value = (((ib_longlong) mach_read_from_4(dest)) << 32) |
+ ((ib_longlong) mach_read_from_4(dest + 4));
if (UNIV_LIKELY_NULL(heap)) {
mem_heap_free(heap);