Unix Technical Forum

short ciruit logic of plpgsql in 8.2

This is a discussion on short ciruit logic of plpgsql in 8.2 within the Pgsql General forums, part of the PostgreSQL category; --> Does anyone know if logic operations in plpgsql are short circuited in 8.2? Regards, Richard Broersma Jr. ---------------------------(end of ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-09-2008, 05:18 PM
Richard Broersma Jr
 
Posts: n/a
Default short ciruit logic of plpgsql in 8.2

Does anyone know if logic operations in plpgsql are short circuited in 8.2?

Regards,
Richard Broersma Jr.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-09-2008, 05:18 PM
Pavel Stehule
 
Posts: n/a
Default Re: short ciruit logic of plpgsql in 8.2

hello,

it depends on SQL. plpgsql hasn't own arithmetic unit. You can test it simply:



postgres=# create or replace function a() returns bool as $$ begin
raise notice 'a'; return true; end$$ language plpgsql;
CREATE FUNCTION
postgres=# create or replace function b() returns bool as $$ begin
raise notice 'a'; return true; end$$ language plpgsql;
CREATE FUNCTION
postgres=# select a() or b();
NOTICE: a
?column?
----------
t
(1 row)

result: statements are short circuited.

2007/5/17, Richard Broersma Jr <rabroersma@yahoo.com>:
> Does anyone know if logic operations in plpgsql are short circuited in 8.2?
>
> Regards,
> Richard Broersma Jr.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org/
>


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-09-2008, 05:18 PM
Tom Lane
 
Posts: n/a
Default Re: short ciruit logic of plpgsql in 8.2

Richard Broersma Jr <rabroersma@yahoo.com> writes:
> Does anyone know if logic operations in plpgsql are short circuited in 8.2?


They are often optimized, but if you expect "short circuiting" following
exactly the rules of, say, C, you are likely to be disappointed. See
the manual:

http://www.postgresql.org/docs/8.2/s...X-EXPRESS-EVAL

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-09-2008, 05:22 PM
Ian Harding
 
Posts: n/a
Default Re: short ciruit logic of plpgsql in 8.2

This keeps biting me. In a trigger function for INSERT OR UPDATE if you try

IF TG_OP = 'UPDATE' AND OLD.foo = 'bar' THEN
....

it will blow up on inserts because there is no OLD. I always expect
this to short circuit and am always disappointed. Easy fix, of
course...

IF TG_OP = 'UPDATE' THEN
IF OLD.foo = 'bar' THEN
....

In case this was what the OP was asking about in particular, it still
happens to me in 8.2

- Ian


On 5/17/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Richard Broersma Jr <rabroersma@yahoo.com> writes:
> > Does anyone know if logic operations in plpgsql are short circuited in 8.2?

>
> They are often optimized, but if you expect "short circuiting" following
> exactly the rules of, say, C, you are likely to be disappointed. See
> the manual:
>
> http://www.postgresql.org/docs/8.2/s...X-EXPRESS-EVAL
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:26 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com