Support tab-complete for TRUNCATE on foreign tables.
Commit 8ff1c94649
extended TRUNCATE command so that it can also truncate
foreign tables. But it forgot to support tab-complete for TRUNCATE on
foreign tables. That is, previously tab-complete for TRUNCATE displayed
only the names of regular tables.
This commit improves tab-complete for TRUNCATE so that it displays also
the names of foreign tables.
Author: Fujii Masao
Reviewed-by: Bharath Rupireddy
Discussion: https://postgr.es/m/551ed8c1-f531-818b-664a-2cecdab99cd8@oss.nttdata.com
This commit is contained in:
parent
b094063cd1
commit
81e094bdfd
|
@ -549,6 +549,18 @@ static const SchemaQuery Query_for_list_of_selectables = {
|
||||||
.result = "pg_catalog.quote_ident(c.relname)",
|
.result = "pg_catalog.quote_ident(c.relname)",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Relations supporting TRUNCATE */
|
||||||
|
static const SchemaQuery Query_for_list_of_truncatables = {
|
||||||
|
.catname = "pg_catalog.pg_class c",
|
||||||
|
.selcondition =
|
||||||
|
"c.relkind IN (" CppAsString2(RELKIND_RELATION) ", "
|
||||||
|
CppAsString2(RELKIND_FOREIGN_TABLE) ", "
|
||||||
|
CppAsString2(RELKIND_PARTITIONED_TABLE) ")",
|
||||||
|
.viscondition = "pg_catalog.pg_table_is_visible(c.oid)",
|
||||||
|
.namespace = "c.relnamespace",
|
||||||
|
.result = "pg_catalog.quote_ident(c.relname)",
|
||||||
|
};
|
||||||
|
|
||||||
/* Relations supporting GRANT are currently same as those supporting SELECT */
|
/* Relations supporting GRANT are currently same as those supporting SELECT */
|
||||||
#define Query_for_list_of_grantables Query_for_list_of_selectables
|
#define Query_for_list_of_grantables Query_for_list_of_selectables
|
||||||
|
|
||||||
|
@ -3834,14 +3846,14 @@ psql_completion(const char *text, int start, int end)
|
||||||
|
|
||||||
/* TRUNCATE */
|
/* TRUNCATE */
|
||||||
else if (Matches("TRUNCATE"))
|
else if (Matches("TRUNCATE"))
|
||||||
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
|
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_truncatables,
|
||||||
" UNION SELECT 'TABLE'"
|
" UNION SELECT 'TABLE'"
|
||||||
" UNION SELECT 'ONLY'");
|
" UNION SELECT 'ONLY'");
|
||||||
else if (Matches("TRUNCATE", "TABLE"))
|
else if (Matches("TRUNCATE", "TABLE"))
|
||||||
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables,
|
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_truncatables,
|
||||||
" UNION SELECT 'ONLY'");
|
" UNION SELECT 'ONLY'");
|
||||||
else if (HeadMatches("TRUNCATE") && TailMatches("ONLY"))
|
else if (HeadMatches("TRUNCATE") && TailMatches("ONLY"))
|
||||||
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
|
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_truncatables, NULL);
|
||||||
else if (Matches("TRUNCATE", MatchAny) ||
|
else if (Matches("TRUNCATE", MatchAny) ||
|
||||||
Matches("TRUNCATE", "TABLE|ONLY", MatchAny) ||
|
Matches("TRUNCATE", "TABLE|ONLY", MatchAny) ||
|
||||||
Matches("TRUNCATE", "TABLE", "ONLY", MatchAny))
|
Matches("TRUNCATE", "TABLE", "ONLY", MatchAny))
|
||||||
|
|
Loading…
Reference in New Issue