Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux