-- 0.1.0 -> 0.2.0 with live data: the counts 0.2.0 keeps must start equal to a full recount of what -- 0.1.0 left, in every state. \set VERBOSITY terse CREATE EXTENSION pg_phasevec VERSION '0.1.0'; SELECT phasevec.reader_register('u1', repeat('1', 64), 4) > 0 AS u1; u1 ---- t (1 row) SELECT phasevec.reader_register('u2', repeat('2', 64), 4) > 0 AS u2; u2 ---- t (1 row) CREATE TABLE up (id int PRIMARY KEY, body text); INSERT INTO up SELECT g, 'row ' || g FROM generate_series(1, 10) g; SELECT phasevec.watch('up', 'up'::regclass, 'id', 'r.body', 'u1') > 0 AS watch; watch ------- t (1 row) -- rows 1-6 read; 7-10 pending SELECT count(phasevec.record('up', n.key, 'u1', n.text_hash, n.key::bigint, ARRAY[1,2,3,4]::smallint[])) FROM phasevec.next('up', 6) n; count ------- 6 (1 row) -- 1 stale, 2 failed, 3 orphan (row deleted after reading) UPDATE up SET body = 'changed' WHERE id = 1; SELECT phasevec.record_failure('up', '2', 'u1', (SELECT text_hash FROM phasevec.sources WHERE key = '2'), 'no tokens'); record_failure ---------------- (1 row) DELETE FROM up WHERE id = 3; SELECT state, n FROM phasevec.coverage('up') WHERE n > 0; state | n ---------+--- fresh | 3 stale | 1 pending | 4 failed | 1 orphan | 1 (5 rows) ALTER EXTENSION pg_phasevec UPDATE TO '0.2.0'; SELECT extversion FROM pg_extension WHERE extname = 'pg_phasevec'; extversion ------------ 0.2.0 (1 row) -- the counts kept by 0.2.0 equal the recount of the tables SELECT state, n FROM phasevec.coverage('up') WHERE n > 0; state | n ---------+--- fresh | 3 stale | 1 pending | 4 failed | 1 orphan | 1 (5 rows) SELECT count(*) AS mismatches FROM phasevec.coverage_check('up'); mismatches ------------ 0 (1 row) -- and they keep agreeing after changes made under 0.2.0, a reader switch included UPDATE up SET body = 'changed again' WHERE id = 4; SELECT phasevec.reader_switch('up', 'u2'); reader_switch --------------- (1 row) SELECT count(*) AS mismatches FROM phasevec.coverage_check('up'); mismatches ------------ 0 (1 row) SELECT state, n FROM phasevec.coverage('up') WHERE n > 0; state | n ---------+--- pending | 9 foreign | 6 (2 rows) -- 0.2.0 -> 0.3.0: the queue now comes from kstate; it hands out the same rows the 0.2.0 one did SELECT count(*) AS to_read_020 FROM phasevec.next('up', 100); to_read_020 ------------- 9 (1 row) ALTER EXTENSION pg_phasevec UPDATE TO '0.3.0'; SELECT extversion FROM pg_extension WHERE extname = 'pg_phasevec'; extversion ------------ 0.3.0 (1 row) SELECT count(*) AS to_read_030 FROM phasevec.next('up', 100); to_read_030 ------------- 9 (1 row) SELECT count(*) AS mismatches FROM phasevec.coverage_check('up'); mismatches ------------ 0 (1 row) DROP TABLE up; DROP EXTENSION pg_phasevec;