Re: psql: tab-completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM - Mailing list pgsql-hackers
From | Yugo Nagata |
---|---|
Subject | Re: psql: tab-completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM |
Date | |
Msg-id | 20250828162204.a2bcd6a988a1b6906a4c9045@sraoss.co.jp Whole thread Raw |
In response to | Re: psql: tab-completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM (Kirill Reshke <reshkekirill@gmail.com>) |
Responses |
Re: psql: tab-completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM
|
List | pgsql-hackers |
Hi > > > > > > Currently, tab completion for COPY only suggests filenames after TO or > > > > > > FROM, even though STDIN, STDOUT, and PROGRAM are also valid syntax options. > > > > > > > > > > > > I'd like to propose improving the tab completion behavior as described in > > > > > > the subject, so that these keywords are suggested appropriately, and filenames > > > > > > are offered as potential command names after the PROGRAM keyword. > > > > > > > > > > > > I've attached this proposal as a patch series with the following three parts: > > > > > > > > > > I'm sorry but the previous patches were accidentally broken and didn't work. > > > > > I've attached fixed patches. > > > > > > > > > > > > > > > > > 0001: Refactor match_previous_words() to remove direct use of rl_completion_matches() > > > > > > > > > > > > This is a preparatory cleanup. Most completions in match_previous_words() already use > > > > > > COMPLETE_WITH* macros, which wrap rl_completion_matches(). However, some direct calls > > > > > > still remain. > > > > > > > > > > > > This patch replaces the remaining direct calls with COMPLETE_WITH_FILES or > > > > > > COMPLETE_WITH_GENERATOR, improving consistency and readability. > > > > > > > > > > > > 0002: Add tab completion support for COPY ... TO/FROM STDIN, STDOUT, and PROGRAM > > > > > > > > > > > > This is the main patch. It extends tab completion to suggest STDIN, STDOUT, and PROGRAM > > > > > > after TO or FROM. After PROGRAM, filenames are suggested as possible command names. > > > > > > > > > > > > To support this, a new macro COMPLETE_WITH_FILES_PLUS is introduced. This allows > > > > > > combining literal keywords with filename suggestions in the completion list. > > > > > > > > > > > > 0003: Improve tab completion for COPY option lists > > > > > > > > > > > > Currently, only the first option in a parenthesized list is suggested during completion, > > > > > > and nothing is suggested after a comma. > > > > > > > > > > > > This patch enables suggestions after each comma, improving usability when specifying > > > > > > multiple options. > > > > > > > > > > > > Although not directly related to the main proposal, I believe this is a helpful enhancement > > > > > > to COPY tab completion and included it here for completeness. > > > > > > > > > > > > I’d appreciate your review and feedback on this series. > Hi! This tab completion support is indeed very useful. Thanks for > working on this. Thank you for your feedback! > I spotted potential improvement here: current v5 does not support COPY > completion for a pattern I do frequently use: > specifying COPY options without WITH clause e.g. "copy yy from > '/home/reshke/cpg/csv.csv' <tab>" Is not completed with BINARY, CSV, > DELIMITER etc. This is the old syntax and is supported for backward compatibility (commit 923413ac6d3), but I’m not sure it’s worth supporting in tab completion. Perhaps it would be better to discuss this point in a separate thread. Regards, Yugo Nagata -- Yugo Nagata <nagata@sraoss.co.jp>
pgsql-hackers by date: