From dabe9f8196eeacf708d1dcf227efd96bcf9cbce0 Mon Sep 17 00:00:00 2001 From: shihao zhong Date: Mon, 5 Oct 2026 00:18:57 -0400 Subject: [PATCH v1 2/2] Test dropped-column values in inserts replayed by REPACK Add a concurrent INSERT to repack_dropped. A BEFORE INSERT trigger makes the new row a copy of an existing one, so it carries the value of the dropped column. Discussion: https://postgr.es/m/CAJgoLkK2UBzB1J9buCsSUbjf7bOqz-o_0=CeiTruU789BhBw-Q@mail.gmail.com --- .../injection_points/expected/repack_dropped.out | 8 ++++++-- .../injection_points/specs/repack_dropped.spec | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/test/modules/injection_points/expected/repack_dropped.out b/src/test/modules/injection_points/expected/repack_dropped.out index 8aaab73aebb..4186ce4981c 100644 --- a/src/test/modules/injection_points/expected/repack_dropped.out +++ b/src/test/modules/injection_points/expected/repack_dropped.out @@ -1,6 +1,6 @@ Parsed test spec with 3 sessions -starting permutation: s1_size s2_repack s3_updates s1_unlock s2_noop s1_size +starting permutation: s1_size s2_repack s3_updates s3_insert s1_unlock s2_noop s1_size injection_points_attach ----------------------- @@ -23,6 +23,9 @@ step s2_repack: step s3_updates: UPDATE repack_dropped SET a = a || a; +step s3_insert: + INSERT INTO repack_dropped (id, a) VALUES (3, 'three'); + step s1_unlock: SELECT injection_points_wakeup('repack-concurrently-before-lock'); @@ -43,5 +46,6 @@ id|fits_in_one_block --+----------------- 1|t 2|t -(2 rows) + 3|t +(3 rows) diff --git a/src/test/modules/injection_points/specs/repack_dropped.spec b/src/test/modules/injection_points/specs/repack_dropped.spec index 099cf744202..57700968032 100644 --- a/src/test/modules/injection_points/specs/repack_dropped.spec +++ b/src/test/modules/injection_points/specs/repack_dropped.spec @@ -13,11 +13,18 @@ setup { INSERT INTO repack_dropped (id, a, b) VALUES (2, 'two', repeat(encode(sha256('2'), 'hex'), current_setting('block_size')::int / 32)); CREATE FUNCTION repack_dropped_f() RETURNS trigger LANGUAGE plpgsql AS - $$ BEGIN + $$ DECLARE r repack_dropped; + BEGIN + IF TG_OP = 'INSERT' THEN + r := (SELECT t FROM repack_dropped t WHERE id = 1); + r.id := NEW.id; + RETURN r; + END IF; IF NEW.id = 1 THEN return OLD; END IF; RETURN NEW; END $$; CREATE TRIGGER repack_dropped_t BEFORE UPDATE ON repack_dropped FOR EACH ROW EXECUTE FUNCTION repack_dropped_f(); + CREATE TRIGGER repack_dropped_ins_t BEFORE INSERT ON repack_dropped FOR EACH ROW EXECUTE FUNCTION repack_dropped_f(); ALTER TABLE repack_dropped DROP COLUMN b; } @@ -62,10 +69,17 @@ step s3_updates UPDATE repack_dropped SET a = a || a; } +# The trigger makes tuple 3 a copy of tuple 1, dropped column included. +step s3_insert +{ + INSERT INTO repack_dropped (id, a) VALUES (3, 'three'); +} + permutation s1_size s2_repack s3_updates + s3_insert s1_unlock s2_noop s1_size -- 2.37.1 (Apple Git-137.1)