Skip to content

Commit ca28d90

Browse files
committed
MDEV-7655 SHOW CREATE TABLE returns invalid DDL when using virtual columns along with a table collation
1 parent f560c1b commit ca28d90

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

mysql-test/suite/vcol/r/vcol_misc.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,11 @@ drop table t1;
322322
create table t1 (a int, b int as (b is null) virtual);
323323
ERROR HY000: A computed column cannot be based on a computed column
324324
# end of 5.3 tests
325+
create table t1 (v1 varchar(255) as (c1) persistent, c1 varchar(50)) collate=latin1_general_ci;
326+
show create table t1;
327+
Table Create Table
328+
t1 CREATE TABLE `t1` (
329+
`v1` varchar(255) AS (c1) PERSISTENT,
330+
`c1` varchar(50) COLLATE latin1_general_ci DEFAULT NULL
331+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
332+
drop table t1;

mysql-test/suite/vcol/t/vcol_misc.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,3 +283,10 @@ drop table t1;
283283
create table t1 (a int, b int as (b is null) virtual);
284284

285285
--echo # end of 5.3 tests
286+
287+
#
288+
# MDEV-7655 SHOW CREATE TABLE returns invalid DDL when using virtual columns along with a table collation
289+
#
290+
create table t1 (v1 varchar(255) as (c1) persistent, c1 varchar(50)) collate=latin1_general_ci;
291+
show create table t1;
292+
drop table t1;

sql/sql_show.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1611,7 +1611,7 @@ int store_create_info(THD *thd, TABLE_LIST *table_list, String *packet,
16111611
For string types dump collation name only if
16121612
collation is not primary for the given charset
16131613
*/
1614-
if (!(field->charset()->state & MY_CS_PRIMARY))
1614+
if (!(field->charset()->state & MY_CS_PRIMARY) && !field->vcol_info)
16151615
{
16161616
packet->append(STRING_WITH_LEN(" COLLATE "));
16171617
packet->append(field->charset()->name);

0 commit comments

Comments
 (0)