pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Developers <pgsql-hackers@postgreSQL.org>
Subject: Re: Poorly-thought-out handling of double variables in pgbench
Date: Fri, 6 May 2016 09:14:01 +0200 (CEST)
Message-ID: <alpine.DEB.2.10.1605060842120.30701@sto> (raw)
In-Reply-To: <15599.1462484702@sss.pgh.pa.us>
References: <9188.1462475559@sss.pgh.pa.us>
	<alpine.DEB.2.10.1605052126560.30701@sto>
	<15599.1462484702@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>


Hello Tom,

>>> That's probably a bigger change than we want to be putting in right now,
>>> though I'm a bit tempted to go try it.
>
>> I definitely agree that the text variable solution is pretty ugly, but it
>> was the minimum change solution, and I do not have much time available.
>
> Well, I felt like doing some minor hacking, so I went and adjusted the
> code to work this way.  I'm pretty happy with the result, what do you
> think?

This is a definite improvement.

I like the lazyness between string & numeric forms, and for sorting, that 
is what was needed doing to have something clean.

Applied on head, it works for me.

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.

-- 
Fabien.

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Attachments:

pgbench-scan-double.patch (text/x-diff, 520B) download diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index a484165..9673640 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -928,8 +928,10 @@ makeVariableNumeric(Variable *var) else /* type should be double */ { double dv; + int consumed; - if (sscanf(var->value, "%lf", &dv) != 1) + if (sscanf(var->value, "%lf%n", &dv, &consumed) != 1 || + consumed != strlen(var->value)) { fprintf(stderr, "malformed variable \"%s\" value: \"%s\"\n",

view thread (7+ messages)  latest in thread

Message-ID: <alpine.DEB.2.10.1605060842120.30701@sto>
Permalink:  ../alpine.DEB.2.10.1605060842120.30701@sto/
Also on:    postgresql.org/message-id/alpine.DEB.2.10.1605060842120.30701@sto

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: coelho@cri.ensmp.fr, tgl@sss.pgh.pa.us
  Subject: Re: Poorly-thought-out handling of double variables in pgbench
  In-Reply-To: <alpine.DEB.2.10.1605060842120.30701@sto>
  References: <9188.1462475559@sss.pgh.pa.us> <alpine.DEB.2.10.1605052126560.30701@sto> <15599.1462484702@sss.pgh.pa.us> <alpine.DEB.2.10.1605060842120.30701@sto>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox