From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au> |
Cc: | Neil Conway <neilc(at)samurai(dot)com>, pgsql-bugs(at)postgresql(dot)org, tirny <tirny(at)mail(dot)ru> |
Subject: | Re: BUG #1644: control structeres perfomance in pgsql |
Date: | 2005-05-04 02:48:29 |
Message-ID: | 13896.1115174909@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au> writes:
> On Wed, 04 May 2005 11:52:32 +1000, Neil Conway <neilc(at)samurai(dot)com> wrote:
>> I don't understand. Can you explain what the problem is?
> I think they mean that it doesn't do short-circuit evaluation.
AFAICS the claimed example cannot exhibit any different behavior whether
it's short-circuit or not. I have seen some related issues though, like
IF tg_op = 'UPDATE' AND NEW.foo = 42 THEN ...
In a trigger that is also used for DELETE operations this will fail
--- not because the AND itself isn't short-circuit, but because plpgsql
has to pass down the parameters for the whole IF-expression before the
AND gets to run at all, and so it's forced to evaluate NEW.* which
fails in a DELETE trigger.
We could fix some variants of this problem by modifying plpgsql to
handle top-level AND and OR by itself (ie, split the above into two
separate SQL-expression evaluations with the AND being processed by
plpgsql itself). However the added overhead of multiple executor
calls would be large, and it still wouldn't fix every such case.
Given that we don't promise AND/OR to always behave in short-circuit
fashion anyway, my reaction to the bug report is basically "tough beans,
this is SQL not C" ...
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-05-04 02:55:18 | Re: BUG #1643: dbf2pg broken + quick fix |
Previous Message | Klint Gore | 2005-05-04 02:35:55 | Re: BUG #1644: control structeres perfomance in pgsql |