Re: extend pgbench expressions with functions - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: extend pgbench expressions with functions
Date
Msg-id alpine.DEB.2.10.1509180946110.17841@sto
Whole thread Raw
In response to Re: extend pgbench expressions with functions  (Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>)
Responses Re: extend pgbench expressions with functions  ("Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>)
List pgsql-hackers
Hello Kyotaro-san,

> My description should have been obscure. Indeed the call tree is
> finite for *sane* expression node. But it makes infinit call for
> a value of expr->etype unknown by both evalDouble and
> evalInt.

Such issue would be detected if the function is actually tested, hopefully 
this should be the case... :-)

However I agree that relying implicitely on the "default" case is not very 
good practice, so I updated the code in the attached v11 to fail 
explicitely on such errors.

I also attached a small test script, which exercises most (all?) 
functions:
  ./pgbench -f functions.sql -t 1

> [...]
> By the way, the complexity comes from separating integer and
> double. If there is no serios reason to separate them, handling
> all values as double makes things far simpler.

Yep, but no.

> Could you let me know the reason why it strictly separates integer and 
> double? I don't see no problem in possible errors of floating point 
> calculations for this purpose. Is there any?

Indeed it would make things simpler, but it would break large integers as 
the int64 -> double -> int64 casts would result in approximations. The 
integer type is the important one here because it is used for primary 
keys, and you do not want a key to be approximated in any way, so the 
int64 type must be fully and exactly supported.

-- 
Fabien.

pgsql-hackers by date:

Previous
From: Vladimir Borodin
Date:
Subject: Re: RFC: replace pg_stat_activity.waiting with something more descriptive
Next
From: "Shulgin, Oleksandr"
Date:
Subject: Re: On-demand running query plans using auto_explain and signals