Apply snapshot innodb-5.1-ss2034

The following bugs are fixed:

Bug #31860: Server crashes after inserting into InnoDB table with auto_increment column
  In the Bug 16979 fix there was an erroneous assertion that
  autoincrement columns can't contain negative values. With the fix, the
  autoincrement table counter is set to 0 if the maximum value read from
  the autoinc column index is negative.
parent eb654791
......@@ -3152,6 +3152,22 @@ c25 CHAR(255), c26 CHAR(255), c27 CHAR(255), c28 CHAR(255),
c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
) ENGINE = InnoDB;
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 8126. You have to change some columns to TEXT or BLOBs
DROP TABLE IF EXISTS t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE t1(
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(-10);
SELECT * FROM t1;
id
-10
INSERT INTO t1 VALUES(NULL);
SELECT * FROM t1;
id
-10
1
DROP TABLE t1;
SET TX_ISOLATION='read-committed';
SET AUTOCOMMIT=0;
DROP TABLE IF EXISTS t1, t2;
......
......@@ -2290,6 +2290,25 @@ CREATE TABLE t1 (
c29 CHAR(255), c30 CHAR(255), c31 CHAR(255), c32 CHAR(255)
) ENGINE = InnoDB;
#
# Bug #31860 InnoDB assumes AUTOINC values can only be positive.
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(-10);
SELECT * FROM t1;
#
# NOTE: The server really needs to be restarted at this point
# for the test to be useful.
#
# Without the fix InnoDB would trip over an assertion here.
INSERT INTO t1 VALUES(NULL);
# The next value should be 1 and not -9 or a -ve number
SELECT * FROM t1;
DROP TABLE t1;
#
# Bug #21409 Incorrect result returned when in READ-COMMITTED with
# query_cache ON
......
......@@ -1144,7 +1144,6 @@ innobase_query_caching_of_table_permitted(
}
if (trx->has_search_latch) {
ut_print_timestamp(stderr);
sql_print_error("The calling thread is holding the adaptive "
"search, latch though calling "
"innobase_query_caching_of_table_permitted.");
......@@ -2322,7 +2321,6 @@ ha_innobase::open(
ib_table = dict_table_get(norm_name, TRUE);
if (NULL == ib_table) {
ut_print_timestamp(stderr);
sql_print_error("Cannot find or open table %s from\n"
"the internal data dictionary of InnoDB "
"though the .frm file for the\n"
......@@ -2346,7 +2344,6 @@ ha_innobase::open(
}
if (ib_table->ibd_file_missing && !thd_tablespace_op(thd)) {
ut_print_timestamp(stderr);
sql_print_error("MySQL is trying to open a table handle but "
"the .ibd file for\ntable %s does not exist.\n"
"Have you deleted the .ibd file from the "
......@@ -3420,7 +3417,7 @@ ha_innobase::write_row(
/*
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB error: ALTER TABLE is holding lock"
" InnoDB: ALTER TABLE is holding lock"
" on %lu tables!\n",
prebuilt->trx->mysql_n_tables_locked);
*/
......@@ -5723,7 +5720,6 @@ ha_innobase::info(
for (i = 0; i < table->s->keys; i++) {
if (index == NULL) {
ut_print_timestamp(stderr);
sql_print_error("Table %s contains fewer "
"indexes inside InnoDB than "
"are defined in the MySQL "
......@@ -5739,7 +5735,6 @@ ha_innobase::info(
for (j = 0; j < table->key_info[i].key_parts; j++) {
if (j + 1 > index->n_uniq) {
ut_print_timestamp(stderr);
sql_print_error(
"Index %s of %s has %lu columns unique inside InnoDB, but MySQL is asking "
"statistics for %lu columns. Have you mixed up .frm files from different "
......@@ -5804,7 +5799,6 @@ ha_innobase::info(
ret = innobase_read_and_init_auto_inc(&auto_inc);
if (ret != 0) {
ut_print_timestamp(stderr);
sql_print_error("Cannot get table %s auto-inc"
"counter value in ::info\n",
ib_table->name);
......@@ -6578,14 +6572,17 @@ ha_innobase::transactional_table_lock(
if (prebuilt->table->ibd_file_missing && !thd_tablespace_op(thd)) {
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB error:\n"
"MySQL is trying to use a table handle but the .ibd file for\n"
"table %s does not exist.\n"
"Have you deleted the .ibd file from the database directory under\n"
"the MySQL datadir?"
"See http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n"
"how you can resolve the problem.\n",
prebuilt->table->name);
fprintf(stderr,
" InnoDB: MySQL is trying to use a table handle"
" but the .ibd file for\n"
"InnoDB: table %s does not exist.\n"
"InnoDB: Have you deleted the .ibd file"
" from the database directory under\n"
"InnoDB: the MySQL datadir?"
"InnoDB: See"
" http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html\n"
"InnoDB: how you can resolve the problem.\n",
prebuilt->table->name);
DBUG_RETURN(HA_ERR_CRASHED);
}
......@@ -7194,7 +7191,8 @@ ha_innobase::innobase_read_and_init_auto_inc(
++auto_inc;
dict_table_autoinc_initialize(innodb_table, auto_inc);
} else {
fprintf(stderr, " InnoDB error (%lu): Couldn't read "
ut_print_timestamp(stderr);
fprintf(stderr, " InnoDB: Error: (%lu) Couldn't read "
"the max AUTOINC value from the index (%s).\n",
error, index->name);
......@@ -7281,8 +7279,7 @@ ha_innobase::innobase_get_auto_increment(
and can be ignored. */
} else if (error != DB_DEADLOCK) {
ut_print_timestamp(stderr);
sql_print_error(" InnoDB Error %lu in "
sql_print_error("InnoDB: Error: %lu in "
"::innobase_get_auto_increment()",
error);
}
......
......@@ -309,22 +309,22 @@ typedef void* os_thread_ret_t;
# define UNIV_MEM_FREE(addr, size) VALGRIND_MAKE_MEM_NOACCESS(addr, size)
# define UNIV_MEM_ALLOC(addr, size) VALGRIND_MAKE_MEM_UNDEFINED(addr, size)
# define UNIV_MEM_ASSERT_RW(addr, size) do { \
const void* _p = (const void*) \
const void* _p = (const void*) (ulint) \
VALGRIND_CHECK_MEM_IS_DEFINED(addr, size); \
if (UNIV_LIKELY_NULL(_p)) \
fprintf(stderr, "%s:%d: %p[%u] undefined at %d\n", \
fprintf(stderr, "%s:%d: %p[%u] undefined at %ld\n", \
__FILE__, __LINE__, \
(const void*) (addr), (unsigned) (size), \
((const char*) _p) - ((const char*) (addr))); \
(const void*) (addr), (unsigned) (size), (long) \
(((const char*) _p) - ((const char*) (addr)))); \
} while (0)
# define UNIV_MEM_ASSERT_W(addr, size) do { \
const void* _p = (const void*) \
const void* _p = (const void*) (ulint) \
VALGRIND_CHECK_MEM_IS_ADDRESSABLE(addr, size); \
if (UNIV_LIKELY_NULL(_p)) \
fprintf(stderr, "%s:%d: %p[%u] unwritable at %d\n", \
fprintf(stderr, "%s:%d: %p[%u] unwritable at %ld\n", \
__FILE__, __LINE__, \
(const void*) (addr), (unsigned) (size), \
((const char*) _p) - ((const char*) (addr))); \
(const void*) (addr), (unsigned) (size), (long) \
(((const char*) _p) - ((const char*) (addr)))); \
} while (0)
#else
# define UNIV_MEM_VALID(addr, size) do {} while(0)
......
......@@ -4526,7 +4526,8 @@ row_search_check_if_query_cache_permitted(
}
/***********************************************************************
Read the AUTOINC column from the current row. */
Read the AUTOINC column from the current row. If the value is less than
0 and the type is not unsigned then we reset the value to 0. */
static
ib_longlong
row_search_autoinc_read_column(
......@@ -4594,7 +4595,9 @@ row_search_autoinc_read_column(
mem_heap_free(heap);
}
ut_a(value >= 0);
if (!unsigned_type && value < 0) {
value = 0;
}
return(value);
}
......
......@@ -830,7 +830,7 @@ sync_thread_levels_g(
mutex = slot->latch;
fprintf(stderr,
"InnoDB error: sync levels should be"
"InnoDB: sync levels should be"
" > %lu but a level is %lu\n",
(ulong) limit, (ulong) slot->level);
......
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