PL/Python: Update example
Change the usesavedplan() example to use a more modern Python style using the .setdefault() function.
This commit is contained in:
parent
326b922e8b
commit
6f6b46c9c0
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user