Re: pgbench - allow backslash continuations in \set expressions

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Rafia Sabih <rafia(dot)sabih(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench - allow backslash continuations in \set expressions
Date: 2017-01-11 12:09:17
Message-ID: alpine.DEB.2.20.1701111257010.11499@lancre
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-hackers


Hello,

>> The attached patch adds backslash-return (well newline really) continuations
>> to all pgbench backslash-commands.
>>
>> The attached test uses continuations on all such commands (sleep set
>> setshell and shell).
>>
>> I think that adding continuations to psql should be a distinct patch.

> The patch does not apply on the latest head, I guess this requires
> rebasing since yours is posted in December.

Strange. Here is a new version and a test for all known backslash-commands
in pgbench.

sh> git br test master
sh> git apply ~/pgbench-continuation-3.patch
# ok
sh> git diff
# ok
sh> cd src/bin/pgbench
sh> make
sh> ./pgbench -t 1 -f SQL/cont.sql
starting vacuum...end.
debug(script=0,command=1): int 0
debug(script=0,command=2): int 1
debug(script=0,command=4): int 2
3
debug(script=0,command=8): int 4
transaction type: SQL/cont.sql

> Again, it is giving trailing whitespace errors (as I reported for the
> earlier version), plus it does not apply with git apply,

It does above with the attached version.

> hopefully that would be fixed once rebased. Other than that, I observed
> that if after backslash space is there, then the command fails.

Yes, this is expected.

> I think it should be something like if after backslash some spaces are
> there, followed by end-of-line then it should ignore these spaces and
> read next line, atleast with this new meaning of backslash.

Hmmm. This is not the behavior of backslash continuation in bash or
python, I do not think that this is desirable to have a different
behavior.

> Otherwise, it should be mentioned in the docs that backslash should not
> be followed by space.

I'm not sure. Doc says that continuation is "backslash-return", it cannot
be more explicit. If it must say what it is not, where should it stop?

--
Fabien.

Attachment Content-Type Size
pgbench-continuation-3.patch text/x-diff 1.6 KB
cont.sql application/x-sql 231 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2017-01-11 12:15:34 Re: Push down more full joins in postgres_fdw
Previous Message tushar 2017-01-11 12:03:13 Re: Parallel bitmap heap scan