pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Jaime Soler <jaime.soler@gmail.com>
Cc: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: PostgreSQL mailing lists <pgsql-general@postgresql.org>
Subject: Re: pgbench and timestamps
Date: Wed, 24 Jun 2020 11:17:20 -0400
Message-ID: <2206076.1593011840@sss.pgh.pa.us> (raw)
In-Reply-To: <2203820.1593008123@sss.pgh.pa.us>
References: <CAKVUGgQaZVAUi1Ex41H4wrru=FU+MfwgjG0aM1br6st7sz31Vw@mail.gmail.com>
	<CAApHDvpgRhWmDGPxBkVogbo46PadcgAGtMST7orosa2cYvW4WA@mail.gmail.com>
	<2203820.1593008123@sss.pgh.pa.us>

I wrote:
> David Rowley <dgrowleyml@gmail.com> writes:
>> I don't often do much with pgbench and variables, but there are a few
>> things that surprise me here.
>> 1) That pgbench replaces variables within single quotes, and;
>> 2) that we still think it's a variable name when it starts with a digit, and;
>> 3) We replace variables that are undefined.

> Also (4) this only happens when in non-simple query mode --- the
> example works fine without "-M prepared".

After looking around in the code, it seems like the core of the issue
is that pgbench.c's parseQuery() doesn't check whether a possible
variable name is actually defined, unlike assignVariables() which is
what does the same job in simple query mode.  So that explains the
behavioral difference.

The reason for doing that probably was that parseQuery() is run when
the input file is read, so that relevant variables might not be set
yet.  We could fix that by postponing the work to be done at first
execution of the query, as is already the case for PQprepare'ing the
query.

Also, after further thought I realize that (1) absolutely is a bug
in the non-simple query modes, whatever you think about it in simple
mode.  The non-simple modes are trying to pass the variable values
as extended-query-protocol parameters, and the backend is not going
to recognize $n inside a literal as being a parameter.

If we fixed (1) and (3) I think there wouldn't be any great need
to tighten up (2).

			regards, tom lane





view thread (8+ messages)  latest in thread

Message-ID: <2206076.1593011840@sss.pgh.pa.us>
Permalink:  ../2206076.1593011840@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2206076.1593011840@sss.pgh.pa.us

 · 

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-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, jaime.soler@gmail.com, coelho@cri.ensmp.fr
  Subject: Re: pgbench and timestamps
  In-Reply-To: <2206076.1593011840@sss.pgh.pa.us>
  References: <CAKVUGgQaZVAUi1Ex41H4wrru=FU+MfwgjG0aM1br6st7sz31Vw@mail.gmail.com> <CAApHDvpgRhWmDGPxBkVogbo46PadcgAGtMST7orosa2cYvW4WA@mail.gmail.com> <2203820.1593008123@sss.pgh.pa.us> <2206076.1593011840@sss.pgh.pa.us>

* 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