forked from stoneatom/stonedb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tianmu): support 'ALTER TABLE t1 CHARACTER SET = ...' clause. (s…
…toneatom#848) [summary] 1 add implement in check_if_supported_inplace_alter of tianmu handler; 2 add implement in inplace_alter_table of tianmu handler; 3 add implement in commit_inplace_alter_table of tianmu handler;
- Loading branch information
lujiashun
committed
Nov 3, 2022
1 parent
8050671
commit 478cf5e
Showing
4 changed files
with
240 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
create database test_issue848; | ||
use test_issue848; | ||
CREATE TABLE `test_alter_table_option_charset` ( | ||
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint DEFAULT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
show create table test_alter_table_option_charset; | ||
Table Create Table | ||
test_alter_table_option_charset CREATE TABLE `test_alter_table_option_charset` ( | ||
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint(6) DEFAULT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint(9) DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int(11) DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint(20) DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci | ||
ALTER TABLE test_alter_table_option_charset DEFAULT CHARACTER SET gbk; | ||
show create table test_alter_table_option_charset; | ||
Table Create Table | ||
test_alter_table_option_charset CREATE TABLE `test_alter_table_option_charset` ( | ||
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint(6) DEFAULT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint(9) DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int(11) DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint(20) DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=gbk | ||
insert into test_alter_table_option_charset(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text) | ||
values(105,105,105,105,105,5.2,10.88,105.083,'2016-02-25','2016-02-25 10:20:01','2016-02-25 05:20:01','10:20:01','stoneatom1','hello1','bcdefghijklmn'); | ||
ALTER TABLE test_alter_table_option_charset CHARACTER SET latin1; | ||
show create table test_alter_table_option_charset; | ||
Table Create Table | ||
test_alter_table_option_charset CREATE TABLE `test_alter_table_option_charset` ( | ||
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint(6) DEFAULT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint(9) DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int(11) DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint(20) DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=latin1 | ||
alter table test_alter_table_option_charset add column ex_column char(30); | ||
show create table test_alter_table_option_charset; | ||
Table Create Table | ||
test_alter_table_option_charset CREATE TABLE `test_alter_table_option_charset` ( | ||
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint(6) DEFAULT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint(9) DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int(11) DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint(20) DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob', | ||
`ex_column` char(30) DEFAULT NULL | ||
) ENGINE=TIANMU DEFAULT CHARSET=latin1 | ||
insert into test_alter_table_option_charset(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text,ex_column) | ||
values(106,106,106,106,106,6.2,60.88,106.083,'2017-02-25','2017-02-25 10:20:01','2017-02-25 05:20:01','10:21:01','stoneatom2','hello2','ddddbcdefghijklmn','ex_column_char'); | ||
ALTER TABLE test_alter_table_option_charset CHARACTER SET latin2; | ||
show create table test_alter_table_option_charset; | ||
Table Create Table | ||
test_alter_table_option_charset CREATE TABLE `test_alter_table_option_charset` ( | ||
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint(6) DEFAULT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint(9) DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int(11) DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint(20) DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob', | ||
`ex_column` char(30) CHARACTER SET latin1 DEFAULT NULL | ||
) ENGINE=TIANMU DEFAULT CHARSET=latin2 | ||
alter table test_alter_table_option_charset add column ex_column2 varchar(30); | ||
show create table test_alter_table_option_charset; | ||
Table Create Table | ||
test_alter_table_option_charset CREATE TABLE `test_alter_table_option_charset` ( | ||
`c_tinyint` tinyint(4) DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint(6) DEFAULT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint(9) DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int(11) DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint(20) DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob', | ||
`ex_column` char(30) CHARACTER SET latin1 DEFAULT NULL, | ||
`ex_column2` varchar(30) DEFAULT NULL | ||
) ENGINE=TIANMU DEFAULT CHARSET=latin2 | ||
insert into test_alter_table_option_charset(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text,ex_column,ex_column2) | ||
values(107,107,107,107,107,7.2,80.88,105.083,'2018-02-25','2018-02-25 10:20:01','2018-02-25 05:20:01','10:22:01','stoneatom3','hello3','ijklmnbcdefgh',"ex_column_char", 'ex_column_varchar2'); | ||
drop table test_alter_table_option_charset; | ||
drop database test_issue848; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--source include/have_tianmu.inc | ||
create database test_issue848; | ||
use test_issue848; | ||
CREATE TABLE `test_alter_table_option_charset` ( | ||
`c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint', | ||
`c_smallint` smallint DEFAULT NULL COMMENT 'smallint', | ||
`c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint', | ||
`c_int` int DEFAULT NULL COMMENT 'int', | ||
`c_bigint` bigint DEFAULT NULL COMMENT 'bigint', | ||
`c_float` float DEFAULT NULL COMMENT 'float', | ||
`c_double` double DEFAULT NULL COMMENT 'double', | ||
`c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal', | ||
`c_date` date DEFAULT NULL COMMENT 'date', | ||
`c_datetime` datetime DEFAULT NULL COMMENT 'datetime', | ||
`c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp', | ||
`c_time` time DEFAULT NULL COMMENT 'time', | ||
`c_char` char(10) DEFAULT NULL COMMENT 'char', | ||
`c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar', | ||
`c_blob` blob COMMENT 'blob', | ||
`c_text` text COMMENT 'text', | ||
`c_longblob` longblob COMMENT 'longblob' | ||
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
|
||
show create table test_alter_table_option_charset; | ||
|
||
ALTER TABLE test_alter_table_option_charset DEFAULT CHARACTER SET gbk; | ||
show create table test_alter_table_option_charset; | ||
insert into test_alter_table_option_charset(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text) | ||
values(105,105,105,105,105,5.2,10.88,105.083,'2016-02-25','2016-02-25 10:20:01','2016-02-25 05:20:01','10:20:01','stoneatom1','hello1','bcdefghijklmn'); | ||
|
||
ALTER TABLE test_alter_table_option_charset CHARACTER SET latin1; | ||
show create table test_alter_table_option_charset; | ||
|
||
alter table test_alter_table_option_charset add column ex_column char(30); | ||
show create table test_alter_table_option_charset; | ||
insert into test_alter_table_option_charset(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text,ex_column) | ||
values(106,106,106,106,106,6.2,60.88,106.083,'2017-02-25','2017-02-25 10:20:01','2017-02-25 05:20:01','10:21:01','stoneatom2','hello2','ddddbcdefghijklmn','ex_column_char'); | ||
|
||
|
||
ALTER TABLE test_alter_table_option_charset CHARACTER SET latin2; | ||
show create table test_alter_table_option_charset; | ||
|
||
alter table test_alter_table_option_charset add column ex_column2 varchar(30); | ||
show create table test_alter_table_option_charset; | ||
insert into test_alter_table_option_charset(c_tinyint,c_smallint,c_mediumint,c_int,c_bigint,c_float,c_double,c_decimal,c_date,c_datetime,c_timestamp,c_time,c_char,c_varchar,c_text,ex_column,ex_column2) | ||
values(107,107,107,107,107,7.2,80.88,105.083,'2018-02-25','2018-02-25 10:20:01','2018-02-25 05:20:01','10:22:01','stoneatom3','hello3','ijklmnbcdefgh',"ex_column_char", 'ex_column_varchar2'); | ||
|
||
drop table test_alter_table_option_charset; | ||
drop database test_issue848; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters