From: Peter Eisentraut Date: Wed, 18 Jan 2012 19:02:09 +0000 (+0200) Subject: PL/Python: Update example X-Git-Tag: REL9_2_BETA1~570 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f6b46c9c0ca3d96acbebc5499c32ee6369e1eec;p=postgresql PL/Python: Update example Change the usesavedplan() example to use a more modern Python style using the .setdefault() function. --- diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml index 618f8d055e..5a3c8caa68 100644 --- 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;