Re: PL/Python prepare example's use of setdefault

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Jonathan Rogers <jrogers(at)socialserve(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: PL/Python prepare example's use of setdefault
Date: 2014-11-01 16:13:37
Message-ID: 545506B1.6070608@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/15/14 5:58 PM, Jonathan Rogers wrote:
> BTW, I would rewrite the 9.1 example to be shorter while
> behaving the same:
>
>
> CREATE FUNCTION usesavedplan() RETURNS trigger AS $$
> plan = SD.get("plan")
> if plan is None:

If we're going for shortness, how about

if not plan:

?

> SD["plan"] = plan = plpy.prepare("SELECT 1")

and here maybe

plan = SD["plan"] = plpy.prepare("SELECT 1")

to emphasize the assignment to "plan"?

> # rest of function
> $$ LANGUAGE plpythonu;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anil Menon 2014-11-01 16:37:46 Re: Basic question regarding insert
Previous Message Peter Eisentraut 2014-11-01 16:06:14 Re: PL/Python prepare example's use of setdefault