Re: [PROPOSAL] bracketed-paste support for psql - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: [PROPOSAL] bracketed-paste support for psql
Date
Msg-id 20171229170156.4nwcbclsyzsdkl5h@alvherre.pgsql
Whole thread Raw
In response to Re: [PROPOSAL] bracketed-paste support for psql  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
Peter Eisentraut wrote:
> On 12/15/17 11:22, Geoff Winkless wrote:
> > It occurred to me the other day while people were talking about
> > pasting blocks of text creating problems, especially with tabs, that
> > xterm bracketed-paste support (also works in at least putty and
> > probably others) that would block curses handling and just paste as-is
> > would be a useful (and I'm guessing relatively simple) thing to add.
> 
> You need to put
> 
> set enable-bracketed-paste on
> 
> into ~/.inputrc, then it works.

Thanks for mentioning this -- I didn't know if, and it's a nice feature.
I've been trying it for a few days and it seems to work pretty well.

There is a problem with backslash commands, though: the parser seems to
search for arguments to the commands all the way to the end of the
buffer rather than the end of the line, so if you paste this:

\d tab1
select * from tab1;

it fails in this seemingly very stupid way:

alvherre=# \d tab1
select * from tab1;
                Table "public.tab1"
 Column │  Type   │ Collation │ Nullable │ Default 
────────┼─────────┼───────────┼──────────┼─────────
 a      │ integer │           │          │ 

\d: extra argument "select" ignored
\d: extra argument "*" ignored
\d: extra argument "from" ignored
\d: extra argument "tab1;" ignored

It would be useful to stop looking for arguments at EOL.  This behavior
is at odds with how backslash commands work elsewhere.


However, if you don't have a table named 'tab1', processing stops right
there:

alvherre=# \d tab1
select * from tab1;
Did not find any relation named "tab1".
alvherre=# 

I think this would be fine in ON_ERROR_STOP mode, but I have that turned
off here, so it looks like a bug to me.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Jack Christensen
Date:
Subject: Re: Possible hole in Windows directory restrictions?
Next
From: Tom Lane
Date:
Subject: Re: Possible hole in Windows directory restrictions?