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

Lines changed: 1 addition & 5 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy