Commit 83d2cd7a authored by marko's avatar marko

branches/innodb+: Merge revisions 6773:6801 from branches/zip:

  ------------------------------------------------------------------------
  r6777 | marko | 2010-03-04 13:01:25 +0200 (Thu, 04 Mar 2010) | 2 lines
  Changed paths:
     M /branches/zip/trx/trx0rec.c

  branches/zip: trx_undo_update_rec_get_update(): Silence a bogus GCC warning
  about a possibly uninitialized variable.
  ------------------------------------------------------------------------
  r6779 | marko | 2010-03-08 14:35:42 +0200 (Mon, 08 Mar 2010) | 6 lines
  Changed paths:
     M /branches/zip/ChangeLog
     M /branches/zip/fil/fil0fil.c

  branches/zip: Fix IMPORT TABLESPACE of compressed tables.  Previously,
  a wrong parameter was passed to buf_flush_init_for_writing().

  fil_reset_too_high_lsns(): Set up page_zip and use it if needed.

  rb://264, Issue #352
  ------------------------------------------------------------------------
  r6781 | marko | 2010-03-09 09:41:08 +0200 (Tue, 09 Mar 2010) | 4 lines
  Changed paths:
     M /branches/zip/ChangeLog
     M /branches/zip/handler/ha_innodb.cc

  branches/zip: Make SHOW ENGINE INNODB MUTEX display SUM(os_waits)
  for block mutexes and blocks.

  Designed by Michael and Marko. rb://188, Issue #358
  ------------------------------------------------------------------------
  r6782 | marko | 2010-03-09 14:09:26 +0200 (Tue, 09 Mar 2010) | 1 line
  Changed paths:
     M /branches/zip/fil/fil0fil.c

  branches/zip: fil0fil.c: Update comments on table->flags as of r6252.
  ------------------------------------------------------------------------
  r6786 | vasil | 2010-03-10 09:16:50 +0200 (Wed, 10 Mar 2010) | 4 lines
  Changed paths:
     M /branches/zip/mysql-test/innodb-consistent.test

  branches/zip:

  Fix typo in comment
  ------------------------------------------------------------------------
  r6787 | marko | 2010-03-10 10:35:06 +0200 (Wed, 10 Mar 2010) | 10 lines
  Changed paths:
     M /branches/zip/ChangeLog
     M /branches/zip/log/log0recv.c

  branches/zip: recv_parse_log_rec(): Remove a bogus assertion about page_no.
  TODO: We might also consider removing recv_max_parsed_page_no, because
  it does not make much sense with *.ibd files.

  recv_report_corrupt_log(), recv_scan_log_recs(): Abort when a
  corrupted log record has been found, unless innodb_force_recovery has
  been set.

  This fixes Issue #464.
  rb://265 approved by Heikki Tuuri
  ------------------------------------------------------------------------
  r6789 | jyang | 2010-03-10 11:18:18 +0200 (Wed, 10 Mar 2010) | 10 lines
  Changed paths:
     M /branches/zip/handler/ha_innodb.cc
     M /branches/zip/handler/handler0alter.cc
     A /branches/zip/mysql-test/innodb_bug51378.result
     A /branches/zip/mysql-test/innodb_bug51378.test

  branches/zip: If a unique index is on a column prefix, such
  unique index cannot be upgrade to primary index even if there
  is no primary index already defined. Also fix possible corruption
  when initialize "ref_length" value in case there is a mismatch
  between MySQL and InnoDB primary key. Fix bug #51378: "Init
  'ref_length'  to correct value, in case an out of bound MySQL
  primary_key".
  rb://262 approved by Marko.
  ------------------------------------------------------------------------
  r6790 | jyang | 2010-03-10 13:09:41 +0200 (Wed, 10 Mar 2010) | 7 lines
  Changed paths:
     M /branches/zip/handler/ha_innodb.cc

  branches/zip: Fix bug #51356: "many valgrind errors in error messages
  with concurrent ddl". Null terminate the name string returned
  from innobase_convert_identifier() call when reporting DB_DUPLICATE_KEY
  error in create_table_def().
  rb://266 approved by Marko
  ------------------------------------------------------------------------
  r6791 | marko | 2010-03-10 13:39:06 +0200 (Wed, 10 Mar 2010) | 1 line
  Changed paths:
     M /branches/zip/ChangeLog

  branches/zip: Add ChangeLog entries for r6789, r6790.
  ------------------------------------------------------------------------
  r6792 | marko | 2010-03-10 13:56:41 +0200 (Wed, 10 Mar 2010) | 1 line
  Changed paths:
     A /branches/zip/mysql-test/innodb_bug38231.result (from /branches/5.1/mysql-test/innodb_bug38231.result:6791)
     A /branches/zip/mysql-test/innodb_bug38231.test (from /branches/5.1/mysql-test/innodb_bug38231.test:6791)
     A /branches/zip/mysql-test/innodb_bug39438-master.opt (from /branches/5.1/mysql-test/innodb_bug39438-master.opt:6791)
     A /branches/zip/mysql-test/innodb_bug39438.result (from /branches/5.1/mysql-test/innodb_bug39438.result:6791)
     A /branches/zip/mysql-test/innodb_bug39438.test (from /branches/5.1/mysql-test/innodb_bug39438.test:6791)

  branches/zip: Copy tests from branches/5.1 that were lost in some merge.
  ------------------------------------------------------------------------
  r6793 | marko | 2010-03-10 14:02:19 +0200 (Wed, 10 Mar 2010) | 60 lines
  Changed paths:
     M /branches/zip/ChangeLog
     M /branches/zip/handler/ha_innodb.cc
     M /branches/zip/mysql-test/innodb_bug21704.result
     A /branches/zip/mysql-test/innodb_bug47621.result (from /branches/5.1/mysql-test/innodb_bug47621.result:6788)
     A /branches/zip/mysql-test/innodb_bug47621.test (from /branches/5.1/mysql-test/innodb_bug47621.test:6788)
     M /branches/zip/plug.in
     M /branches/zip/trx/trx0sys.c

  branches/zip: Merge revisions 6669:6788 from branches/5.1:

    ------------------------------------------------------------------------
    r6774 | calvin | 2010-03-03 23:56:10 +0200 (Wed, 03 Mar 2010) | 2 lines
    Changed paths:
       M /branches/5.1/trx/trx0sys.c

    branches/5.1: fix bug#51653: outdated reference to set-variable
    Non functional change.
    ------------------------------------------------------------------------
    r6780 | vasil | 2010-03-08 19:13:20 +0200 (Mon, 08 Mar 2010) | 4 lines
    Changed paths:
       M /branches/5.1/plug.in

    branches/5.1:

    Whitespace fixup.
    ------------------------------------------------------------------------
    r6783 | jyang | 2010-03-09 17:54:14 +0200 (Tue, 09 Mar 2010) | 9 lines
    Changed paths:
       M /branches/5.1/handler/ha_innodb.cc
       M /branches/5.1/mysql-test/innodb_bug21704.result
       A /branches/5.1/mysql-test/innodb_bug47621.result
       A /branches/5.1/mysql-test/innodb_bug47621.test

    branches/5.1: Fix bug #47621 "MySQL and InnoDB data dictionaries
    will become out of sync when renaming columns". MySQL does not
    provide new column name information to storage engine to
    update the system table. To avoid column name mismatch, we shall
    just request a table copy for now.

    rb://246 approved by Marko.
    ------------------------------------------------------------------------
    r6785 | vasil | 2010-03-10 09:04:38 +0200 (Wed, 10 Mar 2010) | 11 lines
    Changed paths:
       M /branches/5.1/mysql-test/innodb_bug38231.test

    branches/5.1:

    Add the missing --reap statements in innodb_bug38231.test. Probably MySQL
    enforced the presence of those recently and the test started failing like:

      main.innodb_bug38231                     [ fail ]
              Test ended at 2010-03-10 08:48:32

      CURRENT_TEST: main.innodb_bug38231
      mysqltest: At line 49: Cannot run query on connection between send and reap
    ------------------------------------------------------------------------
    r6788 | vasil | 2010-03-10 10:53:21 +0200 (Wed, 10 Mar 2010) | 8 lines
    Changed paths:
       M /branches/5.1/mysql-test/innodb_bug38231.test

    branches/5.1:

    In innodb_bug38231.test: replace the fragile sleep 0.2 that depends on timing
    with a more robust condition which waits for the TRUNCATE and LOCK commands
    to appear in information_schema.processlist. This could also break if there
    are other sessions executing the same SQL commands, but there are none during
    the execution of the mysql test.
    ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  r6798 | marko | 2010-03-11 09:53:01 +0200 (Thu, 11 Mar 2010) | 14 lines
  Changed paths:
     M /branches/zip/ChangeLog
     M /branches/zip/include/buf0buf.h
     M /branches/zip/include/buf0buf.ic

  branches/zip: Fix and clarify the latching of some buf_block_t members.

  buf_block_t::check_index_page_at_flush: Note that this field is not
  protected by any mutex. Make it a separate field, not a bitfield that
  could share the machine word with other fields.

  buf_block_t::lock_hash_val: Note that this field is protected by
  buf_block_t::lock (or during block creation, by buf_pool_mutex and
  buf_block_t::mutex).

  buf_block_get_lock_hash_val(): Assert that block->lock is held by the
  current thread.

  Issue #465, rb://267 approved by Inaam Rana
  ------------------------------------------------------------------------
  r6799 | jyang | 2010-03-11 09:59:42 +0200 (Thu, 11 Mar 2010) | 5 lines
  Changed paths:
     M /branches/zip/mysql-test/innodb_bug44571.result
     M /branches/zip/mysql-test/innodb_bug44571.test

  branches/zip: Once change in bug #47621 merges into zip branch,
  zip only test innodb_bug44571 needs to be updated to reflect the
  column name change would be successful be done in InnoDB as well.
  ------------------------------------------------------------------------
  r6800 | marko | 2010-03-11 12:02:57 +0200 (Thu, 11 Mar 2010) | 1 line
  Changed paths:
     M /branches/zip/btr/btr0pcur.c
     M /branches/zip/buf/buf0buf.c
     M /branches/zip/include/mtr0mtr.ic

  branches/zip: Add ut_ad(mtr->state == MTR_ACTIVE) to various places.
  ------------------------------------------------------------------------
  r6801 | marko | 2010-03-11 13:34:28 +0200 (Thu, 11 Mar 2010) | 2 lines
  Changed paths:
     M /branches/zip/include/mtr0mtr.ic

  branches/zip: mtr_memo_contains(): Relax the assertion of r6800,
  allowing mtr->state == MTR_COMMITTING.
  ------------------------------------------------------------------------
