pgbench - allow to store select results into variables

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: pgbench - allow to store select results into variables
Date: 2016-07-09 08:20:39
Message-ID: alpine.DEB.2.20.1607091005330.3412@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello devs,

I mentionned my intention to add some features to pgbench back in March:
https://www.postgresql.org/message-id/alpine.DEB.2.10.1603301618570.5677@sto

The attached patch adds an \into meta command to store results of
preceding SELECTs into pgbench variables, so that they can be reused
afterwards.

The feature is useful to make more realistic scripts, currently pgbench
script cannot really interact with the database as results are discarded.

The chosen syntax is easy to understand and the implementation is quite
light, with minimal impact on the code base. I think that this is a
reasonnable compromise.

The SELECTs must yield exactly one row, the number of variables must be
less than the number of columns.

Also attached a set of test scripts, especially to trigger various error
cases.

--
Fabien.

Attachment Content-Type Size
pgbench-into-1.patch text/x-diff 7.1 KB
into.sql application/x-sql 299 bytes
into-err-1.sql application/x-sql 31 bytes
into-err-2.sql application/x-sql 47 bytes
into-err-3.sql application/x-sql 76 bytes
into-err-4.sql application/x-sql 42 bytes
into-err-5.sql application/x-sql 75 bytes
into-err-6.sql application/x-sql 88 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2016-07-09 08:42:27 pgbench - compute & show latency consistently
Previous Message Fabien COELHO 2016-07-09 07:48:38 pgbench - minor doc improvements