Skip to content

Commit

Permalink
MDEV-4621 select returns null for information_schema.statistics.colla…
Browse files Browse the repository at this point in the history
…tion field

information_schema.statistics.collation column needs OPEN_FULL_TABLE,
because it checks index_flags() for HA_READ_ORDER capability.
  • Loading branch information
vuvova committed Jan 14, 2022
1 parent a88a433 commit 3548e80
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions mysql-test/r/show.result
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,16 @@ nm varchar(32) YES NULL
a int(11) YES NULL
drop table t1;
#
# MDEV-4621 select returns null for information_schema.statistics.collation field
#
create table t1 (f varchar(64), key(f));
select index_name, column_name, collation, cardinality from information_schema.STATISTICS where table_schema='test' and table_name='t1';
index_name column_name collation cardinality
f f A NULL
select index_name, column_name, collation from information_schema.STATISTICS where table_schema='test' and table_name='t1';
index_name column_name collation
f f A
drop table t1;
#
# End of 10.2 tests
#
8 changes: 8 additions & 0 deletions mysql-test/t/show.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ show fields from test.t1 where field in
where table_name='t1' group by column_name) dt);
drop table t1;

--echo #
--echo # MDEV-4621 select returns null for information_schema.statistics.collation field
--echo #
create table t1 (f varchar(64), key(f));
select index_name, column_name, collation, cardinality from information_schema.STATISTICS where table_schema='test' and table_name='t1';
select index_name, column_name, collation from information_schema.STATISTICS where table_schema='test' and table_name='t1';
drop table t1;

--echo #
--echo # End of 10.2 tests
--echo #
2 changes: 1 addition & 1 deletion sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8967,7 +8967,7 @@ ST_FIELD_INFO stat_fields_info[]=
{"SEQ_IN_INDEX", 2, MYSQL_TYPE_LONGLONG, 0, 0, "Seq_in_index", OPEN_FRM_ONLY},
{"COLUMN_NAME", NAME_CHAR_LEN, MYSQL_TYPE_STRING, 0, 0, "Column_name",
OPEN_FRM_ONLY},
{"COLLATION", 1, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FRM_ONLY},
{"COLLATION", 1, MYSQL_TYPE_STRING, 0, 1, "Collation", OPEN_FULL_TABLE},
{"CARDINALITY", MY_INT64_NUM_DECIMAL_DIGITS, MYSQL_TYPE_LONGLONG, 0, 1,
"Cardinality", OPEN_FULL_TABLE},
{"SUB_PART", 3, MYSQL_TYPE_LONGLONG, 0, 1, "Sub_part", OPEN_FRM_ONLY},
Expand Down

0 comments on commit 3548e80

Please sign in to comment.