Skip to content

Commit fdeeab0

Browse files
author
Alexey Botchkov
committed
MDEV-6390 CONVERT TO CHARACTER SET utf8 doesn't change DEFAULT CHARSET.
ALTER_CONVERT flag removed and replaced for ALTER_OPTIONS for the CONVERT TO CHARACTER SET command.
1 parent ae142c2 commit fdeeab0

File tree

4 files changed

+49
-20
lines changed

4 files changed

+49
-20
lines changed

mysql-test/r/alter_table.result

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2091,3 +2091,24 @@ Warnings:
20912091
Note 1061 Duplicate key name 'id1'
20922092
DROP TABLE t2;
20932093
DROP TABLE t1;
2094+
#
2095+
# MDEV-6390 CONVERT TO CHARACTER SET utf8 doesn't change DEFAULT CHARSET.
2096+
#
2097+
CREATE TABLE t1 (id int(11) NOT NULL, a int(11) NOT NULL, b int(11))
2098+
ENGINE=InnoDB DEFAULT CHARSET=latin1;
2099+
SHOW CREATE TABLE t1;
2100+
Table Create Table
2101+
t1 CREATE TABLE `t1` (
2102+
`id` int(11) NOT NULL,
2103+
`a` int(11) NOT NULL,
2104+
`b` int(11) DEFAULT NULL
2105+
) ENGINE=InnoDB DEFAULT CHARSET=latin1
2106+
ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
2107+
SHOW CREATE TABLE t1;
2108+
Table Create Table
2109+
t1 CREATE TABLE `t1` (
2110+
`id` int(11) NOT NULL,
2111+
`a` int(11) NOT NULL,
2112+
`b` int(11) DEFAULT NULL
2113+
) ENGINE=InnoDB DEFAULT CHARSET=utf8
2114+
DROP TABLE t1;

mysql-test/t/alter_table.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,3 +1756,14 @@ REFERENCES t1 (id);
17561756
DROP TABLE t2;
17571757
DROP TABLE t1;
17581758

1759+
1760+
--echo #
1761+
--echo # MDEV-6390 CONVERT TO CHARACTER SET utf8 doesn't change DEFAULT CHARSET.
1762+
--echo #
1763+
1764+
CREATE TABLE t1 (id int(11) NOT NULL, a int(11) NOT NULL, b int(11))
1765+
ENGINE=InnoDB DEFAULT CHARSET=latin1;
1766+
SHOW CREATE TABLE t1;
1767+
ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
1768+
SHOW CREATE TABLE t1;
1769+
DROP TABLE t1;

sql/sql_alter.h

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,59 +70,56 @@ class Alter_info
7070
// Set for DISABLE KEYS | ENABLE KEYS
7171
static const uint ALTER_KEYS_ONOFF = 1L << 9;
7272

73-
// Set for CONVERT TO CHARACTER SET
74-
static const uint ALTER_CONVERT = 1L << 10;
75-
7673
// Set for FORCE
7774
// Set for ENGINE(same engine)
7875
// Set by mysql_recreate_table()
79-
static const uint ALTER_RECREATE = 1L << 11;
76+
static const uint ALTER_RECREATE = 1L << 10;
8077

8178
// Set for ADD PARTITION
82-
static const uint ALTER_ADD_PARTITION = 1L << 12;
79+
static const uint ALTER_ADD_PARTITION = 1L << 11;
8380

8481
// Set for DROP PARTITION
85-
static const uint ALTER_DROP_PARTITION = 1L << 13;
82+
static const uint ALTER_DROP_PARTITION = 1L << 12;
8683

8784
// Set for COALESCE PARTITION
88-
static const uint ALTER_COALESCE_PARTITION = 1L << 14;
85+
static const uint ALTER_COALESCE_PARTITION = 1L << 13;
8986

9087
// Set for REORGANIZE PARTITION ... INTO
91-
static const uint ALTER_REORGANIZE_PARTITION = 1L << 15;
88+
static const uint ALTER_REORGANIZE_PARTITION = 1L << 14;
9289

9390
// Set for partition_options
94-
static const uint ALTER_PARTITION = 1L << 16;
91+
static const uint ALTER_PARTITION = 1L << 15;
9592

9693
// Set for LOAD INDEX INTO CACHE ... PARTITION
9794
// Set for CACHE INDEX ... PARTITION
98-
static const uint ALTER_ADMIN_PARTITION = 1L << 17;
95+
static const uint ALTER_ADMIN_PARTITION = 1L << 16;
9996

10097
// Set for REORGANIZE PARTITION
101-
static const uint ALTER_TABLE_REORG = 1L << 18;
98+
static const uint ALTER_TABLE_REORG = 1L << 17;
10299

103100
// Set for REBUILD PARTITION
104-
static const uint ALTER_REBUILD_PARTITION = 1L << 19;
101+
static const uint ALTER_REBUILD_PARTITION = 1L << 18;
105102

106103
// Set for partitioning operations specifying ALL keyword
107-
static const uint ALTER_ALL_PARTITION = 1L << 20;
104+
static const uint ALTER_ALL_PARTITION = 1L << 19;
108105

109106
// Set for REMOVE PARTITIONING
110-
static const uint ALTER_REMOVE_PARTITIONING = 1L << 21;
107+
static const uint ALTER_REMOVE_PARTITIONING = 1L << 20;
111108

112109
// Set for ADD FOREIGN KEY
113-
static const uint ADD_FOREIGN_KEY = 1L << 22;
110+
static const uint ADD_FOREIGN_KEY = 1L << 21;
114111

115112
// Set for DROP FOREIGN KEY
116-
static const uint DROP_FOREIGN_KEY = 1L << 23;
113+
static const uint DROP_FOREIGN_KEY = 1L << 22;
117114

118115
// Set for EXCHANGE PARITION
119-
static const uint ALTER_EXCHANGE_PARTITION = 1L << 24;
116+
static const uint ALTER_EXCHANGE_PARTITION = 1L << 23;
120117

121118
// Set by Sql_cmd_alter_table_truncate_partition::execute()
122-
static const uint ALTER_TRUNCATE_PARTITION = 1L << 25;
119+
static const uint ALTER_TRUNCATE_PARTITION = 1L << 24;
123120

124121
// Set for ADD [COLUMN] FIRST | AFTER
125-
static const uint ALTER_COLUMN_ORDER = 1L << 26;
122+
static const uint ALTER_COLUMN_ORDER = 1L << 25;
126123

127124

128125
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };

sql/sql_yacc.yy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7643,7 +7643,7 @@ alter_list_item:
76437643
LEX *lex= Lex;
76447644
if (lex->create_info.add_alter_list_item_convert_to_charset($5))
76457645
MYSQL_YYABORT;
7646-
lex->alter_info.flags|= Alter_info::ALTER_CONVERT;
7646+
lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
76477647
}
76487648
| create_table_options_space_separated
76497649
{

0 commit comments

Comments
 (0)