Re: Poorly-thought-out handling of double variables in pgbench - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: Poorly-thought-out handling of double variables in pgbench
Date
Msg-id alpine.DEB.2.10.1605061832210.22692@sto
Whole thread Raw
In response to Re: Poorly-thought-out handling of double variables in pgbench  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Poorly-thought-out handling of double variables in pgbench
List 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.



pgsql-hackers by date:

Previous
From: "Daniel Verite"
Date:
Subject: Re: \crosstabview fixes
Next
From: Oleksandr Shulgin
Date:
Subject: Re: Stopping logical replication protocol