Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6f6b46c

Browse files
committed
PL/Python: Update example
Change the usesavedplan() example to use a more modern Python style using the .setdefault() function.
1 parent 326b922 commit 6f6b46c

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

doc/src/sgml/plpython.sgml

+1-5
Original file line numberDiff line numberDiff line change
@@ -955,11 +955,7 @@ rv = plpy.execute(plan, [ "name" ], 5)
955955
<xref linkend="plpython-sharing">). For example:
956956
<programlisting>
957957
CREATE FUNCTION usesavedplan() RETURNS trigger AS $$
958-
if SD.has_key("plan"):
959-
plan = SD["plan"]
960-
else:
961-
plan = plpy.prepare("SELECT 1")
962-
SD["plan"] = plan
958+
plan = SD.setdefault("plan", plpy.prepare("SELECT 1"))
963959
# rest of function
964960
$$ LANGUAGE plpythonu;
965961
</programlisting>

0 commit comments

Comments
 (0)