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

2014-11-01 Thread Jonathan Rogers
On 11/01/2014 12:13 PM, Peter Eisentraut wrote: > 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

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

2014-11-01 Thread Peter Eisentraut
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: ?

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

2014-11-01 Thread Peter Eisentraut
On 10/15/14 5:56 PM, Tom Lane wrote: > Hm ... this was changed in commit 6f6b46c9c0ca3d96. Peter, did > you consider efficiency here? Fixed. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-ge

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

2014-10-15 Thread Jonathan Rogers
On 10/15/2014 05:51 PM, Adrian Klaver wrote: > On 10/15/2014 02:39 PM, Jonathan Rogers wrote: >> I was just reading the PL/Python docs section "42.7.1 Database Access >> Functions" and saw this example: >> >> CREATE FUNCTION usesavedplan() RETURNS trigger AS $$ >> plan = SD.setdefault("plan",

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

2014-10-15 Thread Tom Lane
Adrian Klaver writes: > On 10/15/2014 02:39 PM, Jonathan Rogers wrote: >> I was just reading the PL/Python docs section "42.7.1 Database Access >> Functions" and saw this example: >> >> CREATE FUNCTION usesavedplan() RETURNS trigger AS $$ >> plan = SD.setdefault("plan", plpy.prepare("SELECT 1"))

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

2014-10-15 Thread Adrian Klaver
On 10/15/2014 02:39 PM, Jonathan Rogers wrote: I was just reading the PL/Python docs section "42.7.1 Database Access Functions" and saw this example: CREATE FUNCTION usesavedplan() RETURNS trigger AS $$ plan = SD.setdefault("plan", plpy.prepare("SELECT 1")) # rest of function $$ LANGUA

[GENERAL] PL/Python prepare example's use of setdefault

2014-10-15 Thread Jonathan Rogers
I was just reading the PL/Python docs section "42.7.1 Database Access Functions" and saw this example: CREATE FUNCTION usesavedplan() RETURNS trigger AS $$ plan = SD.setdefault("plan", plpy.prepare("SELECT 1")) # rest of function $$ LANGUAGE plpythonu; The above example uses the plpy.prep