Re: pgbench - allow backslash-continuations in custom scripts

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: coelho(at)cri(dot)ensmp(dot)fr
Cc: hlinnaka(at)iki(dot)fi, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgbench - allow backslash-continuations in custom scripts
Date: 2015-09-04 05:11:14
Message-ID: 20150904.141114.155567080.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello, Thank you for registering this to CF-Sep.
I missed the regtration window.. It ended earlier than usual..

Most troubles have gone and I'll be back next week.

> The work to be left is eliminating double-format of Command
> struct.

This is done as the additional fourth patch, not merged into
previous ones, to show what's changed in the manner of command
storing.

I repost on this thread the new version of this patch including
this and posted before. This is rebased to current master.

The changes in behaviors brought by this patch has been described
in the privous mail as the following,

> Hmm. psqlscan.l handles multistatement naturally.
> I worked on that and the attached patche set does,
>
> - backslash continuation for pgbench metacommands.
>
> set variable \
> <some value>
>
> - SQL statement natural continuation lines.
>
> SELECT :foo
> FROM :bar;
>
> - SQL multi-statement.
>
> SELECT 1; SELECT 2;

Each of the four patches does the following thigs,

1. 0001-Prepare-to-share-psqlscan-with-pgbench.patch

The global variable pset, VariableSpace and backslash syntax of
psql are the obstacles for psqlscan.l from being used by
pgbench. This patch eliminates direct reference to pset and
masks VariableSpace feature (looks ugry..), and enables
backslash syntax in psqlscan.l to be hidden from outside psql
by defining the symbol OUTSIDE_PSQL.

No behavioral changes of pasql are introduced by ths patch.

2. 0002-Make-use-of-psqlscan-for-parsing-of-custom-script.patch

This is the core of this patch, which makes pgbench to use
psqlscan.l and enables multi-statements,
multiline-SQL-statement and backslash-continuation of
metacommands.

The struct Command is modified that it can be chained in order
to convey multistatement in one line. But the commands are
stored in an array of Command just outside process_commands as
of old. This double-formatting will be removed by the fourth
patch.

psqlscan.c is compiled as a part of mainloop.c for some reason
described at the end of the file. I haven't confirmed that the
same thing will happen in pgbench, but I did the same thing for
pgbenc.c.

Compilation will fail on Windows as of this patch.

3. 0003-Change-MSVC-Build-script.patch

Changes the build script for Windows platform. It certainly
works but might look a bit odd because of the anormaly of the
compilation way of psqlscan.l

4. 0004-Change-the-way-to-hold-command-list.patch

Changes the way to hold commad list from an array to linked
list, to remove the double formatting of Command-list
introduced by the second patch. This removes the explicit
limitation on the number of commands in scripts, as a
side-effect.

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
0001-Prepare-to-share-psqlscan-with-pgbench.patch text/x-patch 8.6 KB
0002-Make-use-of-psqlscan-for-parsing-of-custom-script.patch text/x-patch 19.0 KB
0003-Change-MSVC-Build-script.patch text/x-patch 1.2 KB
0004-Change-the-way-to-hold-command-list.patch text/x-patch 14.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2015-09-04 05:14:08 Re: Allow replication roles to use file access functions
Previous Message Amit Langote 2015-09-04 05:06:08 Re: BRIN INDEX value