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: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench - allow backslash continuations in \set expressions
Date: 2016-11-08 10:33:36
Message-ID: alpine.DEB.2.20.1611081124080.4409@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello Rafia,

Please keep copying to the list.

> Though I find the first version of this patch acceptable in terms that it
> would be helpful on enhancing the readability of expressions as you
> mentioned. However, the second version is not clear as I mentioned before
> also, there has to be detailed documentation regarding this, still as an
> end-user one needs to be too careful to decide which statements to split
> lines based on the patch, for example following
> \set bid
> CASE WHEN random(0, 99) < 85
> THEN :tbid
> ELSE :abid + (:abid >= :tbid)
> should be written as
> \set bid CASE WHEN random(0, 99) < 85
> THEN :tbid
> ELSE :abid + (:abid >= :tbid)

I do not understand the "should". It is a matter of style, and both cases
would work with the second version of the patch.

> (and a few more variants of splitting lines just after an operator or
> open parenthesis) which does not look like much enhancement in
> readability to me.

As I said, I will not fight over this one. I like inferred continuations
in scala, but I guess it would be surprising for such an old school script
like pgbench, and it would be hard to do that consistently for pgsql
because the backslash command syntax may depends on the command itself (eg
does it have to respect strings and parenthesis, or some other

> So this patch needs to add the support to read the next line even when
> "\set a" and other such similar expressions are encountered.

The scala convention is that if the line is not finished the user must
either use explicit parenthesis are use an unambiguous operator which
expects an operand, so that the lexer knows it has to go on.

I do not think that having both inferred continuations and explicit
backslash continuations is desirable, it should be one or the other.


In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Sharma 2016-11-08 10:53:06 Re: Re: [COMMITTERS] pgsql: Change the way that LWLocks for extensions are allocated.
Previous Message Fabien COELHO 2016-11-08 09:04:56 Re: Specifying the log file name of pgbench -l option