Sha256: c31d293955284f7efab03e5980d538e8111cd2fd169fee0ac6f9b0058e3cca02
Contents?: true
Size: 1.22 KB
Versions: 79
Compression:
Stored size: 1.22 KB
Contents
BEGIN { require("pathname") basedir = Pathname.new("(string)").expand_path.dirname.parent libdir = (basedir + "lib") $LOAD_PATH.unshift(libdir.to_s) unless $LOAD_PATH.include?(libdir.to_s) } require("cipherstash-pg") TRIGGER_TABLE = "\n\tCREATE TABLE IF NOT EXISTS test ( message text );\n" TRIGGER_FUNCTION = "\nCREATE OR REPLACE FUNCTION notify_test()\nRETURNS TRIGGER\nLANGUAGE plpgsql\nAS $$\n BEGIN\n NOTIFY woo;\n RETURN NULL;\n END\n$$\n" DROP_TRIGGER = "\nDROP TRIGGER IF EXISTS notify_trigger ON test\n" TRIGGER = "\nCREATE TRIGGER notify_trigger\nAFTER UPDATE OR INSERT OR DELETE\nON test\nFOR EACH STATEMENT\nEXECUTE PROCEDURE notify_test();\n" conn = CipherStashPG.connect(:dbname => "test") conn.exec(TRIGGER_TABLE) conn.exec(TRIGGER_FUNCTION) conn.exec(DROP_TRIGGER) conn.exec(TRIGGER) conn.exec("LISTEN woo") notifications = [] puts("Now switch to a different term and run:", "", " psql test -c \"insert into test values ('A message.')\"", "") puts("Waiting up to 30 seconds for for an event!") conn.wait_for_notify(30) { |notify, pid| (notifications << [pid, notify]) } if notifications.empty? then puts("Awww, I didn't see any events.") else puts(("I got one from pid %d: %s" % notifications.first)) end
Version data entries
79 entries across 79 versions & 1 rubygems