Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6163981

Browse files
committed
Fix error messages
Some messages related to foreign servers were reporting the server name without quotes, or not at all; our style is to have all names be quoted, and the server name already appears quoted in a few other messages, so just add quotes and make them all consistent. Remove an extra "s" in other messages (typos introduced by myself in f56f8f8).
1 parent df631eb commit 6163981

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

src/backend/commands/foreigncmds.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
11841184
{
11851185
ereport(NOTICE,
11861186
(errcode(ERRCODE_DUPLICATE_OBJECT),
1187-
errmsg("user mapping for \"%s\" already exists for server %s, skipping",
1187+
errmsg("user mapping for \"%s\" already exists for server \"%s\", skipping",
11881188
MappingUserName(useId),
11891189
stmt->servername)));
11901190

@@ -1194,7 +1194,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
11941194
else
11951195
ereport(ERROR,
11961196
(errcode(ERRCODE_DUPLICATE_OBJECT),
1197-
errmsg("user mapping for \"%s\" already exists for server %s",
1197+
errmsg("user mapping for \"%s\" already exists for server \"%s\"",
11981198
MappingUserName(useId),
11991199
stmt->servername)));
12001200
}
@@ -1294,8 +1294,8 @@ AlterUserMapping(AlterUserMappingStmt *stmt)
12941294
if (!OidIsValid(umId))
12951295
ereport(ERROR,
12961296
(errcode(ERRCODE_UNDEFINED_OBJECT),
1297-
errmsg("user mapping for \"%s\" does not exist for the server",
1298-
MappingUserName(useId))));
1297+
errmsg("user mapping for \"%s\" does not exist for server \"%s\"",
1298+
MappingUserName(useId), stmt->servername)));
12991299

13001300
user_mapping_ddl_aclcheck(useId, srv->serverid, stmt->servername);
13011301

@@ -1396,7 +1396,9 @@ RemoveUserMapping(DropUserMappingStmt *stmt)
13961396
errmsg("server \"%s\" does not exist",
13971397
stmt->servername)));
13981398
/* IF EXISTS, just note it */
1399-
ereport(NOTICE, (errmsg("server does not exist, skipping")));
1399+
ereport(NOTICE,
1400+
(errmsg("server \"%s\" does not exist, skipping",
1401+
stmt->servername)));
14001402
return InvalidOid;
14011403
}
14021404

@@ -1409,13 +1411,13 @@ RemoveUserMapping(DropUserMappingStmt *stmt)
14091411
if (!stmt->missing_ok)
14101412
ereport(ERROR,
14111413
(errcode(ERRCODE_UNDEFINED_OBJECT),
1412-
errmsg("user mapping for \"%s\" does not exist for the server",
1413-
MappingUserName(useId))));
1414+
errmsg("user mapping for \"%s\" does not exist for server \"%s\"",
1415+
MappingUserName(useId), stmt->servername)));
14141416

14151417
/* IF EXISTS specified, just note it */
14161418
ereport(NOTICE,
1417-
(errmsg("user mapping for \"%s\" does not exist for the server, skipping",
1418-
MappingUserName(useId))));
1419+
(errmsg("user mapping for \"%s\" does not exist for server \"%s\", skipping",
1420+
MappingUserName(useId), stmt->servername)));
14191421
return InvalidOid;
14201422
}
14211423

src/backend/commands/tablecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8184,7 +8184,7 @@ addFkRecurseReferencing(List **wqueue, Constraint *fkconstraint, Relation rel,
81848184
if (rel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
81858185
ereport(ERROR,
81868186
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
8187-
errmsg("foreign keys constraints are not supported on foreign tables")));
8187+
errmsg("foreign key constraints are not supported on foreign tables")));
81888188

81898189
/*
81908190
* If the referencing relation is a plain table, add the check triggers to
@@ -8572,7 +8572,7 @@ CloneFkReferencing(List **wqueue, Relation parentRel, Relation partRel)
85728572
if (partRel->rd_rel->relkind == RELKIND_FOREIGN_TABLE)
85738573
ereport(ERROR,
85748574
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
8575-
errmsg("foreign keys constraints are not supported on foreign tables")));
8575+
errmsg("foreign key constraints are not supported on foreign tables")));
85768576

85778577
/*
85788578
* The constraint key may differ, if the columns in the partition are

src/test/regress/expected/foreign_data.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ CREATE SERVER s1 FOREIGN DATA WRAPPER foo;
238238
COMMENT ON SERVER s1 IS 'foreign server';
239239
CREATE USER MAPPING FOR current_user SERVER s1;
240240
CREATE USER MAPPING FOR current_user SERVER s1; -- ERROR
241-
ERROR: user mapping for "regress_foreign_data_user" already exists for server s1
241+
ERROR: user mapping for "regress_foreign_data_user" already exists for server "s1"
242242
CREATE USER MAPPING IF NOT EXISTS FOR current_user SERVER s1; -- NOTICE
243-
NOTICE: user mapping for "regress_foreign_data_user" already exists for server s1, skipping
243+
NOTICE: user mapping for "regress_foreign_data_user" already exists for server "s1", skipping
244244
\dew+
245245
List of foreign-data wrappers
246246
Name | Owner | Handler | Validator | Access privileges | FDW options | Description
@@ -578,7 +578,7 @@ CREATE USER MAPPING FOR current_user SERVER s1; -- ERROR
578578
ERROR: server "s1" does not exist
579579
CREATE USER MAPPING FOR current_user SERVER s4;
580580
CREATE USER MAPPING FOR user SERVER s4; -- ERROR duplicate
581-
ERROR: user mapping for "regress_foreign_data_user" already exists for server s4
581+
ERROR: user mapping for "regress_foreign_data_user" already exists for server "s4"
582582
CREATE USER MAPPING FOR public SERVER s4 OPTIONS ("this mapping" 'is public');
583583
CREATE USER MAPPING FOR user SERVER s8 OPTIONS (username 'test', password 'secret'); -- ERROR
584584
ERROR: invalid option "username"
@@ -618,7 +618,7 @@ ERROR: role "regress_test_missing_role" does not exist
618618
ALTER USER MAPPING FOR user SERVER ss4 OPTIONS (gotcha 'true'); -- ERROR
619619
ERROR: server "ss4" does not exist
620620
ALTER USER MAPPING FOR public SERVER s5 OPTIONS (gotcha 'true'); -- ERROR
621-
ERROR: user mapping for "public" does not exist for the server
621+
ERROR: user mapping for "public" does not exist for server "s5"
622622
ALTER USER MAPPING FOR current_user SERVER s8 OPTIONS (username 'test'); -- ERROR
623623
ERROR: invalid option "username"
624624
HINT: Valid options in this context are: user, password
@@ -648,13 +648,13 @@ ERROR: role "regress_test_missing_role" does not exist
648648
DROP USER MAPPING FOR user SERVER ss4;
649649
ERROR: server "ss4" does not exist
650650
DROP USER MAPPING FOR public SERVER s7; -- ERROR
651-
ERROR: user mapping for "public" does not exist for the server
651+
ERROR: user mapping for "public" does not exist for server "s7"
652652
DROP USER MAPPING IF EXISTS FOR regress_test_missing_role SERVER s4;
653653
NOTICE: role "regress_test_missing_role" does not exist, skipping
654654
DROP USER MAPPING IF EXISTS FOR user SERVER ss4;
655-
NOTICE: server does not exist, skipping
655+
NOTICE: server "ss4" does not exist, skipping
656656
DROP USER MAPPING IF EXISTS FOR public SERVER s7;
657-
NOTICE: user mapping for "public" does not exist for the server, skipping
657+
NOTICE: user mapping for "public" does not exist for server "s7", skipping
658658
CREATE USER MAPPING FOR public SERVER s8;
659659
SET ROLE regress_test_role;
660660
DROP USER MAPPING FOR public SERVER s8; -- ERROR

0 commit comments

Comments
 (0)