-- The directory entry of a write buffer that holds reference records (sift.col_wbuf_ref) is column format minor 44, so that a release that does not know the records refuses the index; a buffer -- of records that hold their values stays as it was (minor 6), and the entry is marked before the first reference is written, whether the row goes in at once or from the backend's batch of a transaction. CREATE EXTENSION pg_sift_test CASCADE; NOTICE: installing required extension "pg_sift" SET client_min_messages = warning; SET sift.async_maintenance = off; SET sift.col_auto_merge = off; SET max_parallel_workers_per_gather = 0; CREATE TABLE f (id int PRIMARY KEY, g int NOT NULL, v int) WITH (autovacuum_enabled = false); CREATE INDEX f_ix ON f USING sift_col (id, g, v); SET sift.col_wbuf_ref = off; INSERT INTO f SELECT i, i % 5, i FROM generate_series(1, 100) i; SELECT sift._test_wbuf_format('f_ix') AS values_only; values_only ------------- 6 (1 row) SET sift.col_wbuf_ref = on; INSERT INTO f SELECT i, i % 5, i FROM generate_series(101, 200) i; SELECT sift._test_wbuf_format('f_ix') AS with_references; with_references ----------------- 44 (1 row) SELECT sift.col_promote('f_ix') >= 0 AS promoted; promoted ---------- t (1 row) SELECT sift._test_wbuf_format('f_ix') AS buffer_after_the_promotion; buffer_after_the_promotion ---------------------------- 6 (1 row) SET sift.col_wbuf_ref = off; INSERT INTO f SELECT i, i % 5, i FROM generate_series(201, 300) i; SELECT sift._test_wbuf_format('f_ix') AS new_buffer_values_only; new_buffer_values_only ------------------------ 6 (1 row) -- the rows of a transaction after its first one are batched in the backend: the first one that is a reference marks the buffer all the same SELECT sift.col_promote('f_ix') >= 0 AS promoted_again; promoted_again ---------------- t (1 row) BEGIN; SET LOCAL sift.col_wbuf_ref = on; INSERT INTO f VALUES (400, 0, 0); INSERT INTO f SELECT i, i % 5, i FROM generate_series(401, 410) i; COMMIT; SELECT sift._test_wbuf_format('f_ix') AS from_a_batch; from_a_batch -------------- 44 (1 row) SELECT sift.col_verify('f_ix', true); col_verify ------------ (1 row) SELECT count(*), sum(v) FROM f; count | sum -------+------- 311 | 49205 (1 row) DROP TABLE f; DROP EXTENSION pg_sift_test; DROP EXTENSION pg_sift;