Improve tab completion for COPY

torikoshia <torikoshia@oss.nttdata.com>

From: torikoshia <torikoshia@oss.nttdata.com>
To: Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2025-05-07T06:39:26Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix tab-completion for COPY and \copy options.

  2. Add tab completion for REJECT_LIMIT option.

  3. Allow "COPY table TO" command to copy rows from materialized views.

  4. Add REJECT_LIMIT option to the COPY command.

Attachments

Hi,

I noticed that REJECT_LIMIT, an option available for COPY FROM, is not 
currently supported in psql's tab completion.

Additionally, some options are only valid for COPY FROM or COPY TO, i.e. 
FREEZE, ON_ERROR, FORCE_QUOTE, but psql currently suggests them for both 
COPY FROM and COPY TO.
As the number of COPY options continues to grow, I feel that having 
irrelevant suggestions makes tab completion noisier.

Attached patch splits the tab completion rules between COPY FROM and 
COPY TO, so that only the appropriate options are suggested for each.

What do you think?


Regards,

--
Atsushi Torikoshi
Seconded from NTT DATA GROUP CORPORATION to SRA OSS K.K.