回归测试用例cluster的sql设计不合理
This commit is contained in:
@ -57,41 +57,41 @@ INSERT INTO clstr_tst (b, c) VALUES (8, 'ocho');
|
||||
-- This entry is needed to test that TOASTED values are copied correctly.
|
||||
INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('xyzzy', 100000));
|
||||
CLUSTER clstr_tst_c ON clstr_tst;
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c;
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst;
|
||||
a | b | c | substring | length
|
||||
----+----+---------------+--------------------------------+--------
|
||||
1 | 11 | once | |
|
||||
10 | 14 | catorce | |
|
||||
18 | 5 | cinco | |
|
||||
9 | 4 | cuatro | |
|
||||
26 | 19 | diecinueve | |
|
||||
12 | 18 | dieciocho | |
|
||||
30 | 16 | dieciseis | |
|
||||
24 | 17 | diecisiete | |
|
||||
2 | 10 | diez | |
|
||||
23 | 12 | doce | |
|
||||
11 | 2 | dos | |
|
||||
25 | 9 | nueve | |
|
||||
31 | 8 | ocho | |
|
||||
1 | 11 | once | |
|
||||
28 | 15 | quince | |
|
||||
32 | 6 | seis | xyzzyxyzzyxyzzyxyzzyxyzzyxyzzy | 500000
|
||||
29 | 7 | siete | |
|
||||
15 | 13 | trece | |
|
||||
22 | 30 | treinta | |
|
||||
17 | 32 | treinta y dos | |
|
||||
3 | 31 | treinta y uno | |
|
||||
4 | 22 | veintidos | |
|
||||
5 | 3 | tres | |
|
||||
20 | 1 | uno | |
|
||||
6 | 20 | veinte | |
|
||||
14 | 25 | veinticinco | |
|
||||
21 | 24 | veinticuatro | |
|
||||
4 | 22 | veintidos | |
|
||||
19 | 29 | veintinueve | |
|
||||
16 | 28 | veintiocho | |
|
||||
27 | 26 | veintiseis | |
|
||||
13 | 27 | veintisiete | |
|
||||
7 | 23 | veintitres | |
|
||||
8 | 21 | veintiuno | |
|
||||
9 | 4 | cuatro | |
|
||||
10 | 14 | catorce | |
|
||||
11 | 2 | dos | |
|
||||
12 | 18 | dieciocho | |
|
||||
13 | 27 | veintisiete | |
|
||||
14 | 25 | veinticinco | |
|
||||
15 | 13 | trece | |
|
||||
16 | 28 | veintiocho | |
|
||||
17 | 32 | treinta y dos | |
|
||||
18 | 5 | cinco | |
|
||||
19 | 29 | veintinueve | |
|
||||
20 | 1 | uno | |
|
||||
21 | 24 | veinticuatro | |
|
||||
22 | 30 | treinta | |
|
||||
23 | 12 | doce | |
|
||||
24 | 17 | diecisiete | |
|
||||
25 | 9 | nueve | |
|
||||
26 | 19 | diecinueve | |
|
||||
27 | 26 | veintiseis | |
|
||||
28 | 15 | quince | |
|
||||
29 | 7 | siete | |
|
||||
30 | 16 | dieciseis | |
|
||||
31 | 8 | ocho | |
|
||||
32 | 6 | seis | xyzzyxyzzyxyzzyxyzzyxyzzyxyzzy | 500000
|
||||
(32 rows)
|
||||
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a;
|
||||
@ -207,41 +207,41 @@ SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY c;
|
||||
|
||||
-- Verify that inheritance link still works
|
||||
-- INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table');
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c;
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst;
|
||||
a | b | c | substring | length
|
||||
----+----+---------------+--------------------------------+--------
|
||||
1 | 11 | once | |
|
||||
10 | 14 | catorce | |
|
||||
18 | 5 | cinco | |
|
||||
9 | 4 | cuatro | |
|
||||
26 | 19 | diecinueve | |
|
||||
12 | 18 | dieciocho | |
|
||||
30 | 16 | dieciseis | |
|
||||
24 | 17 | diecisiete | |
|
||||
2 | 10 | diez | |
|
||||
23 | 12 | doce | |
|
||||
11 | 2 | dos | |
|
||||
25 | 9 | nueve | |
|
||||
31 | 8 | ocho | |
|
||||
1 | 11 | once | |
|
||||
28 | 15 | quince | |
|
||||
32 | 6 | seis | xyzzyxyzzyxyzzyxyzzyxyzzyxyzzy | 500000
|
||||
29 | 7 | siete | |
|
||||
15 | 13 | trece | |
|
||||
22 | 30 | treinta | |
|
||||
17 | 32 | treinta y dos | |
|
||||
3 | 31 | treinta y uno | |
|
||||
4 | 22 | veintidos | |
|
||||
5 | 3 | tres | |
|
||||
20 | 1 | uno | |
|
||||
6 | 20 | veinte | |
|
||||
14 | 25 | veinticinco | |
|
||||
21 | 24 | veinticuatro | |
|
||||
4 | 22 | veintidos | |
|
||||
19 | 29 | veintinueve | |
|
||||
16 | 28 | veintiocho | |
|
||||
27 | 26 | veintiseis | |
|
||||
13 | 27 | veintisiete | |
|
||||
7 | 23 | veintitres | |
|
||||
8 | 21 | veintiuno | |
|
||||
9 | 4 | cuatro | |
|
||||
10 | 14 | catorce | |
|
||||
11 | 2 | dos | |
|
||||
12 | 18 | dieciocho | |
|
||||
13 | 27 | veintisiete | |
|
||||
14 | 25 | veinticinco | |
|
||||
15 | 13 | trece | |
|
||||
16 | 28 | veintiocho | |
|
||||
17 | 32 | treinta y dos | |
|
||||
18 | 5 | cinco | |
|
||||
19 | 29 | veintinueve | |
|
||||
20 | 1 | uno | |
|
||||
21 | 24 | veinticuatro | |
|
||||
22 | 30 | treinta | |
|
||||
23 | 12 | doce | |
|
||||
24 | 17 | diecisiete | |
|
||||
25 | 9 | nueve | |
|
||||
26 | 19 | diecinueve | |
|
||||
27 | 26 | veintiseis | |
|
||||
28 | 15 | quince | |
|
||||
29 | 7 | siete | |
|
||||
30 | 16 | dieciseis | |
|
||||
31 | 8 | ocho | |
|
||||
32 | 6 | seis | xyzzyxyzzyxyzzyxyzzyxyzzyxyzzy | 500000
|
||||
(32 rows)
|
||||
|
||||
-- Verify that foreign key link still works
|
||||
@ -328,16 +328,15 @@ CLUSTER clstr_1_pkey ON clstr_1;
|
||||
CLUSTER clstr_2 USING clstr_2_pkey;
|
||||
SELECT * FROM clstr_1 UNION ALL
|
||||
SELECT * FROM clstr_2 UNION ALL
|
||||
SELECT * FROM clstr_3
|
||||
ORDER BY 1;
|
||||
SELECT * FROM clstr_3;
|
||||
a
|
||||
---
|
||||
1
|
||||
1
|
||||
2
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
1
|
||||
(6 rows)
|
||||
|
||||
-- revert to the original state
|
||||
@ -356,16 +355,15 @@ SET SESSION AUTHORIZATION clstr_user PASSWORD 'ttest@123';
|
||||
CLUSTER;
|
||||
SELECT * FROM clstr_1 UNION ALL
|
||||
SELECT * FROM clstr_2 UNION ALL
|
||||
SELECT * FROM clstr_3
|
||||
ORDER BY 1;
|
||||
SELECT * FROM clstr_3;
|
||||
a
|
||||
---
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
1
|
||||
(6 rows)
|
||||
|
||||
-- cluster a single table using the indisclustered bit previously set
|
||||
@ -373,8 +371,7 @@ DELETE FROM clstr_1;
|
||||
INSERT INTO clstr_1 VALUES (2);
|
||||
INSERT INTO clstr_1 VALUES (1);
|
||||
CLUSTER clstr_1;
|
||||
SELECT * FROM clstr_1
|
||||
ORDER BY 1;
|
||||
SELECT * FROM clstr_1;
|
||||
a
|
||||
---
|
||||
1
|
||||
@ -400,22 +397,22 @@ UPDATE clustertest SET key = 35 WHERE key = 40;
|
||||
UPDATE clustertest SET key = 60 WHERE key = 50;
|
||||
UPDATE clustertest SET key = 70 WHERE key = 60;
|
||||
UPDATE clustertest SET key = 80 WHERE key = 70;
|
||||
SELECT * FROM clustertest ORDER BY 1;
|
||||
SELECT * FROM clustertest;
|
||||
key
|
||||
-----
|
||||
20
|
||||
30
|
||||
100
|
||||
35
|
||||
80
|
||||
100
|
||||
(5 rows)
|
||||
|
||||
CLUSTER clustertest_pkey ON clustertest;
|
||||
ERROR: CLUSTER cannot run inside a transaction block
|
||||
SELECT * FROM clustertest ORDER BY 1;
|
||||
--?ERROR: current transaction is aborted, commands ignored until end of transaction block.*
|
||||
SELECT * FROM clustertest;
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block, firstChar[Q]
|
||||
COMMIT;
|
||||
SELECT * FROM clustertest ORDER BY 1;
|
||||
SELECT * FROM clustertest;
|
||||
key
|
||||
-----
|
||||
10
|
||||
@ -433,7 +430,7 @@ create temp table clstr_temp (col1 int primary key, col2 text);
|
||||
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clstr_temp_pkey" for table "clstr_temp"
|
||||
insert into clstr_temp values (2, 'two'), (1, 'one');
|
||||
cluster clstr_temp using clstr_temp_pkey;
|
||||
select * from clstr_temp order by 1;
|
||||
select * from clstr_temp;
|
||||
col1 | col2
|
||||
------+------
|
||||
1 | one
|
||||
|
||||
@ -61,14 +61,14 @@ INSERT INTO clstr_tst (b, c, d) VALUES (6, 'seis', repeat('xyzzy', 100000));
|
||||
|
||||
CLUSTER clstr_tst_c ON clstr_tst;
|
||||
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c;
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst;
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a;
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY b;
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY c;
|
||||
|
||||
-- Verify that inheritance link still works
|
||||
-- INSERT INTO clstr_tst_inh VALUES (0, 100, 'in child table');
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst ORDER BY a, b, c;
|
||||
SELECT a,b,c,substring(d for 30), length(d) from clstr_tst;
|
||||
|
||||
-- Verify that foreign key link still works
|
||||
INSERT INTO clstr_tst (b, c) VALUES (1111, 'this should fail');
|
||||
@ -126,8 +126,7 @@ CLUSTER clstr_1_pkey ON clstr_1;
|
||||
CLUSTER clstr_2 USING clstr_2_pkey;
|
||||
SELECT * FROM clstr_1 UNION ALL
|
||||
SELECT * FROM clstr_2 UNION ALL
|
||||
SELECT * FROM clstr_3
|
||||
ORDER BY 1;
|
||||
SELECT * FROM clstr_3;
|
||||
|
||||
-- revert to the original state
|
||||
DELETE FROM clstr_1;
|
||||
@ -146,16 +145,14 @@ SET SESSION AUTHORIZATION clstr_user PASSWORD 'ttest@123';
|
||||
CLUSTER;
|
||||
SELECT * FROM clstr_1 UNION ALL
|
||||
SELECT * FROM clstr_2 UNION ALL
|
||||
SELECT * FROM clstr_3
|
||||
ORDER BY 1;
|
||||
SELECT * FROM clstr_3;
|
||||
|
||||
-- cluster a single table using the indisclustered bit previously set
|
||||
DELETE FROM clstr_1;
|
||||
INSERT INTO clstr_1 VALUES (2);
|
||||
INSERT INTO clstr_1 VALUES (1);
|
||||
CLUSTER clstr_1;
|
||||
SELECT * FROM clstr_1
|
||||
ORDER BY 1;
|
||||
SELECT * FROM clstr_1;
|
||||
|
||||
-- Test MVCC-safety of cluster. There isn't much we can do to verify the
|
||||
-- results with a single backend...
|
||||
@ -182,13 +179,13 @@ UPDATE clustertest SET key = 60 WHERE key = 50;
|
||||
UPDATE clustertest SET key = 70 WHERE key = 60;
|
||||
UPDATE clustertest SET key = 80 WHERE key = 70;
|
||||
|
||||
SELECT * FROM clustertest ORDER BY 1;
|
||||
SELECT * FROM clustertest;
|
||||
CLUSTER clustertest_pkey ON clustertest;
|
||||
SELECT * FROM clustertest ORDER BY 1;
|
||||
SELECT * FROM clustertest;
|
||||
|
||||
COMMIT;
|
||||
|
||||
SELECT * FROM clustertest ORDER BY 1;
|
||||
SELECT * FROM clustertest;
|
||||
|
||||
-- check that temp tables can be clustered
|
||||
-- Enforce use of COMMIT instead of 2PC for temporary objects
|
||||
@ -198,7 +195,7 @@ SET SESSION AUTHORIZATION clstr_user PASSWORD 'ttest@123';
|
||||
create temp table clstr_temp (col1 int primary key, col2 text);
|
||||
insert into clstr_temp values (2, 'two'), (1, 'one');
|
||||
cluster clstr_temp using clstr_temp_pkey;
|
||||
select * from clstr_temp order by 1;
|
||||
select * from clstr_temp;
|
||||
drop table clstr_temp;
|
||||
|
||||
-- clean up
|
||||
|
||||
Reference in New Issue
Block a user