parent 6429bcd5
2010-03-11 The InnoDB Team
* buf0buf.h, buf0buf.ic:
Fix and clarify the latching of some buf_block_t members.
Note that check_index_page_at_flush is not protected by any mutex.
Note and assert that lock_hash_val is protected by the rw-latch.
2010-03-10 The InnoDB Team
* trx/trx0sys.c:
Fix Bug #51653 outdated reference to set-variable
2010-03-10 The InnoDB Team
* handler/ha_innodb.cc, mysql-test/innodb_bug21704.result,
mysql-test/innodb_bug47621.result, mysql-test/innodb_bug47621.test:
Fix Bug #47621 MySQL and InnoDB data dictionaries will become
out of sync when renaming columns
2010-03-10 The InnoDB Team
* handler/ha_innodb.cc:
Fix Bug #51356 Many Valgrind errors in error messages
with concurrent DDL
2010-03-10 The InnoDB Team
* handler/ha_innodb.cc, handler/handler0alter.cc,
mysql-test/innodb_bug51378.result, mysql-test/innodb_bug51378.test:
Fix Bug #51378 Init 'ref_length' to correct value, in case an out
of bound MySQL primary_key
2010-03-10 The InnoDB Team
* log/log0recv.c:
Remove a bogus assertion about page numbers exceeding 0x90000000
in the redo log. Abort when encountering a corrupted redo log
record, unless innodb_force_recovery is set.
2010-03-09 The InnoDB Team
* handler/ha_innodb.cc:
Make SHOW ENGINE INNODB MUTEX STATUS display SUM(os_waits)
for the buffer pool block mutexes and locks.
2010-03-08 The InnoDB Team
* fil/fil0fil.c:
Fix ALTER TABLE ... IMPORT TABLESPACE of compressed tables.
2010-03-03 The InnoDB Team
* handler/handler0alter.cc, innodb-index.result, innodb-index.test,
......
......@@ -219,6 +219,9 @@ btr_pcur_restore_position_func(
ulint old_mode;
mem_heap_t* heap;
ut_ad(mtr);
ut_ad(mtr->state == MTR_ACTIVE);
index = btr_cur_get_index(btr_pcur_get_btr_cur(cursor));
if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED)
......
......@@ -2240,6 +2240,7 @@ buf_page_get_gen(
ulint retries = 0;
ut_ad(mtr);
ut_ad(mtr->state == MTR_ACTIVE);
ut_ad((rw_latch == RW_S_LATCH)
|| (rw_latch == RW_X_LATCH)
|| (rw_latch == RW_NO_LATCH));
......@@ -2608,7 +2609,9 @@ buf_page_optimistic_get(
ibool success;
ulint fix_type;
ut_ad(mtr && block);
ut_ad(block);
ut_ad(mtr);
ut_ad(mtr->state == MTR_ACTIVE);
ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
mutex_enter(&block->mutex);
......@@ -2720,6 +2723,7 @@ buf_page_get_known_nowait(
ulint fix_type;
ut_ad(mtr);
ut_ad(mtr->state == MTR_ACTIVE);
ut_ad((rw_latch == RW_S_LATCH) || (rw_latch == RW_X_LATCH));
mutex_enter(&block->mutex);
......@@ -2819,6 +2823,9 @@ buf_page_try_get_func(
ibool success;
ulint fix_type;
ut_ad(mtr);
ut_ad(mtr->state == MTR_ACTIVE);
buf_pool_mutex_enter();
block = buf_block_hash_get(space_id, page_no);
......@@ -3227,6 +3234,7 @@ buf_page_create(
ulint fold;
ut_ad(mtr);
ut_ad(mtr->state == MTR_ACTIVE);
ut_ad(space || !zip_size);
free_block = buf_LRU_get_free_block(0);
......
......@@ -38,6 +38,7 @@ Created 10/25/1995 Heikki Tuuri
#include "mtr0mtr.h"
#include "mtr0log.h"
#include "dict0dict.h"
#include "page0page.h"
#include "page0zip.h"
#ifndef UNIV_HOTBACKUP
# include "buf0lru.h"
......@@ -1097,9 +1098,11 @@ fil_space_create(
fil_space_t* space;
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
ROW_FORMAT=COMPACT
((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
format, the tablespace flags should equal table->flags. */
format, the tablespace flags should equal
(table->flags & ~(~0 << DICT_TF_BITS)). */
ut_a(flags != DICT_TF_COMPACT);
ut_a(!(flags & (~0UL << DICT_TF_BITS)));
......@@ -2583,9 +2586,11 @@ fil_create_new_single_table_tablespace(
ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE);
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
ROW_FORMAT=COMPACT
((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
format, the tablespace flags should equal table->flags. */
format, the tablespace flags should equal
(table->flags & ~(~0 << DICT_TF_BITS)). */
ut_a(flags != DICT_TF_COMPACT);
ut_a(!(flags & (~0UL << DICT_TF_BITS)));
......@@ -2788,6 +2793,7 @@ fil_reset_too_high_lsns(
ib_int64_t offset;
ulint zip_size;
ibool success;
page_zip_des_t page_zip;
filepath = fil_make_ibd_name(name, FALSE);
......@@ -2835,6 +2841,12 @@ fil_reset_too_high_lsns(
space_id = fsp_header_get_space_id(page);
zip_size = fsp_header_get_zip_size(page);
page_zip_des_init(&page_zip);
page_zip_set_size(&page_zip, zip_size);
if (zip_size) {
page_zip.data = page + UNIV_PAGE_SIZE;
}
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Flush lsn in the tablespace file %lu"
......@@ -2869,20 +2881,23 @@ fil_reset_too_high_lsns(
/* We have to reset the lsn */
if (zip_size) {
memcpy(page + UNIV_PAGE_SIZE, page, zip_size);
memcpy(page_zip.data, page, zip_size);
buf_flush_init_for_writing(
page, page + UNIV_PAGE_SIZE,
current_lsn);
page, &page_zip, current_lsn);
success = os_file_write(
filepath, file, page_zip.data,
(ulint) offset & 0xFFFFFFFFUL,
(ulint) (offset >> 32), zip_size);
} else {
buf_flush_init_for_writing(
page, NULL, current_lsn);
success = os_file_write(
filepath, file, page,
(ulint)(offset & 0xFFFFFFFFUL),
(ulint)(offset >> 32),
UNIV_PAGE_SIZE);
}
success = os_file_write(filepath, file, page,
(ulint)(offset & 0xFFFFFFFFUL),
(ulint)(offset >> 32),
zip_size
? zip_size
: UNIV_PAGE_SIZE);
if (!success) {
goto func_exit;
......@@ -2958,10 +2973,11 @@ fil_open_single_table_tablespace(
filepath = fil_make_ibd_name(name, FALSE);
/* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for
ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and
ROW_FORMAT=COMPACT
((table->flags & ~(~0 << DICT_TF_BITS)) == DICT_TF_COMPACT) and
ROW_FORMAT=REDUNDANT (table->flags == 0). For any other
format, the tablespace flags should be equal to
table->flags & ~(~0 << DICT_TF_BITS). */
format, the tablespace flags should equal
(table->flags & ~(~0 << DICT_TF_BITS)). */
ut_a(flags != DICT_TF_COMPACT);
ut_a(!(flags & (~0UL << DICT_TF_BITS)));
......
......@@ -3308,6 +3308,9 @@ ha_innobase::innobase_initialize_autoinc()
ulint err;
update_thd(ha_thd());
ut_a(prebuilt->trx == thd_to_trx(user_thd));
col_name = field->field_name;
index = innobase_get_index(table->s->next_number_index);
......@@ -3498,31 +3501,86 @@ retry:
of length ref_length! */
if (!row_table_got_default_clust_index(ib_table)) {
if (primary_key >= MAX_KEY) {
sql_print_error("Table %s has a primary key in InnoDB data "
"dictionary, but not in MySQL!", name);
}
prebuilt->clust_index_was_generated = FALSE;
/* MySQL allocates the buffer for ref. key_info->key_length
includes space for all key columns + one byte for each column
that may be NULL. ref_length must be as exact as possible to
save space, because all row reference buffers are allocated
based on ref_length. */
if (UNIV_UNLIKELY(primary_key >= MAX_KEY)) {
sql_print_error("Table %s has a primary key in "
"InnoDB data dictionary, but not "
"in MySQL!", name);
/* This mismatch could cause further problems
if not attended, bring this to the user's attention
by printing a warning in addition to log a message
in the errorlog */
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_NO_SUCH_INDEX,
"InnoDB: Table %s has a "
"primary key in InnoDB data "
"dictionary, but not in "
"MySQL!", name);
/* If primary_key >= MAX_KEY, its (primary_key)
value could be out of bound if continue to index
into key_info[] array. Find InnoDB primary index,
and assign its key_length to ref_length.
In addition, since MySQL indexes are sorted starting
with primary index, unique index etc., initialize
ref_length to the first index key length in
case we fail to find InnoDB cluster index.
Please note, this will not resolve the primary
index mismatch problem, other side effects are
possible if users continue to use the table.
However, we allow this table to be opened so
that user can adopt necessary measures for the
mismatch while still being accessible to the table
date. */
ref_length = table->key_info[0].key_length;
/* Find correspoinding cluster index
key length in MySQL's key_info[] array */
for (ulint i = 0; i < table->s->keys; i++) {
dict_index_t* index;
index = innobase_get_index(i);
if (dict_index_is_clust(index)) {
ref_length =
table->key_info[i].key_length;
}
}
} else {
/* MySQL allocates the buffer for ref.
key_info->key_length includes space for all key
columns + one byte for each column that may be
NULL. ref_length must be as exact as possible to
save space, because all row reference buffers are
allocated based on ref_length. */
ref_length = table->key_info[primary_key].key_length;
ref_length = table->key_info[primary_key].key_length;
}
} else {
if (primary_key != MAX_KEY) {
sql_print_error("Table %s has no primary key in InnoDB data "
"dictionary, but has one in MySQL! If you "
"created the table with a MySQL version < "
"3.23.54 and did not define a primary key, "
"but defined a unique key with all non-NULL "
"columns, then MySQL internally treats that "
"key as the primary key. You can fix this "
"error by dump + DROP + CREATE + reimport "
"of the table.", name);
sql_print_error(
"Table %s has no primary key in InnoDB data "
"dictionary, but has one in MySQL! If you "
"created the table with a MySQL version < "
"3.23.54 and did not define a primary key, "
"but defined a unique key with all non-NULL "
"columns, then MySQL internally treats that "
"key as the primary key. You can fix this "
"error by dump + DROP + CREATE + reimport "
"of the table.", name);
/* This mismatch could cause further problems
if not attended, bring this to the user attention
by printing a warning in addition to log a message
in the errorlog */
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
ER_NO_SUCH_INDEX,
"InnoDB: Table %s has no "
"primary key in InnoDB data "
"dictionary, but has one in "
"MySQL!", name);
}
prebuilt->clust_index_was_generated = TRUE;
......@@ -5406,9 +5464,6 @@ ha_innobase::innobase_get_index(
DBUG_ENTER("innobase_get_index");
ha_statistic_increment(&SSV::ha_read_key_count);
ut_ad(user_thd == ha_thd());
ut_a(prebuilt->trx == thd_to_trx(user_thd));
if (keynr != MAX_KEY && table->s->keys > 0) {
key = table->key_info + keynr;
......@@ -5994,9 +6049,11 @@ create_table_def(
if (error == DB_DUPLICATE_KEY) {
char buf[100];
innobase_convert_identifier(buf, sizeof buf,
table_name, strlen(table_name),
trx->mysql_thd, TRUE);
char* buf_end = innobase_convert_identifier(
buf, sizeof buf - 1, table_name, strlen(table_name),
trx->mysql_thd, TRUE);
*buf_end = '\0';
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), buf);
}
......@@ -8663,19 +8720,25 @@ innodb_show_status(
}
/************************************************************************//**
Implements the SHOW MUTEX STATUS command. . */
Implements the SHOW MUTEX STATUS command.
@return TRUE on failure, FALSE on success. */
static
bool
innodb_mutex_show_status(
/*=====================*/
handlerton* hton, /*!< in: the innodb handlerton */
handlerton* hton, /*!< in: the innodb handlerton */
THD* thd, /*!< in: the MySQL query thread of the
caller */
stat_print_fn* stat_print)
stat_print_fn* stat_print) /*!< in: function for printing
statistics */
{
char buf1[IO_SIZE], buf2[IO_SIZE];
mutex_t* mutex;
rw_lock_t* lock;
ulint block_mutex_oswait_count = 0;
ulint block_lock_oswait_count = 0;
mutex_t* block_mutex = NULL;
rw_lock_t* block_lock = NULL;
#ifdef UNIV_DEBUG
ulint rw_lock_count= 0;
ulint rw_lock_count_spin_loop= 0;
......@@ -8690,12 +8753,16 @@ innodb_mutex_show_status(
mutex_enter(&mutex_list_mutex);
mutex = UT_LIST_GET_FIRST(mutex_list);
for (mutex = UT_LIST_GET_FIRST(mutex_list); mutex != NULL;
mutex = UT_LIST_GET_NEXT(list, mutex)) {
if (mutex->count_os_wait == 0) {
continue;
}
while (mutex != NULL) {
if (mutex->count_os_wait == 0
|| buf_pool_is_block_mutex(mutex)) {
goto next_mutex;
if (buf_pool_is_block_mutex(mutex)) {
block_mutex = mutex;
block_mutex_oswait_count += mutex->count_os_wait;
continue;
}
#ifdef UNIV_DEBUG
if (mutex->mutex_type != 1) {
......@@ -8722,8 +8789,7 @@ innodb_mutex_show_status(
DBUG_RETURN(1);
}
}
}
else {
} else {
rw_lock_count += mutex->count_using;
rw_lock_count_spin_loop += mutex->count_spin_loop;
rw_lock_count_spin_rounds += mutex->count_spin_rounds;
......@@ -8735,7 +8801,7 @@ innodb_mutex_show_status(
buf1len= (uint) my_snprintf(buf1, sizeof(buf1), "%s:%lu",
mutex->cfile_name, (ulong) mutex->cline);
buf2len= (uint) my_snprintf(buf2, sizeof(buf2), "os_waits=%lu",
mutex->count_os_wait);
(ulong) mutex->count_os_wait);
if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len,
......@@ -8744,45 +8810,83 @@ innodb_mutex_show_status(
DBUG_RETURN(1);
}
#endif /* UNIV_DEBUG */
}
if (block_mutex) {
buf1len = (uint) my_snprintf(buf1, sizeof buf1,
"combined %s:%lu",
block_mutex->cfile_name,
(ulong) block_mutex->cline);
buf2len = (uint) my_snprintf(buf2, sizeof buf2,
"os_waits=%lu",
(ulong) block_mutex_oswait_count);
next_mutex:
mutex = UT_LIST_GET_NEXT(list, mutex);
if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len,
buf2, buf2len)) {
mutex_exit(&mutex_list_mutex);
DBUG_RETURN(1);
}
}
mutex_exit(&mutex_list_mutex);
mutex_enter(&rw_lock_list_mutex);
lock = UT_LIST_GET_FIRST(rw_lock_list);
while (lock != NULL) {
if (lock->count_os_wait
&& !buf_pool_is_block_lock(lock)) {
buf1len= my_snprintf(buf1, sizeof(buf1), "%s:%lu",
lock->cfile_name, (ulong) lock->cline);
buf2len= my_snprintf(buf2, sizeof(buf2),
"os_waits=%lu", lock->count_os_wait);
if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len,
buf2, buf2len)) {
mutex_exit(&rw_lock_list_mutex);
DBUG_RETURN(1);
}
for (lock = UT_LIST_GET_FIRST(rw_lock_list); lock != NULL;
lock = UT_LIST_GET_NEXT(list, lock)) {
if (lock->count_os_wait) {
continue;
}
if (buf_pool_is_block_lock(lock)) {
block_lock = lock;
block_lock_oswait_count += lock->count_os_wait;
continue;
}
buf1len = my_snprintf(buf1, sizeof buf1, "%s:%lu",
lock->cfile_name, (ulong) lock->cline);
buf2len = my_snprintf(buf2, sizeof buf2, "os_waits=%lu",
(ulong) lock->count_os_wait);
if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len,
buf2, buf2len)) {
mutex_exit(&rw_lock_list_mutex);
DBUG_RETURN(1);
}
}
if (block_lock) {
buf1len = (uint) my_snprintf(buf1, sizeof buf1,
"combined %s:%lu",
block_lock->cfile_name,
(ulong) block_lock->cline);
buf2len = (uint) my_snprintf(buf2, sizeof buf2,
"os_waits=%lu",
(ulong) block_lock_oswait_count);
if (stat_print(thd, innobase_hton_name,
hton_name_len, buf1, buf1len,
buf2, buf2len)) {
mutex_exit(&rw_lock_list_mutex);
DBUG_RETURN(1);
}
lock = UT_LIST_GET_NEXT(list, lock);
}
mutex_exit(&rw_lock_list_mutex);
#ifdef UNIV_DEBUG
buf2len= my_snprintf(buf2, sizeof(buf2),
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
rw_lock_count, rw_lock_count_spin_loop,
rw_lock_count_spin_rounds,
rw_lock_count_os_wait, rw_lock_count_os_yield,
(ulong) (rw_lock_wait_time/1000));
buf2len = my_snprintf(buf2, sizeof buf2,
"count=%lu, spin_waits=%lu, spin_rounds=%lu, "
"os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
(ulong) rw_lock_count,
(ulong) rw_lock_count_spin_loop,
(ulong) rw_lock_count_spin_rounds,
(ulong) rw_lock_count_os_wait,
(ulong) rw_lock_count_os_yield,
(ulong) (rw_lock_wait_time / 1000));
if (stat_print(thd, innobase_hton_name, hton_name_len,
STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
......@@ -9733,33 +9837,60 @@ innobase_set_cursor_view(
(cursor_view_t*) curview);
}
/*******************************************************************//**
If col_name is not NULL, check whether the named column is being
renamed in the table. If col_name is not provided, check
whether any one of columns in the table is being renamed.
@return true if the column is being renamed */
static
bool
check_column_being_renamed(
/*=======================*/
const TABLE* table, /*!< in: MySQL table */
const char* col_name) /*!< in: name of the column */
{
uint k;
Field* field;
for (k = 0; k < table->s->fields; k++) {
field = table->field[k];
/***********************************************************************
Check whether any of the given columns is being renamed in the table. */
if (field->flags & FIELD_IS_RENAMED) {
/* If col_name is not provided, return
if the field is marked as being renamed. */
if (!col_name) {
return(true);
}
/* If col_name is provided, return only
if names match */
if (innobase_strcasecmp(field->field_name,
col_name) == 0) {
return(true);
}
}
}
return(false);
}
/*******************************************************************//**
Check whether any of the given columns is being renamed in the table.
@return true if any of col_names is being renamed in table */
static
bool
column_is_being_renamed(
/*====================*/
/* out: true if any of col_names is
being renamed in table */
TABLE* table, /* in: MySQL table */
uint n_cols, /* in: number of columns */
const char** col_names) /* in: names of the columns */
TABLE* table, /*!< in: MySQL table */
uint n_cols, /*!< in: number of columns */
const char** col_names) /*!< in: names of the columns */
{
uint j;
uint k;
Field* field;
const char* col_name;
for (j = 0; j < n_cols; j++) {
col_name = col_names[j];
for (k = 0; k < table->s->fields; k++) {
field = table->field[k];
if ((field->flags & FIELD_IS_RENAMED)
&& innobase_strcasecmp(field->field_name,
col_name) == 0) {
return(true);
}
if (check_column_being_renamed(table, col_names[j])) {
return(true);
}
}
......@@ -9843,6 +9974,15 @@ ha_innobase::check_if_incompatible_data(
return(COMPATIBLE_DATA_NO);
}
/* For column rename operation, MySQL does not supply enough
information (new column name etc.) for InnoDB to make appropriate
system metadata change. To avoid system metadata inconsistency,
currently we can just request a table rebuild/copy by returning
COMPATIBLE_DATA_NO */
if (check_column_being_renamed(table, NULL)) {
return COMPATIBLE_DATA_NO;
}
/* Check if a column participating in a foreign key is being renamed.
There is no mechanism for updating InnoDB foreign key definitions. */
if (foreign_key_column_is_being_renamed(prebuilt, table)) {
......
......@@ -528,12 +528,14 @@ innobase_create_key_def(
key_info->name, "PRIMARY");
/* If there is a UNIQUE INDEX consisting entirely of NOT NULL
columns, MySQL will treat it as a PRIMARY KEY unless the
table already has one. */
columns and if the index does not contain column prefix(es)
(only prefix/part of the column is indexed), MySQL will treat the
index as a PRIMARY KEY unless the table already has one. */
if (!new_primary && (key_info->flags & HA_NOSAME)
&& (!(key_info->flags & HA_KEY_HAS_PART_KEY_SEG))
&& row_table_got_default_clust_index(table)) {
uint key_part = key_info->key_parts;
uint key_part = key_info->key_parts;
new_primary = TRUE;
......
......@@ -1258,15 +1258,21 @@ struct buf_block_struct{
rw_lock_t lock; /*!< read-write lock of the buffer
frame */
unsigned lock_hash_val:32;/*!< hashed value of the page address
in the record lock hash table */
unsigned check_index_page_at_flush:1;
in the record lock hash table;
protected by buf_block_t::lock
(or buf_block_t::mutex, buf_pool_mutex
in buf_page_get_gen(),
buf_page_init_for_read()
and buf_page_create()) */
ibool check_index_page_at_flush;
/*!< TRUE if we know that this is
an index page, and want the database
to check its consistency before flush;
note that there may be pages in the
buffer pool which are index pages,
but this flag is not set because
we do not keep track of all pages */
we do not keep track of all pages;
NOT protected by any mutex */
/* @} */
/** @name Optimistic search field */
/* @{ */
......
......@@ -705,6 +705,12 @@ buf_block_get_lock_hash_val(
/*========================*/
const buf_block_t* block) /*!< in: block */
{
ut_ad(block);
ut_ad(buf_page_in_file(&block->page));
#ifdef UNIV_SYNC_DEBUG
ut_ad(rw_lock_own(&(((buf_block_t*) block)->lock), RW_LOCK_EXCLUSIVE)
|| rw_lock_own(&(((buf_block_t*) block)->lock), RW_LOCK_SHARED));
#endif /* UNIV_SYNC_DEBUG */
return(block->lock_hash_val);
}
......
......@@ -70,6 +70,7 @@ mtr_memo_push(
ut_ad(type <= MTR_MEMO_X_LOCK);
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
ut_ad(mtr->state == MTR_ACTIVE);
memo = &(mtr->memo);
......@@ -92,6 +93,7 @@ mtr_set_savepoint(
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
ut_ad(mtr->state == MTR_ACTIVE);
memo = &(mtr->memo);
......@@ -149,6 +151,7 @@ mtr_memo_contains(
ut_ad(mtr);
ut_ad(mtr->magic_n == MTR_MAGIC_N);
ut_ad(mtr->state == MTR_ACTIVE || mtr->state == MTR_COMMITTING);
memo = &(mtr->memo);
......
......@@ -2071,15 +2071,6 @@ recv_parse_log_rec(
}
#endif /* UNIV_LOG_LSN_DEBUG */
/* Check that page_no is sensible */
if (UNIV_UNLIKELY(*page_no > 0x8FFFFFFFUL)) {
recv_sys->found_corrupt_log = TRUE;
return(0);
}
new_ptr = recv_parse_or_apply_log_rec_body(*type, new_ptr, end_ptr,
NULL, NULL);
if (UNIV_UNLIKELY(new_ptr == NULL)) {
......@@ -2188,6 +2179,14 @@ recv_report_corrupt_log(
putc('\n', stderr);
}
#ifndef UNIV_HOTBACKUP
if (!srv_force_recovery) {
fputs("InnoDB: Set innodb_force_recovery"
" to ignore this error.\n", stderr);
ut_error;
}
#endif /* !UNIV_HOTBACKUP */
fputs("InnoDB: WARNING: the log file may have been corrupt and it\n"
"InnoDB: is possible that the log scan did not proceed\n"
"InnoDB: far enough in recovery! Please run CHECK TABLE\n"
......@@ -2702,6 +2701,16 @@ recv_scan_log_recs(
recv_sys->found_corrupt_log = TRUE;
#ifndef UNIV_HOTBACKUP
if (!srv_force_recovery) {
fputs("InnoDB: Set"
" innodb_force_recovery"
" to ignore this error.\n",
stderr);
ut_error;
}
#endif /* !UNIV_HOTBACKUP */
} else if (!recv_sys->found_corrupt_log) {
more_data = recv_sys_add_to_parsing_buf(
log_block, scanned_lsn);
......
......@@ -25,7 +25,7 @@ replace into t1 select * from t2;
connection b;
set session transaction isolation level read committed;
set autocommit=0;
# should not cuase a lock wait.
# should not cause a lock wait.
delete from t2 where a=5;
commit;
delete from t2;
......@@ -41,7 +41,7 @@ insert into t1 select * from t2;
connection b;
set session transaction isolation level read committed;
set autocommit=0;
# should not cuase a lock wait.
# should not cause a lock wait.
delete from t2 where a=5;
commit;
delete from t2;
......
......@@ -25,8 +25,8 @@ ALTER TABLE t1 CHANGE a c INT;
ERROR HY000: Error on rename of '#sql-temporary' to './test/t1' (errno: 150)
# Ensure that online column rename works.
ALTER TABLE t1 CHANGE b c INT;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
affected rows: 3
info: Records: 3 Duplicates: 0 Warnings: 0
# Test renaming the column in the referencing table
......@@ -34,8 +34,8 @@ ALTER TABLE t2 CHANGE a c INT;
ERROR HY000: Error on rename of '#sql-temporary' to './test/t2' (errno: 150)
# Ensure that online column rename works.
ALTER TABLE t2 CHANGE b c INT;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
affected rows: 3
info: Records: 3 Duplicates: 0 Warnings: 0
# Test with self-referential constraints
......@@ -45,8 +45,8 @@ ALTER TABLE t3 CHANGE b d INT;
ERROR HY000: Error on rename of '#sql-temporary' to './test/t3' (errno: 150)
# Ensure that online column rename works.
ALTER TABLE t3 CHANGE c d INT;
affected rows: 0
info: Records: 0 Duplicates: 0 Warnings: 0
affected rows: 3
info: Records: 3 Duplicates: 0 Warnings: 0
# Cleanup.
......
SET storage_engine=InnoDB;
INSERT INTO bug38231 VALUES (1), (10), (300);
SET autocommit=0;
SELECT * FROM bug38231 FOR UPDATE;
a
1
10
300
TRUNCATE TABLE bug38231;
COMMIT;
DROP TABLE bug38231;
#
# Bug#38231 Innodb crash in lock_reset_all_on_table() on TRUNCATE + LOCK / UNLOCK
# http://bugs.mysql.com/38231
#
-- source include/have_innodb.inc
SET storage_engine=InnoDB;
# we care only that the following SQL commands do not crash the server
-- disable_query_log
-- disable_result_log
DROP TABLE IF EXISTS bug38231;
CREATE TABLE bug38231 (a INT);
-- connect (con1,localhost,root,,)
-- connect (con2,localhost,root,,)
-- connect (con3,localhost,root,,)
-- connection con1
SET autocommit=0;
LOCK TABLE bug38231 WRITE;
-- connection con2
SET autocommit=0;
-- send
LOCK TABLE bug38231 WRITE;
-- connection con3
SET autocommit=0;
-- send
LOCK TABLE bug38231 WRITE;
-- connection default
-- send
TRUNCATE TABLE bug38231;
-- connection con1
# Wait for TRUNCATE and the other two LOCKs to be executed; without this,
# sometimes UNLOCK executes before them. We assume there are no other
# sessions executing at the same time with the same SQL commands.
let $wait_condition =
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE info = 'TRUNCATE TABLE bug38231';
-- source include/wait_condition.inc
let $wait_condition =
SELECT COUNT(*) = 2 FROM information_schema.processlist
WHERE info = 'LOCK TABLE bug38231 WRITE';
-- source include/wait_condition.inc
# the above enables query log, re-disable it
-- disable_query_log
# this crashes the server if the bug is present
UNLOCK TABLES;
# clean up
-- connection con2
-- reap
UNLOCK TABLES;
-- connection con3
-- reap
UNLOCK TABLES;
-- connection default
-- reap
-- disconnect con1
-- disconnect con2
-- disconnect con3
# test that TRUNCATE works with with row-level locks
-- enable_query_log
-- enable_result_log
INSERT INTO bug38231 VALUES (1), (10), (300);
-- connect (con4,localhost,root,,)
-- connection con4
SET autocommit=0;
SELECT * FROM bug38231 FOR UPDATE;
-- connection default
TRUNCATE TABLE bug38231;
-- connection con4
COMMIT;
-- connection default
-- disconnect con4
DROP TABLE bug38231;
SET storage_engine=InnoDB;
#
# Bug#39438 Testcase for Bug#39436 crashes on 5.1 in fil_space_get_latch
# http://bugs.mysql.com/39438
#
# This test must be run with innodb_file_per_table=1 because the crash
# only occurs if that option is turned on and DISCARD TABLESPACE only
# works with innodb_file_per_table.
#
-- source include/have_innodb.inc
SET storage_engine=InnoDB;
# we care only that the following SQL commands do not crash the server
-- disable_query_log
-- disable_result_log
DROP TABLE IF EXISTS bug39438;
CREATE TABLE bug39438 (id INT) ENGINE=INNODB;
# remove: XXX Uncomment the following ALTER and remove those lines after
# remove: applying the patch.
# remove: Obviously this test is useless without this ALTER command,
# remove: but it causes warnings to be printed by mysqld and the whole
# remove: mysql-test suite fails at the end (returns non-zero). Please
# remove: apply this patch to the mysql source tree, remove those lines
# remove: and uncomment the following ALTER. We do not care about the
# remove: warnings, this test is to ensure mysqld does not crash.
# remove: === modified file 'mysql-test/lib/mtr_report.pl'
# remove: --- mysql-test/lib/mtr_report.pl 2008-08-12 10:26:23 +0000
# remove: +++ mysql-test/lib/mtr_report.pl 2008-10-01 11:57:41 +0000
# remove: @@ -412,7 +412,10 @@
# remove:
# remove: # When trying to set lower_case_table_names = 2
# remove: # on a case sensitive file system. Bug#37402.
# remove: - /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive. Now setting lower_case_table_names to 0 to avoid future problems./
# remove: + /lower_case_table_names was set to 2, even though your the file system '.*' is case sensitive. Now setting lower_case_table_names to 0 to avoid future problems./ or
# remove: +
# remove: + # this test is expected to print warnings
# remove: + ($testname eq 'main.innodb_bug39438')
# remove: )
# remove: {
# remove: next; # Skip these lines
# remove:
#ALTER TABLE bug39438 DISCARD TABLESPACE;
# this crashes the server if the bug is present
SHOW TABLE STATUS;
DROP TABLE bug39438;
......@@ -2,8 +2,7 @@ CREATE TABLE bug44571 (foo INT) ENGINE=InnoDB;
ALTER TABLE bug44571 CHANGE foo bar INT;
ALTER TABLE bug44571 ADD INDEX bug44571b (foo);
ERROR 42000: Key column 'foo' doesn't exist in table
ALTER TABLE bug44571 ADD INDEX bug44571b (bar);
ERROR HY000: Incorrect key file for table 'bug44571'; try to repair it
CREATE INDEX bug44571b ON bug44571 (bar);
ERROR HY000: Incorrect key file for table 'bug44571'; try to repair it
ALTER TABLE bug44571 ADD INDEX bug44571c (bar);
DROP INDEX bug44571c ON bug44571;
CREATE INDEX bug44571c ON bug44571 (bar);
DROP TABLE bug44571;
#
# Bug#44571 InnoDB Plugin crashes on ADD INDEX
# http://bugs.mysql.com/44571
# Please also refer to related fix in
# http://bugs.mysql.com/47621
#
-- source include/have_innodb.inc
CREATE TABLE bug44571 (foo INT) ENGINE=InnoDB;
ALTER TABLE bug44571 CHANGE foo bar INT;
# Create index with the old column name will fail,
# because the CHANGE foo bar is successful. And
# the column name change would communicate to
# InnoDB with the fix from bug #47621
-- error ER_KEY_COLUMN_DOES_NOT_EXITS
ALTER TABLE bug44571 ADD INDEX bug44571b (foo);
# The following will fail, because the CHANGE foo bar was
# not communicated to InnoDB.
--error ER_NOT_KEYFILE
ALTER TABLE bug44571 ADD INDEX bug44571b (bar);
--error ER_NOT_KEYFILE
CREATE INDEX bug44571b ON bug44571 (bar);
# The following create indexes should succeed,
# indirectly confirm the CHANGE foo bar is successful.
ALTER TABLE bug44571 ADD INDEX bug44571c (bar);
DROP INDEX bug44571c ON bug44571;
CREATE INDEX bug44571c ON bug44571 (bar);
DROP TABLE bug44571;
CREATE TABLE bug47621 (salesperson INT) ENGINE=InnoDB;
ALTER TABLE bug47621 CHANGE salesperson sales_acct_id INT;
create index orgs on bug47621(sales_acct_id);
ALTER TABLE bug47621 CHANGE sales_acct_id salesperson INT;
drop table bug47621;
CREATE TABLE bug47621_sale (
salesperson INT,
PRIMARY KEY(salesperson)) engine = innodb;
CREATE TABLE bug47621_shirt(
id SMALLINT,
owner INT,
FOREIGN KEY(owner)
references bug47621_sale(salesperson) ON DELETE RESTRICT)
engine = innodb;
insert into bug47621_sale values(9);
insert into bug47621_shirt values(1, 9);
ALTER TABLE bug47621_shirt CHANGE id new_id INT;
drop table bug47621_shirt;
ALTER TABLE bug47621_sale CHANGE salesperson sales_acct_id INT;
ALTER TABLE bug47621_sale ADD INDEX idx (sales_acct_id);
drop table bug47621_sale;
# This is the test for bug #47621, column rename operation should
# not result in column definition inconsistency between MySQL and
# InnoDB
--source include/have_innodb.inc
CREATE TABLE bug47621 (salesperson INT) ENGINE=InnoDB;
# Change the column name
ALTER TABLE bug47621 CHANGE salesperson sales_acct_id INT;
# If there is inconsistency of column name definition
# in MySQL or InnoDB, following create index would fail
create index orgs on bug47621(sales_acct_id);
# Change the column name back with the index defined on it.
ALTER TABLE bug47621 CHANGE sales_acct_id salesperson INT;
drop table bug47621;
CREATE TABLE bug47621_sale (
salesperson INT,
PRIMARY KEY(salesperson)) engine = innodb;
CREATE TABLE bug47621_shirt(
id SMALLINT,
owner INT,
FOREIGN KEY(owner)
references bug47621_sale(salesperson) ON DELETE RESTRICT)
engine = innodb;
insert into bug47621_sale values(9);
insert into bug47621_shirt values(1, 9);
# Any rename operation on columns involved in a reference constraint will
# fail, as it will be rejected by InnoDB row_rename_table_for_mysql().
# In above example, any rename on column "salesperson" for table
# "bug47621_sale", or on column "owner" for table "bug47621_shirt will
# be blocked. We do not put such rename in the test since InnoDB error
# message will be printed in the error log, and result in test failure.
#
# ALTER TABLE bug47621_sale CHANGE salesperson sales_acct_id INT;
# Any rename on columns not involved in the foreign key constraint
# could still proceed
ALTER TABLE bug47621_shirt CHANGE id new_id INT;
# Referencing table dropped, the rename operation on related columns
# could proceed
drop table bug47621_shirt;
ALTER TABLE bug47621_sale CHANGE salesperson sales_acct_id INT;
ALTER TABLE bug47621_sale ADD INDEX idx (sales_acct_id);
drop table bug47621_sale;
create table bug51378 (
col1 int not null,
col2 blob not null,
col3 time not null) engine = innodb;
create unique index idx on bug51378(col1, col2(31));
alter table bug51378 add unique index idx2(col1, col2(31));
create unique index idx3 on bug51378(col1, col3);
SHOW CREATE TABLE bug51378;
Table Create Table
bug51378 CREATE TABLE `bug51378` (
`col1` int(11) NOT NULL,
`col2` blob NOT NULL,
`col3` time NOT NULL,
UNIQUE KEY `idx3` (`col1`,`col3`),
UNIQUE KEY `idx` (`col1`,`col2`(31)),
UNIQUE KEY `idx2` (`col1`,`col2`(31))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop index idx3 on bug51378;
SHOW CREATE TABLE bug51378;
Table Create Table
bug51378 CREATE TABLE `bug51378` (
`col1` int(11) NOT NULL,
`col2` blob NOT NULL,
`col3` time NOT NULL,
UNIQUE KEY `idx` (`col1`,`col2`(31)),
UNIQUE KEY `idx2` (`col1`,`col2`(31))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
alter table bug51378 add primary key idx3(col1, col2(31));
SHOW CREATE TABLE bug51378;
Table Create Table
bug51378 CREATE TABLE `bug51378` (
`col1` int(11) NOT NULL,
`col2` blob NOT NULL,
`col3` time NOT NULL,
PRIMARY KEY (`col1`,`col2`(31)),
UNIQUE KEY `idx` (`col1`,`col2`(31)),
UNIQUE KEY `idx2` (`col1`,`col2`(31))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table bug51378;
create table bug51378 (
col1 int not null,
col2 blob not null,
col3 time not null, primary key(col1, col2(31))) engine = innodb;
create unique index idx on bug51378(col1, col2(31));
SHOW CREATE TABLE bug51378;
Table Create Table
bug51378 CREATE TABLE `bug51378` (
`col1` int(11) NOT NULL,
`col2` blob NOT NULL,
`col3` time NOT NULL,
PRIMARY KEY (`col1`,`col2`(31)),
UNIQUE KEY `idx` (`col1`,`col2`(31))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table bug51378;
create table bug51378 (
col1 int not null,
col2 int ) engine = innodb;
create unique index idx on bug51378(col1, col2);
SHOW CREATE TABLE bug51378;
Table Create Table
bug51378 CREATE TABLE `bug51378` (
`col1` int(11) NOT NULL,
`col2` int(11) DEFAULT NULL,
UNIQUE KEY `idx` (`col1`,`col2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table bug51378;
# This is the test for bug 51378. Unique index created
# through "create index" and "alter table add unique index"
# interfaces should not be treated as primary index if indexed
# columns contain one or more column prefix(es) (only prefix/part of
# the column is indexed)
# On the other hand, if there is a unique index covers all
# columns of a table, and they are non-null columns, and
# full length of the column are indexed, then this index
# will be created as primary index
# Following queries test various scenario, no mismatch
# error message should be printed.
--source include/have_innodb.inc
# Create a table contains a BLOB column
create table bug51378 (
col1 int not null,
col2 blob not null,
col3 time not null) engine = innodb;
# Create following unique indexes on 'col1' and 'col2(31)'
# of the table, the index should not be treated as primary
# key because it indexes only first 31 bytes of col2.
# Thus it contains "column prefix", and will not be
# upgraded to primary index.
# There should not be mismatch message printed in the
# errorlog
create unique index idx on bug51378(col1, col2(31));
alter table bug51378 add unique index idx2(col1, col2(31));
# Unique index on 'col1' and 'col3' will be created as primary index,
# since the index does not contain column prefix
create unique index idx3 on bug51378(col1, col3);
# Show create table would show idx3 created as unique index, internally,
# idx3 is treated as primary index both by MySQL and Innodb
SHOW CREATE TABLE bug51378;
# "GEN_CLUST_INDEX" will be re-created as default primary index
# after idx3 is dropped
drop index idx3 on bug51378;
SHOW CREATE TABLE bug51378;
# Or we can add the primary key through alter table interfaces
alter table bug51378 add primary key idx3(col1, col2(31));
SHOW CREATE TABLE bug51378;
drop table bug51378;
# Or we can create such primary key through create table interfaces
create table bug51378 (
col1 int not null,
col2 blob not null,
col3 time not null, primary key(col1, col2(31))) engine = innodb;
# Unique index on one or more column prefix(es) will be created
# as non-cluster index
create unique index idx on bug51378(col1, col2(31));
SHOW CREATE TABLE bug51378;
drop table bug51378;
# If a table has a NULLABLE column, unique index on it will not
# be treated as primary index.
create table bug51378 (
col1 int not null,
col2 int ) engine = innodb;
# This will be created as non-cluster index since col2 is nullable
create unique index idx on bug51378(col1, col2);
SHOW CREATE TABLE bug51378;
drop table bug51378;
......@@ -14,7 +14,7 @@
# Place, Suite 330, Boston, MA 02111-1307 USA
#
MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
MYSQL_STORAGE_ENGINE(innobase, innodb, [InnoDB Storage Engine],
[Transactional Tables using InnoDB], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(innobase, [storage/innobase])
MYSQL_PLUGIN_STATIC(innobase, [libinnobase.a])
......
......@@ -977,6 +977,7 @@ trx_undo_update_rec_get_update(
fprintf(stderr, "\n"
"InnoDB: n_fields = %lu, i = %lu, ptr %p\n",
(ulong) n_fields, (ulong) i, ptr);
*upd = NULL;
return(NULL);
}
......
......@@ -584,8 +584,8 @@ trx_sys_doublewrite_init_or_restore_pages(
" recover the database"
" with the my.cnf\n"
"InnoDB: option:\n"
"InnoDB: set-variable="
"innodb_force_recovery=6\n");
"InnoDB:"
" innodb_force_recovery=6\n");
exit(1);
}
......
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