diff options
| author | Tom Lane | 2007-02-09 03:35:35 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-02-09 03:35:35 +0000 |
| commit | c398300330cb3060d50652800dbd12729ab9f5ef (patch) | |
| tree | 53d16880d6a38ffe3f6ddd125d644e1e984d14d1 /src/test | |
| parent | acb3416686d44885b6f7d40daacb8e4c1a28e366 (diff) | |
Combine cmin and cmax fields of HeapTupleHeaders into a single field, by
keeping private state in each backend that has inserted and deleted the same
tuple during its current top-level transaction. This is sufficient since
there is no need to be able to determine the cmin/cmax from any other
transaction. This gets us back down to 23-byte headers, removing a penalty
paid in 8.0 to support subtransactions. Patch by Heikki Linnakangas, with
minor revisions by moi, following a design hashed out awhile back on the
pghackers list.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/combocid.out | 242 | ||||
| -rw-r--r-- | src/test/regress/expected/without_oid.out | 7 | ||||
| -rw-r--r-- | src/test/regress/parallel_schedule | 4 | ||||
| -rw-r--r-- | src/test/regress/serial_schedule | 3 | ||||
| -rw-r--r-- | src/test/regress/sql/combocid.sql | 93 | ||||
| -rw-r--r-- | src/test/regress/sql/without_oid.sql | 7 |
6 files changed, 347 insertions, 9 deletions
diff --git a/src/test/regress/expected/combocid.out b/src/test/regress/expected/combocid.out new file mode 100644 index 00000000000..14e45fe4893 --- /dev/null +++ b/src/test/regress/expected/combocid.out @@ -0,0 +1,242 @@ +-- +-- Tests for some likely failure cases with combo cmin/cmax mechanism +-- +CREATE TEMP TABLE combocidtest (foobar int); +BEGIN; +-- a few dummy ops to push up the CommandId counter +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +INSERT INTO combocidtest VALUES (1); +INSERT INTO combocidtest VALUES (2); +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 10 | 1 + (0,2) | 11 | 2 +(2 rows) + +SAVEPOINT s1; +UPDATE combocidtest SET foobar = foobar + 10; +-- here we should see only updated tuples +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,3) | 13 | 11 + (0,4) | 13 | 12 +(2 rows) + +ROLLBACK TO s1; +-- now we should see old tuples, but with combo CIDs starting at 0 +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 0 | 1 + (0,2) | 1 | 2 +(2 rows) + +COMMIT; +-- combo data is not there anymore, but should still see tuples +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 0 | 1 + (0,2) | 1 | 2 +(2 rows) + +-- Test combo cids with portals +BEGIN; +INSERT INTO combocidtest VALUES (333); +DECLARE c CURSOR FOR SELECT ctid,cmin,* FROM combocidtest; +DELETE FROM combocidtest; +FETCH ALL FROM c; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 2 | 1 + (0,2) | 2 | 2 + (0,5) | 0 | 333 +(3 rows) + +ROLLBACK; +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 2 | 1 + (0,2) | 2 | 2 +(2 rows) + +-- check behavior with locked tuples +BEGIN; +-- a few dummy ops to push up the CommandId counter +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +INSERT INTO combocidtest VALUES (444); +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 2 | 1 + (0,2) | 2 | 2 + (0,6) | 10 | 444 +(3 rows) + +SAVEPOINT s1; +-- this doesn't affect cmin +SELECT ctid,cmin,* FROM combocidtest FOR UPDATE; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 2 | 1 + (0,2) | 2 | 2 + (0,6) | 10 | 444 +(3 rows) + +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 2 | 1 + (0,2) | 2 | 2 + (0,6) | 10 | 444 +(3 rows) + +-- but this does +UPDATE combocidtest SET foobar = foobar + 10; +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,7) | 14 | 11 + (0,8) | 14 | 12 + (0,9) | 14 | 454 +(3 rows) + +ROLLBACK TO s1; +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 14 | 1 + (0,2) | 14 | 2 + (0,6) | 0 | 444 +(3 rows) + +COMMIT; +SELECT ctid,cmin,* FROM combocidtest; + ctid | cmin | foobar +-------+------+-------- + (0,1) | 14 | 1 + (0,2) | 14 | 2 + (0,6) | 0 | 444 +(3 rows) + diff --git a/src/test/regress/expected/without_oid.out b/src/test/regress/expected/without_oid.out index c32daf815d6..cb2c0c01371 100644 --- a/src/test/regress/expected/without_oid.out +++ b/src/test/regress/expected/without_oid.out @@ -5,14 +5,15 @@ -- This test tries to verify that WITHOUT OIDS actually saves space. -- On machines where MAXALIGN is 8, WITHOUT OIDS may or may not save any -- space, depending on the size of the tuple header + null bitmap. --- As of 8.0 we need a 9-bit null bitmap to force the difference to appear. +-- As of 8.3 we need a null bitmap of 8 or less bits for the difference +-- to appear. -- CREATE TABLE wi (i INT, n1 int, n2 int, n3 int, n4 int, - n5 int, n6 int, n7 int, n8 int) WITH OIDS; + n5 int, n6 int, n7 int) WITH OIDS; CREATE TABLE wo (i INT, n1 int, n2 int, n3 int, n4 int, - n5 int, n6 int, n7 int, n8 int) WITHOUT OIDS; + n5 int, n6 int, n7 int) WITHOUT OIDS; INSERT INTO wi VALUES (1); -- 1 INSERT INTO wo SELECT i FROM wi; -- 1 INSERT INTO wo SELECT i+1 FROM wi; -- 1+1=2 diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index efc1f1fef6e..096d2c1c7a7 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -1,6 +1,6 @@ # ---------- # The first group of parallel test -# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.38 2007/01/28 16:16:54 neilc Exp $ +# $PostgreSQL: pgsql/src/test/regress/parallel_schedule,v 1.39 2007/02/09 03:35:35 tgl Exp $ # ---------- test: boolean char name varchar text int2 int4 int8 oid float4 float8 bit numeric uuid @@ -69,7 +69,7 @@ test: misc # ---------- # The fifth group of parallel test # ---------- -test: select_views portals_p2 rules foreign_key cluster dependency guc +test: select_views portals_p2 rules foreign_key cluster dependency guc combocid # ---------- # The sixth group of parallel test diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule index 75e8b83138b..d109dabdc25 100644 --- a/src/test/regress/serial_schedule +++ b/src/test/regress/serial_schedule @@ -1,4 +1,4 @@ -# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.36 2007/01/28 16:16:54 neilc Exp $ +# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.37 2007/02/09 03:35:35 tgl Exp $ # This should probably be in an order similar to parallel_schedule. test: boolean test: char @@ -88,6 +88,7 @@ test: foreign_key test: cluster test: dependency test: guc +test: combocid test: limit test: plpgsql test: copy2 diff --git a/src/test/regress/sql/combocid.sql b/src/test/regress/sql/combocid.sql new file mode 100644 index 00000000000..3f30839b1f6 --- /dev/null +++ b/src/test/regress/sql/combocid.sql @@ -0,0 +1,93 @@ +-- +-- Tests for some likely failure cases with combo cmin/cmax mechanism +-- +CREATE TEMP TABLE combocidtest (foobar int); + +BEGIN; + +-- a few dummy ops to push up the CommandId counter +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; + +INSERT INTO combocidtest VALUES (1); +INSERT INTO combocidtest VALUES (2); + +SELECT ctid,cmin,* FROM combocidtest; + +SAVEPOINT s1; + +UPDATE combocidtest SET foobar = foobar + 10; + +-- here we should see only updated tuples +SELECT ctid,cmin,* FROM combocidtest; + +ROLLBACK TO s1; + +-- now we should see old tuples, but with combo CIDs starting at 0 +SELECT ctid,cmin,* FROM combocidtest; + +COMMIT; + +-- combo data is not there anymore, but should still see tuples +SELECT ctid,cmin,* FROM combocidtest; + +-- Test combo cids with portals +BEGIN; + +INSERT INTO combocidtest VALUES (333); + +DECLARE c CURSOR FOR SELECT ctid,cmin,* FROM combocidtest; + +DELETE FROM combocidtest; + +FETCH ALL FROM c; + +ROLLBACK; + +SELECT ctid,cmin,* FROM combocidtest; + +-- check behavior with locked tuples +BEGIN; + +-- a few dummy ops to push up the CommandId counter +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; +SELECT 1; + +INSERT INTO combocidtest VALUES (444); + +SELECT ctid,cmin,* FROM combocidtest; + +SAVEPOINT s1; + +-- this doesn't affect cmin +SELECT ctid,cmin,* FROM combocidtest FOR UPDATE; +SELECT ctid,cmin,* FROM combocidtest; + +-- but this does +UPDATE combocidtest SET foobar = foobar + 10; + +SELECT ctid,cmin,* FROM combocidtest; + +ROLLBACK TO s1; + +SELECT ctid,cmin,* FROM combocidtest; + +COMMIT; + +SELECT ctid,cmin,* FROM combocidtest; diff --git a/src/test/regress/sql/without_oid.sql b/src/test/regress/sql/without_oid.sql index 1a10a8533df..9fbb454d4dc 100644 --- a/src/test/regress/sql/without_oid.sql +++ b/src/test/regress/sql/without_oid.sql @@ -6,14 +6,15 @@ -- This test tries to verify that WITHOUT OIDS actually saves space. -- On machines where MAXALIGN is 8, WITHOUT OIDS may or may not save any -- space, depending on the size of the tuple header + null bitmap. --- As of 8.0 we need a 9-bit null bitmap to force the difference to appear. +-- As of 8.3 we need a null bitmap of 8 or less bits for the difference +-- to appear. -- CREATE TABLE wi (i INT, n1 int, n2 int, n3 int, n4 int, - n5 int, n6 int, n7 int, n8 int) WITH OIDS; + n5 int, n6 int, n7 int) WITH OIDS; CREATE TABLE wo (i INT, n1 int, n2 int, n3 int, n4 int, - n5 int, n6 int, n7 int, n8 int) WITHOUT OIDS; + n5 int, n6 int, n7 int) WITHOUT OIDS; INSERT INTO wi VALUES (1); -- 1 INSERT INTO wo SELECT i FROM wi; -- 1 |
