Re: pgbench - allow backslash continuations in \set expressions

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Rafia Sabih <rafia(dot)sabih(at)enterprisedb(dot)com>, 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-20 13:00:51
Message-ID: alpine.DEB.2.20.1701201341310.2145@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> You have rules for
>
> {nonspace}+ [...]
> {continuation}
>
> Remember that flex always takes the rule that produces the longest match
> starting at the current point. {space}+ and {newline} don't conflict with
> continuations, but {nonspace}+ does:

Indeed, I totally overlooked "{nonspace}+".

> [...] I think this is surprising and inconsistent.

Sure.

> Probably the easiest fix is to add a rule that explicitly matches this
> situation:
>
> {nonspace}+{continuation} { ... throw back 2 chars and return the rest ... }

Well, as the continuation characters must be ignored, so there is no need
to throw them back, just adding the special case is enough?

Attached a patch which adds the rule and just sends the found word, plus a
test script which also exercises this particular case.

Note anyway that it is not necessarily what people may intend when using a
continuation:

foo\
bla

might mean "foobla" rather than "foo" then "bla". For instance with bash:

sh>ec\
> ho 1
1

But the same trick in python gives a syntax error:

py> print\
... (1)
1 # ok...
py> pri\
... nt(1)
File "<stdin>", line 2
nt(1)
^
SyntaxError: invalid syntax

I think it fine if pgbench behaves as python.

--
Fabien.

Attachment Content-Type Size
pgbench-continuation-5.patch text/x-diff 1.9 KB
cont.sql application/x-sql 269 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2017-01-20 13:09:29 Valgrind-detected bug in partitioning code
Previous Message Ashutosh Sharma 2017-01-20 13:00:21 Re: Improvements in psql hooks for variables