Skip to content

Commit

Permalink
fix(mtr): add test case for add column.(#1140)
Browse files Browse the repository at this point in the history
Add test case: when alter table xxx add colmn operation is failed firstly, executing
alter table xxx add colmn by successful case again
  • Loading branch information
DandreChen authored and mergify[bot] committed Dec 30, 2022
1 parent 71fd8e7 commit e5efa89
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
22 changes: 22 additions & 0 deletions mysql-test/suite/tianmu/r/alter_column.result
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,26 @@ NULL 2 b NULL NULL
NULL 3 c NULL NULL
NULL 4 d NULL NULL
NULL 5 e NULL NULL
CREATE TABLE st1 (
task_id INT NOT NULL,
subject VARCHAR(45) NULL,
start_date DATE NULL,
end_date DATE NULL,
description VARCHAR(200) NULL,
PRIMARY KEY (task_id)
);
ALTER TABLE st1 ADD COLUMN test numeric(20,10);
ERROR HY000: Unable to inplace alter table
ALTER TABLE st1 ADD COLUMN test1 numeric(8,2);
SHOW CREATE TABLE st1;
Table Create Table
st1 CREATE TABLE `st1` (
`task_id` int(11) NOT NULL,
`subject` varchar(45) DEFAULT NULL,
`start_date` date DEFAULT NULL,
`end_date` date DEFAULT NULL,
`description` varchar(200) DEFAULT NULL,
`test1` decimal(8,2) DEFAULT NULL,
PRIMARY KEY (`task_id`)
) ENGINE=TIANMU DEFAULT CHARSET=latin1
DROP DATABASE alter_colunm;
20 changes: 20 additions & 0 deletions mysql-test/suite/tianmu/t/alter_column.test
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,25 @@ ALTER TABLE t1 DROP COLUMN c11;
SHOW CREATE TABLE t1;
SELECT * FROM t1 ORDER BY c1;

#################
# ADD COLUMEN BEFORE THE FIRST ADDING COLUMN IS WRONG
#################

CREATE TABLE st1 (
task_id INT NOT NULL,
subject VARCHAR(45) NULL,
start_date DATE NULL,
end_date DATE NULL,
description VARCHAR(200) NULL,
PRIMARY KEY (task_id)
);

--error 6
ALTER TABLE st1 ADD COLUMN test numeric(20,10);

ALTER TABLE st1 ADD COLUMN test1 numeric(8,2);

SHOW CREATE TABLE st1;

# Clean UP
DROP DATABASE alter_colunm;
1 change: 0 additions & 1 deletion storage/tianmu/core/value_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ void ValueSet::Add(const types::TianmuValueObject &rcv) {
if (rcv.IsNull())
contains_nulls = true;
else {
// Add(rcv.Get()->Clone());
std::unique_ptr<types::TianmuDataType> tianmu_dt = rcv.Get()->Clone();
if (tianmu_dt->IsNull()) {
contains_nulls = true;
Expand Down

0 comments on commit e5efa89

Please sign in to comment.