projects
/
postgresql.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
326b922
)
PL/Python: Update example
author
Peter Eisentraut
Wed, 18 Jan 2012 19:02:09 +0000
(21:02 +0200)
committer
Peter Eisentraut
Wed, 18 Jan 2012 19:02:09 +0000
(21:02 +0200)
Change the usesavedplan() example to use a more modern Python style
using the .setdefault() function.
doc/src/sgml/plpython.sgml
patch
|
blob
|
blame
|
history
diff --git
a/doc/src/sgml/plpython.sgml
b/doc/src/sgml/plpython.sgml
index 618f8d055e919ba6ec4dae651fcbe1608e80b107..5a3c8caa689efcfcdc0094ddab1b32424dbd07ab 100644
(file)
--- a/
doc/src/sgml/plpython.sgml
+++ b/
doc/src/sgml/plpython.sgml
@@
-955,11
+955,7
@@
rv = plpy.execute(plan, [ "name" ], 5)
). For example:
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;