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

Commit81e094b

Browse files
committed
Support tab-complete for TRUNCATE on foreign tables.
Commit8ff1c94 extended TRUNCATE command so that it can also truncateforeign tables. But it forgot to support tab-complete for TRUNCATE onforeign tables. That is, previously tab-complete for TRUNCATE displayedonly the names of regular tables.This commit improves tab-complete for TRUNCATE so that it displays alsothe names of foreign tables.Author: Fujii MasaoReviewed-by: Bharath RupireddyDiscussion:https://postgr.es/m/551ed8c1-f531-818b-664a-2cecdab99cd8@oss.nttdata.com
1 parentb094063 commit81e094b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,18 @@ static const SchemaQuery Query_for_list_of_selectables = {
549549
.result="pg_catalog.quote_ident(c.relname)",
550550
};
551551

552+
/* Relations supporting TRUNCATE */
553+
staticconstSchemaQueryQuery_for_list_of_truncatables= {
554+
.catname="pg_catalog.pg_class c",
555+
.selcondition=
556+
"c.relkind IN ("CppAsString2(RELKIND_RELATION)", "
557+
CppAsString2(RELKIND_FOREIGN_TABLE)", "
558+
CppAsString2(RELKIND_PARTITIONED_TABLE)")",
559+
.viscondition="pg_catalog.pg_table_is_visible(c.oid)",
560+
.namespace="c.relnamespace",
561+
.result="pg_catalog.quote_ident(c.relname)",
562+
};
563+
552564
/* Relations supporting GRANT are currently same as those supporting SELECT */
553565
#defineQuery_for_list_of_grantables Query_for_list_of_selectables
554566

@@ -3834,14 +3846,14 @@ psql_completion(const char *text, int start, int end)
38343846

38353847
/* TRUNCATE */
38363848
elseif (Matches("TRUNCATE"))
3837-
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
3849+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_truncatables,
38383850
" UNION SELECT 'TABLE'"
38393851
" UNION SELECT 'ONLY'");
38403852
elseif (Matches("TRUNCATE","TABLE"))
3841-
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
3853+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_truncatables,
38423854
" UNION SELECT 'ONLY'");
38433855
elseif (HeadMatches("TRUNCATE")&&TailMatches("ONLY"))
3844-
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,NULL);
3856+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_truncatables,NULL);
38453857
elseif (Matches("TRUNCATE",MatchAny)||
38463858
Matches("TRUNCATE","TABLE|ONLY",MatchAny)||
38473859
Matches("TRUNCATE","TABLE","ONLY",MatchAny))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp