Skip to content

Commit 0496f7c

Browse files
gopshankdahlerlend
authored andcommitted
Bug#27593348 INFORMATION_SCHEMA.STATISTICS FIELD TYPE CHANGE
The column type INFORMATION_SCHEMA.STATISTICS.NON_UNIQUE is of type 'VARCHAR' in 8.0, whereas it was 'BIGINT' in 5.7. The bug was introduced when implementing INFORMATION_SCHEMA.STATISTICS as system view over dictionary tables. This patch changes the type of this column to INT, as this column can really be either 0 or 1. Change-Id: I0f029c90687d96ad7b1ae3b85652aa6e78148f37
1 parent 6a491b3 commit 0496f7c

File tree

6 files changed

+17
-13
lines changed

6 files changed

+17
-13
lines changed

mysql-test/r/show_check.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test.t1 analyze status OK
7070
show index from t1;
7171
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
7272
def mysql tables SHOW_STATISTICS Table Table 253 256 2 N # 0 255
73-
def SHOW_STATISTICS Non_unique Non_unique 253 4 1 N 1 0 255
73+
def SHOW_STATISTICS Non_unique Non_unique 3 1 1 N 32769 0 63
7474
def SHOW_STATISTICS Key_name Key_name 253 256 7 Y 0 0 255
7575
def mysql index_column_usage SHOW_STATISTICS Seq_in_index Seq_in_index 3 10 1 N 36897 0 63
7676
def SHOW_STATISTICS Column_name Column_name 253 256 1 Y 0 0 255
@@ -696,7 +696,7 @@ PRIMARY KEY(field1(750))
696696
show index from t1;
697697
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
698698
def mysql tables SHOW_STATISTICS Table Table 253 64 2 N # 0 63
699-
def SHOW_STATISTICS Non_unique Non_unique 253 1 1 N 1 0 63
699+
def SHOW_STATISTICS Non_unique Non_unique 3 1 1 N 32769 0 63
700700
def SHOW_STATISTICS Key_name Key_name 253 64 7 Y 0 0 63
701701
def mysql index_column_usage SHOW_STATISTICS Seq_in_index Seq_in_index 3 10 1 N 36897 0 63
702702
def SHOW_STATISTICS Column_name Column_name 253 64 6 Y 0 0 63
@@ -914,7 +914,7 @@ t1 CREATE TABLE `t1` (
914914
SHOW INDEX FROM t1;
915915
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
916916
def mysql tables SHOW_STATISTICS Table Table 253 192 2 N # 0 33
917-
def SHOW_STATISTICS Non_unique Non_unique 253 3 1 N 1 0 33
917+
def SHOW_STATISTICS Non_unique Non_unique 3 1 1 N 32769 0 63
918918
def SHOW_STATISTICS Key_name Key_name 253 192 7 Y 0 0 33
919919
def mysql index_column_usage SHOW_STATISTICS Seq_in_index Seq_in_index 3 10 1 N 36897 0 63
920920
def SHOW_STATISTICS Column_name Column_name 253 192 1 Y 0 0 33

mysql-test/suite/funcs_1/r/is_columns_is.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def information_schema SCHEMA_PRIVILEGES IS_GRANTABLE 5 NO varchar 1 3 NULL NUL
258258
def information_schema STATISTICS TABLE_CATALOG 1 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
259259
def information_schema STATISTICS TABLE_SCHEMA 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
260260
def information_schema STATISTICS TABLE_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
261-
def information_schema STATISTICS NON_UNIQUE 4 NO varchar 1 3 NULL NULL NULL utf8 utf8_general_ci varchar(1) select NULL
261+
def information_schema STATISTICS NON_UNIQUE 4 0 NO int NULL NULL 10 0 NULL NULL NULL int(1) select NULL
262262
def information_schema STATISTICS INDEX_SCHEMA 5 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
263263
def information_schema STATISTICS INDEX_NAME 6 NULL YES varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
264264
def information_schema STATISTICS SEQ_IN_INDEX 7 NULL NO int NULL NULL 10 0 NULL NULL NULL int(10) unsigned select NULL
@@ -693,7 +693,7 @@ NULL information_schema SCHEMATA SQL_PATH binary 0 0 NULL NULL binary(0)
693693
3.0000 information_schema STATISTICS TABLE_CATALOG varchar 64 192 utf8 utf8_bin varchar(64)
694694
3.0000 information_schema STATISTICS TABLE_SCHEMA varchar 64 192 utf8 utf8_bin varchar(64)
695695
3.0000 information_schema STATISTICS TABLE_NAME varchar 64 192 utf8 utf8_bin varchar(64)
696-
3.0000 information_schema STATISTICS NON_UNIQUE varchar 1 3 utf8 utf8_general_ci varchar(1)
696+
NULL information_schema STATISTICS NON_UNIQUE int NULL NULL NULL NULL int(1)
697697
3.0000 information_schema STATISTICS INDEX_SCHEMA varchar 64 192 utf8 utf8_bin varchar(64)
698698
3.0000 information_schema STATISTICS INDEX_NAME varchar 64 192 utf8 utf8_bin varchar(64)
699699
NULL information_schema STATISTICS SEQ_IN_INDEX int NULL NULL NULL NULL int(10) unsigned

mysql-test/suite/funcs_1/r/is_statistics.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Field Type Null Key Default Extra
3131
TABLE_CATALOG varchar(64) NO NULL
3232
TABLE_SCHEMA varchar(64) NO NULL
3333
TABLE_NAME varchar(64) NO NULL
34-
NON_UNIQUE varchar(1) NO
34+
NON_UNIQUE int(1) NO 0
3535
INDEX_SCHEMA varchar(64) NO NULL
3636
INDEX_NAME varchar(64) YES NULL
3737
SEQ_IN_INDEX int(10) unsigned NO NULL
@@ -47,13 +47,13 @@ INDEX_COMMENT varchar(2048) NO NULL
4747
IS_VISIBLE varchar(3) NO
4848
SHOW CREATE TABLE information_schema.STATISTICS;
4949
View Create View character_set_client collation_connection
50-
STATISTICS CREATE ALGORITHM=UNDEFINED DEFINER=`mysql.infoschema`@`localhost` SQL SECURITY DEFINER VIEW `information_schema`.`STATISTICS` AS select `cat`.`name` AS `TABLE_CATALOG`,`sch`.`name` AS `TABLE_SCHEMA`,`tbl`.`name` AS `TABLE_NAME`,if(((`idx`.`type` = 'PRIMARY') or (`idx`.`type` = 'UNIQUE')),'0','1') AS `NON_UNIQUE`,`sch`.`name` AS `INDEX_SCHEMA`,(`idx`.`name` collate utf8_tolower_ci) AS `INDEX_NAME`,`icu`.`ordinal_position` AS `SEQ_IN_INDEX`,(`col`.`name` collate utf8_tolower_ci) AS `COLUMN_NAME`,(case when (`icu`.`order` = 'DESC') then 'D' when (`icu`.`order` = 'ASC') then 'A' else NULL end) AS `COLLATION`,internal_index_column_cardinality(`sch`.`name`,`tbl`.`name`,`idx`.`name`,`col`.`name`,`idx`.`ordinal_position`,`icu`.`ordinal_position`,`tbl`.`engine`,`tbl`.`se_private_id`,((`tbl`.`hidden` <> 'Visible') or `idx`.`hidden` or `icu`.`hidden`),coalesce(`stat`.`cardinality`,cast(-(1) as unsigned)),coalesce(cast(`stat`.`cached_time` as unsigned),0)) AS `CARDINALITY`,get_dd_index_sub_part_length(`icu`.`length`,`col`.`type`,`col`.`char_length`,`col`.`collation_id`,`idx`.`type`) AS `SUB_PART`,NULL AS `PACKED`,if((`col`.`is_nullable` = 1),'YES','') AS `NULLABLE`,(case when (`idx`.`type` = 'SPATIAL') then 'SPATIAL' when (`idx`.`algorithm` = 'SE_PRIVATE') then '' else `idx`.`algorithm` end) AS `INDEX_TYPE`,if(((`idx`.`type` = 'PRIMARY') or (`idx`.`type` = 'UNIQUE')),'',if(internal_keys_disabled(`tbl`.`options`),'disabled','')) AS `COMMENT`,`idx`.`comment` AS `INDEX_COMMENT`,if(`idx`.`is_visible`,'YES','NO') AS `IS_VISIBLE` from (((((((`mysql`.`index_column_usage` `icu` join `mysql`.`indexes` `idx` on((`idx`.`id` = `icu`.`index_id`))) join `mysql`.`tables` `tbl` on((`idx`.`table_id` = `tbl`.`id`))) join `mysql`.`columns` `col` on((`icu`.`column_id` = `col`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) join `mysql`.`collations` `coll` on((`tbl`.`collation_id` = `coll`.`id`))) left join `mysql`.`index_stats` `stat` on(((`tbl`.`name` = `stat`.`table_name`) and (`sch`.`name` = `stat`.`schema_name`) and (`idx`.`name` = `stat`.`index_name`) and (`col`.`name` = `stat`.`column_name`)))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`,(`idx`.`hidden` or `icu`.`hidden`))) utf8 utf8_general_ci
50+
STATISTICS CREATE ALGORITHM=UNDEFINED DEFINER=`mysql.infoschema`@`localhost` SQL SECURITY DEFINER VIEW `information_schema`.`STATISTICS` AS select `cat`.`name` AS `TABLE_CATALOG`,`sch`.`name` AS `TABLE_SCHEMA`,`tbl`.`name` AS `TABLE_NAME`,if(((`idx`.`type` = 'PRIMARY') or (`idx`.`type` = 'UNIQUE')),0,1) AS `NON_UNIQUE`,`sch`.`name` AS `INDEX_SCHEMA`,(`idx`.`name` collate utf8_tolower_ci) AS `INDEX_NAME`,`icu`.`ordinal_position` AS `SEQ_IN_INDEX`,(`col`.`name` collate utf8_tolower_ci) AS `COLUMN_NAME`,(case when (`icu`.`order` = 'DESC') then 'D' when (`icu`.`order` = 'ASC') then 'A' else NULL end) AS `COLLATION`,internal_index_column_cardinality(`sch`.`name`,`tbl`.`name`,`idx`.`name`,`col`.`name`,`idx`.`ordinal_position`,`icu`.`ordinal_position`,`tbl`.`engine`,`tbl`.`se_private_id`,((`tbl`.`hidden` <> 'Visible') or `idx`.`hidden` or `icu`.`hidden`),coalesce(`stat`.`cardinality`,cast(-(1) as unsigned)),coalesce(cast(`stat`.`cached_time` as unsigned),0)) AS `CARDINALITY`,get_dd_index_sub_part_length(`icu`.`length`,`col`.`type`,`col`.`char_length`,`col`.`collation_id`,`idx`.`type`) AS `SUB_PART`,NULL AS `PACKED`,if((`col`.`is_nullable` = 1),'YES','') AS `NULLABLE`,(case when (`idx`.`type` = 'SPATIAL') then 'SPATIAL' when (`idx`.`algorithm` = 'SE_PRIVATE') then '' else `idx`.`algorithm` end) AS `INDEX_TYPE`,if(((`idx`.`type` = 'PRIMARY') or (`idx`.`type` = 'UNIQUE')),'',if(internal_keys_disabled(`tbl`.`options`),'disabled','')) AS `COMMENT`,`idx`.`comment` AS `INDEX_COMMENT`,if(`idx`.`is_visible`,'YES','NO') AS `IS_VISIBLE` from (((((((`mysql`.`index_column_usage` `icu` join `mysql`.`indexes` `idx` on((`idx`.`id` = `icu`.`index_id`))) join `mysql`.`tables` `tbl` on((`idx`.`table_id` = `tbl`.`id`))) join `mysql`.`columns` `col` on((`icu`.`column_id` = `col`.`id`))) join `mysql`.`schemata` `sch` on((`tbl`.`schema_id` = `sch`.`id`))) join `mysql`.`catalogs` `cat` on((`cat`.`id` = `sch`.`catalog_id`))) join `mysql`.`collations` `coll` on((`tbl`.`collation_id` = `coll`.`id`))) left join `mysql`.`index_stats` `stat` on(((`tbl`.`name` = `stat`.`table_name`) and (`sch`.`name` = `stat`.`schema_name`) and (`idx`.`name` = `stat`.`index_name`) and (`col`.`name` = `stat`.`column_name`)))) where (can_access_table(`sch`.`name`,`tbl`.`name`) and is_visible_dd_object(`tbl`.`hidden`,(`idx`.`hidden` or `icu`.`hidden`))) utf8 utf8_general_ci
5151
SHOW COLUMNS FROM information_schema.STATISTICS;
5252
Field Type Null Key Default Extra
5353
TABLE_CATALOG varchar(64) NO NULL
5454
TABLE_SCHEMA varchar(64) NO NULL
5555
TABLE_NAME varchar(64) NO NULL
56-
NON_UNIQUE varchar(1) NO
56+
NON_UNIQUE int(1) NO 0
5757
INDEX_SCHEMA varchar(64) NO NULL
5858
INDEX_NAME varchar(64) YES NULL
5959
SEQ_IN_INDEX int(10) unsigned NO NULL

mysql-test/suite/sysschema/r/v_schema_redundant_indexes.result

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ table_schema varchar(64) NO NULL
44
table_name varchar(64) NO NULL
55
redundant_index_name varchar(64) YES NULL
66
redundant_index_columns text YES NULL
7-
redundant_index_non_unique varchar(1) YES NULL
7+
redundant_index_non_unique int(1) YES NULL
88
dominant_index_name varchar(64) YES NULL
99
dominant_index_columns text YES NULL
10-
dominant_index_non_unique varchar(1) YES NULL
10+
dominant_index_non_unique int(1) YES NULL
1111
subpart_exists int(1) NO 0
1212
sql_drop_index varchar(223) YES NULL
1313
SELECT * FROM sys.schema_redundant_indexes;
@@ -16,7 +16,7 @@ Field Type Null Key Default Extra
1616
table_schema varchar(64) NO NULL
1717
table_name varchar(64) NO NULL
1818
index_name varchar(64) YES NULL
19-
non_unique varchar(1) YES NULL
19+
non_unique int(1) YES NULL
2020
subpart_exists bigint(1) YES NULL
2121
index_columns text YES NULL
2222
SELECT * FROM sys.x$schema_flattened_keys;

sql/dd/impl/system_views/statistics.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -48,7 +48,7 @@ Statistics_base::Statistics_base() {
4848
"tbl.name" + m_target_def.fs_name_collation());
4949
m_target_def.add_field(
5050
FIELD_NON_UNIQUE, "NON_UNIQUE",
51-
"IF (idx.type = 'PRIMARY' OR idx.type = 'UNIQUE','0','1')");
51+
"IF (idx.type = 'PRIMARY' OR idx.type = 'UNIQUE',0,1)");
5252
m_target_def.add_field(FIELD_INDEX_SCHEMA, "INDEX_SCHEMA",
5353
"sch.name" + m_target_def.fs_name_collation());
5454
m_target_def.add_field(FIELD_INDEX_NAME, "INDEX_NAME",

sql/dd/info_schema/metadata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ namespace info_schema {
5858
- Bug#27309116: Add a new column `external_language` to `mysql`.`routines`
5959
and update `information_schema`.`routines` to reflect this column.
6060
61+
- Bug#27593348: INFORMATION_SCHEMA.STATISTICS FIELD TYPE CHANGE.
62+
Changes the column I_S.STATISTICS.NON_UNIQUE type from VARCHAR
63+
to INT.
64+
6165
80012: Next I_S version number to use when there is change.
6266
-----------------------------------------------------------
6367
No changes yet, hence this number is not used yet.

0 commit comments

Comments
 (0)