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: Christoph Berg <myon(at)debian(dot)org>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench - allow backslash continuations in \set expressions
Date: 2016-11-01 08:07:56
Message-ID: alpine.DEB.2.20.1611010834100.12273@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Rafia,

> Seems like an interesting addition to pgbench interface, but not sure where
> it's required, it'll be good if you may provide some cases where it's
> utility can be witnessed. Something like where you absolutely need
> continuations in expression.

It is never "absolutely needed", you can always put the expression on one
longer line.

As an long line example, supposing some other currently submitted patches
are committed to pgbench, for implementing tpc-b according to the
specification one may write the following:

\set bid CASE WHEN random(0, 99) < 85 THEN :tbid ELSE :abid + (:abid >= :tbid) END

or

\set bid \
CASE WHEN random(0, 99) < 85 \
THEN :tbid \
ELSE :abid + (:abid >= :tbid) \
END

I find the second version more readable, but it is a really matter of
taste, obviously.

> While applying it is giving some trailing whitespace errors, please
> correct them.

sh> git checkout -b tmp
sh> git apply ~/pgbench-set-continuation-1.patch
sh> git commit -a
sh>

I do not get any errors, and I have not found any trailing spaces in the
patch. Could you give me the precise error message you got?

> As an additional comment you may consider reformatting
> following snippet
>
>> {continuation} { /* ignore */ }
>>
>> as
>
>> {continuation} {
>> /* ignore */
>> }

Hmmm... Other lex rules to ignore spaces use the one line syntax, I would
prefer to keep it the same as those.

--
Fabien.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2016-11-01 09:05:58 Re: [BUGS] BUG #14350: VIEW with INSTEAD OF INSERT TRIGGER and COPY. Missing feature or working as designed.
Previous Message Michael Paquier 2016-11-01 07:53:11 Re: commit fest manager for CF 2016-11?