-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Milestone
Description
Description
If a user renames a table we don't act on it and leave Readyset on stale state for that table:
CREATE TABLE t1 (ID INT PRIMARY KEY);
INSERT INTO t1 VALUES(1);
CREATE CACHE FROM SELECT * FROM t1;
CREATE TABLE t1_new LIKE t1;
RENAME TABLE t1 TO t1_old;
RENAME TABLE t1_new TO t1;
readyset> SELECT * FROM t1;
+----+
| ID |
+----+
| 1 |
+----+
1 row in set (0,001 sec)
readyset> EXPLAIN LAST STATEMENT;
+-------------------+----------------+
| Query_destination | ReadySet_error |
+-------------------+----------------+
| readyset | ok |
+-------------------+----------------+
1 row in set (0,001 sec)
readyset> SELECT * FROM t1 ORDER BY ID;
Empty set (0,011 sec)
readyset> EXPLAIN LAST STATEMENT;
+-------------------+----------------+
| Query_destination | ReadySet_error |
+-------------------+----------------+
| upstream | ok |
+-------------------+----------------+
1 row in set (0,001 sec)
MySQL has two was to rename a table. Via ALTER TABLE:
mysql> ALTER TABLE t1 RENAME AS t1_old;
Query OK, 0 rows affected (0,022 sec)
mysql> ALTER TABLE t1 RENAME TO t1_old;
Query OK, 0 rows affected (0,013 sec)
This one we act, and we resnapshot. As part of the resnapshot we identify table t1
is present on readyset but missing on upstream and we drop it, we also copy t1_old
MySQL: https://dev.mysql.com/doc/refman/8.4/en/rename-table.html
RENAME TABLE old_table1 TO new_table1,
old_table2 TO new_table2,
old_table3 TO new_table3;
PostgreSQL: https://www.postgresql.org/docs/current/sql-altertable.html
CREATE TABLE t1 (ID INT PRIMARY KEY);
INSERT INTO t1 VALUES(1);
CREATE CACHE FROM SELECT * FROM t1;
CREATE TABLE t1_new LIKE t1;
ALTER TABLE t1 RENAME TO t1_old;
ALTER TABLE t1_new RENAME TO t1;
DROP TABLE t1_old;
This we don't act and have stale data.
Description
Change in user-visible behavior
Requires documentation change
Metadata
Metadata
Assignees
Labels
No labels