-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wenqi Mou <[email protected]>
- Loading branch information
1 parent
6180fb7
commit de2100f
Showing
4 changed files
with
150 additions
and
2 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,73 @@ | ||
#!/bin/sh | ||
|
||
echo "=== Verifying Data Integrity ===" | ||
|
||
# Verify original table key data is intact | ||
run_sql "SELECT COUNT(*) as cnt FROM key_types_test.table_key_test;" | ||
check_contains "cnt: 4" | ||
run_sql "SELECT id, name, value FROM key_types_test.table_key_test ORDER BY id;" | ||
check_contains "id: 1" | ||
check_contains "name: test1" | ||
check_contains "value: 100" | ||
check_contains "id: 2" | ||
check_contains "name: test2" | ||
check_contains "value: 200" | ||
check_contains "id: 3" | ||
check_contains "name: test3" | ||
check_contains "value: 300" | ||
|
||
# Verify new table key data | ||
run_sql "SELECT COUNT(*) as cnt FROM key_types_test.table_key_test2;" | ||
check_contains "cnt: 1" | ||
run_sql "SELECT id, name, value FROM key_types_test.table_key_test2 ORDER BY id;" | ||
check_contains "id: 1" | ||
check_contains "name: test1" | ||
check_contains "value: 100" | ||
|
||
# Verify original auto increment data | ||
run_sql "SELECT COUNT(*) as cnt FROM key_types_test.auto_inc_test;" | ||
check_contains "cnt: 4" | ||
run_sql "SELECT id FROM key_types_test.auto_inc_test ORDER BY id;" | ||
check_contains "id: 1" | ||
check_contains "id: 2" | ||
check_contains "id: 3" | ||
check_contains "id: 4" | ||
|
||
# Verify new auto increment data | ||
run_sql "SELECT COUNT(*) as cnt FROM key_types_test.auto_inc_test2;" | ||
check_contains "cnt: 2" | ||
run_sql "SELECT id FROM key_types_test.auto_inc_test2 ORDER BY id;" | ||
check_contains "id: 1" | ||
check_contains "id: 2" | ||
|
||
# Verify original sequence data | ||
run_sql "SELECT COUNT(*) as cnt FROM key_types_test.sequence_test;" | ||
check_contains "cnt: 4" | ||
run_sql "SELECT id FROM key_types_test.sequence_test ORDER BY id;" | ||
check_contains "id: 1" | ||
check_contains "id: 3" | ||
check_contains "id: 5" | ||
check_contains "id: 7" | ||
|
||
# Verify new sequence data | ||
run_sql "SELECT COUNT(*) as cnt FROM key_types_test.sequence_test2;" | ||
check_contains "cnt: 2" | ||
run_sql "SELECT id FROM key_types_test.sequence_test2 ORDER BY id;" | ||
check_contains "id: 1" | ||
check_contains "id: 3" | ||
|
||
# Verify original auto random data | ||
run_sql "SELECT COUNT(*) as cnt FROM key_types_test.auto_random_test;" | ||
check_contains "cnt: 4" | ||
run_sql "SELECT name FROM key_types_test.auto_random_test ORDER BY id;" | ||
check_contains "name: rand1" | ||
check_contains "name: rand2" | ||
check_contains "name: rand3" | ||
check_contains "name: random4" | ||
|
||
# Verify new auto random data | ||
run_sql "SELECT COUNT(*) as cnt FROM key_types_test.auto_random_test2;" | ||
check_contains "cnt: 2" | ||
run_sql "SELECT name FROM key_types_test.auto_random_test2 ORDER BY id;" | ||
check_contains "name: rand1" | ||
check_contains "name: rand2" |
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,38 @@ | ||
-- incremental changes to test during log backup | ||
|
||
-- test existing tables | ||
INSERT INTO key_types_test.table_key_test VALUES (3, 'test3', 300); | ||
INSERT INTO key_types_test.auto_inc_test (name) VALUES ('auto4'); | ||
INSERT INTO key_types_test.sequence_test (name) VALUES ('seq4'); | ||
INSERT INTO key_types_test.auto_random_test (name) VALUES ('random4'); | ||
|
||
-- Create new tables during log backup to test table creation with special keys | ||
-- 1. New table with regular key | ||
CREATE TABLE key_types_test.table_key_test2 ( | ||
id INT PRIMARY KEY NONCLUSTERED, | ||
name VARCHAR(255), | ||
value INT | ||
); | ||
INSERT INTO key_types_test.table_key_test2 VALUES (1, 'test1', 100); | ||
|
||
-- 2. New table with auto increment | ||
CREATE TABLE key_types_test.auto_inc_test2 ( | ||
id INT PRIMARY KEY AUTO_INCREMENT, | ||
name VARCHAR(255) | ||
); | ||
INSERT INTO key_types_test.auto_inc_test2 (name) VALUES ('auto1'), ('auto2'); | ||
|
||
-- 3. New sequence and table using it | ||
CREATE SEQUENCE key_types_test.seq2 START WITH 1 INCREMENT BY 2 NOCACHE; | ||
CREATE TABLE key_types_test.sequence_test2 ( | ||
id INT PRIMARY KEY DEFAULT NEXT VALUE FOR key_types_test.seq2, | ||
name VARCHAR(255) | ||
); | ||
INSERT INTO key_types_test.sequence_test2 (name) VALUES ('seq1'), ('seq2'); | ||
|
||
-- 4. New table with auto random | ||
CREATE TABLE key_types_test.auto_random_test2 ( | ||
id BIGINT PRIMARY KEY AUTO_RANDOM(5), | ||
name VARCHAR(255) | ||
); | ||
INSERT INTO key_types_test.auto_random_test2 (name) VALUES ('rand1'), ('rand2'); |
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,33 @@ | ||
-- Test cases for different key types during PITR restore | ||
|
||
-- 1. regular table key | ||
CREATE DATABASE IF NOT EXISTS key_types_test; | ||
CREATE TABLE key_types_test.table_key_test ( | ||
id INT PRIMARY KEY NONCLUSTERED, | ||
name VARCHAR(255), | ||
value INT | ||
); | ||
INSERT INTO key_types_test.table_key_test VALUES (1, 'test1', 100), (2, 'test2', 200); | ||
|
||
-- 2. auto Increment ID Key Test | ||
CREATE TABLE key_types_test.auto_inc_test ( | ||
id INT PRIMARY KEY AUTO_INCREMENT, | ||
name VARCHAR(255) | ||
); | ||
|
||
INSERT INTO key_types_test.auto_inc_test (name) VALUES ('auto1'), ('auto2'), ('auto3'); | ||
|
||
-- 3. sequence Key Test | ||
CREATE SEQUENCE key_types_test.seq1 START WITH 1 INCREMENT BY 2 NOCACHE; | ||
CREATE TABLE key_types_test.sequence_test ( | ||
id INT PRIMARY KEY DEFAULT NEXT VALUE FOR key_types_test.seq1, | ||
name VARCHAR(255) | ||
); | ||
INSERT INTO key_types_test.sequence_test (name) VALUES ('seq1'), ('seq2'), ('seq3'); | ||
|
||
-- 4. auto Random Table ID Key Test | ||
CREATE TABLE key_types_test.auto_random_test ( | ||
id BIGINT PRIMARY KEY AUTO_RANDOM(5), | ||
name VARCHAR(255) | ||
); | ||
INSERT INTO key_types_test.auto_random_test (name) VALUES ('rand1'), ('rand2'), ('rand3'); |
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