]> granicus.if.org Git - postgresql/commitdiff
PL/Python: Fix example
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 1 Nov 2014 15:31:35 +0000 (11:31 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 1 Nov 2014 15:33:30 +0000 (11:33 -0400)
Revert "6f6b46c9c0ca3d96acbebc5499c32ee6369e1eec", which was broken.

Reported-by: Jonathan Rogers <jrogers@socialserve.com>
doc/src/sgml/plpython.sgml

index 3f0e6290bb2325a3534f22cb84cf3aacda5efcf1..ce9052b61b8a982ff5e415275080738012916f88 100644 (file)
@@ -1044,7 +1044,11 @@ rv = plpy.execute(plan, ["name"], 5)
       <xref linkend="plpython-sharing">). For example:
 <programlisting>
 CREATE FUNCTION usesavedplan() RETURNS trigger AS $$
-    plan = SD.setdefault("plan", plpy.prepare("SELECT 1"))
+    if "plan" in SD:
+        plan = SD["plan"]
+    else:
+        plan = plpy.prepare("SELECT 1")
+        SD["plan"] = plan
     # rest of function
 $$ LANGUAGE plpythonu;
 </programlisting>