-
+
PL/Python - Python Procedural Language
The global dictionary SD is available to store data between
function calls. This variable is private static data. The global
dictionary GD is public data, available to all python functions
- within a backend. Use with care. When the function is used in a
- trigger, the triggers tuples are in TD["new"] and/or TD["old"]
- depending on the trigger event. Return 'None' or "OK" from the
- python function to indicate the tuple is unmodified, "SKIP" to
- abort the event, or "MODIFIED" to indicate you've modified the
- tuple. If the trigger was called with arguments they are available
- in TD["args"][0] to TD["args"][(n -1)].
+ within a backend. Use with care.
dictionary, as mentioned above.
+
+ When a function is used in a trigger, the dictionary TD contains
+ transaction related values. The trigger tuples are in TD["new"]
+ and/or TD["old"] depending on the trigger event. TD["event"]
+ contains the event as a string ("INSERT", "UPDATE", "DELETE", or
+ "UNKNOWN"). TD["when"] contains one of ("BEFORE", "AFTER", or
+ "UNKNOWN"). TD["level"] contains one of ("ROW", "STATEMENT", or
+ "UNKNOWN"). TD["name"] contains the trigger name, and TD["relid"]
+ contains the relation id of the table on which the trigger occurred.
+ If the trigger was called with arguments they are available
+ in TD["args"][0] to TD["args"][(n -1)]
+
+
+ If the trigger 'when' is "BEFORE", you may Return 'None' or "OK"
+ from the python function to indicate the tuple is unmodified,
+ "SKIP" to abort the event, or "MODIFIED" to indicate you've
+ modified the tuple.
+
+
The PL/Python language module automatically imports a Python module
called plpy. The functions and constants in