1
- <!-- $Header: /cvsroot/pgsql/doc/src/sgml/plpython.sgml,v 1.2 2001/09/10 21 :58:47 petere Exp $ -->
1
+ <!-- $Header: /cvsroot/pgsql/doc/src/sgml/plpython.sgml,v 1.3 2001/09/12 03 :58:15 momjian Exp $ -->
2
2
3
3
<chapter id="plpython">
4
4
<title>PL/Python - Python Procedural Language</title>
@@ -58,13 +58,7 @@ def __plpython_procedure_myfunc_23456():
58
58
The global dictionary SD is available to store data between
59
59
function calls. This variable is private static data. The global
60
60
dictionary GD is public data, available to all python functions
61
- within a backend. Use with care. When the function is used in a
62
- trigger, the triggers tuples are in <literal>TD["new"]</literal> and/or <literal>TD["old"]</literal>
63
- depending on the trigger event. Return 'None' or "OK" from the
64
- python function to indicate the tuple is unmodified, "SKIP" to
65
- abort the event, or "MODIFIED" to indicate you've modified the
66
- tuple. If the trigger was called with arguments they are available
67
- in <literal>TD["args"][0] to TD["args"][(n -1)]</literal>.
61
+ within a backend. Use with care.
68
62
</para>
69
63
70
64
<para>
@@ -75,6 +69,26 @@ def __plpython_procedure_myfunc_23456():
75
69
dictionary, as mentioned above.
76
70
</para>
77
71
72
+ </para>
73
+ When a function is used in a trigger, the dictionary TD contains
74
+ transaction related values. The trigger tuples are in TD["new"]
75
+ and/or TD["old"] depending on the trigger event. TD["event"]
76
+ contains the event as a string ("INSERT", "UPDATE", "DELETE", or
77
+ "UNKNOWN"). TD["when"] contains one of ("BEFORE", "AFTER", or
78
+ "UNKNOWN"). TD["level"] contains one of ("ROW", "STATEMENT", or
79
+ "UNKNOWN"). TD["name"] contains the trigger name, and TD["relid"]
80
+ contains the relation id of the table on which the trigger occurred.
81
+ If the trigger was called with arguments they are available
82
+ in TD["args"][0] to TD["args"][(n -1)]
83
+ </para>
84
+
85
+ <para>
86
+ If the trigger 'when' is "BEFORE", you may Return 'None' or "OK"
87
+ from the python function to indicate the tuple is unmodified,
88
+ "SKIP" to abort the event, or "MODIFIED" to indicate you've
89
+ modified the tuple.
90
+ </para>
91
+
78
92
<para>
79
93
The PL/Python language module automatically imports a Python module
80
94
called <literal>plpy</literal>. The functions and constants in
0 commit comments