Commit 6f6b46c9 authored by Peter Eisentraut's avatar Peter Eisentraut

PL/Python: Update example

Change the usesavedplan() example to use a more modern Python style
using the .setdefault() function.
parent 326b922e
......@@ -955,11 +955,7 @@ rv = plpy.execute(plan, [ "name" ], 5)
<xref linkend="plpython-sharing">). For example:
<programlisting>
CREATE FUNCTION usesavedplan() RETURNS trigger AS $$
if SD.has_key("plan"):
plan = SD["plan"]
else:
plan = plpy.prepare("SELECT 1")
SD["plan"] = plan
plan = SD.setdefault("plan", plpy.prepare("SELECT 1"))
# rest of function
$$ LANGUAGE plpythonu;
</programlisting>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment