Skip to content

Commit 2d22329

Browse files
committed
Update tab-completion for CREATE PUBLICATION with sequences
Commit 75b1521 added support for sequences to built-in replication, but the tab-completion was updated only for ALTER PUBLICATION, not for CREATE PUBLICATION. Report and patch by Masahiko Sawada. Author: Masahiko Sawada Discussion: https://postgr.es/m/CAD21AoDtKpdJcHOLjfPQ7TmpFqNB5__%3DQ_g1e8OBRrwT5LP-%3Dg%40mail.gmail.com
1 parent 49d9cfc commit 2d22329

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/bin/psql/tab-complete.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2971,21 +2971,27 @@ psql_completion(const char *text, int start, int end)
29712971

29722972
/* CREATE PUBLICATION */
29732973
else if (Matches("CREATE", "PUBLICATION", MatchAny))
2974-
COMPLETE_WITH("FOR TABLE", "FOR ALL TABLES", "FOR ALL TABLES IN SCHEMA", "WITH (");
2974+
COMPLETE_WITH("FOR TABLE", "FOR ALL TABLES", "FOR ALL TABLES IN SCHEMA",
2975+
"FOR SEQUENCE", "FOR ALL SEQUENCES", "FOR ALL SEQUENCES IN SCHEMA",
2976+
"WITH (");
29752977
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR"))
2976-
COMPLETE_WITH("TABLE", "ALL TABLES", "ALL TABLES IN SCHEMA");
2978+
COMPLETE_WITH("TABLE", "ALL TABLES", "ALL TABLES IN SCHEMA",
2979+
"SEQUENCE", "ALL SEQUENCES", "ALL SEQUENCES IN SCHEMA");
29772980
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL"))
2978-
COMPLETE_WITH("TABLES", "TABLES IN SCHEMA");
2979-
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES"))
2981+
COMPLETE_WITH("TABLES", "TABLES IN SCHEMA", "SEQUENCES", "SEQUENCES IN SCHEMA");
2982+
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES|SEQUENCES"))
29802983
COMPLETE_WITH("IN SCHEMA", "WITH (");
2981-
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLE", MatchAny) && !ends_with(prev_wd, ','))
2984+
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLE|SEQUENCE", MatchAny) && !ends_with(prev_wd, ','))
29822985
COMPLETE_WITH("WHERE (", "WITH (");
29832986
/* Complete "CREATE PUBLICATION <name> FOR TABLE" with "<table>, ..." */
29842987
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLE"))
29852988
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables);
2989+
/* Complete "CREATE PUBLICATION <name> FOR SEQUENCE" with "<sequence>, ..." */
2990+
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "SEQUENCE"))
2991+
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_sequences);
29862992

29872993
/*
2988-
* "CREATE PUBLICATION <name> FOR TABLE <name> WHERE (" - complete with
2994+
* "CREATE PUBLICATION <name> FOR TABLE|SEQUENCE <name> WHERE (" - complete with
29892995
* table attributes
29902996
*/
29912997
else if (HeadMatches("CREATE", "PUBLICATION", MatchAny) && TailMatches("WHERE"))
@@ -2996,14 +3002,14 @@ psql_completion(const char *text, int start, int end)
29963002
COMPLETE_WITH(" WITH (");
29973003

29983004
/*
2999-
* Complete "CREATE PUBLICATION <name> FOR ALL TABLES IN SCHEMA <schema>,
3005+
* Complete "CREATE PUBLICATION <name> FOR ALL TABLES|SEQUENCES IN SCHEMA <schema>,
30003006
* ..."
30013007
*/
3002-
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES", "IN", "SCHEMA"))
3008+
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES|SEQUENCES", "IN", "SCHEMA"))
30033009
COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_schemas
30043010
" AND nspname NOT LIKE E'pg\\\\_%%'",
30053011
"CURRENT_SCHEMA");
3006-
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES", "IN", "SCHEMA", MatchAny) && (!ends_with(prev_wd, ',')))
3012+
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES|SEQUENCES", "IN", "SCHEMA", MatchAny) && (!ends_with(prev_wd, ',')))
30073013
COMPLETE_WITH("WITH (");
30083014
/* Complete "CREATE PUBLICATION <name> [...] WITH" */
30093015
else if (HeadMatches("CREATE", "PUBLICATION") && TailMatches("WITH", "("))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy