summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzr-mysql/default.conf6
-rw-r--r--mysql-test/suite/innodb_plugin/r/innodb-autoinc-18274.result26
-rw-r--r--mysql-test/suite/innodb_plugin/t/innodb-autoinc-18274.test29
-rw-r--r--storage/innodb_plugin/ChangeLog4
-rw-r--r--storage/innodb_plugin/buf/buf0lru.c16
-rw-r--r--storage/innodb_plugin/handler/ha_innodb.cc206
-rw-r--r--storage/innodb_plugin/plug.in3
-rw-r--r--storage/innodb_plugin/trx/trx0i_s.c2
8 files changed, 180 insertions, 112 deletions
diff --git a/.bzr-mysql/default.conf b/.bzr-mysql/default.conf
index e613cefc614..4ea90534645 100644
--- a/.bzr-mysql/default.conf
+++ b/.bzr-mysql/default.conf
@@ -1,4 +1,4 @@
[MYSQL]
-post_commit_to = "commits@lists.mysql.com"
-post_push_to = "commits@lists.mysql.com"
-tree_name = "mysql-5.1-bugteam"
+post_commit_to = commits@lists.mysql.com, innodb_dev_ww@oracle.com
+post_push_to = commits@lists.mysql.com, innodb_dev_ww@oracle.com
+tree_name = "mysql-5.1-innodb"
diff --git a/mysql-test/suite/innodb_plugin/r/innodb-autoinc-18274.result b/mysql-test/suite/innodb_plugin/r/innodb-autoinc-18274.result
new file mode 100644
index 00000000000..22afc65a649
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/r/innodb-autoinc-18274.result
@@ -0,0 +1,26 @@
+drop table if exists t1;
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (null);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
+DELETE FROM t1;
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
+test.t1 optimize status OK
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (`c1`)
+) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES(null);
+SELECT * FROM t1;
+c1
+2
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb_plugin/t/innodb-autoinc-18274.test b/mysql-test/suite/innodb_plugin/t/innodb-autoinc-18274.test
new file mode 100644
index 00000000000..8734311dd7a
--- /dev/null
+++ b/mysql-test/suite/innodb_plugin/t/innodb-autoinc-18274.test
@@ -0,0 +1,29 @@
+-- source include/have_innodb_plugin.inc
+# embedded server ignores 'delayed', so skip this
+-- source include/not_embedded.inc
+
+let $innodb_file_format_check_orig=`select @@innodb_file_format_check`;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
+# Bug #18274 InnoDB auto_increment field reset on OPTIMIZE TABLE
+SET @@SESSION.AUTO_INCREMENT_INCREMENT=1, @@SESSION.AUTO_INCREMENT_OFFSET=1;
+CREATE TABLE t1 (c1 INT PRIMARY KEY AUTO_INCREMENT) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (null);
+SHOW CREATE TABLE t1;
+DELETE FROM t1;
+OPTIMIZE TABLE t1;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES(null);
+SELECT * FROM t1;
+DROP TABLE t1;
+
+#
+# restore environment to the state it was before this test execution
+#
+
+-- disable_query_log
+eval set global innodb_file_format_check=$innodb_file_format_check_orig;
diff --git a/storage/innodb_plugin/ChangeLog b/storage/innodb_plugin/ChangeLog
index 5ca60eb73d5..347dc9a5183 100644
--- a/storage/innodb_plugin/ChangeLog
+++ b/storage/innodb_plugin/ChangeLog
@@ -1,3 +1,7 @@
+2010-12-09 The InnoDB Team
+ * buf/buf0lru.c:
+ Fix Bug#57600 output of I/O sum[%lu] can go negative
+
2010-11-11 The InnoDB Team
* thr/thr0loc.c, trx/trx0i_s.c:
Fix Bug#57802 Empty ASSERTION parameter passed to the HASH_SEARCH macro
diff --git a/storage/innodb_plugin/buf/buf0lru.c b/storage/innodb_plugin/buf/buf0lru.c
index 78d8d348e2a..e4cf218bf2e 100644
--- a/storage/innodb_plugin/buf/buf0lru.c
+++ b/storage/innodb_plugin/buf/buf0lru.c
@@ -1942,6 +1942,7 @@ buf_LRU_stat_update(void)
/*=====================*/
{
buf_LRU_stat_t* item;
+ buf_LRU_stat_t cur_stat;
/* If we haven't started eviction yet then don't update stats. */
if (buf_pool->freed_page_clock == 0) {
@@ -1955,12 +1956,19 @@ buf_LRU_stat_update(void)
buf_LRU_stat_arr_ind++;
buf_LRU_stat_arr_ind %= BUF_LRU_STAT_N_INTERVAL;
- /* Add the current value and subtract the obsolete entry. */
- buf_LRU_stat_sum.io += buf_LRU_stat_cur.io - item->io;
- buf_LRU_stat_sum.unzip += buf_LRU_stat_cur.unzip - item->unzip;
+ /* Add the current value and subtract the obsolete entry.
+ Since buf_LRU_stat_cur is not protected by any mutex,
+ it can be changing between adding to buf_LRU_stat_sum
+ and copying to item. Assign it to local variables to make
+ sure the same value assign to the buf_LRU_stat_sum
+ and item */
+ cur_stat = buf_LRU_stat_cur;
+
+ buf_LRU_stat_sum.io += cur_stat.io - item->io;
+ buf_LRU_stat_sum.unzip += cur_stat.unzip - item->unzip;
/* Put current entry in the array. */
- memcpy(item, &buf_LRU_stat_cur, sizeof *item);
+ memcpy(item, &cur_stat, sizeof *item);
buf_pool_mutex_exit();
diff --git a/storage/innodb_plugin/handler/ha_innodb.cc b/storage/innodb_plugin/handler/ha_innodb.cc
index 5965bd0e59e..86168e2bc9b 100644
--- a/storage/innodb_plugin/handler/ha_innodb.cc
+++ b/storage/innodb_plugin/handler/ha_innodb.cc
@@ -6293,10 +6293,11 @@ create_clustered_index_when_no_primary(
/*****************************************************************//**
Return a display name for the row format
@return row format name */
-
-const char *get_row_format_name(
-/*============================*/
-enum row_type row_format) /*!< in: Row Format */
+UNIV_INTERN
+const char*
+get_row_format_name(
+/*================*/
+ enum row_type row_format) /*!< in: Row Format */
{
switch (row_format) {
case ROW_TYPE_COMPACT:
@@ -6311,12 +6312,38 @@ enum row_type row_format) /*!< in: Row Format */
return("DEFAULT");
case ROW_TYPE_FIXED:
return("FIXED");
- default:
+ case ROW_TYPE_PAGE:
+ case ROW_TYPE_NOT_USED:
break;
}
return("NOT USED");
}
+/** If file-per-table is missing, issue warning and set ret false */
+#define CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE \
+ if (!srv_file_per_table) { \
+ push_warning_printf( \
+ thd, MYSQL_ERROR::WARN_LEVEL_WARN, \
+ ER_ILLEGAL_HA_CREATE_OPTION, \
+ "InnoDB: ROW_FORMAT=%s requires" \
+ " innodb_file_per_table.", \
+ get_row_format_name(row_format)); \
+ ret = FALSE; \
+ }
+
+/** If file-format is Antelope, issue warning and set ret false */
+#define CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE \
+ if (srv_file_format < DICT_TF_FORMAT_ZIP) { \
+ push_warning_printf( \
+ thd, MYSQL_ERROR::WARN_LEVEL_WARN, \
+ ER_ILLEGAL_HA_CREATE_OPTION, \
+ "InnoDB: ROW_FORMAT=%s requires" \
+ " innodb_file_format > Antelope.", \
+ get_row_format_name(row_format)); \
+ ret = FALSE; \
+ }
+
+
/*****************************************************************//**
Validates the create options. We may build on this function
in future. For now, it checks two specifiers:
@@ -6334,7 +6361,7 @@ create_options_are_valid(
{
ibool kbs_specified = FALSE;
ibool ret = TRUE;
- enum row_type row_type = form->s->row_type;
+ enum row_type row_format = form->s->row_type;
ut_ad(thd != NULL);
@@ -6343,23 +6370,6 @@ create_options_are_valid(
return(TRUE);
}
- /* Check for a valid Innodb ROW_FORMAT specifier. For example,
- ROW_TYPE_FIXED can be sent to Innodb */
- switch (row_type) {
- case ROW_TYPE_COMPACT:
- case ROW_TYPE_COMPRESSED:
- case ROW_TYPE_DYNAMIC:
- case ROW_TYPE_REDUNDANT:
- case ROW_TYPE_DEFAULT:
- break;
- default:
- push_warning(
- thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: invalid ROW_FORMAT specifier.");
- ret = FALSE;
- }
-
ut_ad(form != NULL);
ut_ad(create_info != NULL);
@@ -6372,7 +6382,23 @@ create_options_are_valid(
case 4:
case 8:
case 16:
- /* Valid value. */
+ /* Valid KEY_BLOCK_SIZE, check its dependencies. */
+ if (!srv_file_per_table) {
+ push_warning(
+ thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ "InnoDB: KEY_BLOCK_SIZE requires"
+ " innodb_file_per_table.");
+ ret = FALSE;
+ }
+ if (srv_file_format < DICT_TF_FORMAT_ZIP) {
+ push_warning(
+ thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION,
+ "InnoDB: KEY_BLOCK_SIZE requires"
+ " innodb_file_format > Antelope.");
+ ret = FALSE;
+ }
break;
default:
push_warning_printf(
@@ -6382,72 +6408,43 @@ create_options_are_valid(
" Valid values are [1, 2, 4, 8, 16]",
create_info->key_block_size);
ret = FALSE;
+ break;
}
}
- /* If KEY_BLOCK_SIZE was specified, check for its
- dependencies. */
- if (kbs_specified && !srv_file_per_table) {
- push_warning(
- thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: KEY_BLOCK_SIZE"
- " requires innodb_file_per_table.");
- ret = FALSE;
- }
-
- if (kbs_specified && srv_file_format < DICT_TF_FORMAT_ZIP) {
- push_warning(
- thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: KEY_BLOCK_SIZE requires"
- " innodb_file_format > Antelope.");
- ret = FALSE;
- }
-
- switch (row_type) {
+ /* Check for a valid Innodb ROW_FORMAT specifier and
+ other incompatibilities. */
+ switch (row_format) {
case ROW_TYPE_COMPRESSED:
- case ROW_TYPE_DYNAMIC:
- /* These two ROW_FORMATs require srv_file_per_table
- and srv_file_format > Antelope */
- if (!srv_file_per_table) {
- push_warning_printf(
- thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: ROW_FORMAT=%s"
- " requires innodb_file_per_table.",
- get_row_format_name(row_type));
- ret = FALSE;
- }
-
- if (srv_file_format < DICT_TF_FORMAT_ZIP) {
- push_warning_printf(
- thd, MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: ROW_FORMAT=%s requires"
- " innodb_file_format > Antelope.",
- get_row_format_name(row_type));
- ret = FALSE;
- }
- default:
+ CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE;
+ CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE;
break;
- }
-
- switch (row_type) {
- case ROW_TYPE_REDUNDANT:
- case ROW_TYPE_COMPACT:
case ROW_TYPE_DYNAMIC:
- /* KEY_BLOCK_SIZE is only allowed with Compressed or Default */
+ CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE;
+ CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE;
+ /* fall through since dynamic also shuns KBS */
+ case ROW_TYPE_COMPACT:
+ case ROW_TYPE_REDUNDANT:
if (kbs_specified) {
push_warning_printf(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: cannot specify ROW_FORMAT = %s"
" with KEY_BLOCK_SIZE.",
- get_row_format_name(row_type));
- ret = FALSE;
+ get_row_format_name(row_format));
+ ret = FALSE;
}
- default:
+ break;
+ case ROW_TYPE_DEFAULT:
+ break;
+ case ROW_TYPE_FIXED:
+ case ROW_TYPE_PAGE:
+ case ROW_TYPE_NOT_USED:
+ push_warning(
+ thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_ILLEGAL_HA_CREATE_OPTION, \
+ "InnoDB: invalid ROW_FORMAT specifier.");
+ ret = FALSE;
break;
}
@@ -6498,7 +6495,7 @@ ha_innobase::create(
const ulint file_format = srv_file_format;
const char* stmt;
size_t stmt_len;
- enum row_type row_type;
+ enum row_type row_format;
DBUG_ENTER("ha_innobase::create");
@@ -6598,8 +6595,8 @@ ha_innobase::create(
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: KEY_BLOCK_SIZE"
- " requires innodb_file_per_table.");
+ "InnoDB: KEY_BLOCK_SIZE requires"
+ " innodb_file_per_table.");
flags = 0;
}
@@ -6616,20 +6613,19 @@ ha_innobase::create(
push_warning_printf(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
- "InnoDB: ignoring"
- " KEY_BLOCK_SIZE=%lu.",
+ "InnoDB: ignoring KEY_BLOCK_SIZE=%lu.",
create_info->key_block_size);
}
}
- row_type = form->s->row_type;
+ row_format = form->s->row_type;
if (flags) {
/* if ROW_FORMAT is set to default,
automatically change it to COMPRESSED.*/
- if (row_type == ROW_TYPE_DEFAULT) {
- row_type = ROW_TYPE_COMPRESSED;
- } else if (row_type != ROW_TYPE_COMPRESSED) {
+ if (row_format == ROW_TYPE_DEFAULT) {
+ row_format = ROW_TYPE_COMPRESSED;
+ } else if (row_format != ROW_TYPE_COMPRESSED) {
/* ROW_FORMAT other than COMPRESSED
ignores KEY_BLOCK_SIZE. It does not
make sense to reject conflicting
@@ -6646,7 +6642,7 @@ ha_innobase::create(
}
} else {
/* flags == 0 means no KEY_BLOCK_SIZE.*/
- if (row_type == ROW_TYPE_COMPRESSED) {
+ if (row_format == ROW_TYPE_COMPRESSED) {
/* ROW_FORMAT=COMPRESSED without
KEY_BLOCK_SIZE implies half the
maximum KEY_BLOCK_SIZE. */
@@ -6661,7 +6657,7 @@ ha_innobase::create(
}
}
- switch (row_type) {
+ switch (row_format) {
case ROW_TYPE_REDUNDANT:
break;
case ROW_TYPE_COMPRESSED:
@@ -6672,25 +6668,25 @@ ha_innobase::create(
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ROW_FORMAT=%s requires"
" innodb_file_per_table.",
- get_row_format_name(row_type));
+ get_row_format_name(row_format));
} else if (file_format < DICT_TF_FORMAT_ZIP) {
push_warning_printf(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
"InnoDB: ROW_FORMAT=%s requires"
" innodb_file_format > Antelope.",
- get_row_format_name(row_type));
+ get_row_format_name(row_format));
} else {
flags |= DICT_TF_COMPACT
- | (DICT_TF_FORMAT_ZIP
- << DICT_TF_FORMAT_SHIFT);
+ | (DICT_TF_FORMAT_ZIP
+ << DICT_TF_FORMAT_SHIFT);
break;
}
/* fall through */
case ROW_TYPE_NOT_USED:
case ROW_TYPE_FIXED:
- default:
+ case ROW_TYPE_PAGE:
push_warning(
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_ILLEGAL_HA_CREATE_OPTION,
@@ -6808,23 +6804,25 @@ ha_innobase::create(
setup at this stage and so we use thd. */
/* We need to copy the AUTOINC value from the old table if
- this is an ALTER TABLE or CREATE INDEX because CREATE INDEX
- does a table copy too. */
+ this is an ALTER|OPTIMIZE TABLE or CREATE INDEX because CREATE INDEX
+ does a table copy too. If query was one of :
+
+ CREATE TABLE ...AUTO_INCREMENT = x; or
+ ALTER TABLE...AUTO_INCREMENT = x; or
+ OPTIMIZE TABLE t; or
+ CREATE INDEX x on t(...);
+
+ Find out a table definition from the dictionary and get
+ the current value of the auto increment field. Set a new
+ value to the auto increment field if the value is greater
+ than the maximum value in the column. */
if (((create_info->used_fields & HA_CREATE_USED_AUTO)
|| thd_sql_command(thd) == SQLCOM_ALTER_TABLE
+ || thd_sql_command(thd) == SQLCOM_OPTIMIZE
|| thd_sql_command(thd) == SQLCOM_CREATE_INDEX)
&& create_info->auto_increment_value > 0) {
- /* Query was one of :
- CREATE TABLE ...AUTO_INCREMENT = x; or
- ALTER TABLE...AUTO_INCREMENT = x; or
- CREATE INDEX x on t(...);
- Find out a table definition from the dictionary and get
- the current value of the auto increment field. Set a new
- value to the auto increment field if the value is greater
- than the maximum value in the column. */
-
auto_inc_value = create_info->auto_increment_value;
dict_table_autoinc_lock(innobase_table);
diff --git a/storage/innodb_plugin/plug.in b/storage/innodb_plugin/plug.in
index 2ee45389e9c..b2af11295bc 100644
--- a/storage/innodb_plugin/plug.in
+++ b/storage/innodb_plugin/plug.in
@@ -17,6 +17,9 @@
MYSQL_STORAGE_ENGINE(innodb_plugin,, [InnoDB Storage Engine],
[Transactional Tables using InnoDB], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(innodb_plugin, [storage/innodb_plugin])
+# Enable if you know what you are doing (trying to link both InnoDB and
+# InnoDB Plugin statically into MySQL does not work).
+#MYSQL_PLUGIN_STATIC(innodb_plugin, [libinnobase.a])
MYSQL_PLUGIN_DYNAMIC(innodb_plugin, [ha_innodb_plugin.la])
MYSQL_PLUGIN_ACTIONS(innodb_plugin, [
AC_CHECK_HEADERS(sched.h)
diff --git a/storage/innodb_plugin/trx/trx0i_s.c b/storage/innodb_plugin/trx/trx0i_s.c
index a3ffc4ec015..3bf5ece9b9c 100644
--- a/storage/innodb_plugin/trx/trx0i_s.c
+++ b/storage/innodb_plugin/trx/trx0i_s.c
@@ -435,7 +435,7 @@ i_s_locks_row_validate(
/* record lock */
ut_ad(!strcmp("RECORD", row->lock_type));
ut_ad(row->lock_index != NULL);
- ut_ad(row->lock_data != NULL);
+ /* row->lock_data == NULL if buf_page_try_get() == NULL */
ut_ad(row->lock_page != ULINT_UNDEFINED);
ut_ad(row->lock_rec != ULINT_UNDEFINED);
}