Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit765a4c9

Browse files
Fix tab-completion for COPY and \copy options.
Commitc273d9d reworked tab-completion of COPY and \copy in psqland added support for completing options within WITH clauses. However,the same COPY options were suggested for both COPY TO and COPY FROMcommands, even though some options are only valid for one or theother.This commit separates the COPY options for COPY FROM and COPY TOcommands to provide more accurate auto-completion suggestions.Back-patch to v14 where tab-completion for COPY and \copy optionswithin WITH clauses was first supported.Author: Atsushi Torikoshi <torikoshia@oss.nttdata.com>Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp>Discussion:https://postgr.es/m/079e7a2c801f252ae8d522b772790ed7@oss.nttdata.comBackpatch-through: 14
1 parent5d9e675 commit765a4c9

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

‎src/bin/psql/tab-complete.in.c‎

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,19 @@ Alter_procedure_options, "COST", "IMMUTABLE", "LEAKPROOF", "NOT LEAKPROOF", \
11901190
Alter_routine_options, "CALLED ON NULL INPUT", "RETURNS NULL ON NULL INPUT", \
11911191
"STRICT", "SUPPORT"
11921192

1193+
/* COPY options shared between FROM and TO */
1194+
#defineCopy_common_options \
1195+
"DELIMITER", "ENCODING", "ESCAPE", "FORMAT", "HEADER", "NULL", "QUOTE"
1196+
1197+
/* COPY FROM options */
1198+
#defineCopy_from_options \
1199+
Copy_common_options, "DEFAULT", "FORCE_NOT_NULL", "FORCE_NULL", "FREEZE", \
1200+
"LOG_VERBOSITY", "ON_ERROR", "REJECT_LIMIT"
1201+
1202+
/* COPY TO options */
1203+
#defineCopy_to_options \
1204+
Copy_common_options, "FORCE_QUOTE"
1205+
11931206
/*
11941207
* These object types were introduced later than our support cutoff of
11951208
* server version 9.2. We use the VersionedQuery infrastructure so that
@@ -3284,23 +3297,24 @@ match_previous_words(int pattern_id,
32843297
elseif (Matches("COPY|\\copy",MatchAny,"FROM",MatchAny))
32853298
COMPLETE_WITH("WITH (","WHERE");
32863299

3287-
/* Complete COPY <sth> FROM|TO filename WITH ( */
3288-
elseif (Matches("COPY|\\copy",MatchAny,"FROM|TO",MatchAny,"WITH","("))
3289-
COMPLETE_WITH("FORMAT","FREEZE","DELIMITER","NULL",
3290-
"HEADER","QUOTE","ESCAPE","FORCE_QUOTE",
3291-
"FORCE_NOT_NULL","FORCE_NULL","ENCODING","DEFAULT",
3292-
"ON_ERROR","LOG_VERBOSITY","REJECT_LIMIT");
3300+
/* Complete COPY <sth> FROM filename WITH ( */
3301+
elseif (Matches("COPY|\\copy",MatchAny,"FROM",MatchAny,"WITH","("))
3302+
COMPLETE_WITH(Copy_from_options);
3303+
3304+
/* Complete COPY <sth> TO filename WITH ( */
3305+
elseif (Matches("COPY|\\copy",MatchAny,"TO",MatchAny,"WITH","("))
3306+
COMPLETE_WITH(Copy_to_options);
32933307

32943308
/* Complete COPY <sth> FROM|TO filename WITH (FORMAT */
32953309
elseif (Matches("COPY|\\copy",MatchAny,"FROM|TO",MatchAny,"WITH","(","FORMAT"))
32963310
COMPLETE_WITH("binary","csv","text");
32973311

32983312
/* Complete COPY <sth> FROM filename WITH (ON_ERROR */
3299-
elseif (Matches("COPY|\\copy",MatchAny,"FROM|TO",MatchAny,"WITH","(","ON_ERROR"))
3313+
elseif (Matches("COPY|\\copy",MatchAny,"FROM",MatchAny,"WITH","(","ON_ERROR"))
33003314
COMPLETE_WITH("stop","ignore");
33013315

33023316
/* Complete COPY <sth> FROM filename WITH (LOG_VERBOSITY */
3303-
elseif (Matches("COPY|\\copy",MatchAny,"FROM|TO",MatchAny,"WITH","(","LOG_VERBOSITY"))
3317+
elseif (Matches("COPY|\\copy",MatchAny,"FROM",MatchAny,"WITH","(","LOG_VERBOSITY"))
33043318
COMPLETE_WITH("silent","default","verbose");
33053319

33063320
/* Complete COPY <sth> FROM <sth> WITH (<options>) */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp