-- 0.18.0: brief() hands what still holds, best first, inside a budget; never what was replaced, refuted or -- expired; the text with the caller's rights. \set VERBOSITY terse CREATE EXTENSION pg_phasevec VERSION $v$0.17.0$v$; ALTER EXTENSION pg_phasevec UPDATE TO $v$0.18.0$v$; SELECT extversion FROM pg_extension WHERE extname = $e$pg_phasevec$e$; extversion ------------ 0.18.0 (1 row) SELECT phasevec.reader_register($n$r1$n$, repeat($h$a$h$, 64), 4) > 0 AS r1; r1 ---- t (1 row) CREATE TABLE work (id int PRIMARY KEY, body text); INSERT INTO work VALUES (1, $t$open: fix the planner regression$t$), (2, $t$closed: the planner regression was fixed in 4a1b$t$), (3, $t$open: its proof still holds$t$), (4, $t$open: its proof says it is done$t$), (5, $t$open: nobody touched it for a month$t$), (6, repeat($t$a long note $t$, 20)), (7, $t$open: plain, nothing said$t$); SELECT phasevec.watch($w$work$w$, $w$work$w$::regclass, $k$id$k$, $r$r.body$r$, $n$r1$n$) > 0 AS watch; watch ------- t (1 row) -- control: nothing said about truth, everything comes out SELECT count(*) AS all_served FROM phasevec.brief($w$work$w$); all_served ------------ 7 (1 row) SELECT phasevec.supersede($w$work$w$, $k$1$k$, $k$2$k$, $m$closed$m$); supersede ----------- (1 row) SELECT phasevec.assert($w$work$w$, $k$3$k$, $p$SELECT true$p$); assert -------- (1 row) SELECT phasevec.assert($w$work$w$, $k$4$k$, $p$SELECT false$p$); assert -------- (1 row) SELECT phasevec.assert($w$work$w$, $k$5$k$, p_expires_at => now() - interval $i$1 day$i$); assert -------- (1 row) SELECT key, verdict FROM phasevec.verify($w$work$w$) ORDER BY key; key | verdict -----+---------- 3 | verified 4 | refuted (2 rows) SELECT phasevec.note_use($w$work$w$, $k$2$k$, 1::smallint), phasevec.note_use($w$work$w$, $k$2$k$, 1::smallint); note_use | note_use ----------+---------- | (1 row) -- served: verified first, then the useful one, then the rest; never 1 (replaced), 4 (refuted), 5 (expired) SELECT key, verdict, net_use, left(line, 40) AS line FROM phasevec.brief($w$work$w$); key | verdict | net_use | line -----+----------+---------+------------------------------------------ 3 | verified | 0 | open: its proof still holds 2 | unproven | 2 | closed: the planner regression was fixed 6 | unproven | 0 | a long note a long note a long note a lo 7 | unproven | 0 | open: plain, nothing said (4 rows) -- the budget: the long note does not fit, the short ones after it still do SELECT string_agg(key, $s$,$s$) AS keys, sum(length(line)) AS chars FROM phasevec.brief($w$work$w$, 120); keys | chars -------+------- 3,2,7 | 100 (1 row) -- the text is read with the caller's rights CREATE ROLE brief_stranger; GRANT USAGE ON SCHEMA phasevec TO brief_stranger; -- as any user of the extension SET ROLE brief_stranger; SELECT count(*) FROM phasevec.brief($w$work$w$); ERROR: permission denied for table work RESET ROLE; GRANT SELECT ON work TO brief_stranger; SET ROLE brief_stranger; SELECT count(*) AS served_to_a_reader FROM phasevec.brief($w$work$w$); served_to_a_reader -------------------- 4 (1 row) RESET ROLE; DROP OWNED BY brief_stranger; DROP ROLE brief_stranger; -- a brief needs a budget SELECT * FROM phasevec.brief($w$work$w$, 0); ERROR: phasevec: a brief needs a positive budget DROP TABLE work; DROP EXTENSION pg_phasevec;