-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RENAME TABLE test for x-database RENAME and DROP DATABASE
Summary: This adds a test case for RENAME TABLE across different database and then dropping the database - this is the scenario that triggers bug in db_number change. This makes sure our metadata works correctly in these cases regardless of format. Reviewed By: hermanlee Differential Revision: D28922167 fbshipit-source-id: afa3304b204
- Loading branch information
1 parent
15d6968
commit 6a279bc
Showing
2 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
CREATE DATABASE db1; | ||
USE db1; | ||
CREATE TABLE t1 (pk int primary key); | ||
INSERT INTO t1 values (1), (2), (3); | ||
CREATE TABLE t2 (pk int primary key); | ||
INSERT INTO t2 values (4), (5), (6); | ||
CREATE DATABASE db2; | ||
USE db2; | ||
RENAME TABLE db1.t1 TO db2.t1; | ||
# restart | ||
SELECT * from db2.t1 ORDER BY pk; | ||
pk | ||
1 | ||
2 | ||
3 | ||
SELECT * from db1.t2 ORDER BY pk; | ||
pk | ||
4 | ||
5 | ||
6 | ||
RENAME TABLE db1.t2 TO db2.t2; | ||
DROP DATABASE db1; | ||
SELECT * from db2.t2 ORDER BY pk; | ||
pk | ||
4 | ||
5 | ||
6 | ||
CREATE DATABASE db1; | ||
USE db1; | ||
CREATE TABLE t3 (pk int primary key); | ||
INSERT INTO t3 values (7), (8), (9); | ||
SELECT * from db2.t1 ORDER BY pk; | ||
pk | ||
1 | ||
2 | ||
3 | ||
SELECT * from db2.t2 ORDER BY pk; | ||
pk | ||
4 | ||
5 | ||
6 | ||
SELECT * from db1.t3 ORDER BY pk; | ||
pk | ||
7 | ||
8 | ||
9 | ||
# restart | ||
SELECT * from db2.t1 ORDER BY pk; | ||
pk | ||
1 | ||
2 | ||
3 | ||
SELECT * from db2.t2 ORDER BY pk; | ||
pk | ||
4 | ||
5 | ||
6 | ||
SELECT * from db1.t3 ORDER BY pk; | ||
pk | ||
7 | ||
8 | ||
9 | ||
RENAME TABLE db2.t1 TO db1.t1; | ||
RENAME TABLE db2.t2 TO db1.t2; | ||
DROP DATABASE db2; | ||
SELECT * from db1.t1 ORDER BY pk; | ||
pk | ||
1 | ||
2 | ||
3 | ||
SELECT * from db1.t2 ORDER BY pk; | ||
pk | ||
4 | ||
5 | ||
6 | ||
SELECT * from db1.t3 ORDER BY pk; | ||
pk | ||
7 | ||
8 | ||
9 | ||
# restart | ||
SELECT * from db1.t1 ORDER BY pk; | ||
pk | ||
1 | ||
2 | ||
3 | ||
SELECT * from db1.t2 ORDER BY pk; | ||
pk | ||
4 | ||
5 | ||
6 | ||
SELECT * from db1.t3 ORDER BY pk; | ||
pk | ||
7 | ||
8 | ||
9 | ||
DROP DATABASE db1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# RENAME table across database test | ||
|
||
CREATE DATABASE db1; | ||
|
||
USE db1; | ||
|
||
CREATE TABLE t1 (pk int primary key); | ||
INSERT INTO t1 values (1), (2), (3); | ||
|
||
CREATE TABLE t2 (pk int primary key); | ||
INSERT INTO t2 values (4), (5), (6); | ||
|
||
CREATE DATABASE db2; | ||
|
||
USE db2; | ||
|
||
RENAME TABLE db1.t1 TO db2.t1; | ||
|
||
# Restart to trigger validation and make sure dictionary data is intact | ||
--source include/restart_mysqld.inc | ||
|
||
SELECT * from db2.t1 ORDER BY pk; | ||
SELECT * from db1.t2 ORDER BY pk; | ||
|
||
RENAME TABLE db1.t2 TO db2.t2; | ||
DROP DATABASE db1; | ||
|
||
SELECT * from db2.t2 ORDER BY pk; | ||
|
||
# Recreate db1 | ||
CREATE DATABASE db1; | ||
USE db1; | ||
|
||
CREATE TABLE t3 (pk int primary key); | ||
INSERT INTO t3 values (7), (8), (9); | ||
|
||
SELECT * from db2.t1 ORDER BY pk; | ||
SELECT * from db2.t2 ORDER BY pk; | ||
SELECT * from db1.t3 ORDER BY pk; | ||
|
||
# Restart to trigger validation and make sure dictionary data is intact | ||
--source include/restart_mysqld.inc | ||
|
||
SELECT * from db2.t1 ORDER BY pk; | ||
SELECT * from db2.t2 ORDER BY pk; | ||
SELECT * from db1.t3 ORDER BY pk; | ||
|
||
RENAME TABLE db2.t1 TO db1.t1; | ||
RENAME TABLE db2.t2 TO db1.t2; | ||
|
||
DROP DATABASE db2; | ||
|
||
SELECT * from db1.t1 ORDER BY pk; | ||
SELECT * from db1.t2 ORDER BY pk; | ||
SELECT * from db1.t3 ORDER BY pk; | ||
|
||
# Restart to trigger validation and make sure dictionary data is intact | ||
--source include/restart_mysqld.inc | ||
|
||
SELECT * from db1.t1 ORDER BY pk; | ||
SELECT * from db1.t2 ORDER BY pk; | ||
SELECT * from db1.t3 ORDER BY pk; | ||
|
||
DROP DATABASE db1; |