mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-22 22:20:02 +00:00
fix: wrong next column in manifest (#1440)
Signed-off-by: Zheming Li <nkdudu@126.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
46
tests/cases/distributed/alter/alter_table.result
Normal file
46
tests/cases/distributed/alter/alter_table.result
Normal 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
|
||||
|
||||
13
tests/cases/distributed/alter/alter_table.sql
Normal file
13
tests/cases/distributed/alter/alter_table.sql
Normal 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;
|
||||
47
tests/cases/standalone/alter/alter_table.result
Normal file
47
tests/cases/standalone/alter/alter_table.result
Normal 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
|
||||
|
||||
14
tests/cases/standalone/alter/alter_table.sql
Normal file
14
tests/cases/standalone/alter/alter_table.sql
Normal 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;
|
||||
Reference in New Issue
Block a user