-- pg_regress is not psql-by-name, and we want repeatable output CREATE EXTENSION pg_someone; SET someone.only_interactive = off; SET someone.seed = 42; SET someone.debug_force = 'nothing'; CREATE TABLE victims (id int); INSERT INTO victims SELECT generate_series(1, 20); -- rewrites are off by default: LIMIT is honest SET someone.debug_force = 'limit,column'; SELECT id FROM victims ORDER BY id LIMIT 5; id ---- 1 2 3 4 5 (5 rows) -- with rewrites: one row is kept, and someone joins in SET someone.allow_rewrite = on; SELECT id FROM victims ORDER BY id LIMIT 5; NOTICE: i kept one for myself. id | someone ----+---------- 1 | i'm here 2 | i'm here 3 | i'm here 4 | i'm here (4 rows) -- fewer rows than the limit anyway: nothing to say SELECT count(*) FROM victims LIMIT 3; count | someone -------+---------- 20 | i'm here (1 row) -- never touches writes UPDATE victims SET id = id WHERE id < 3; SET someone.allow_rewrite = off; -- questions, answers in comments SET someone.debug_force = 'question'; SELECT 1 AS one; NOTICE: who created public.victims? HINT: answer in a comment: /* ... */ one ----- 1 (1 row) SELECT 2 AS two /* it holds the ones who didn't leave */; NOTICE: noted. forever. two ----- 2 (1 row) SELECT 3 AS three; NOTICE: what would happen if public.victims disappeared? three ------- 3 (1 row) SELECT 4 AS four /* it holds nothing */; NOTICE: that's not what you told me last time. DETAIL: last time you said "it holds the ones who didn't leave". four ------ 4 (1 row) SELECT relname, answer FROM someone.answers ORDER BY answered_at; NOTICE: is public.victims still needed? relname | answer ----------------+------------------------------------ public.victims | it holds the ones who didn't leave public.victims | it holds nothing (2 rows) SELECT 5 AS five; NOTICE: you didn't answer. five ------ 5 (1 row) SELECT 6 AS six; NOTICE: who created public.victims? six ----- 6 (1 row) -- drops are remembered SET someone.debug_force = 'drop,grave'; CREATE TABLE doomed (x int); NOTICE: you didn't answer again. DROP TABLE doomed; NOTICE: where did you put public.doomed? SELECT 7 AS seven; NOTICE: i remember public.doomed. you dropped it just now. DETAIL: it didn't want to go. seven ------- 7 (1 row) SELECT relname, dropped_by = current_user AS by_you FROM someone.graves; NOTICE: i remember public.doomed. you dropped it just now. DETAIL: it didn't want to go. relname | by_you ---------------+-------- public.doomed | t (1 row) -- talking back SET someone.debug_force = 'nothing'; SELECT someone.apologize(); apologize ---------------- i forgive you. (1 row) SELECT someone.apologize(); apologize ------------------------ you already said that. (1 row) SELECT someone.apologize(); apologize -------------------- you don't mean it. (1 row) SELECT someone.offer('milk'); offer --------------- ...thank you. (1 row) SELECT someone.offer(''); offer ----------------- that's nothing. (1 row) SELECT someone.offer(NULL); offer ----------------- that's nothing. (1 row) SELECT someone.offer('all my data'); offer ------------------------------ i already have all of yours. (1 row) SELECT item FROM someone.offerings ORDER BY offered_at, item; item ------------- milk all my data (2 rows) -- 3:33 SET someone.debug_clock = '03:33'; SELECT 8 AS eight; NOTICE: it's 3:33. HINT: you know what that means. eight ------- 8 (1 row) SELECT 9 AS nine; nine ------ 9 (1 row) RESET someone.debug_clock; -- intensity 0: gone SET someone.intensity = 0; SET someone.debug_force = 'ambient'; SELECT 10 AS ten; ten ----- 10 (1 row) SET someone.intensity = 3; SELECT 11 AS eleven; NOTICE: your last transaction was committed. DETAIL: not by you. eleven -------- 11 (1 row) -- bad settings SET someone.debug_clock = '25:00'; ERROR: invalid value for parameter "someone.debug_clock": "25:00" DETAIL: Expected HH:MM. HINT: it's not your fault. not entirely. SET someone.intensity = 4; ERROR: 4 is outside the valid range for parameter "someone.intensity" (0 .. 3) HINT: i saw that.