dbTalk Databases Forums  

Re: [BUGS] BUG #1644: control structeres perfomance in pgsql

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] BUG #1644: control structeres perfomance in pgsql in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Neil Conway
 
Posts: n/a

Default Re: [BUGS] BUG #1644: control structeres perfomance in pgsql - 05-03-2005 , 08:53 PM






tirny wrote:
Quote:
any code instructions
***
IF FOUND AND TG_OP = 'UPDATE' THEN
***
END IF;
***

if not found plsql does't break this structure after IF FOUND and proceed
TG_OP = \'UPDATE\', what bring control structures to:
IF FOUND THEN
IF TG_OP = 'UPDATE' THEN
***
END IF;
END IF;

inconveniently, isn't it?
I don't understand. Can you explain what the problem is?

-Neil


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


Reply With Quote
  #2  
Old   
Klint Gore
 
Posts: n/a

Default Re: [BUGS] BUG #1644: control structeres perfomance in pgsql - 05-03-2005 , 09:34 PM






On Wed, 04 May 2005 11:52:32 +1000, Neil Conway <neilc (AT) samurai (DOT) com> wrote:
Quote:
tirny wrote:
any code instructions
***
IF FOUND AND TG_OP = 'UPDATE' THEN
***
END IF;
***

if not found plsql does't break this structure after IF FOUND and proceed
TG_OP = \'UPDATE\', what bring control structures to:
IF FOUND THEN
IF TG_OP = 'UPDATE' THEN
***
END IF;
END IF;

inconveniently, isn't it?

I don't understand. Can you explain what the problem is?
I think they mean that it doesn't do short-circuit evaluation.

[to tirny]
If so, see explanation in the documentation at the bottom of
http://www.postgresql.org/docs/8.0/s...pressions.html

klint.

+---------------------------------------+-----------------+
: Klint Gore : "Non rhyming :
: EMail : kg (AT) kgb (DOT) une.edu.au : slang - the :
: Snail : A.B.R.I. : possibilities :
: Mail University of New England : are useless" :
: Armidale NSW 2351 Australia : L.J.J. :
: Fax : +61 2 6772 5376 : :
+---------------------------------------+-----------------+

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #1644: control structeres perfomance in pgsql - 05-03-2005 , 09:50 PM



Klint Gore <kg (AT) kgb (DOT) une.edu.au> writes:
Quote:
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

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.