Re: Poorly-thought-out handling of double variables in pgbench

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: Poorly-thought-out handling of double variables in pgbench
Date: 2016-05-06 16:42:58
Message-ID: alpine.DEB.2.10.1605061832210.22692@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


>> While testing the patch I found a minor preexisting (mine...) bug: when
>> string-scanning doubles, whether the whole string is consumed or not is
>> not checked. This means that -D x=0one is interpreted as double 0.
>
>> I came up with the attached check, but maybe there is a cleaner way to do
>> that.
>
> I like the way the zic code does it:

> + char xs;
> ! if (sscanf(var->value, "%lf%c", &dv, &xs) != 1)

Indeed... I cannot say that it is cleaner such, but at least it is short
and it avoids the strlen call.

> Neither way allows for trailing whitespace, though. I don't see that
> that's important here.

No, this is not an issue here for variables specified from the command
line. Consider pushing this fix?

--
Fabien.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleksandr Shulgin 2016-05-06 16:45:31 Re: Stopping logical replication protocol
Previous Message Daniel Verite 2016-05-06 16:37:06 Re: \crosstabview fixes