[regression test]Test the unique model by modify a key type from BOOLEAN to other type (#31540)

* Test the unique model by modify a value type from BOOLEAN to other type

* Test the unique model by modify a key type from BOOLEAN to other type

* Test the unique model by modify a key type from BOOLEAN to other type
This commit is contained in:
kkop
2024-03-02 01:15:26 +08:00
committed by yiguolei
parent ff5e9341bf
commit 5e684c23ba

View File

@ -254,4 +254,141 @@ suite("test_unique_model_schema_key_change","p0") {
}, insertSql, true,"${tbName}")*/
/**
* Test the unique model by modify a value type
*/
initTable = " CREATE TABLE IF NOT EXISTS ${tbName}\n" +
" (\n" +
" `user_id` LARGEINT NOT NULL COMMENT \"用户id\",\n" +
" `username` VARCHAR(50) NOT NULL COMMENT \"用户昵称\",\n" +
" `is_teacher` BOOLEAN COMMENT \"是否是老师\",\n" +
" `city` VARCHAR(20) COMMENT \"用户所在城市\",\n" +
" `age` SMALLINT COMMENT \"用户年龄\",\n" +
" `sex` TINYINT COMMENT \"用户性别\",\n" +
" `phone` LARGEINT COMMENT \"用户电话\",\n" +
" `address` VARCHAR(500) COMMENT \"用户地址\",\n" +
" `register_time` DATETIME COMMENT \"用户注册时间\"\n" +
" )\n" +
" UNIQUE KEY(`user_id`, `username`, `is_teacher`)\n" +
" DISTRIBUTED BY HASH(`user_id`) BUCKETS 1\n" +
" PROPERTIES (\n" +
" \"replication_allocation\" = \"tag.location.default: 1\",\n" +
" \"enable_unique_key_merge_on_write\" = \"true\"\n" +
" );"
initTableData = "insert into ${tbName} values(123456789, 'Alice', 0, 'Beijing', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00')," +
" (234567890, 'Bob', 0, 'Shanghai', 30, 1, 13998765432, 'No. 456 Street, Shanghai', '2022-02-02 12:00:00')," +
" (345678901, 'Carol', 1, 'Guangzhou', 28, 0, 13724681357, 'No. 789 Street, Guangzhou', '2022-03-03 14:00:00')," +
" (456789012, 'Dave', 0, 'Shenzhen', 35, 1, 13680864279, 'No. 987 Street, Shenzhen', '2022-04-04 16:00:00')," +
" (567890123, 'Eve', 0, 'Chengdu', 27, 0, 13572468091, 'No. 654 Street, Chengdu', '2022-05-05 18:00:00')," +
" (678901234, 'Frank', 1, 'Hangzhou', 32, 1, 13467985213, 'No. 321 Street, Hangzhou', '2022-06-06 20:00:00')," +
" (789012345, 'Grace', 0, 'Xian', 29, 0, 13333333333, 'No. 222 Street, Xian', '2022-07-07 22:00:00');"
//Test the unique model by modify a key type from BOOLEAN to TINYINT
//TODO java.sql.SQLException: errCode = 2, detailMessage = Can not change BOOLEAN to TINYINT
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher TINYINT KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', 1, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
//Test the unique model by modify a key type from BOOLEAN to SMALLINT
//TODO java.sql.SQLException: errCode = 2, detailMessage = Can not change BOOLEAN to SMALLINT
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher SMALLINT KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', 1, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
//Test the unique model by modify a key type from BOOLEAN to INT
//TODO java.sql.SQLException: errCode = 2, detailMessage = Can not change BOOLEAN to INT
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher INT KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', 1, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
//Test the unique model by modify a key type from BOOLEAN to BIGINT
//TODO java.sql.SQLException: errCode = 2, detailMessage = Can not change BOOLEAN to BIGINT
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher BIGINT KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', 1, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
//Test the unique model by modify a key type from BOOLEAN to FLOAT
//TODO Float or double can not used as a key, use decimal instead
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher FLOAT KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', 1.0, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
//Test the unique model by modify a key type from BOOLEAN to DECIMAL
//TODO java.sql.SQLException: errCode = 2, detailMessage = Can not change BOOLEAN to DECIMAL32
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher DECIMAL KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', 1.0, 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
//Test the unique model by modify a key type from BOOLEAN to CHAR
//TODO java.sql.SQLException: errCode = 2, detailMessage = Can not change BOOLEAN to CHAR
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher CHAR KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', '1', 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
//Test the unique model by modify a key type from BOOLEAN to STRING
//TODO java.sql.SQLException: errCode = 2, detailMessage = String Type should not be used in key column[is_teacher].
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher STRING KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', '1', 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
//Test the unique model by modify a key type from BOOLEAN to VARCHAR
//TODO java.sql.SQLException: errCode = 2, detailMessage = Can not change BOOLEAN to VARCHAR
/* sql initTable
sql initTableData
sql """ alter table ${tbName} MODIFY column is_teacher VARCHAR(32) KEY DEFAULT "0" """
insertSql = "insert into ${tbName} values(123456689, 'Alice', '1', 'Yaan', 25, 0, 13812345678, 'No. 123 Street, Beijing', '2022-01-01 10:00:00'); "
waitForSchemaChangeDone({
sql getTableStatusSql
time 60
}, insertSql, true,"${tbName}")*/
}