Fix tab-completion after commit 790bf615dd

I (Álvaro) broke tab-completion for GRANT .. ALL TABLES IN SCHEMA while
removing ALL from the publication syntax for schemas in the
aforementioned commit.  I also missed to update a bunch of
tab-completion rules for ALTER/CREATE PUBLICATION that match each
individual piece of ALL TABLES IN SCHEMA.  Repair those bugs.

While fixing up that commit, update a couple of outdated comments
related to the same change.

Backpatch to 15.

Author: Shi yu <shiy.fnst@fujitsu.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/OSZPR01MB6310FCE8609185A56344EED2FD559@OSZPR01MB6310.jpnprd01.prod.outlook.com
This commit is contained in:
Alvaro Herrera 2022-09-30 12:53:31 +02:00
parent 51fd7cdfd0
commit 69298db8e1
No known key found for this signature in database
GPG Key ID: 1C20ACB9D5C564AE
3 changed files with 12 additions and 10 deletions

View File

@ -978,8 +978,8 @@ fetch_remote_table_info(char *nspname, char *relname,
* *
* 2) one of the subscribed publications has puballtables set to true * 2) one of the subscribed publications has puballtables set to true
* *
* 3) one of the subscribed publications is declared as ALL TABLES IN * 3) one of the subscribed publications is declared as TABLES IN SCHEMA
* SCHEMA that includes this relation * that includes this relation
*/ */
if (walrcv_server_version(LogRepWorkerWalRcvConn) >= 150000) if (walrcv_server_version(LogRepWorkerWalRcvConn) >= 150000)
{ {

View File

@ -1848,7 +1848,7 @@ psql_completion(const char *text, int start, int end)
/* ALTER PUBLICATION <name> SET */ /* ALTER PUBLICATION <name> SET */
else if (Matches("ALTER", "PUBLICATION", MatchAny, "SET")) else if (Matches("ALTER", "PUBLICATION", MatchAny, "SET"))
COMPLETE_WITH("(", "TABLES IN SCHEMA", "TABLE"); COMPLETE_WITH("(", "TABLES IN SCHEMA", "TABLE");
else if (Matches("ALTER", "PUBLICATION", MatchAny, "ADD|DROP|SET", "ALL", "TABLES", "IN", "SCHEMA")) else if (Matches("ALTER", "PUBLICATION", MatchAny, "ADD|DROP|SET", "TABLES", "IN", "SCHEMA"))
COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_schemas COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_schemas
" AND nspname NOT LIKE E'pg\\\\_%%'", " AND nspname NOT LIKE E'pg\\\\_%%'",
"CURRENT_SCHEMA"); "CURRENT_SCHEMA");
@ -2994,9 +2994,11 @@ psql_completion(const char *text, int start, int end)
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR")) else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR"))
COMPLETE_WITH("TABLE", "ALL TABLES", "TABLES IN SCHEMA"); COMPLETE_WITH("TABLE", "ALL TABLES", "TABLES IN SCHEMA");
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL")) else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL"))
COMPLETE_WITH("TABLES", "TABLES IN SCHEMA"); COMPLETE_WITH("TABLES");
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES")) else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES"))
COMPLETE_WITH("IN SCHEMA", "WITH ("); COMPLETE_WITH("WITH (");
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLES"))
COMPLETE_WITH("IN SCHEMA");
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLE", MatchAny) && !ends_with(prev_wd, ',')) else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLE", MatchAny) && !ends_with(prev_wd, ','))
COMPLETE_WITH("WHERE (", "WITH ("); COMPLETE_WITH("WHERE (", "WITH (");
/* Complete "CREATE PUBLICATION <name> FOR TABLE" with "<table>, ..." */ /* Complete "CREATE PUBLICATION <name> FOR TABLE" with "<table>, ..." */
@ -3017,11 +3019,11 @@ psql_completion(const char *text, int start, int end)
/* /*
* Complete "CREATE PUBLICATION <name> FOR TABLES IN SCHEMA <schema>, ..." * Complete "CREATE PUBLICATION <name> FOR TABLES IN SCHEMA <schema>, ..."
*/ */
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES", "IN", "SCHEMA")) else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLES", "IN", "SCHEMA"))
COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_schemas COMPLETE_WITH_QUERY_PLUS(Query_for_list_of_schemas
" AND nspname NOT LIKE E'pg\\\\_%%'", " AND nspname NOT LIKE E'pg\\\\_%%'",
"CURRENT_SCHEMA"); "CURRENT_SCHEMA");
else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "ALL", "TABLES", "IN", "SCHEMA", MatchAny) && (!ends_with(prev_wd, ','))) else if (Matches("CREATE", "PUBLICATION", MatchAny, "FOR", "TABLES", "IN", "SCHEMA", MatchAny) && (!ends_with(prev_wd, ',')))
COMPLETE_WITH("WITH ("); COMPLETE_WITH("WITH (");
/* Complete "CREATE PUBLICATION <name> [...] WITH" */ /* Complete "CREATE PUBLICATION <name> [...] WITH" */
else if (HeadMatches("CREATE", "PUBLICATION") && TailMatches("WITH", "(")) else if (HeadMatches("CREATE", "PUBLICATION") && TailMatches("WITH", "("))
@ -3835,7 +3837,7 @@ psql_completion(const char *text, int start, int end)
"ALL PROCEDURES IN SCHEMA", "ALL PROCEDURES IN SCHEMA",
"ALL ROUTINES IN SCHEMA", "ALL ROUTINES IN SCHEMA",
"ALL SEQUENCES IN SCHEMA", "ALL SEQUENCES IN SCHEMA",
"TABLES IN SCHEMA", "ALL TABLES IN SCHEMA",
"DATABASE", "DATABASE",
"DOMAIN", "DOMAIN",
"FOREIGN DATA WRAPPER", "FOREIGN DATA WRAPPER",

View File

@ -899,8 +899,8 @@ is( $node_subscriber->safe_psql('postgres', "SELECT * FROM test_mix_2"),
'all columns should be replicated'); 'all columns should be replicated');
# TEST: With a table included in the publication which is FOR ALL TABLES # TEST: With a table included in the publication which is FOR TABLES IN
# IN SCHEMA, it means replicate all columns. # SCHEMA, it means replicate all columns.
$node_subscriber->safe_psql( $node_subscriber->safe_psql(
'postgres', qq( 'postgres', qq(