From 75ceb6ff130cdac67fadc1d45cd64578a19b4835 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 31 Oct 2018 14:25:26 +0400 Subject: MDEV-17298 ASAN unknown-crash / READ of size 1 in my_strntoul_8bit upon INSERT .. SELECT --- mysql-test/r/ctype_latin1.result | 9 +++++++++ mysql-test/t/ctype_latin1.test | 12 ++++++++++++ strings/ctype-simple.c | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 8913c8082c8..d2e4cc31097 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -7963,5 +7963,14 @@ ABCDEFGHI-ABCDEFGHI DROP TABLE t1; SET optimizer_switch=@save_optimizer_switch; # +# MDEV-17298 ASAN unknown-crash / READ of size 1 in my_strntoul_8bit upon INSERT .. SELECT +# +SET NAMES latin1; +CREATE TABLE t1 (a CHAR); +CREATE TABLE t2 (b ENUM('foo','bar')); +INSERT INTO t1 VALUES ('1'); +INSERT INTO t2 SELECT * FROM t1; +DROP TABLE t1, t2; +# # End of 10.0 tests # diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index da4d76ee2cf..0ec983b8b74 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -264,6 +264,18 @@ SET NAMES latin1; --source include/ctype_mdev13118.inc +--echo # +--echo # MDEV-17298 ASAN unknown-crash / READ of size 1 in my_strntoul_8bit upon INSERT .. SELECT +--echo # + +SET NAMES latin1; +CREATE TABLE t1 (a CHAR); +CREATE TABLE t2 (b ENUM('foo','bar')); +INSERT INTO t1 VALUES ('1'); +INSERT INTO t2 SELECT * FROM t1; +DROP TABLE t1, t2; + + --echo # --echo # End of 10.0 tests --echo # diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 61b14b84820..8d12c05db18 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -454,7 +454,6 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, register uint cutlim; register uint32 i; register const char *s; - register uchar c; const char *save, *e; int overflow; @@ -489,8 +488,9 @@ ulong my_strntoul_8bit(CHARSET_INFO *cs, overflow = 0; i = 0; - for (c = *s; s != e; c = *++s) + for ( ; s != e; ++s) { + register uchar c= *s; if (c>='0' && c<='9') c -= '0'; else if (c>='A' && c<='Z') -- cgit v1.2.1 From b2f39a5f567d006000aad8b431267298cf81b569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 1 Nov 2018 09:15:41 +0200 Subject: Add missing wsrep.cnf.sh --- support-files/CMakeLists.txt | 7 +++ support-files/wsrep.cnf.sh | 125 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 support-files/wsrep.cnf.sh diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index cc9eed6c7be..d02da51194c 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -50,6 +50,13 @@ FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small) ENDFOREACH() ENDIF() +IF(WITH_WSREP) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/wsrep.cnf.sh + ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension} @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension} + DESTINATION ${inst_location} COMPONENT IniFiles) +ENDIF() + IF(UNIX) SET(prefix ${CMAKE_INSTALL_PREFIX}) FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure) diff --git a/support-files/wsrep.cnf.sh b/support-files/wsrep.cnf.sh new file mode 100644 index 00000000000..51ce3dca2dd --- /dev/null +++ b/support-files/wsrep.cnf.sh @@ -0,0 +1,125 @@ +# This file contains wsrep-related mysqld options. It should be included +# in the main MySQL configuration file. +# +# Options that need to be customized: +# - wsrep_provider +# - wsrep_cluster_address +# - wsrep_sst_auth +# The rest of defaults should work out of the box. + +## +## mysqld options _MANDATORY_ for correct opration of the cluster +## +[mysqld] + +# (This must be substituted by wsrep_format) +binlog_format=ROW + +# Currently only InnoDB storage engine is supported +default-storage-engine=innodb + +# to avoid issues with 'bulk mode inserts' using autoinc +innodb_autoinc_lock_mode=2 + +# Override bind-address +# In some systems bind-address defaults to 127.0.0.1, and with mysqldump SST +# it will have (most likely) disastrous consequences on donor node +bind-address=0.0.0.0 + +## +## WSREP options +## + +# Enable wsrep +wsrep_on=1 + +# Full path to wsrep provider library or 'none' +wsrep_provider=none + +# Provider specific configuration options +#wsrep_provider_options= + +# Logical cluster name. Should be the same for all nodes. +wsrep_cluster_name="my_wsrep_cluster" + +# Group communication system handle +#wsrep_cluster_address="dummy://" + +# Human-readable node name (non-unique). Hostname by default. +#wsrep_node_name= + +# Base replication [:port] of the node. +# The values supplied will be used as defaults for state transfer receiving, +# listening ports and so on. Default: address of the first network interface. +#wsrep_node_address= + +# Address for incoming client connections. Autodetect by default. +#wsrep_node_incoming_address= + +# How many threads will process writesets from other nodes +wsrep_slave_threads=1 + +# DBUG options for wsrep provider +#wsrep_dbug_option + +# Generate fake primary keys for non-PK tables (required for multi-master +# and parallel applying operation) +wsrep_certify_nonPK=1 + +# Maximum number of rows in write set +wsrep_max_ws_rows=131072 + +# Maximum size of write set +wsrep_max_ws_size=1073741824 + +# to enable debug level logging, set this to 1 +wsrep_debug=0 + +# convert locking sessions into transactions +wsrep_convert_LOCK_to_trx=0 + +# how many times to retry deadlocked autocommits +wsrep_retry_autocommit=1 + +# change auto_increment_increment and auto_increment_offset automatically +wsrep_auto_increment_control=1 + +# retry autoinc insert, which failed for duplicate key error +wsrep_drupal_282555_workaround=0 + +# enable "strictly synchronous" semantics for read operations +wsrep_causal_reads=0 + +# Command to call when node status or cluster membership changes. +# Will be passed all or some of the following options: +# --status - new status of this node +# --uuid - UUID of the cluster +# --primary - whether the component is primary or not ("yes"/"no") +# --members - comma-separated list of members +# --index - index of this node in the list +wsrep_notify_cmd= + +## +## WSREP State Transfer options +## + +# State Snapshot Transfer method +wsrep_sst_method=rsync + +# Address which donor should send State Snapshot to. +# Should be the address of THIS node. DON'T SET IT TO DONOR ADDRESS!!! +# (SST method dependent. Defaults to the first IP of the first interface) +#wsrep_sst_receive_address= + +# SST authentication string. This will be used to send SST to joining nodes. +# Depends on SST method. For mysqldump method it is root: +wsrep_sst_auth=root: + +# Desired SST donor name. +#wsrep_sst_donor= + +# Reject client queries when donating SST (false) +#wsrep_sst_donor_rejects_queries=0 + +# Protocol version to use +# wsrep_protocol_version= -- cgit v1.2.1 From c4c738e1ef983a0a4353957cf5d488a3f2cb0a58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Thu, 1 Nov 2018 09:27:59 +0200 Subject: Revert commit b2f39a5f567d006000aad8b431267298cf81b569 wrong branch. --- support-files/CMakeLists.txt | 7 --- support-files/wsrep.cnf.sh | 125 ------------------------------------------- 2 files changed, 132 deletions(-) delete mode 100644 support-files/wsrep.cnf.sh diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt index d02da51194c..cc9eed6c7be 100644 --- a/support-files/CMakeLists.txt +++ b/support-files/CMakeLists.txt @@ -50,13 +50,6 @@ FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small) ENDFOREACH() ENDIF() -IF(WITH_WSREP) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/wsrep.cnf.sh - ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension} @ONLY) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/wsrep.${ini_file_extension} - DESTINATION ${inst_location} COMPONENT IniFiles) -ENDIF() - IF(UNIX) SET(prefix ${CMAKE_INSTALL_PREFIX}) FOREACH(script mysqld_multi.server mysql-log-rotate binary-configure) diff --git a/support-files/wsrep.cnf.sh b/support-files/wsrep.cnf.sh deleted file mode 100644 index 51ce3dca2dd..00000000000 --- a/support-files/wsrep.cnf.sh +++ /dev/null @@ -1,125 +0,0 @@ -# This file contains wsrep-related mysqld options. It should be included -# in the main MySQL configuration file. -# -# Options that need to be customized: -# - wsrep_provider -# - wsrep_cluster_address -# - wsrep_sst_auth -# The rest of defaults should work out of the box. - -## -## mysqld options _MANDATORY_ for correct opration of the cluster -## -[mysqld] - -# (This must be substituted by wsrep_format) -binlog_format=ROW - -# Currently only InnoDB storage engine is supported -default-storage-engine=innodb - -# to avoid issues with 'bulk mode inserts' using autoinc -innodb_autoinc_lock_mode=2 - -# Override bind-address -# In some systems bind-address defaults to 127.0.0.1, and with mysqldump SST -# it will have (most likely) disastrous consequences on donor node -bind-address=0.0.0.0 - -## -## WSREP options -## - -# Enable wsrep -wsrep_on=1 - -# Full path to wsrep provider library or 'none' -wsrep_provider=none - -# Provider specific configuration options -#wsrep_provider_options= - -# Logical cluster name. Should be the same for all nodes. -wsrep_cluster_name="my_wsrep_cluster" - -# Group communication system handle -#wsrep_cluster_address="dummy://" - -# Human-readable node name (non-unique). Hostname by default. -#wsrep_node_name= - -# Base replication [:port] of the node. -# The values supplied will be used as defaults for state transfer receiving, -# listening ports and so on. Default: address of the first network interface. -#wsrep_node_address= - -# Address for incoming client connections. Autodetect by default. -#wsrep_node_incoming_address= - -# How many threads will process writesets from other nodes -wsrep_slave_threads=1 - -# DBUG options for wsrep provider -#wsrep_dbug_option - -# Generate fake primary keys for non-PK tables (required for multi-master -# and parallel applying operation) -wsrep_certify_nonPK=1 - -# Maximum number of rows in write set -wsrep_max_ws_rows=131072 - -# Maximum size of write set -wsrep_max_ws_size=1073741824 - -# to enable debug level logging, set this to 1 -wsrep_debug=0 - -# convert locking sessions into transactions -wsrep_convert_LOCK_to_trx=0 - -# how many times to retry deadlocked autocommits -wsrep_retry_autocommit=1 - -# change auto_increment_increment and auto_increment_offset automatically -wsrep_auto_increment_control=1 - -# retry autoinc insert, which failed for duplicate key error -wsrep_drupal_282555_workaround=0 - -# enable "strictly synchronous" semantics for read operations -wsrep_causal_reads=0 - -# Command to call when node status or cluster membership changes. -# Will be passed all or some of the following options: -# --status - new status of this node -# --uuid - UUID of the cluster -# --primary - whether the component is primary or not ("yes"/"no") -# --members - comma-separated list of members -# --index - index of this node in the list -wsrep_notify_cmd= - -## -## WSREP State Transfer options -## - -# State Snapshot Transfer method -wsrep_sst_method=rsync - -# Address which donor should send State Snapshot to. -# Should be the address of THIS node. DON'T SET IT TO DONOR ADDRESS!!! -# (SST method dependent. Defaults to the first IP of the first interface) -#wsrep_sst_receive_address= - -# SST authentication string. This will be used to send SST to joining nodes. -# Depends on SST method. For mysqldump method it is root: -wsrep_sst_auth=root: - -# Desired SST donor name. -#wsrep_sst_donor= - -# Reject client queries when donating SST (false) -#wsrep_sst_donor_rejects_queries=0 - -# Protocol version to use -# wsrep_protocol_version= -- cgit v1.2.1 From 38b3e52c3c40b35339b1d18c09053be416a93420 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Wed, 31 Oct 2018 23:30:34 +0530 Subject: MDEV-16695: Estimate for rows of derived tables is very high when we are using index_merge union For index merge union[or sort union], the estimates are not taken into account while calculating the selectivity of a condition. So instead of showing the estimates of the index merge union[or sort union], it shows estimates equal to all the records of the table. The fix for the issue is to include the selectivity of index merge union[or sort union] while calculating the selectivity of a condition. --- mysql-test/r/index_merge_myisam.result | 50 ++++++++++++++++++++++++++++++++++ mysql-test/t/index_merge_myisam.test | 35 ++++++++++++++++++++++++ sql/opt_range.cc | 6 ++++ 3 files changed, 91 insertions(+) diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result index b3beff5a967..51b764213ca 100644 --- a/mysql-test/r/index_merge_myisam.result +++ b/mysql-test/r/index_merge_myisam.result @@ -1712,3 +1712,53 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL PRIMARY,c1,i,c2 NULL NULL NULL 69 Using where DROP TABLE t1; set optimizer_switch= @optimizer_switch_save; +# +# MDEV-16695: Estimate for rows of derived tables is very high when we are using index_merge union +# +create table t0 +( +key1 int not null, +INDEX i1(key1) +); +insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8); +set @d=8; +insert into t0 select key1+ @d from t0; +set @d=@d*2; +insert into t0 select key1+ @d from t0; +set @d=@d*2; +insert into t0 select key1+ @d from t0; +set @d=@d*2; +insert into t0 select key1+ @d from t0; +set @d=@d*2; +insert into t0 select key1+ @d from t0; +set @d=@d*2; +insert into t0 select key1+ @d from t0; +set @d=@d*2; +insert into t0 select key1+ @d from t0; +set @d=@d*2; +alter table t0 add key2 int not null, add index i2(key2); +alter table t0 add key3 int not null, add index i3(key3); +alter table t0 add key8 int not null, add index i8(key8); +update t0 set key2=key1,key3=key1,key8=1024-key1; +analyze table t0; +Table Op Msg_type Msg_text +test.t0 analyze status OK +set @optimizer_switch_save=@@optimizer_switch; +set optimizer_switch='derived_merge=off,derived_with_keys=off'; +explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 Using where +2 DERIVED t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where +select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5; +key1 key2 key3 key8 +3 3 3 1021 +set optimizer_use_condition_selectivity=2; +explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 2 Using where +2 DERIVED t0 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where +select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5; +key1 key2 key3 key8 +3 3 3 1021 +set @@optimizer_switch= @optimizer_switch_save; +drop table t0; diff --git a/mysql-test/t/index_merge_myisam.test b/mysql-test/t/index_merge_myisam.test index d265007431e..75beb9bd883 100644 --- a/mysql-test/t/index_merge_myisam.test +++ b/mysql-test/t/index_merge_myisam.test @@ -243,3 +243,38 @@ DROP TABLE t1; set optimizer_switch= @optimizer_switch_save; +--echo # +--echo # MDEV-16695: Estimate for rows of derived tables is very high when we are using index_merge union +--echo # + +create table t0 +( + key1 int not null, + INDEX i1(key1) +); + +insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8); +let $1=7; +set @d=8; +while ($1) +{ + eval insert into t0 select key1+ @d from t0; + eval set @d=@d*2; + dec $1; +} +alter table t0 add key2 int not null, add index i2(key2); +alter table t0 add key3 int not null, add index i3(key3); +alter table t0 add key8 int not null, add index i8(key8); + +update t0 set key2=key1,key3=key1,key8=1024-key1; +analyze table t0; + +set @optimizer_switch_save=@@optimizer_switch; +set optimizer_switch='derived_merge=off,derived_with_keys=off'; +explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5; +select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5; +set optimizer_use_condition_selectivity=2; +explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5; +select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5; +set @@optimizer_switch= @optimizer_switch_save; +drop table t0; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 0fd2cd267fc..3bcaa72e32f 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3725,6 +3725,12 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item *cond) } + if (quick && (quick->get_type() == QUICK_SELECT_I::QS_TYPE_ROR_UNION || + quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE)) + { + table->cond_selectivity*= (quick->records/table_records); + } + bitmap_union(used_fields, &handled_columns); /* Check if we can improve selectivity estimates by using sampling */ -- cgit v1.2.1 From 9eb8a46790c556a9f683a14aea71e775f4fbe802 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Thu, 1 Nov 2018 11:09:32 -0400 Subject: bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2eee908ea01..163137684a2 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=0 -MYSQL_VERSION_PATCH=37 +MYSQL_VERSION_PATCH=38 -- cgit v1.2.1 From f0cb21ea2e00b9f985ed0a76f1e6edbdf9d846cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Nov 2018 12:42:01 +0200 Subject: Remove dead code is_thd_killed() --- include/mysql/service_kill_statement.h | 4 ++-- storage/xtradb/handler/ha_innodb.cc | 11 +---------- storage/xtradb/handler/ha_innodb.h | 6 +----- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/include/mysql/service_kill_statement.h b/include/mysql/service_kill_statement.h index 995b21f0a9f..bfb222301eb 100644 --- a/include/mysql/service_kill_statement.h +++ b/include/mysql/service_kill_statement.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, Monty Program Ab. +/* Copyright (c) 2013, 2018, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,7 +27,7 @@ time-consuming loops, and gracefully abort the operation if it is non-zero. - thd_is_killed(thd) + thd_killed(thd) @return 0 - no KILL statement was issued, continue normally @return 1 - there was a KILL statement, abort the execution. diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 5179b49dc04..e7992c3f161 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -4,7 +4,7 @@ Copyright (c) 2000, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -19611,15 +19611,6 @@ int ha_innobase::multi_range_read_explain_info(uint mrr_mode, char *str, size_t return ds_mrr.dsmrr_explain_info(mrr_mode, str, size); } -/* - A helper function used only in index_cond_func_innodb -*/ - -bool ha_innobase::is_thd_killed() -{ - return thd_kill_level(user_thd); -} - /********************************************************************** Issue a warning that the row is too big. */ UNIV_INTERN diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index cf44e14aff0..e65e0964f9d 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2017, MariaDB Corporation. +Copyright (c) 2013, 2018, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -364,10 +364,6 @@ public: * @return idx_cond if pushed; NULL if not pushed */ class Item* idx_cond_push(uint keyno, class Item* idx_cond); - - /* An helper function for index_cond_func_innodb: */ - bool is_thd_killed(); - private: /** The multi range read session object */ DsMrr_impl ds_mrr; -- cgit v1.2.1 From 03977e8273cbd33c3cbfec191ceee856f973ce1a Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 25 Oct 2018 21:36:24 +0300 Subject: MDEV-13671 InnoDB should use case-insensitive column name comparisons like the rest of the server Problem affects INPLACE ALTER rename columns. innobase_rename_column_try(): some strcmp() was replaced with my_strcasecmp(), queries to update data dictionary was updated to not match column name case. --- mysql-test/suite/innodb/r/innodb-alter.result | 138 ++++++++++++++++++++++++-- mysql-test/suite/innodb/t/innodb-alter.test | 101 ++++++++++++++++++- storage/innobase/dict/dict0mem.cc | 4 +- storage/innobase/handler/handler0alter.cc | 30 +++--- storage/xtradb/dict/dict0mem.cc | 4 +- storage/xtradb/handler/handler0alter.cc | 30 +++--- 6 files changed, 261 insertions(+), 46 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result index bd82cc8a764..2f9b832328b 100644 --- a/mysql-test/suite/innodb/r/innodb-alter.result +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -714,6 +714,7 @@ t2 CREATE TABLE `t2` ( CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ALTER TABLE t1 CHANGE COLUMN c1 C1 INT; +ALTER TABLE t2 CHANGE COLUMN c2 C2 INT; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -723,24 +724,147 @@ t1 CREATE TABLE `t1` ( SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( - `c2` int(11) NOT NULL, - KEY `c2` (`c2`), + `C2` int(11) DEFAULT NULL, + KEY `c2` (`C2`), CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; +ALTER TABLE t2 CHANGE COLUMN C2 c6 INT; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `C1` int(11) NOT NULL DEFAULT '0', - PRIMARY KEY (`C1`) + `c5` int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (`c5`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( - `c2` int(11) NOT NULL, - KEY `c2` (`c2`), - CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c2`) REFERENCES `t1` (`c1`) + `c6` int(11) DEFAULT NULL, + KEY `c2` (`c6`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c6`) REFERENCES `t1` (`c5`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN +INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID +WHERE T.NAME='test/t1'; +NAME +c5 +SELECT F.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS F INNER JOIN +INFORMATION_SCHEMA.INNODB_SYS_INDEXES I ON F.INDEX_ID=I.INDEX_ID INNER JOIN +INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON I.TABLE_ID=T.TABLE_ID +WHERE T.NAME='test/t1' AND I.NAME='PRIMARY'; +NAME +c5 +SELECT C.REF_COL_NAME, C.FOR_COL_NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS C INNER JOIN +INFORMATION_SCHEMA.INNODB_SYS_FOREIGN F ON C.ID=F.ID +WHERE F.FOR_NAME='test/t2'; +REF_COL_NAME FOR_COL_NAME +c5 c6 DROP TABLE t2, t1; +# virtual columns case too +CREATE TABLE t1 (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL) ENGINE = InnoDB; +ALTER TABLE t1 CHANGE COLUMN a A INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `A` int(11) DEFAULT NULL, + `b` int(11) AS (a) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN +INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID +WHERE T.NAME='test/t1'; +NAME +a +DROP TABLE t1; +# different FOREIGN KEY cases +CREATE TABLE t1 ( +a INT UNIQUE KEY, +b INT UNIQUE KEY, +c INT UNIQUE KEY, +d INT UNIQUE KEY +) ENGINE=INNODB; +CREATE TABLE t2 ( +aa INT, +bb INT, +cc INT, +dd INT +) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 1, 1, 1); +INSERT INTO t2 VALUES (1, 1, 1, 1); +ALTER TABLE t1 CHANGE a A INT, ALGORITHM=INPLACE; +ALTER TABLE t1 CHANGE c C INT, ALGORITHM=INPLACE; +ALTER TABLE t2 CHANGE cc CC INT, ALGORITHM=INPLACE; +ALTER TABLE t2 CHANGE dd DD INT, ALGORITHM=INPLACE; +SET foreign_key_checks=0; +ALTER TABLE t2 +ADD FOREIGN KEY(aa) REFERENCES t1(a), +ADD FOREIGN KEY(bb) REFERENCES t1(b), +ADD FOREIGN KEY(cc) REFERENCES t1(c), +ADD FOREIGN KEY(dd) REFERENCES t1(d), +ALGORITHM=INPLACE; +ALTER TABLE t1 CHANGE b B INT, ALGORITHM=INPLACE; +ALTER TABLE t2 CHANGE aa AA INT, ALGORITHM=INPLACE; +ALTER TABLE t1 CHANGE d D INT, ALGORITHM=INPLACE; +ALTER TABLE t2 CHANGE bb BB INT, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `A` int(11) DEFAULT NULL, + `B` int(11) DEFAULT NULL, + `C` int(11) DEFAULT NULL, + `D` int(11) DEFAULT NULL, + UNIQUE KEY `a` (`A`), + UNIQUE KEY `b` (`B`), + UNIQUE KEY `c` (`C`), + UNIQUE KEY `d` (`D`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `AA` int(11) DEFAULT NULL, + `BB` int(11) DEFAULT NULL, + `CC` int(11) DEFAULT NULL, + `DD` int(11) DEFAULT NULL, + KEY `aa` (`AA`), + KEY `bb` (`BB`), + KEY `CC` (`CC`), + KEY `DD` (`DD`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`), + CONSTRAINT `t2_ibfk_2` FOREIGN KEY (`bb`) REFERENCES `t1` (`b`), + CONSTRAINT `t2_ibfk_3` FOREIGN KEY (`cc`) REFERENCES `t1` (`c`), + CONSTRAINT `t2_ibfk_4` FOREIGN KEY (`dd`) REFERENCES `t1` (`d`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DELETE FROM t1 WHERE a=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`)) +DELETE FROM t1 WHERE A=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`)) +DELETE FROM t1 WHERE b=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`)) +DELETE FROM t1 WHERE B=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`)) +DELETE FROM t1 WHERE c=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`)) +DELETE FROM t1 WHERE C=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`)) +DELETE FROM t1 WHERE d=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`)) +DELETE FROM t1 WHERE D=1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`aa`) REFERENCES `t1` (`a`)) +DROP TABLE t2, t1; +# virtual columns case too +CREATE TABLE t1 (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL) ENGINE = InnoDB; +ALTER TABLE t1 CHANGE COLUMN a A INT; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `A` int(11) DEFAULT NULL, + `b` int(11) AS (a) VIRTUAL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN +INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID +WHERE T.NAME='test/t1'; +NAME +a +DROP TABLE t1; # # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN # DICT_MEM_TABLE_COL_RENAME_LOW diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test index 0d3cc6f1733..30e3292ec10 100644 --- a/mysql-test/suite/innodb/t/innodb-alter.test +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -419,15 +419,110 @@ CREATE TABLE t2(c2 INT NOT NULL, FOREIGN KEY(c2) REFERENCES t1(c1))ENGINE=INNODB SHOW CREATE TABLE t1; SHOW CREATE TABLE t2; ALTER TABLE t1 CHANGE COLUMN c1 C1 INT; +ALTER TABLE t2 CHANGE COLUMN c2 C2 INT; SHOW CREATE TABLE t1; SHOW CREATE TABLE t2; -# FIXME: MDEV-13671 InnoDB should use case-insensitive column name comparisons -# like the rest of the server -#ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; +ALTER TABLE t1 CHANGE COLUMN C1 c5 INT; +ALTER TABLE t2 CHANGE COLUMN C2 c6 INT; SHOW CREATE TABLE t1; SHOW CREATE TABLE t2; + +SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN + INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID + WHERE T.NAME='test/t1'; + +SELECT F.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FIELDS F INNER JOIN + INFORMATION_SCHEMA.INNODB_SYS_INDEXES I ON F.INDEX_ID=I.INDEX_ID INNER JOIN + INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON I.TABLE_ID=T.TABLE_ID + WHERE T.NAME='test/t1' AND I.NAME='PRIMARY'; + +SELECT C.REF_COL_NAME, C.FOR_COL_NAME FROM INFORMATION_SCHEMA.INNODB_SYS_FOREIGN_COLS C INNER JOIN + INFORMATION_SCHEMA.INNODB_SYS_FOREIGN F ON C.ID=F.ID + WHERE F.FOR_NAME='test/t2'; + +DROP TABLE t2, t1; +--echo # virtual columns case too +CREATE TABLE t1 (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL) ENGINE = InnoDB; +ALTER TABLE t1 CHANGE COLUMN a A INT; +SHOW CREATE TABLE t1; +SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN + INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID + WHERE T.NAME='test/t1'; +DROP TABLE t1; + + +--echo # different FOREIGN KEY cases +CREATE TABLE t1 ( + a INT UNIQUE KEY, + b INT UNIQUE KEY, + c INT UNIQUE KEY, + d INT UNIQUE KEY +) ENGINE=INNODB; +CREATE TABLE t2 ( + aa INT, + bb INT, + cc INT, + dd INT +) ENGINE=INNODB; + +INSERT INTO t1 VALUES (1, 1, 1, 1); +INSERT INTO t2 VALUES (1, 1, 1, 1); + +ALTER TABLE t1 CHANGE a A INT, ALGORITHM=INPLACE; +ALTER TABLE t1 CHANGE c C INT, ALGORITHM=INPLACE; +ALTER TABLE t2 CHANGE cc CC INT, ALGORITHM=INPLACE; +ALTER TABLE t2 CHANGE dd DD INT, ALGORITHM=INPLACE; + +SET foreign_key_checks=0; +ALTER TABLE t2 + ADD FOREIGN KEY(aa) REFERENCES t1(a), + ADD FOREIGN KEY(bb) REFERENCES t1(b), + ADD FOREIGN KEY(cc) REFERENCES t1(c), + ADD FOREIGN KEY(dd) REFERENCES t1(d), + ALGORITHM=INPLACE; + +ALTER TABLE t1 CHANGE b B INT, ALGORITHM=INPLACE; +ALTER TABLE t2 CHANGE aa AA INT, ALGORITHM=INPLACE; + +--source include/restart_mysqld.inc + +ALTER TABLE t1 CHANGE d D INT, ALGORITHM=INPLACE; +ALTER TABLE t2 CHANGE bb BB INT, ALGORITHM=INPLACE; +SHOW CREATE TABLE t1; +SHOW CREATE TABLE t2; + +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM t1 WHERE a=1; +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM t1 WHERE A=1; + +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM t1 WHERE b=1; +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM t1 WHERE B=1; + +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM t1 WHERE c=1; +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM t1 WHERE C=1; + +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM t1 WHERE d=1; +--error ER_ROW_IS_REFERENCED_2 +DELETE FROM t1 WHERE D=1; + DROP TABLE t2, t1; +--echo # virtual columns case too +CREATE TABLE t1 (a INT, b INT GENERATED ALWAYS AS (a) VIRTUAL) ENGINE = InnoDB; +ALTER TABLE t1 CHANGE COLUMN a A INT; +SHOW CREATE TABLE t1; +SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN + INFORMATION_SCHEMA.INNODB_SYS_TABLES T ON C.TABLE_ID=T.TABLE_ID + WHERE T.NAME='test/t1'; +DROP TABLE t1; + + --echo # --echo # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN --echo # DICT_MEM_TABLE_COL_RENAME_LOW diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index 81a4cd9c6c6..c182aaba676 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -498,9 +498,7 @@ dict_mem_table_col_rename( s += len + 1; } - /* This could fail if the data dictionaries are out of sync. - Proceed with the renaming anyway. */ - ut_ad(!strcmp(from, s)); + ut_ad(!my_strcasecmp(system_charset_info, from, s)); dict_mem_table_col_rename_low(table, nth_col, to, s); } diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 8f95772268c..6f43e921099 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4514,7 +4514,6 @@ innobase_rename_column_try( pars_info_add_ull_literal(info, "tableid", user_table->id); pars_info_add_int4_literal(info, "nth", nth_col); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); trx->op_info = "renaming column in SYS_COLUMNS"; @@ -4524,7 +4523,7 @@ innobase_rename_column_try( "PROCEDURE RENAME_SYS_COLUMNS_PROC () IS\n" "BEGIN\n" "UPDATE SYS_COLUMNS SET NAME=:new\n" - "WHERE TABLE_ID=:tableid AND NAME=:old\n" + "WHERE TABLE_ID=:tableid\n" "AND POS=:nth;\n" "END;\n", FALSE, trx); @@ -4548,8 +4547,10 @@ err_exit: index = dict_table_get_next_index(index)) { for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - if (strcmp(dict_index_get_nth_field(index, i)->name, - from)) { + if (my_strcasecmp( + system_charset_info, + dict_index_get_nth_field(index, i)->name, + from)) { continue; } @@ -4557,7 +4558,6 @@ err_exit: pars_info_add_ull_literal(info, "indexid", index->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4566,14 +4566,14 @@ err_exit: "BEGIN\n" "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid AND COL_NAME=:old\n" + "WHERE INDEX_ID=:indexid\n" "AND POS=:nth;\n" /* Try again, in case there is a prefix_len encoded in SYS_FIELDS.POS */ "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid AND COL_NAME=:old\n" + "WHERE INDEX_ID=:indexid\n" "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n" "END;\n", @@ -4599,7 +4599,9 @@ rename_foreign: foreign_modified = false; for (unsigned i = 0; i < foreign->n_fields; i++) { - if (strcmp(foreign->foreign_col_names[i], from)) { + if (my_strcasecmp(system_charset_info, + foreign->foreign_col_names[i], + from)) { continue; } @@ -4607,7 +4609,6 @@ rename_foreign: pars_info_add_str_literal(info, "id", foreign->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4616,8 +4617,7 @@ rename_foreign: "BEGIN\n" "UPDATE SYS_FOREIGN_COLS\n" "SET FOR_COL_NAME=:new\n" - "WHERE ID=:id AND POS=:nth\n" - "AND FOR_COL_NAME=:old;\n" + "WHERE ID=:id AND POS=:nth;\n" "END;\n", FALSE, trx); @@ -4641,7 +4641,9 @@ rename_foreign: dict_foreign_t* foreign = *it; for (unsigned i = 0; i < foreign->n_fields; i++) { - if (strcmp(foreign->referenced_col_names[i], from)) { + if (my_strcasecmp(system_charset_info, + foreign->referenced_col_names[i], + from)) { continue; } @@ -4649,7 +4651,6 @@ rename_foreign: pars_info_add_str_literal(info, "id", foreign->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4658,8 +4659,7 @@ rename_foreign: "BEGIN\n" "UPDATE SYS_FOREIGN_COLS\n" "SET REF_COL_NAME=:new\n" - "WHERE ID=:id AND POS=:nth\n" - "AND REF_COL_NAME=:old;\n" + "WHERE ID=:id AND POS=:nth;\n" "END;\n", FALSE, trx); diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc index 12cbd2f4a97..fb6895867fe 100644 --- a/storage/xtradb/dict/dict0mem.cc +++ b/storage/xtradb/dict/dict0mem.cc @@ -499,9 +499,7 @@ dict_mem_table_col_rename( s += len + 1; } - /* This could fail if the data dictionaries are out of sync. - Proceed with the renaming anyway. */ - ut_ad(!strcmp(from, s)); + ut_ad(!my_strcasecmp(system_charset_info, from, s)); dict_mem_table_col_rename_low(table, nth_col, to, s); } diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 8235263b305..0b7588918bc 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -4516,7 +4516,6 @@ innobase_rename_column_try( pars_info_add_ull_literal(info, "tableid", user_table->id); pars_info_add_int4_literal(info, "nth", nth_col); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); trx->op_info = "renaming column in SYS_COLUMNS"; @@ -4526,7 +4525,7 @@ innobase_rename_column_try( "PROCEDURE RENAME_SYS_COLUMNS_PROC () IS\n" "BEGIN\n" "UPDATE SYS_COLUMNS SET NAME=:new\n" - "WHERE TABLE_ID=:tableid AND NAME=:old\n" + "WHERE TABLE_ID=:tableid\n" "AND POS=:nth;\n" "END;\n", FALSE, trx); @@ -4550,8 +4549,10 @@ err_exit: index = dict_table_get_next_index(index)) { for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - if (strcmp(dict_index_get_nth_field(index, i)->name, - from)) { + if (my_strcasecmp( + system_charset_info, + dict_index_get_nth_field(index, i)->name, + from)) { continue; } @@ -4559,7 +4560,6 @@ err_exit: pars_info_add_ull_literal(info, "indexid", index->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4568,14 +4568,14 @@ err_exit: "BEGIN\n" "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid AND COL_NAME=:old\n" + "WHERE INDEX_ID=:indexid\n" "AND POS=:nth;\n" /* Try again, in case there is a prefix_len encoded in SYS_FIELDS.POS */ "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid AND COL_NAME=:old\n" + "WHERE INDEX_ID=:indexid\n" "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n" "END;\n", @@ -4601,7 +4601,9 @@ rename_foreign: foreign_modified = false; for (unsigned i = 0; i < foreign->n_fields; i++) { - if (strcmp(foreign->foreign_col_names[i], from)) { + if (my_strcasecmp(system_charset_info, + foreign->foreign_col_names[i], + from)) { continue; } @@ -4609,7 +4611,6 @@ rename_foreign: pars_info_add_str_literal(info, "id", foreign->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4618,8 +4619,7 @@ rename_foreign: "BEGIN\n" "UPDATE SYS_FOREIGN_COLS\n" "SET FOR_COL_NAME=:new\n" - "WHERE ID=:id AND POS=:nth\n" - "AND FOR_COL_NAME=:old;\n" + "WHERE ID=:id AND POS=:nth;\n" "END;\n", FALSE, trx); @@ -4643,7 +4643,9 @@ rename_foreign: dict_foreign_t* foreign = *it; for (unsigned i = 0; i < foreign->n_fields; i++) { - if (strcmp(foreign->referenced_col_names[i], from)) { + if (my_strcasecmp(system_charset_info, + foreign->referenced_col_names[i], + from)) { continue; } @@ -4651,7 +4653,6 @@ rename_foreign: pars_info_add_str_literal(info, "id", foreign->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4660,8 +4661,7 @@ rename_foreign: "BEGIN\n" "UPDATE SYS_FOREIGN_COLS\n" "SET REF_COL_NAME=:new\n" - "WHERE ID=:id AND POS=:nth\n" - "AND REF_COL_NAME=:old;\n" + "WHERE ID=:id AND POS=:nth;\n" "END;\n", FALSE, trx); -- cgit v1.2.1