ganapathi / rpms / mariadb

Forked from rpms/mariadb 4 years ago
Clone

Blame SOURCES/rhbz_1686818.patch

665d94
Patch for https://bugzilla.redhat.com/show_bug.cgi?id=1686818
665d94
Picked from https://github.com/MariaDB/server/commit/802ce9672f
665d94
665d94
Fixed by rebase to 10.3.12
665d94
665d94
--- mariadb-10.3.11/storage/innobase/handler/handler0alter.cc	2018-11-16 19:04:53.000000000 +0100
665d94
+++ mariadb-10.3.11/storage/innobase/handler/handler0alter.cc_patched	2019-03-13 11:52:15.752268825 +0100
665d94
@@ -7712,36 +7712,40 @@ err_exit:
665d94
 	     index != NULL;
665d94
 	     index = dict_table_get_next_index(index)) {
665d94
 
665d94
+		bool has_prefixes = false;
665d94
+		for (size_t i = 0; i < dict_index_get_n_fields(index); i++) {
665d94
+			if (dict_index_get_nth_field(index, i)->prefix_len) {
665d94
+				has_prefixes = true;
665d94
+				break;
665d94
+			}
665d94
+		}
665d94
+
665d94
 		for (ulint i = 0; i < dict_index_get_n_fields(index); i++) {
665d94
-			if (my_strcasecmp(
665d94
-				system_charset_info,
665d94
-				dict_index_get_nth_field(index, i)->name,
665d94
-				from)) {
665d94
+			const dict_field_t* field
665d94
+			    = dict_index_get_nth_field(index, i);
665d94
+			if (my_strcasecmp(system_charset_info, field->name,
665d94
+					  from)) {
665d94
 				continue;
665d94
 			}
665d94
 
665d94
 			info = pars_info_create();
665d94
 
665d94
+			int pos = i;
665d94
+			if (has_prefixes) {
665d94
+				pos = (pos << 16) + field->prefix_len;
665d94
+			}
665d94
+
665d94
 			pars_info_add_ull_literal(info, "indexid", index->id);
665d94
-			pars_info_add_int4_literal(info, "nth", i);
665d94
+			pars_info_add_int4_literal(info, "nth", pos);
665d94
 			pars_info_add_str_literal(info, "new", to);
665d94
 
665d94
 			error = que_eval_sql(
665d94
 				info,
665d94
 				"PROCEDURE RENAME_SYS_FIELDS_PROC () IS\n"
665d94
 				"BEGIN\n"
665d94
-
665d94
 				"UPDATE SYS_FIELDS SET COL_NAME=:new\n"
665d94
 				"WHERE INDEX_ID=:indexid\n"
665d94
 				"AND POS=:nth;\n"
665d94
-
665d94
-				/* Try again, in case there is a prefix_len
665d94
-				encoded in SYS_FIELDS.POS */
665d94
-
665d94
-				"UPDATE SYS_FIELDS SET COL_NAME=:new\n"
665d94
-				"WHERE INDEX_ID=:indexid\n"
665d94
-				"AND POS>=65536*:nth AND POS<65536*(:nth+1);\n"
665d94
-
665d94
 				"END;\n",
665d94
 				FALSE, trx);
665d94
 
665d94
--- mariadb-10.3.11/mysql-test/suite/innodb/r/innodb-alter.result	2018-11-16 19:04:50.000000000 +0100
665d94
+++ mariadb-10.3.11/mysql-test/suite/innodb/r/innodb-alter.result_patched	2019-03-13 12:06:48.788107502 +0100
665d94
@@ -879,6 +879,27 @@ NAME
665d94
 a
665d94
 b
665d94
 DROP TABLE t1;
665d94
+# and an MDEV-18041 regression related to indexes prefixes
665d94
+create table `test` (
665d94
+`test_old` varchar(255) NOT NULL,
665d94
+`other` varchar(255) NOT NULL,
665d94
+PRIMARY KEY (`test_old`,`other`),
665d94
+UNIQUE KEY uk (`test_old`(100), `other`)
665d94
+) ENGINE=InnoDB;
665d94
+select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new');
665d94
+name	pos
665d94
+test_old	0
665d94
+other	1
665d94
+test_old	0
665d94
+other	1
665d94
+alter table `test` CHANGE COLUMN `test_old` `test_new` varchar(255) NOT NULL;
665d94
+select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new');
665d94
+name	pos
665d94
+test_new	0
665d94
+other	1
665d94
+test_new	0
665d94
+other	1
665d94
+drop table `test`;
665d94
 #
665d94
 # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN
665d94
 #                DICT_MEM_TABLE_COL_RENAME_LOW
665d94
--- mariadb-10.3.11/mysql-test/suite/innodb/t/innodb-alter.test	2018-11-16 19:04:50.000000000 +0100
665d94
+++ mariadb-10.3.11/mysql-test/suite/innodb/t/innodb-alter.test_patched	2019-03-13 12:08:36.398847184 +0100
665d94
@@ -545,6 +545,19 @@ SELECT C.NAME FROM INFORMATION_SCHEMA.IN
665d94
   WHERE T.NAME='test/t1';
665d94
 DROP TABLE t1;
665d94
 
665d94
+--echo # and an MDEV-18041 regression related to indexes prefixes
665d94
+create table `test` (
665d94
+  `test_old` varchar(255) NOT NULL,
665d94
+  `other` varchar(255) NOT NULL,
665d94
+  PRIMARY KEY (`test_old`,`other`),
665d94
+  UNIQUE KEY uk (`test_old`(100), `other`)
665d94
+) ENGINE=InnoDB;
665d94
+
665d94
+select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new');
665d94
+alter table `test` CHANGE COLUMN `test_old` `test_new` varchar(255) NOT NULL;
665d94
+select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new');
665d94
+drop table `test`;
665d94
+
665d94
 
665d94
 --echo #
665d94
 --echo # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN