dbTalk Databases Forums  

[BUGS] BUG #1371: Short-circuit evaluation on PL/PgSQL

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


Discuss [BUGS] BUG #1371: Short-circuit evaluation on PL/PgSQL in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Aguinaldo Possatto
 
Posts: n/a

Default [BUGS] BUG #1371: Short-circuit evaluation on PL/PgSQL - 01-04-2005 , 11:21 PM







The following bug has been logged online:

Bug reference: 1371
Logged by: Aguinaldo Possatto
Email address: aguinaldo (AT) aswti (DOT) com
PostgreSQL version: 8.0
Operating system: Windows XP
Description: Short-circuit evaluation on PL/PgSQL
Details:

an exception is raised when this block is being executed:

if ( ((tg_op = 'INSERT') and
(new.field is not null)) or
((tg_op = 'DELETE') and
(old.field is not null)) )
then
...
end if;

the error is :
"SQL Error: ERRO: record "old" is not assigned yet"

but if the evaluation was "short-circuit" this error would not happen.

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

http://www.postgresql.org/docs/faqs/FAQ.html

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

Default Re: [BUGS] BUG #1371: Short-circuit evaluation on PL/PgSQL - 01-05-2005 , 01:00 AM






"Aguinaldo Possatto" <aguinaldo (AT) aswti (DOT) com> writes:
Quote:
an exception is raised when this block is being executed:

if ( ((tg_op = 'INSERT') and
(new.field is not null)) or
((tg_op = 'DELETE') and
(old.field is not null)) )
then
...
end if;

the error is :
"SQL Error: ERRO: record "old" is not assigned yet"

but if the evaluation was "short-circuit" this error would not happen.
The evaluation is not short-circuit, and is not going to become so.
See for instance
http://www.postgresql.org/docs/7.4/s...X-EXPRESS-EVAL
The particular problem at hand here arises from different issues
(specifically that plpgsql has to push down all the variable values
it has at hand before the IF expression's evaluation can start)
but the fact remains that SQL does not promise short-circuit
evaluation.

regards, tom lane

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

http://archives.postgresql.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.