First, thank you all involved, and thank you for polishing this
and committing, Tom.

At Mon, 21 Mar 2016 17:15:18 -0400, Tom Lane <> wrote in 
> So I looked into this, and found that persuading psql to let backslash
> commands cross line boundaries is a much bigger deal than just fixing the
> lexer.  The problem is that MainLoop would need to grow an understanding
> of having received only a partial backslash command and needing to go back
> to readline() for another line.  And probably HandleSlashCmds would need
> to be changed to stop parsing and back out without doing anything when it
> hits backslash-newline.  It's do-able no doubt, but it's not going to be a
> small and simple patch.

I agree.

> However, since pgbench is already set up to slurp the entire file and
> lex it in one go, it is just a trivial adjustment to the lexer rules in
> that program.  The only thing I found that made it complicated is that
> syntax_error() had too simplistic an understanding of how to position
> the error cursor usefully, so that needed a bit of work.

The modified lexer treats {backslash}{newline} as the same with
whitespace and it looks ok for me.

> /test.sql:6: syntax error, unexpected FUNCTION, expecting $end in command 
> "set"
> \set naccounts\
> 10x0
>    ^ error found here

The error message seems fine. (The mysterious message would be
another problem.) But it prints the lines after the error indicator.

> \set naccounts\
> 10x0\
>    ^ error found here
> * :scale

I suppose that the trailing lines might be better not be
printed. (gcc doesn't seem to do so.)

> I think it'd be okay to commit this without fixing psql at the same time;
> if you try it in psql you get an error, so on that side it's unimplemented
> behavior rather than an actual incompatibility.  Perhaps somebody will be
> motivated to fix it later, but I'm not going to spend that kind of time
> on it right now.
> I've not written a docs update, but otherwise I think this is committable.
> Comments?
>                       regards, tom lane


Kyotaro Horiguchi
NTT Open Source Software Center

Sent via pgsql-hackers mailing list (
To make changes to your subscription:

Reply via email to