-- 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; -- with rewrites: one row is kept, and someone joins in SET someone.allow_rewrite = on; SELECT id FROM victims ORDER BY id LIMIT 5; -- fewer rows than the limit anyway: nothing to say SELECT count(*) FROM victims LIMIT 3; -- 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; SELECT 2 AS two /* it holds the ones who didn't leave */; SELECT 3 AS three; SELECT 4 AS four /* it holds nothing */; SELECT relname, answer FROM someone.answers ORDER BY answered_at; SELECT 5 AS five; SELECT 6 AS six; -- drops are remembered SET someone.debug_force = 'drop,grave'; CREATE TABLE doomed (x int); DROP TABLE doomed; SELECT 7 AS seven; SELECT relname, dropped_by = current_user AS by_you FROM someone.graves; -- talking back SET someone.debug_force = 'nothing'; SELECT someone.apologize(); SELECT someone.apologize(); SELECT someone.apologize(); SELECT someone.offer('milk'); SELECT someone.offer(''); SELECT someone.offer(NULL); SELECT someone.offer('all my data'); SELECT item FROM someone.offerings ORDER BY offered_at, item; -- 3:33 SET someone.debug_clock = '03:33'; SELECT 8 AS eight; SELECT 9 AS nine; RESET someone.debug_clock; -- intensity 0: gone SET someone.intensity = 0; SET someone.debug_force = 'ambient'; SELECT 10 AS ten; SET someone.intensity = 3; SELECT 11 AS eleven; -- bad settings SET someone.debug_clock = '25:00'; SET someone.intensity = 4;