Skip to content

Commit 6c0b87f

Browse files
Sergey GlukhovSergey Glukhov
Sergey Glukhov
authored and
Sergey Glukhov
committed
Bug#38909 CREATE_OPTIONS in information_schema produces wrong results
table->partition_info is unitialized when we open frm file only. The fix is check share->partition_info_len which is set on frm opening stage.
1 parent 3fa2673 commit 6c0b87f

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

mysql-test/r/information_schema_part.result

+6
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,9 @@ table_schema = "test" AND table_name = "t1";
145145
PARTITION_DESCRIPTION
146146
10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53
147147
drop table t1;
148+
drop table if exists t1;
149+
create table t1 (f1 int key) partition by key(f1) partitions 2;
150+
select create_options from information_schema.tables where table_schema="test";
151+
create_options
152+
partitioned
153+
drop table t1;

mysql-test/t/information_schema_part.test

+10
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,13 @@ SHOW CREATE TABLE t1;
121121
SELECT PARTITION_DESCRIPTION FROM information_schema.partitions WHERE
122122
table_schema = "test" AND table_name = "t1";
123123
drop table t1;
124+
125+
#
126+
# Bug#38909 CREATE_OPTIONS in information_schema produces wrong results
127+
#
128+
--disable_warnings
129+
drop table if exists t1;
130+
--enable_warnings
131+
create table t1 (f1 int key) partition by key(f1) partitions 2;
132+
select create_options from information_schema.tables where table_schema="test";
133+
drop table t1;

sql/sql_show.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -3511,6 +3511,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
35113511
TABLE_SHARE *share= show_table->s;
35123512
handler *file= show_table->file;
35133513
handlerton *tmp_db_type= share->db_type();
3514+
bool is_partitioned= FALSE;
35143515
if (share->tmp_table == SYSTEM_TMP_TABLE)
35153516
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
35163517
else if (share->tmp_table)
@@ -3527,7 +3528,10 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
35273528
#ifdef WITH_PARTITION_STORAGE_ENGINE
35283529
if (share->db_type() == partition_hton &&
35293530
share->partition_info_len)
3531+
{
35303532
tmp_db_type= share->default_part_db_type;
3533+
is_partitioned= TRUE;
3534+
}
35313535
#endif
35323536
tmp_buff= (char *) ha_resolve_storage_engine_name(tmp_db_type);
35333537
table->field[4]->store(tmp_buff, strlen(tmp_buff), cs);
@@ -3572,9 +3576,7 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
35723576
NullS);
35733577
}
35743578
#ifdef WITH_PARTITION_STORAGE_ENGINE
3575-
if (show_table->s->db_type() == partition_hton &&
3576-
show_table->part_info != NULL &&
3577-
show_table->part_info->no_parts > 0)
3579+
if (is_partitioned)
35783580
ptr= strmov(ptr, " partitioned");
35793581
#endif
35803582
if (share->transactional != HA_CHOICE_UNDEF)

0 commit comments

Comments
 (0)