Lists: | pgsql-hackers |
---|
From: | Jingtang Zhang <mrdrivingduck(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Two successive tabs in test case are causing syntax error in psql |
Date: | 2022-07-08 15:31:20 |
Message-ID: | CAPsk3_CiVMdfK6feYMzMsFAz5EJGNxC5SH4TL=wfKXfK3BkigQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi, community.
Recently, when I was developing some function about INSERT ... ON CONFLICT,
I used test cases in `src/test/regress/sql/insert_conflict.sql` to evaluate
my function. When I copy the CREATE TABLE from this case alone, and paste
it to psql, I got a syntax error. As I go through the case carefully, I
found the CREATE TABLE uses two tabs to separate column name and column
type, and this two tabs are regarded as an auto completion instruction by
psql, causing no separation between column name and column type anymore.
It may not be a problem since this case has passed the regression, but
would it be better to use space here to avoid this confusing situation?
Since other part of this case are all using spaces.
Never mind my opinion as a beginner, thanks.
Jingtang Zhang
Attachment | Content-Type | Size |
---|---|---|
0001-Fix-two-tabs-are-regarded-as-auto-completion-in-test.patch | application/octet-stream | 2.7 KB |
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Jingtang Zhang <mrdrivingduck(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Two successive tabs in test case are causing syntax error in psql |
Date: | 2022-07-08 19:35:26 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
Jingtang Zhang <mrdrivingduck(at)gmail(dot)com> writes:
> Recently, when I was developing some function about INSERT ... ON CONFLICT,
> I used test cases in `src/test/regress/sql/insert_conflict.sql` to evaluate
> my function. When I copy the CREATE TABLE from this case alone, and paste
> it to psql, I got a syntax error. As I go through the case carefully, I
> found the CREATE TABLE uses two tabs to separate column name and column
> type, and this two tabs are regarded as an auto completion instruction by
> psql, causing no separation between column name and column type anymore.
> It may not be a problem since this case has passed the regression, but
> would it be better to use space here to avoid this confusing situation?
There are tabs all through the regression test files, and we're certainly
not going to remove them all. (If we did, we'd lose test coverage of
whether the parser accepts tabs as whitespace.) So I can't get excited
about removing one or two.
The usual recommendation for pasting text into psql when it contains
tabs is to start psql with the -n switch to disable tab completion.
regards, tom lane
From: | Jingtang Zhang <mrdrivingduck(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Two successive tabs in test case are causing syntax error in psql |
Date: | 2022-07-09 02:18:45 |
Message-ID: | CAPsk3_CZgChnwg+gbUquZ9GbCdBiHkC8gv04HYed96UT13Np_A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
I see, thank you.
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> 于2022年7月9日周六 03:35写道:
> Jingtang Zhang <mrdrivingduck(at)gmail(dot)com> writes:
> > Recently, when I was developing some function about INSERT ... ON
> CONFLICT,
> > I used test cases in `src/test/regress/sql/insert_conflict.sql` to
> evaluate
> > my function. When I copy the CREATE TABLE from this case alone, and paste
> > it to psql, I got a syntax error. As I go through the case carefully, I
> > found the CREATE TABLE uses two tabs to separate column name and column
> > type, and this two tabs are regarded as an auto completion instruction by
> > psql, causing no separation between column name and column type anymore.
>
> > It may not be a problem since this case has passed the regression, but
> > would it be better to use space here to avoid this confusing situation?
>
> There are tabs all through the regression test files, and we're certainly
> not going to remove them all. (If we did, we'd lose test coverage of
> whether the parser accepts tabs as whitespace.) So I can't get excited
> about removing one or two.
>
> The usual recommendation for pasting text into psql when it contains
> tabs is to start psql with the -n switch to disable tab completion.
>
> regards, tom lane
>
From: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Jingtang Zhang <mrdrivingduck(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Two successive tabs in test case are causing syntax error in psql |
Date: | 2022-07-10 15:26:18 |
Message-ID: | [email protected] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 2022-Jul-08, Tom Lane wrote:
> The usual recommendation for pasting text into psql when it contains
> tabs is to start psql with the -n switch to disable tab completion.
"Bracketed paste" also solves this problem. To enable this feature,
just edit your $HOME/.inputrc file to have the line
set enable-bracketed-paste on
(then restart psql) which will cause the text passed to be used
literally, so the tabs won't invoke tab-completion. There are other
side-effects: if you paste a multi-command string, the whole string is
added as a single entry in the history rather than being separate
entries. I find this extremely useful; there are also claims of this
being more secure.
--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/