Commit 8d57fae2 authored by vasil's avatar vasil

branches/zip: Merge r5341:5497 from branches/5.1, skipping:

c5419 because it is merge from branches/zip into branches/5.1
c5466 because the source code has been adjusted to match the MySQL
  behavior and the innodb-autoinc test does not fail in branches/zip,
  if c5466 is merged, then innodb-autoinc starts failing, Sunny suggested
  not to merge c5466.
and resolving conflicts in c5410, c5440, c5488:

  ------------------------------------------------------------------------
  r5410 | marko | 2009-06-24 22:26:34 +0300 (Wed, 24 Jun 2009) | 2 lines
  Changed paths:
     M /branches/5.1/include/trx0sys.ic
     M /branches/5.1/trx/trx0purge.c
     M /branches/5.1/trx/trx0sys.c
     M /branches/5.1/trx/trx0undo.c
  
  branches/5.1: Add missing #include "mtr0log.h" to avoid warnings
  when compiling with -DUNIV_MUST_NOT_INLINE.
  ------------------------------------------------------------------------
  r5419 | marko | 2009-06-25 16:11:57 +0300 (Thu, 25 Jun 2009) | 18 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     M /branches/5.1/mysql-test/innodb_bug42101-nonzero.result
     M /branches/5.1/mysql-test/innodb_bug42101-nonzero.test
     M /branches/5.1/mysql-test/innodb_bug42101.result
     M /branches/5.1/mysql-test/innodb_bug42101.test
  
  branches/5.1: Merge r5418 from branches/zip:
  
    ------------------------------------------------------------------------
    r5418 | marko | 2009-06-25 15:55:52 +0300 (Thu, 25 Jun 2009) | 5 lines
    Changed paths:
       M /branches/zip/ChangeLog
       M /branches/zip/handler/ha_innodb.cc
       M /branches/zip/mysql-test/innodb_bug42101-nonzero.result
       M /branches/zip/mysql-test/innodb_bug42101-nonzero.test
       M /branches/zip/mysql-test/innodb_bug42101.result
       M /branches/zip/mysql-test/innodb_bug42101.test
    
    branches/zip: Fix a race condition caused by
    SET GLOBAL innodb_commit_concurrency=DEFAULT. (Bug #45749)
    When innodb_commit_concurrency is initially set nonzero,
    DEFAULT would change it back to 0, triggering Bug #42101.
    rb://139 approved by Heikki Tuuri.
    ------------------------------------------------------------------------
  ------------------------------------------------------------------------
  r5440 | vasil | 2009-06-30 13:04:29 +0300 (Tue, 30 Jun 2009) | 8 lines
  Changed paths:
     M /branches/5.1/fil/fil0fil.c
  
  branches/5.1:
  
  Fix Bug#45814 URL reference in InnoDB server errors needs adjusting to match documentation
  
  by changing the URL from
  http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting.html to
  http://dev.mysql.com/doc/refman/5.1/en/innodb-troubleshooting-datadict.html
  
  ------------------------------------------------------------------------
  r5466 | vasil | 2009-07-02 10:46:45 +0300 (Thu, 02 Jul 2009) | 6 lines
  Changed paths:
     M /branches/5.1/mysql-test/innodb-autoinc.result
     M /branches/5.1/mysql-test/innodb-autoinc.test
  
  branches/5.1:
  
  Adjust the failing innodb-autoinc test to conform to the latest behavior
  of the MySQL code. The idea and the comment in innodb-autoinc.test come
  from Sunny.
  
  ------------------------------------------------------------------------
  r5488 | vasil | 2009-07-09 19:16:44 +0300 (Thu, 09 Jul 2009) | 13 lines
  Changed paths:
     M /branches/5.1/handler/ha_innodb.cc
     A /branches/5.1/mysql-test/innodb_bug21704.result
     A /branches/5.1/mysql-test/innodb_bug21704.test
  
  branches/5.1:
  
  Fix Bug#21704 Renaming column does not update FK definition
  
  by checking whether a column that participates in a FK definition is being
  renamed and denying the ALTER in this case.
  
  The patch was originally developed by Davi Arnaut <Davi.Arnaut@Sun.COM>:
  http://lists.mysql.com/commits/77714
  and was later adjusted to conform to InnoDB coding style by me (Vasil),
  I also added some more comments and moved the bug specific mysql-test to
  a separate file to make it more manageable and flexible.
  
  ------------------------------------------------------------------------
parent 0e71cfd9
......@@ -2954,7 +2954,7 @@ fil_open_single_table_tablespace(
" a temporary table #sql...,\n"
"InnoDB: and MySQL removed the .ibd file for this.\n"
"InnoDB: Please refer to\n"
"InnoDB: " REFMAN "innodb-troubleshooting.html\n"
"InnoDB: " REFMAN "innodb-troubleshooting-datadict.html\n"
"InnoDB: for how to resolve the issue.\n", stderr);
mem_free(filepath);
......@@ -2996,7 +2996,7 @@ fil_open_single_table_tablespace(
"InnoDB: commands DISCARD TABLESPACE and"
" IMPORT TABLESPACE?\n"
"InnoDB: Please refer to\n"
"InnoDB: " REFMAN "innodb-troubleshooting.html\n"
"InnoDB: " REFMAN "innodb-troubleshooting-datadict.html\n"
"InnoDB: for how to resolve the issue.\n",
(ulong) space_id, (ulong) space_flags,
(ulong) id, (ulong) flags);
......@@ -3677,7 +3677,7 @@ fil_space_for_table_exists_in_mem(
}
error_exit:
fputs("InnoDB: Please refer to\n"
"InnoDB: " REFMAN "innodb-troubleshooting.html\n"
"InnoDB: " REFMAN "innodb-troubleshooting-datadict.html\n"
"InnoDB: for how to resolve the issue.\n", stderr);
mem_free(path);
......
......@@ -9184,6 +9184,97 @@ innobase_set_cursor_view(
}
/***********************************************************************
Check whether any of the given columns is being renamed in the 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 */
{
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);
}
}
}
return(false);
}
/***********************************************************************
Check whether a column in table "table" is being renamed and if this column
is part of a foreign key, either part of another table, referencing this
table or part of this table, referencing another table. */
static
bool
foreign_key_column_is_being_renamed(
/*================================*/
/* out: true if a column that
participates in a foreign key definition
is being renamed */
row_prebuilt_t* prebuilt, /* in: InnoDB prebuilt struct */
TABLE* table) /* in: MySQL table */
{
dict_foreign_t* foreign;
/* check whether there are foreign keys at all */
if (UT_LIST_GET_LEN(prebuilt->table->foreign_list) == 0
&& UT_LIST_GET_LEN(prebuilt->table->referenced_list) == 0) {
/* no foreign keys involved with prebuilt->table */
return(false);
}
row_mysql_lock_data_dictionary(prebuilt->trx);
/* Check whether any column in the foreign key constraints which refer
to this table is being renamed. */
for (foreign = UT_LIST_GET_FIRST(prebuilt->table->referenced_list);
foreign != NULL;
foreign = UT_LIST_GET_NEXT(referenced_list, foreign)) {
if (column_is_being_renamed(table, foreign->n_fields,
foreign->referenced_col_names)) {
row_mysql_unlock_data_dictionary(prebuilt->trx);
return(true);
}
}
/* Check whether any column in the foreign key constraints in the
table is being renamed. */
for (foreign = UT_LIST_GET_FIRST(prebuilt->table->foreign_list);
foreign != NULL;
foreign = UT_LIST_GET_NEXT(foreign_list, foreign)) {
if (column_is_being_renamed(table, foreign->n_fields,
foreign->foreign_col_names)) {
row_mysql_unlock_data_dictionary(prebuilt->trx);
return(true);
}
}
row_mysql_unlock_data_dictionary(prebuilt->trx);
return(false);
}
UNIV_INTERN
bool
ha_innobase::check_if_incompatible_data(
......@@ -9202,6 +9293,13 @@ ha_innobase::check_if_incompatible_data(
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)) {
return COMPATIBLE_DATA_NO;
}
/* Check that row format didn't change */
if ((info->used_fields & HA_CREATE_USED_ROW_FORMAT)
&& info->row_type != ROW_TYPE_DEFAULT
......
#
# Bug#21704: Renaming column does not update FK definition.
#
# Test that it's not possible to rename columns participating in a
# foreign key (either in the referencing or referenced table).
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB;
CREATE TABLE t2 (a INT PRIMARY KEY, b INT,
CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a))
ROW_FORMAT=COMPACT ENGINE=INNODB;
CREATE TABLE t3 (a INT PRIMARY KEY, b INT, KEY(b), C INT,
CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t3 (a))
ROW_FORMAT=COMPACT ENGINE=INNODB;
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3);
# Test renaming the column in the referenced table.
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
# Test renaming the column in the referencing table
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
# Test with self-referential constraints
ALTER TABLE t3 CHANGE a d INT;
ERROR HY000: Error on rename of '#sql-temporary' to './test/t3' (errno: 150)
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
# Cleanup.
DROP TABLE t3;
DROP TABLE t2;
DROP TABLE t1;
-- source include/have_innodb.inc
--echo #
--echo # Bug#21704: Renaming column does not update FK definition.
--echo #
--echo
--echo # Test that it's not possible to rename columns participating in a
--echo # foreign key (either in the referencing or referenced table).
--echo
--disable_warnings
DROP TABLE IF EXISTS t1;
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t3;
--enable_warnings
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ROW_FORMAT=COMPACT ENGINE=INNODB;
CREATE TABLE t2 (a INT PRIMARY KEY, b INT,
CONSTRAINT fk1 FOREIGN KEY (a) REFERENCES t1(a))
ROW_FORMAT=COMPACT ENGINE=INNODB;
CREATE TABLE t3 (a INT PRIMARY KEY, b INT, KEY(b), C INT,
CONSTRAINT fk2 FOREIGN KEY (b) REFERENCES t3 (a))
ROW_FORMAT=COMPACT ENGINE=INNODB;
INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
INSERT INTO t3 VALUES (1,1,1),(2,2,2),(3,3,3);
--echo
--echo # Test renaming the column in the referenced table.
--echo
# mysqltest first does replace_regex, then replace_result
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
# Embedded server doesn't chdir to data directory
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
--error ER_ERROR_ON_RENAME
ALTER TABLE t1 CHANGE a c INT;
--echo # Ensure that online column rename works.
--enable_info
ALTER TABLE t1 CHANGE b c INT;
--disable_info
--echo
--echo # Test renaming the column in the referencing table
--echo
# mysqltest first does replace_regex, then replace_result
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
# Embedded server doesn't chdir to data directory
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
--error ER_ERROR_ON_RENAME
ALTER TABLE t2 CHANGE a c INT;
--echo # Ensure that online column rename works.
--enable_info
ALTER TABLE t2 CHANGE b c INT;
--disable_info
--echo
--echo # Test with self-referential constraints
--echo
# mysqltest first does replace_regex, then replace_result
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
# Embedded server doesn't chdir to data directory
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
--error ER_ERROR_ON_RENAME
ALTER TABLE t3 CHANGE a d INT;
# mysqltest first does replace_regex, then replace_result
--replace_regex /'[^']*test\/#sql-[0-9a-f_]*'/'#sql-temporary'/
# Embedded server doesn't chdir to data directory
--replace_result $MYSQLTEST_VARDIR . mysqld.1/data/ ''
--error ER_ERROR_ON_RENAME
ALTER TABLE t3 CHANGE b d INT;
--echo # Ensure that online column rename works.
--enable_info
ALTER TABLE t3 CHANGE c d INT;
--disable_info
--echo
--echo # Cleanup.
--echo
DROP TABLE t3;
DROP TABLE t2;
DROP TABLE t1;
......@@ -31,7 +31,7 @@ Created 3/26/1996 Heikki Tuuri
#ifndef UNIV_HOTBACKUP
#include "fsp0fsp.h"
#include "mtr0mtr.h"
#include "mtr0log.h"
#include "mtr0log.h"
#include "trx0trx.h"
#include "trx0rseg.h"
......
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