[PATCH v1] psql: Do not complete HEADER MATCH for COPY TO
[PATCH v1] psql: Do not complete HEADER MATCH for COPY TO
Hi,
I noticed that psql's tab completion suggests MATCH as a value of the
HEADER option for both directions of COPY.
For example:
COPY t1 TO STDOUT WITH (HEADER <TAB><TAB>
false MATCH true
However, the documentation says that HEADER MATCH is valid only for
COPY FROM. If a user selects the suggested "MATCH" candidate for
COPY TO, the command fails:
COPY t1 TO STDOUT WITH (HEADER MATCH);
ERROR: cannot use "match" with HEADER in COPY TO
I think it is misleading for tab completion to suggest syntax that is
explicitly unsupported by the documentation and rejected by the
server.
The attached patch checks the COPY direction and offers "MATCH" only
for COPY FROM. The boolean values remain available in both
directions, and the change applies to both COPY and \copy completion.
Regards,
Taiki Koshino<koshino@sraoss.co.jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/
Re: [PATCH v1] psql: Do not complete HEADER MATCH for COPY TO
От:
Sho Ito <i.sho.0628@gmail.com>
Дата:
On Tue, Nov 3, 2026 at 8:24 PM Koshino Taiki <koshino@sraoss.co.jp> wrote:
The attached patch checks the COPY direction and offers "MATCH" onlyfor COPY FROM. The boolean values remain available in bothdirections, and the change applies to both COPY and \copy completion.
Hi Taiki,
I reviewed v1 on master with assertions enabled. The build and before/after
Readline completion checks pass for both `COPY` and `\copy`: `MATCH` is
removed for `TO` and retained for `FROM`, while `true` and `false` remain
available.
Console checks confirm that both commands reject `HEADER MATCH` for `TO` [1]
and accept it for `FROM`, checking the column names.
I don't see any issues with this patch.
[1] https://github.com/postgres/postgres/blob/126976a8ffcfa47f40d3df09243ebf4606001912/src/backend/commands/copy.c#L434-L441
I reviewed v1 on master with assertions enabled. The build and before/after
Readline completion checks pass for both `COPY` and `\copy`: `MATCH` is
removed for `TO` and retained for `FROM`, while `true` and `false` remain
available.
Console checks confirm that both commands reject `HEADER MATCH` for `TO` [1]
and accept it for `FROM`, checking the column names.
I don't see any issues with this patch.
[1] https://github.com/postgres/postgres/blob/126976a8ffcfa47f40d3df09243ebf4606001912/src/backend/commands/copy.c#L434-L441
Thanks,
Sho
=======================================
Sho Ito (Sean)
E-mail: i.sho.0628@gmail.com
GitHub: https://github.com/sean0628/
=======================================
Re: [PATCH v1] psql: Do not complete HEADER MATCH for COPY TO
От:
Chao Li <li.evan.chao@gmail.com>
Дата:
> On Nov 4, 2026, at 09:24, Koshino Taiki wrote: > > Hi, > > I noticed that psql's tab completion suggests MATCH as a value of the > HEADER option for both directions of COPY. > > For example: > > COPY t1 TO STDOUT WITH (HEADER > false MATCH true > > However, the documentation says that HEADER MATCH is valid only for > COPY FROM. If a user selects the suggested "MATCH" candidate for > COPY TO, the command fails: > > COPY t1 TO STDOUT WITH (HEADER MATCH); > ERROR: cannot use "match" with HEADER in COPY TO > > I think it is misleading for tab completion to suggest syntax that is > explicitly unsupported by the documentation and rejected by the > server. > > The attached patch checks the COPY direction and offers "MATCH" only > for COPY FROM. The boolean values remain available in both > directions, and the change applies to both COPY and \copy completion. > > Regards, > > Taiki Koshino > SRA OSS K.K. > TEL: 03-5979-2701 FAX: 03-5979-2702 > URL: https://www.sraoss.co.jp/ > > The fix looks good, however, there is an earlier patch [1] already. [1] https://postgr.es/m/CAF1DzPXjeGHhpgKzEWmpuoxdZWwErN79yRodOkwRYAt7Bdn2BA@mail.gmail.com Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/
Re: [PATCH v1] psql: Do not complete HEADER MATCH for COPY TO
От:
Koshino Taiki <koshino@sraoss.co.jp>
Дата:
> The fix looks good, however, there is an earlier patch [1] already.
>
> [1] https://postgr.es/m/CAF1DzPXjeGHhpgKzEWmpuoxdZWwErN79yRodOkwRYAt7Bdn2BA@mail.gmail.comHi,As pointed out, the same issues have already been addressedin an earlier patch, so I am withdrawing my patches.Regards,
Taiki Koshino<koshino@sraoss.co.jp>
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/
SRA OSS K.K.
TEL: 03-5979-2701 FAX: 03-5979-2702
URL: https://www.sraoss.co.jp/
差出人: Chao Li <li.evan.chao@gmail.com>
送信日時: 2026年11月4日 16:05
宛先: Koshino Taiki <koshino@sraoss.co.jp>
CC: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; Yugo Nagata <nagata@sraoss.co.jp>
件名: Re: [PATCH v1] psql: Do not complete HEADER MATCH for COPY TO
送信日時: 2026年11月4日 16:05
宛先: Koshino Taiki <koshino@sraoss.co.jp>
CC: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>; Yugo Nagata <nagata@sraoss.co.jp>
件名: Re: [PATCH v1] psql: Do not complete HEADER MATCH for COPY TO
> On Nov 4, 2026, at 09:24, Koshino Taiki <koshino@sraoss.co.jp> wrote:
>
> Hi,
>
> I noticed that psql's tab completion suggests MATCH as a value of the
> HEADER option for both directions of COPY.
>
> For example:
>
> COPY t1 TO STDOUT WITH (HEADER <TAB><TAB>
> false MATCH true
>
> However, the documentation says that HEADER MATCH is valid only for
> COPY FROM. If a user selects the suggested "MATCH" candidate for
> COPY TO, the command fails:
>
> COPY t1 TO STDOUT WITH (HEADER MATCH);
> ERROR: cannot use "match" with HEADER in COPY TO
>
> I think it is misleading for tab completion to suggest syntax that is
> explicitly unsupported by the documentation and rejected by the
> server.
>
> The attached patch checks the COPY direction and offers "MATCH" only
> for COPY FROM. The boolean values remain available in both
> directions, and the change applies to both COPY and \copy completion.
>
> Regards,
>
> Taiki Koshino<koshino@sraoss.co.jp>
> SRA OSS K.K.
> TEL: 03-5979-2701 FAX: 03-5979-2702
> URL: https://www.sraoss.co.jp/
>
> <v1-0001-psql-Do-not-complete-HEADER-MATCH-for-COPY-TO.patch>
The fix looks good, however, there is an earlier patch [1] already.
[1] https://postgr.es/m/CAF1DzPXjeGHhpgKzEWmpuoxdZWwErN79yRodOkwRYAt7Bdn2BA@mail.gmail.com
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/