Skip to content

Commit 8fbb2bc

Browse files
author
Nisha Gopalakrishnan
committed
Merge branch 'mysql-5.6' into mysql-5.7
2 parents 30c9665 + 11c684f commit 8fbb2bc

File tree

4 files changed

+105
-23
lines changed

4 files changed

+105
-23
lines changed

mysql-test/r/alter_table.result

+33
Original file line numberDiff line numberDiff line change
@@ -3464,3 +3464,36 @@ DROP TABLE t1;
34643464
DROP TABLE t2;
34653465
DROP TABLE t3;
34663466
DROP TABLE t4;
3467+
#
3468+
# Bug#21345391: ALTER TABLE ... CONVERT TO CHARACTER SET NOT EFFECT
3469+
# AND REMAIN A TEMP TABLE
3470+
CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE = INNODB CHARACTER SET gbk;
3471+
ALTER TABLE t1 CONVERT TO CHARACTER SET UTF8, ALGORITHM = INPLACE;
3472+
# Without fix, the CHARSET SET for table remains gbk.
3473+
SHOW CREATE TABLE t1;
3474+
Table Create Table
3475+
t1 CREATE TABLE `t1` (
3476+
`fld1` int(11) NOT NULL,
3477+
PRIMARY KEY (`fld1`)
3478+
) ENGINE=InnoDB DEFAULT CHARSET=utf8
3479+
# Without fix, the temporary .frm file is not cleaned up.
3480+
DROP TABLE t1;
3481+
# Test cases added for coverage.
3482+
# Reports an error for tables containing datatypes supporting
3483+
# characters.
3484+
CREATE TABLE t1 (fld1 CHAR(10) PRIMARY KEY) ENGINE = INNODB CHARACTER SET gbk;
3485+
ALTER TABLE t1 CONVERT TO CHARACTER SET UTF8, ALGORITHM = INPLACE;
3486+
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: Cannot change column type INPLACE. Try ALGORITHM=COPY.
3487+
DROP TABLE t1;
3488+
# ALTER TABLE, CHARACTER SET operation.
3489+
CREATE TABLE t1 (fld1 INT PRIMARY KEY, fld2 CHAR(10)) ENGINE = INNODB
3490+
CHARACTER SET gbk;
3491+
ALTER TABLE t1 CHARACTER SET UTF8, ALGORITHM = INPLACE;
3492+
SHOW CREATE TABLE t1;
3493+
Table Create Table
3494+
t1 CREATE TABLE `t1` (
3495+
`fld1` int(11) NOT NULL,
3496+
`fld2` char(10) CHARACTER SET gbk DEFAULT NULL,
3497+
PRIMARY KEY (`fld1`)
3498+
) ENGINE=InnoDB DEFAULT CHARSET=utf8
3499+
DROP TABLE t1;

mysql-test/t/alter_table.test

+51
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,7 @@ SELECT COLUMN_TYPE FROM information_schema.columns WHERE table_name='t1';
25652565
SET @@session.show_old_temporals= @save_show_old_temporals;
25662566
DROP TABLE t1, t2;
25672567

2568+
25682569
--echo #
25692570
--echo #BUG#20106553: ALTER TABLE WHICH CHANGES INDEX COMMENT IS NOT
25702571
--echo # LONGER INPLACE/FAST OPERATION.
@@ -2753,3 +2754,53 @@ DROP TABLE t1;
27532754
DROP TABLE t2;
27542755
DROP TABLE t3;
27552756
DROP TABLE t4;
2757+
2758+
2759+
--echo #
2760+
--echo # Bug#21345391: ALTER TABLE ... CONVERT TO CHARACTER SET NOT EFFECT
2761+
--echo # AND REMAIN A TEMP TABLE
2762+
2763+
CREATE TABLE t1 (fld1 INT PRIMARY KEY) ENGINE = INNODB CHARACTER SET gbk;
2764+
ALTER TABLE t1 CONVERT TO CHARACTER SET UTF8, ALGORITHM = INPLACE;
2765+
2766+
--echo # Without fix, the CHARSET SET for table remains gbk.
2767+
SHOW CREATE TABLE t1;
2768+
2769+
let $test_dir =
2770+
`SELECT CONCAT(variable_value, 'test/') FROM
2771+
INFORMATION_SCHEMA.GLOBAL_VARIABLES
2772+
WHERE LOWER(variable_name) = 'datadir'`;
2773+
2774+
--echo # Without fix, the temporary .frm file is not cleaned up.
2775+
--list_files $test_dir `#sql-*.frm`
2776+
2777+
DROP TABLE t1;
2778+
2779+
--echo # Test cases added for coverage.
2780+
2781+
--echo # Reports an error for tables containing datatypes supporting
2782+
--echo # characters.
2783+
2784+
CREATE TABLE t1 (fld1 CHAR(10) PRIMARY KEY) ENGINE = INNODB CHARACTER SET gbk;
2785+
2786+
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
2787+
ALTER TABLE t1 CONVERT TO CHARACTER SET UTF8, ALGORITHM = INPLACE;
2788+
2789+
DROP TABLE t1;
2790+
2791+
--echo # ALTER TABLE, CHARACTER SET operation.
2792+
2793+
CREATE TABLE t1 (fld1 INT PRIMARY KEY, fld2 CHAR(10)) ENGINE = INNODB
2794+
CHARACTER SET gbk;
2795+
ALTER TABLE t1 CHARACTER SET UTF8, ALGORITHM = INPLACE;
2796+
2797+
SHOW CREATE TABLE t1;
2798+
2799+
let $test_dir =
2800+
`SELECT CONCAT(variable_value, 'test/') FROM
2801+
INFORMATION_SCHEMA.GLOBAL_VARIABLES
2802+
WHERE LOWER(variable_name) = 'datadir'`;
2803+
2804+
--list_files $test_dir `#sql-*.frm`
2805+
2806+
DROP TABLE t1;

sql/sql_alter.h

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights
2+
reserved.
23
34
This program is free software; you can redistribute it and/or modify
45
it under the terms of the GNU General Public License as published by
@@ -141,65 +142,62 @@ class Alter_info
141142
// Set for DISABLE KEYS | ENABLE KEYS
142143
static const uint ALTER_KEYS_ONOFF = 1L << 9;
143144

144-
// Set for CONVERT TO CHARACTER SET
145-
static const uint ALTER_CONVERT = 1L << 10;
146-
147145
// Set for FORCE
148146
// Set for ENGINE(same engine)
149147
// Set by mysql_recreate_table()
150-
static const uint ALTER_RECREATE = 1L << 11;
148+
static const uint ALTER_RECREATE = 1L << 10;
151149

152150
// Set for ADD PARTITION
153-
static const uint ALTER_ADD_PARTITION = 1L << 12;
151+
static const uint ALTER_ADD_PARTITION = 1L << 11;
154152

155153
// Set for DROP PARTITION
156-
static const uint ALTER_DROP_PARTITION = 1L << 13;
154+
static const uint ALTER_DROP_PARTITION = 1L << 12;
157155

158156
// Set for COALESCE PARTITION
159-
static const uint ALTER_COALESCE_PARTITION = 1L << 14;
157+
static const uint ALTER_COALESCE_PARTITION = 1L << 13;
160158

161159
// Set for REORGANIZE PARTITION ... INTO
162-
static const uint ALTER_REORGANIZE_PARTITION = 1L << 15;
160+
static const uint ALTER_REORGANIZE_PARTITION = 1L << 14;
163161

164162
// Set for partition_options
165-
static const uint ALTER_PARTITION = 1L << 16;
163+
static const uint ALTER_PARTITION = 1L << 15;
166164

167165
// Set for LOAD INDEX INTO CACHE ... PARTITION
168166
// Set for CACHE INDEX ... PARTITION
169-
static const uint ALTER_ADMIN_PARTITION = 1L << 17;
167+
static const uint ALTER_ADMIN_PARTITION = 1L << 16;
170168

171169
// Set for REORGANIZE PARTITION
172-
static const uint ALTER_TABLE_REORG = 1L << 18;
170+
static const uint ALTER_TABLE_REORG = 1L << 17;
173171

174172
// Set for REBUILD PARTITION
175-
static const uint ALTER_REBUILD_PARTITION = 1L << 19;
173+
static const uint ALTER_REBUILD_PARTITION = 1L << 18;
176174

177175
// Set for partitioning operations specifying ALL keyword
178-
static const uint ALTER_ALL_PARTITION = 1L << 20;
176+
static const uint ALTER_ALL_PARTITION = 1L << 19;
179177

180178
// Set for REMOVE PARTITIONING
181-
static const uint ALTER_REMOVE_PARTITIONING = 1L << 21;
179+
static const uint ALTER_REMOVE_PARTITIONING = 1L << 20;
182180

183181
// Set for ADD FOREIGN KEY
184-
static const uint ADD_FOREIGN_KEY = 1L << 22;
182+
static const uint ADD_FOREIGN_KEY = 1L << 21;
185183

186184
// Set for DROP FOREIGN KEY
187-
static const uint DROP_FOREIGN_KEY = 1L << 23;
185+
static const uint DROP_FOREIGN_KEY = 1L << 22;
188186

189187
// Set for EXCHANGE PARITION
190-
static const uint ALTER_EXCHANGE_PARTITION = 1L << 24;
188+
static const uint ALTER_EXCHANGE_PARTITION = 1L << 23;
191189

192190
// Set by Sql_cmd_alter_table_truncate_partition::execute()
193-
static const uint ALTER_TRUNCATE_PARTITION = 1L << 25;
191+
static const uint ALTER_TRUNCATE_PARTITION = 1L << 24;
194192

195193
// Set for ADD [COLUMN] FIRST | AFTER
196-
static const uint ALTER_COLUMN_ORDER = 1L << 26;
194+
static const uint ALTER_COLUMN_ORDER = 1L << 25;
197195

198196
// Set for RENAME INDEX
199-
static const uint ALTER_RENAME_INDEX = 1L << 27;
197+
static const uint ALTER_RENAME_INDEX = 1L << 26;
200198

201199
// Set for UPGRADE PARTITIONING
202-
static const uint ALTER_UPGRADE_PARTITIONING = 1L << 30;
200+
static const uint ALTER_UPGRADE_PARTITIONING = 1L << 27;
203201

204202
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
205203

sql/sql_yacc.yy

+1-1
Original file line numberDiff line numberDiff line change
@@ -8276,7 +8276,7 @@ alter_list_item:
82768276
lex->create_info.default_table_charset= $5;
82778277
lex->create_info.used_fields|= (HA_CREATE_USED_CHARSET |
82788278
HA_CREATE_USED_DEFAULT_CHARSET);
8279-
lex->alter_info.flags|= Alter_info::ALTER_CONVERT;
8279+
lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
82808280
}
82818281
| create_table_options_space_separated
82828282
{

0 commit comments

Comments
 (0)