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.1611302335520.20436@lancre
Whole thread Raw
In response to Re: pgbench - allow backslash continuations in \set expressions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pgbench - allow backslash continuations in \set expressions
List pgsql-hackers
Hello Tom,

> In short, I want to mark this RWF for today and ask for a version that
> applies globally to all backslash commands in psql and pgbench.

Hmmm.

The modus operandi of backslash command scanning is to switch to possibly 
another scanner just after scanning the backslash command, so I did the 
simple thing which is to handle this in the expression scanner. A simple 
feature achieved with a simple code.

Factoring out the behavior means handling continuations from the master 
scanner, probably by using some other intermediate buffer which is then 
rescanned...

This implies that all backslash commands share some kind of minimal 
lexical convention that \ followed by a (\r|\n|\r\n) is a continuation...

But then what if the backslash command accept quoted strings, should a 
continuation still be a continuation inside quotes? If not, how do I know? 
Are all currently existing backslash command compatible with a common set 
of lexical convention? Or do some commands should accept backslash 
continuations and others not, and have to be treated differently and 
knowingly by the lexer?

There is also the issue of locating error messages if the continuation is 
in another buffer, probably someone will complain.

Basically, many issues arise, all of them somehow solvable, but I'm afraid 
with many more lines than my essentially one line patch:-)

I'm not sure such a simple feature deserves so much energy.

-- 
Fabien.



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Add support for restrictive RLS policies
Next
From: Tom Lane
Date:
Subject: Re: pgbench - allow backslash continuations in \set expressions