-- 0.19.0 -> 0.20.0 on a database in use: verdicts reached the old way are not carried over as verified, proofs -- wait for an author, grants the DBA gave are kept, PUBLIC loses the internals, and the dump marks do not change. \set VERBOSITY terse CREATE EXTENSION pg_phasevec VERSION $v$0.19.0$v$; SELECT phasevec.reader_register($n$r1$n$, repeat($h$a$h$, 64), 4) > 0 AS r1; r1 ---- t (1 row) CREATE TABLE notes (id int PRIMARY KEY, body text); INSERT INTO notes VALUES (1, $t$holds$t$), (2, $t$does not hold$t$), (3, $t$replaced$t$), (4, $t$plain$t$); SELECT phasevec.watch($w$notes$w$, $w$notes$w$::regclass, $k$id$k$, $r$r.body$r$, $n$r1$n$) > 0 AS watch; watch ------- t (1 row) SELECT phasevec.assert($w$notes$w$, $k$1$k$, $p$SELECT true$p$); assert -------- (1 row) SELECT phasevec.assert($w$notes$w$, $k$2$k$, $p$SELECT false$p$); assert -------- (1 row) SELECT phasevec.supersede($w$notes$w$, $k$3$k$, $k$4$k$, $m$newer$m$); supersede ----------- (1 row) SELECT key, verdict FROM phasevec.verify($w$notes$w$) ORDER BY key; key | verdict -----+---------- 1 | verified 2 | refuted (2 rows) CREATE ROLE pv_up_asker; GRANT USAGE ON SCHEMA phasevec TO pv_up_asker; GRANT EXECUTE ON FUNCTION phasevec.assert(text, text, text, text, jsonb, timestamptz) TO pv_up_asker; GRANT SELECT ON notes TO pv_up_asker; ALTER EXTENSION pg_phasevec UPDATE TO $v$0.20.0$v$; SELECT extversion FROM pg_extension WHERE extname = $e$pg_phasevec$e$; extversion ------------ 0.20.0 (1 row) -- the verified key is unproven, with the reason; the refuted one stays refuted, about its text as it is now SELECT key, verdict, asserted_by, asserted_for IS NOT NULL AS about_text, last_error FROM phasevec.truth ORDER BY key; key | verdict | asserted_by | about_text | last_error -----+----------+-------------+------------+---------------------------------------------------------------------- 1 | unproven | | f | verified before 0.20.0, with the verifier's rights: not carried over 2 | refuted | | t | 3 | replaced | | f | (3 rows) -- proofs without an author do not run SELECT count(*) AS run FROM phasevec.verify($w$notes$w$, p_every => interval $i$0$i$); run ----- 0 (1 row) SELECT phasevec.verify_one($w$notes$w$, $k$1$k$); ERROR: phasevec: the proof of key 1 has no author (asserted before 0.20.0): assert it again -- naming an author by hand is not enough: a claim is also the text its author read UPDATE phasevec.truth SET asserted_by = current_user WHERE asserted_by IS NULL AND proof IS NOT NULL; SELECT count(*) AS run FROM phasevec.verify($w$notes$w$, p_every => interval $i$0$i$); run ----- 0 (1 row) -- adopt() names their author; granted, the author adopts them itself (every proof comes back); then they run as -- it, bound GRANT EXECUTE ON FUNCTION phasevec.adopt(text, regrole, text[], text[]) TO pv_up_asker; -- (twenty-sixth review) adopting changes claims: the table's owner names the author a steward SELECT phasevec.steward($w$notes$w$, $r$pv_up_asker$r$); steward --------- t (1 row) SET ROLE pv_up_asker; SELECT key, proof, adopted, note FROM phasevec.adopt($w$notes$w$, $r$pv_up_asker$r$) ORDER BY key; key | proof | adopted | note -----+--------------+---------+--------- 1 | SELECT true | t | adopted 2 | SELECT false | t | adopted (2 rows) RESET ROLE; SELECT key, verdict FROM phasevec.verify($w$notes$w$, p_every => interval $i$0$i$) ORDER BY key; key | verdict -----+---------- 1 | verified 2 | refuted (2 rows) SELECT key, verdict, asserted_by, verified_for IS NOT NULL AS bound FROM phasevec.truth ORDER BY key; key | verdict | asserted_by | bound -----+----------+-------------+------- 1 | verified | pv_up_asker | t 2 | refuted | pv_up_asker | t 3 | replaced | | f (3 rows) -- the grant on assert() survives its new body; the internals are closed to PUBLIC SELECT has_function_privilege($r$pv_up_asker$r$, $f$phasevec.assert(text, text, text, text, jsonb, timestamptz)$f$, $x$EXECUTE$x$) AS asker_asserts, has_function_privilege($r$public$r$, $f$phasevec.assert(text, text, text, text, jsonb, timestamptz)$f$, $x$EXECUTE$x$) AS public_asserts, has_function_privilege($r$public$r$, $f$phasevec._forget(int, text)$f$, $x$EXECUTE$x$) AS public_forget, has_function_privilege($r$public$r$, $f$phasevec._brief_keys(text)$f$, $x$EXECUTE$x$) AS public_brief_keys; asker_asserts | public_asserts | public_forget | public_brief_keys ---------------+----------------+---------------+------------------- t | f | f | f (1 row) SET ROLE pv_up_asker; SELECT phasevec.assert($w$notes$w$, $k$4$k$, $p$SELECT true$p$); assert -------- (1 row) RESET ROLE; SELECT key, asserted_by FROM phasevec.truth WHERE key = $k$4$k$; key | asserted_by -----+------------- 4 | pv_up_asker (1 row) -- the watch trigger installed by 0.19.0 still notes and forgets UPDATE notes SET body = $t$holds, said again$t$ WHERE id = 1; SELECT t.key, phasevec._verdict(t) AS verdict FROM phasevec.truth t WHERE t.key = $k$1$k$; key | verdict -----+---------- 1 | unproven (1 row) DELETE FROM notes WHERE id = 2; SELECT key FROM phasevec.sources ORDER BY key; key ----- 1 3 4 (3 rows) -- pg_dump still carries the same tables (the new columns travel with phasevec.truth) SELECT array_length(extconfig, 1) AS marked FROM pg_extension WHERE extname = $e$pg_phasevec$e$; marked -------- 20 (1 row) DROP TABLE notes; DROP EXTENSION pg_phasevec; DROP OWNED BY pv_up_asker; DROP ROLE pv_up_asker;