summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut2012-01-18 19:02:09 +0000
committerPeter Eisentraut2012-01-18 19:02:09 +0000
commit6f6b46c9c0ca3d96acbebc5499c32ee6369e1eec (patch)
treedec1f82516c7511430959e309b1f5450e5d20a8f
parent326b922e8b2d65257a635b5f80e5de0f15dffd3a (diff)
PL/Python: Update example
Change the usesavedplan() example to use a more modern Python style using the .setdefault() function.
-rw-r--r--doc/src/sgml/plpython.sgml6
1 files changed, 1 insertions, 5 deletions
diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml
index 618f8d055e9..5a3c8caa689 100644
--- a/doc/src/sgml/plpython.sgml
+++ b/doc/src/sgml/plpython.sgml
@@ -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>