Skip to content

Commit

Permalink
MDEV-6390 CONVERT TO CHARACTER SET utf8 doesn't change DEFAULT CHARSET.
Browse files Browse the repository at this point in the history
        ALTER_CONVERT flag removed and replaced for ALTER_OPTIONS
        for the CONVERT TO CHARACTER SET command.
  • Loading branch information
Alexey Botchkov committed Feb 26, 2017
1 parent ae142c2 commit fdeeab0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
21 changes: 21 additions & 0 deletions mysql-test/r/alter_table.result
Expand Up @@ -2091,3 +2091,24 @@ Warnings:
Note 1061 Duplicate key name 'id1'
DROP TABLE t2;
DROP TABLE t1;
#
# MDEV-6390 CONVERT TO CHARACTER SET utf8 doesn't change DEFAULT CHARSET.
#
CREATE TABLE t1 (id int(11) NOT NULL, a int(11) NOT NULL, b int(11))
ENGINE=InnoDB DEFAULT CHARSET=latin1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`id` int(11) NOT NULL,
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8
DROP TABLE t1;
11 changes: 11 additions & 0 deletions mysql-test/t/alter_table.test
Expand Up @@ -1756,3 +1756,14 @@ REFERENCES t1 (id);
DROP TABLE t2;
DROP TABLE t1;


--echo #
--echo # MDEV-6390 CONVERT TO CHARACTER SET utf8 doesn't change DEFAULT CHARSET.
--echo #

CREATE TABLE t1 (id int(11) NOT NULL, a int(11) NOT NULL, b int(11))
ENGINE=InnoDB DEFAULT CHARSET=latin1;
SHOW CREATE TABLE t1;
ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
SHOW CREATE TABLE t1;
DROP TABLE t1;
35 changes: 16 additions & 19 deletions sql/sql_alter.h
Expand Up @@ -70,59 +70,56 @@ class Alter_info
// Set for DISABLE KEYS | ENABLE KEYS
static const uint ALTER_KEYS_ONOFF = 1L << 9;

// Set for CONVERT TO CHARACTER SET
static const uint ALTER_CONVERT = 1L << 10;

// Set for FORCE
// Set for ENGINE(same engine)
// Set by mysql_recreate_table()
static const uint ALTER_RECREATE = 1L << 11;
static const uint ALTER_RECREATE = 1L << 10;

// Set for ADD PARTITION
static const uint ALTER_ADD_PARTITION = 1L << 12;
static const uint ALTER_ADD_PARTITION = 1L << 11;

// Set for DROP PARTITION
static const uint ALTER_DROP_PARTITION = 1L << 13;
static const uint ALTER_DROP_PARTITION = 1L << 12;

// Set for COALESCE PARTITION
static const uint ALTER_COALESCE_PARTITION = 1L << 14;
static const uint ALTER_COALESCE_PARTITION = 1L << 13;

// Set for REORGANIZE PARTITION ... INTO
static const uint ALTER_REORGANIZE_PARTITION = 1L << 15;
static const uint ALTER_REORGANIZE_PARTITION = 1L << 14;

// Set for partition_options
static const uint ALTER_PARTITION = 1L << 16;
static const uint ALTER_PARTITION = 1L << 15;

// Set for LOAD INDEX INTO CACHE ... PARTITION
// Set for CACHE INDEX ... PARTITION
static const uint ALTER_ADMIN_PARTITION = 1L << 17;
static const uint ALTER_ADMIN_PARTITION = 1L << 16;

// Set for REORGANIZE PARTITION
static const uint ALTER_TABLE_REORG = 1L << 18;
static const uint ALTER_TABLE_REORG = 1L << 17;

// Set for REBUILD PARTITION
static const uint ALTER_REBUILD_PARTITION = 1L << 19;
static const uint ALTER_REBUILD_PARTITION = 1L << 18;

// Set for partitioning operations specifying ALL keyword
static const uint ALTER_ALL_PARTITION = 1L << 20;
static const uint ALTER_ALL_PARTITION = 1L << 19;

// Set for REMOVE PARTITIONING
static const uint ALTER_REMOVE_PARTITIONING = 1L << 21;
static const uint ALTER_REMOVE_PARTITIONING = 1L << 20;

// Set for ADD FOREIGN KEY
static const uint ADD_FOREIGN_KEY = 1L << 22;
static const uint ADD_FOREIGN_KEY = 1L << 21;

// Set for DROP FOREIGN KEY
static const uint DROP_FOREIGN_KEY = 1L << 23;
static const uint DROP_FOREIGN_KEY = 1L << 22;

// Set for EXCHANGE PARITION
static const uint ALTER_EXCHANGE_PARTITION = 1L << 24;
static const uint ALTER_EXCHANGE_PARTITION = 1L << 23;

// Set by Sql_cmd_alter_table_truncate_partition::execute()
static const uint ALTER_TRUNCATE_PARTITION = 1L << 25;
static const uint ALTER_TRUNCATE_PARTITION = 1L << 24;

// Set for ADD [COLUMN] FIRST | AFTER
static const uint ALTER_COLUMN_ORDER = 1L << 26;
static const uint ALTER_COLUMN_ORDER = 1L << 25;


enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_yacc.yy
Expand Up @@ -7643,7 +7643,7 @@ alter_list_item:
LEX *lex= Lex;
if (lex->create_info.add_alter_list_item_convert_to_charset($5))
MYSQL_YYABORT;
lex->alter_info.flags|= Alter_info::ALTER_CONVERT;
lex->alter_info.flags|= Alter_info::ALTER_OPTIONS;
}
| create_table_options_space_separated
{
Expand Down

0 comments on commit fdeeab0

Please sign in to comment.