Re: [HACKERS] pgbench more operators & functions - Mailing list pgsql-hackers

From Teodor Sigaev
Subject Re: [HACKERS] pgbench more operators & functions
Date
Msg-id 992df164-6bb0-6a88-1d03-a97d891d715b@sigaev.ru
Whole thread Raw
In response to Re: [HACKERS] pgbench more operators & functions  (Fabien COELHO <coelho@cri.ensmp.fr>)
Responses Re: [HACKERS] pgbench more operators & functions  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
> Here is a rebase after "pow" addition.

Huh, you are fast.

Investigating your patch I found that all arguments of logical AND/OR and CASE 
are always evaluated. Seems, it should not be for pair of reasons:
- computing of unneeded args could be too expensive
- computing of unneeded args could complicate scripting code, look:
\set zy 0
\set yz case when :zy = 0 then -1 else (1 / :zy) end
This example will fail although programmer tried to check forbidden value

case when 1>0 then 1 when 1/0 > 0 then 0 else -1 end --  fails too

SQL doesn't evaluate unneeded arguments:
select case when 1>0 then 33 when 1/0 > 0 then -33 else null end;
  case
------
    33

-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
                                                    WWW: http://www.sigaev.ru/


pgsql-hackers by date:

Previous
From: Victor Yagofarov
Date:
Subject: Why standby restores some WALs many times from archive?
Next
From: Antonio Belloni
Date:
Subject: Re: Contributing some code