From 0a269db9cf823de737049967a0c03ca82b9abce1 Mon Sep 17 00:00:00 2001
From: Andrew Dunstan <andrew@dunslane.net>
Date: Fri, 26 May 2006 19:23:09 +0000
Subject: Add table_name and table_schema to plpython trigger data, plus docs
 and regression test.

---
 src/pl/plpython/sql/plpython_function.sql | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

(limited to 'src/pl/plpython/sql/plpython_function.sql')

diff --git a/src/pl/plpython/sql/plpython_function.sql b/src/pl/plpython/sql/plpython_function.sql
index c5920685d96..73b1a654055 100644
--- a/src/pl/plpython/sql/plpython_function.sql
+++ b/src/pl/plpython/sql/plpython_function.sql
@@ -140,6 +140,37 @@ CREATE TRIGGER users_delete_trig BEFORE DELETE ON users FOR EACH ROW
 	EXECUTE PROCEDURE users_delete ('willem');
 
 
+
+-- dump trigger data
+
+CREATE TABLE trigger_test
+	(i int, v text );
+
+CREATE FUNCTION trigger_data() returns trigger language plpythonu as $$
+
+if TD.has_key('relid'):
+	TD['relid'] = "bogus:12345"
+
+for key in sorted(TD.keys()):
+	val = TD[key]
+	plpy.notice("TD[" + key + "] => " + str(val))
+
+return None  
+
+$$;
+
+CREATE TRIGGER show_trigger_data_trig 
+BEFORE INSERT OR UPDATE OR DELETE ON trigger_test
+FOR EACH ROW EXECUTE PROCEDURE trigger_data(23,'skidoo');
+
+insert into trigger_test values(1,'insert');
+update trigger_test set v = 'update' where i = 1;
+delete from trigger_test;
+      
+DROP TRIGGER show_trigger_data_trig on trigger_test;
+      
+DROP FUNCTION trigger_data();
+
 -- nested calls
 --
 
-- 
cgit v1.2.3

