diff --git a/mysql-test/r/mysqlpump_basic.result b/mysql-test/r/mysqlpump_basic.result index d2c4a7c421d..a96a44674b0 100644 --- a/mysql-test/r/mysqlpump_basic.result +++ b/mysql-test/r/mysqlpump_basic.result @@ -711,6 +711,7 @@ SET @saved_session_sql_generate_invisible_primary_key = @@session.sql_generate_invisible_primary_key; CREATE TABLE t1 (my_row_id bigint unsigned NOT NULL AUTO_INCREMENT INVISIBLE, f INT, PRIMARY KEY(my_row_id)); +ALTER TABLE t1 ADD INDEX(f, my_row_id); INSERT INTO t1 VALUES (1), (3), (7), (8), (4); SET SESSION sql_generate_invisible_primary_key=ON; CREATE TABLE t2(f1 INT INVISIBLE, f2 INT); @@ -726,22 +727,23 @@ Table Create Table t1 CREATE TABLE `t1` ( `my_row_id` bigint unsigned NOT NULL AUTO_INCREMENT /*!80023 INVISIBLE */, `f` int DEFAULT NULL, - PRIMARY KEY (`my_row_id`) + PRIMARY KEY (`my_row_id`), + KEY `f` (`f`,`my_row_id`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci SELECT * FROM t1; f 1 3 +4 7 8 -4 SELECT my_row_id, f FROM t1; my_row_id f 1 1 2 3 +5 4 3 7 4 8 -5 4 # Table t2 should list generated primary key information. SHOW CREATE TABLE t2; Table Create Table @@ -768,23 +770,24 @@ DROP TABLE t1, t2; SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( - `f` int DEFAULT NULL + `f` int DEFAULT NULL, + KEY `f` (`f`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci SELECT * FROM t1; f 1 3 +4 7 8 -4 SELECT f FROM t1; f 1 3 +4 7 8 -4 -# Table t1 should *not* list generated primary key information. +# Table t2 should *not* list generated primary key information. SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( @@ -812,22 +815,23 @@ Table Create Table t1 CREATE TABLE `t1` ( `my_row_id` bigint unsigned NOT NULL AUTO_INCREMENT /*!80023 INVISIBLE */, `f` int DEFAULT NULL, - PRIMARY KEY (`my_row_id`) + PRIMARY KEY (`my_row_id`), + KEY `f` (`f`) ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci SELECT * FROM t1; f 1 3 +4 7 8 -4 SELECT my_row_id, f FROM t1; my_row_id f 1 1 2 3 -3 7 -4 8 -5 4 +3 4 +4 7 +5 8 # Primary key is generated for the table t2 while loading. # Table t2 should list generated primary key information. SHOW CREATE TABLE t2; diff --git a/mysql-test/t/mysqlpump_basic.test b/mysql-test/t/mysqlpump_basic.test index 42d13d7c02b..d3cc36c3c74 100644 --- a/mysql-test/t/mysqlpump_basic.test +++ b/mysql-test/t/mysqlpump_basic.test @@ -684,6 +684,7 @@ SET @saved_session_sql_generate_invisible_primary_key = # key column. CREATE TABLE t1 (my_row_id bigint unsigned NOT NULL AUTO_INCREMENT INVISIBLE, f INT, PRIMARY KEY(my_row_id)); +ALTER TABLE t1 ADD INDEX(f, my_row_id); INSERT INTO t1 VALUES (1), (3), (7), (8), (4); SET SESSION sql_generate_invisible_primary_key=ON; @@ -723,7 +724,7 @@ SHOW CREATE TABLE t1; SELECT * FROM t1; SELECT f FROM t1; ---echo # Table t1 should *not* list generated primary key information. +--echo # Table t2 should *not* list generated primary key information. SHOW CREATE TABLE t2; SELECT * FROM t2; SELECT f1, f2 FROM t2; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 0fc83dd572d..6a7e999ab88 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2242,6 +2242,10 @@ bool store_create_info(THD *thd, Table_ref *table_list, String *packet, packet->append(STRING_WITH_LEN(" (")); for (uint j = 0; j < key_info->user_defined_key_parts; j++, key_part++) { + assert(key_part->field); + if (skip_gipk && key_part->field->is_hidden_by_user()) + continue; + if (j) packet->append(','); if (key_part->field) {