fix: wrong next column in manifest (#1440)

Signed-off-by: Zheming Li <nkdudu@126.com>
This commit is contained in:
Zheming Li
2023-04-23 11:25:38 +08:00
committed by GitHub
parent 1ee9ad4ca1
commit c75845c570
5 changed files with 123 additions and 3 deletions

View File

@@ -241,6 +241,8 @@ impl<R: Region> Table for MitoTable<R> {
new_info.meta = new_meta;
}
}
// Do create_alter_operation first to bump next_column_id in meta.
let alter_op = create_alter_operation(table_name, &req.alter_kind, &mut new_info.meta)?;
// Increase version of the table.
new_info.ident.version = table_info.ident.version + 1;
@@ -263,9 +265,7 @@ impl<R: Region> Table for MitoTable<R> {
.map_err(BoxedError::new)
.context(table_error::TableOperationSnafu)?;
if let Some(alter_op) =
create_alter_operation(table_name, &req.alter_kind, &mut new_info.meta)?
{
if let Some(alter_op) = alter_op {
// TODO(yingwen): Error handling. Maybe the region need to provide a method to
// validate the request first.
let regions = self.regions();

View File

@@ -0,0 +1,46 @@
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
ALTER TABLE t ADD COLUMN k INTEGER;
Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
ALTER TABLE t ADD COLUMN m INTEGER;
Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
| m | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
DROP TABLE t;
Affected Rows: 1

View File

@@ -0,0 +1,13 @@
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
DESC TABLE t;
ALTER TABLE t ADD COLUMN k INTEGER;
DESC TABLE t;
ALTER TABLE t ADD COLUMN m INTEGER;
DESC TABLE t;
DROP TABLE t;

View File

@@ -0,0 +1,47 @@
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
+-------+-------+------+---------+---------------+
ALTER TABLE t ADD COLUMN k INTEGER;
Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
-- SQLNESS ARG restart=true
ALTER TABLE t ADD COLUMN m INTEGER;
Affected Rows: 0
DESC TABLE t;
+-------+-------+------+---------+---------------+
| Field | Type | Null | Default | Semantic Type |
+-------+-------+------+---------+---------------+
| i | Int32 | YES | | FIELD |
| j | Int64 | NO | | TIME INDEX |
| k | Int32 | YES | | FIELD |
| m | Int32 | YES | | FIELD |
+-------+-------+------+---------+---------------+
DROP TABLE t;
Affected Rows: 1

View File

@@ -0,0 +1,14 @@
CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX);
DESC TABLE t;
ALTER TABLE t ADD COLUMN k INTEGER;
DESC TABLE t;
-- SQLNESS ARG restart=true
ALTER TABLE t ADD COLUMN m INTEGER;
DESC TABLE t;
DROP TABLE t;