Allowing line-continuation in pgbench custom scripts

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Allowing line-continuation in pgbench custom scripts
Date: 2014-05-26 09:50:40
Message-ID: CA+HiwqEMGL3TJknmZBd7hmPtTnqkrkarusi9hDQEkNnaynnv7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

In a custom pgbench script, it seems convenient to be able to split a
really long query to span multiple lines using an escape character
(bash-style). Attached adds that capability to read_line_from_file()
in pgbench.c

For example,

BEGIN;
\setrandom 1 16500000
UPDATE table \
SET col2 = (clock_timestamp() + '10s'::interval * random() * 1000), \
col3 = (clock_timestamp() + '10s'::interval * sin(random() *
(2*pi()) ) * 1000) \
WHERE col1 = :id;
COMMIT;

instead of:

BEGIN;
\setrandom id 1 16500000
UPDATE table SET col2 = (clock_timestamp() + '10s'::interval *
random() * :id), col3 = (clock_timestamp() + '10s'::interval *
sin(random() * (2*pi()) ) * 100000) WHERE col1 = :id;
COMMIT;

Thoughts?

--
Amit

Attachment Content-Type Size
pgbench-custom-script-line-continuation.patch application/octet-stream 527 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matteo Beccati 2014-05-26 10:03:19 Re: [PATCH] Replacement for OSSP-UUID for Linux and BSD
Previous Message Dmitry Samonenko 2014-05-26 08:04:09 libpq: PQexec may block indefinitly