Redundant psql tab-completion for CREATE PUBLICATION
Hi,
While looking at Justin's patch for VACUUM completions, I found an
existing bit of code that tries to match on a word with a space:
/* Complete "CREATE PUBLICATION <name> FOR TABLE <table>" */
else if (Matches4("CREATE", "PUBLICATION", MatchAny, "FOR TABLE"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
I think the clause will never match the "FOR TABLE" word; and can, in
any case, be removed, as the the final check for completable "things"
(at the end of psql_completion) will see "TABLE" and act
appropriately.
Here's a little patch to remove these lines.
Edmund
Attachments:
remove-redundant-create-publication-completion.patchapplication/octet-stream; name=remove-redundant-create-publication-completion.patchDownload
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 7bb47ea..d67b4fb 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2644,9 +2664,6 @@ psql_completion(const char *text, int start, int end)
COMPLETE_WITH_LIST3("FOR TABLE", "FOR ALL TABLES", "WITH (");
else if (Matches4("CREATE", "PUBLICATION", MatchAny, "FOR"))
COMPLETE_WITH_LIST2("TABLE", "ALL TABLES");
- /* Complete "CREATE PUBLICATION <name> FOR TABLE <table>" */
- else if (Matches4("CREATE", "PUBLICATION", MatchAny, "FOR TABLE"))
- COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
/* Complete "CREATE PUBLICATION <name> [...] WITH" */
else if (HeadMatches2("CREATE", "PUBLICATION") && TailMatches2("WITH", "("))
COMPLETE_WITH_CONST("publish");
[ This seems to have slipped through the cracks, sorry about that ]
Edmund Horner <ejrh00@gmail.com> writes:
While looking at Justin's patch for VACUUM completions, I found an
existing bit of code that tries to match on a word with a space:
/* Complete "CREATE PUBLICATION <name> FOR TABLE <table>" */
else if (Matches4("CREATE", "PUBLICATION", MatchAny, "FOR TABLE"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
I think the clause will never match the "FOR TABLE" word;
Yeah, that's certainly right.
and can, in
any case, be removed, as the the final check for completable "things"
(at the end of psql_completion) will see "TABLE" and act
appropriately.
But that only works for the table name immediately after TABLE, not
for a list of table names. I think we need to fix it like this,
instead:
- /* Complete "CREATE PUBLICATION <name> FOR TABLE <table>" */
- else if (Matches4("CREATE", "PUBLICATION", MatchAny, "FOR TABLE"))
+ /* Complete "CREATE PUBLICATION <name> FOR TABLE <table>, ..." */
+ else if (HeadMatches5("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLE"))
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
Pushed like that.
regards, tom lane