ganapathi / rpms / mariadb

Forked from rpms/mariadb 4 years ago
Clone

Blame SOURCES/rhbz_1686818.patch

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