diff --git a/tests/cases/standalone/alter/rename_table.result b/tests/cases/standalone/alter/rename_table.result new file mode 100644 index 0000000000..f05f6523a3 --- /dev/null +++ b/tests/cases/standalone/alter/rename_table.result @@ -0,0 +1,78 @@ +CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX); + +Affected Rows: 0 + +DESC TABLE t; + ++-------+-------+------+---------+---------------+ +| Field | Type | Null | Default | Semantic Type | ++-------+-------+------+---------+---------------+ +| i | Int32 | YES | | VALUE | +| j | Int64 | NO | | TIME INDEX | ++-------+-------+------+---------+---------------+ + +INSERT INTO TABLE t VALUES (1, 1), (3, 3), (NULL, 4); + +Affected Rows: 3 + +SELECT * from t; + ++---+---+ +| i | j | ++---+---+ +| 1 | 1 | +| 3 | 3 | +| | 4 | ++---+---+ + +ALTER TABLE t RENAME new_table; + +Affected Rows: 0 + +DESC TABLE t; + +Error: 1004(InvalidArguments), Table not found: t + +SELECT * FROM t; + +Error: 3000(PlanQuery), Error during planning: table 'greptime.public.t' not found + +CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX); + +Affected Rows: 0 + +DESC TABLE new_table; + ++-------+-------+------+---------+---------------+ +| Field | Type | Null | Default | Semantic Type | ++-------+-------+------+---------+---------------+ +| i | Int32 | YES | | VALUE | +| j | Int64 | NO | | TIME INDEX | ++-------+-------+------+---------+---------------+ + +SELECT * FROM new_table; + ++---+---+ +| i | j | ++---+---+ +| 1 | 1 | +| 3 | 3 | +| | 4 | ++---+---+ + +ALTER TABLE new_table RENAME new_table; + +Error: 1004(InvalidArguments), Table already exists: greptime.public.new_table + +ALTER TABLE new_table RENAME t; + +Error: 1004(InvalidArguments), Table already exists: greptime.public.t + +DROP TABLE t; + +Affected Rows: 1 + +DROP TABLE new_table; + +Affected Rows: 1 + diff --git a/tests/cases/standalone/alter/rename_table.sql b/tests/cases/standalone/alter/rename_table.sql new file mode 100644 index 0000000000..af4de9ca87 --- /dev/null +++ b/tests/cases/standalone/alter/rename_table.sql @@ -0,0 +1,27 @@ +CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX); + +DESC TABLE t; + +INSERT INTO TABLE t VALUES (1, 1), (3, 3), (NULL, 4); + +SELECT * from t; + +ALTER TABLE t RENAME new_table; + +DESC TABLE t; + +SELECT * FROM t; + +CREATE TABLE t(i INTEGER, j BIGINT TIME INDEX); + +DESC TABLE new_table; + +SELECT * FROM new_table; + +ALTER TABLE new_table RENAME new_table; + +ALTER TABLE new_table RENAME t; + +DROP TABLE t; + +DROP TABLE new_table;