mirror of
https://github.com/postgres/postgres.git
synced 2026-02-13 07:43:11 -05:00
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.
93 lines
1.6 KiB
PL/PgSQL
93 lines
1.6 KiB
PL/PgSQL
--
|
|
-- 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;
|