Re: pgbench - allow backslash-continuations in custom scripts

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench - allow backslash-continuations in custom scripts
Date: 2015-06-21 08:12:07
Message-ID: alpine.DEB.2.10.1506210957030.31742@sto
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Josh,

>> Add backslash continuations to pgbench custom scripts.
>> [...]
>> IMHO this approach is the best compromise.
>
> I don't personally agree. I believe that it it worth breaking backwards
> compatibility to support line breaks in pgbench statements, and that if
> we're not going to do that, supporting \ continuations is of little value.
>
> As someone who actively uses pgbench to write custom benchmarks, I need
> to write queries which I can test. \ continuation does NOT work on the
> psql command line, so that's useless for testing my queries; I still
> have to reformat and troubleshoot. If we added \ continuation, I
> wouldn't use it.
>
> I think we should support line breaks, and require semicolons for
> end-of-statement. Backwards-compatability in custom pgbench scripts is
> not critical; pgbench scripts are neither used in produciton, nor used
> in automated systems much that I know of.
>
> I'm not clear on why we'd need a full SQL lexer.

Attached is a "without lexer" version which does ;-terminated SQL commands
and \-continuated meta commands (may be useful for \shell and long \set
expressions).

Also attached is a small pgbench script to test the feature.

Without a lexer it is possible to fool pgbench with somehow contrived
examples, say with:

SELECT 'hello;
world';

The ";" within the string will be considered as end-of-line.

Also, comments intermixed with sql on the same line would generate errors.

SELECT 1 -- one
+ 3;

Would fail, but comments on lines of their own are ok.

It may be argued that these are not a likely scripts and that this
behavior could be declared as a "feature" for keeping the code simple.

ISTM that it would be an overall improvement, but also the ;-termination
requirement breaks backward compatibility.

--
Fabien.

Attachment Content-Type Size
pgbench-conts-2.patch text/x-diff 5.4 KB
test.sql application/x-sql 342 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Prakash Itnal 2015-06-21 09:26:26 Re: Auto-vacuum is not running in 9.1.12
Previous Message Robert Haas 2015-06-21 04:27:25 Re: Inheritance planner CPU and memory usage change since 9.3.2