diff options
| author | Tom Lane | 2007-04-08 01:26:33 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-04-08 01:26:33 +0000 |
| commit | 7b78474da35604152805b2fdd939326e1bc364da (patch) | |
| tree | 6d8d52106c1b10a596f761344b1cfa683a227b0e /src/test | |
| parent | 2fca2c05e7d22dfa1dd2cacf048243adfdf519ce (diff) | |
Make CLUSTER MVCC-safe. Heikki Linnakangas
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/cluster.out | 52 | ||||
| -rw-r--r-- | src/test/regress/sql/cluster.sql | 34 |
2 files changed, 86 insertions, 0 deletions
diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index a9fca4d8fea..0eb83369fbb 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -382,8 +382,60 @@ SELECT * FROM clstr_1; 2 (2 rows) +-- Test MVCC-safety of cluster. There isn't much we can do to verify the +-- results with a single backend... +CREATE TABLE clustertest (key int PRIMARY KEY); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "clustertest_pkey" for table "clustertest" +INSERT INTO clustertest VALUES (10); +INSERT INTO clustertest VALUES (20); +INSERT INTO clustertest VALUES (30); +INSERT INTO clustertest VALUES (40); +INSERT INTO clustertest VALUES (50); +-- Use a transaction so that updates are not committed when CLUSTER sees 'em +BEGIN; +-- Test update where the old row version is found first in the scan +UPDATE clustertest SET key = 100 WHERE key = 10; +-- Test update where the new row version is found first in the scan +UPDATE clustertest SET key = 35 WHERE key = 40; +-- Test longer update chain +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; + key +----- + 20 + 30 + 100 + 35 + 80 +(5 rows) + +CLUSTER clustertest_pkey ON clustertest; +SELECT * FROM clustertest; + key +----- + 20 + 30 + 35 + 80 + 100 +(5 rows) + +COMMIT; +SELECT * FROM clustertest; + key +----- + 20 + 30 + 35 + 80 + 100 +(5 rows) + -- clean up \c - +DROP TABLE clustertest; DROP TABLE clstr_1; DROP TABLE clstr_2; DROP TABLE clstr_3; diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 81a52c23dfa..8f4fc58912b 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -153,8 +153,42 @@ INSERT INTO clstr_1 VALUES (1); CLUSTER clstr_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... + +CREATE TABLE clustertest (key int PRIMARY KEY); + +INSERT INTO clustertest VALUES (10); +INSERT INTO clustertest VALUES (20); +INSERT INTO clustertest VALUES (30); +INSERT INTO clustertest VALUES (40); +INSERT INTO clustertest VALUES (50); + +-- Use a transaction so that updates are not committed when CLUSTER sees 'em +BEGIN; + +-- Test update where the old row version is found first in the scan +UPDATE clustertest SET key = 100 WHERE key = 10; + +-- Test update where the new row version is found first in the scan +UPDATE clustertest SET key = 35 WHERE key = 40; + +-- Test longer update chain +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; +CLUSTER clustertest_pkey ON clustertest; +SELECT * FROM clustertest; + +COMMIT; + +SELECT * FROM clustertest; + -- clean up \c - +DROP TABLE clustertest; DROP TABLE clstr_1; DROP TABLE clstr_2; DROP TABLE clstr_3; |
