Re: pgbench - allow to store select results into variables

Fabien COELHO <coelho@cri.ensmp.fr>

From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Rafia Sabih <rafia.sabih@enterprisedb.com>
Cc: Michael Paquier <michael.paquier@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, Robert Haas <robertmhaas@gmail.com>, Pavel Stehule <pavel.stehule@gmail.com>, PostgreSQL Developers <pgsql-hackers@postgresql.org>
Date: 2017-03-15T19:15:07Z
Lists: pgsql-hackers
Hello Rafia,

> I was reviewing v7 of this patch, to start with I found following white
> space errors when applying with git apply,
> /home/edb/Desktop/patches/others/pgbench-into-7.patch:66: trailing
> whitespace.

Yep.

I do not know why "git apply" sometimes complains. All is fine for me both 
with "git apply" and "patch".

Last time it was because my mailer uses text/x-diff for the mime type, as 
define by the system in "/etc/mime.types", which some mailer then 
interpret as a license to change eol-style when saving, resulting in this 
kind of behavior. Could you tell your mailer just to save the file as is?

> Apart from that, on executing SELECT 1 AS a \gset \set i debug(:a) SELECT 2
> AS a \gcset SELECT 3; given in your provided script gset-1.sql. it is
> giving error Invalid command \gcset.

Are you sure that you are using the compiled pgbench, not a previously 
installed one?

   bin/pgbench> pgbench -t 1 -f SQL/gset-1.sql
     SQL/gset-1.sql:1: invalid command in command "gset"
     \gset

   bin/pgbench> ./pgbench -t 1 -f SQL/gset-1.sql
     starting vacuum...end.
     debug(script=0,command=2): int 1
     debug(script=0,command=4): int 2
     ...

> Not sure what is the intention of this script anyway?

The intention is to test that gset & gcset work as expected in various 
settings, especially with combined queries (\;) the right result must be 
extracted in the sequence.

> Also, instead of so many different files for error why don't you combine 
> it into one.

Because a pgbench scripts stops on the first error, and I wanted to test 
what happens with several kind of errors.

-- 
Fabien.


Commits

  1. pgbench: Remove \cset

  2. pgbench: add \cset and \gset commands

  3. Adjust pgbench to allow non-ASCII characters in variable names.

  4. Refactor script execution state machine in pgbench.

  5. Allow empty queries in pgbench.