Re: pgbench - allow backslash continuations in \set expressions - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: pgbench - allow backslash continuations in \set expressions
Date
Msg-id alpine.DEB.2.20.1611010834100.12273@lancre
Whole thread Raw
In response to Re: pgbench - allow backslash continuations in \set expressions  (Rafia Sabih <rafia.sabih@enterprisedb.com>)
List 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.



pgsql-hackers by date:

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