Skip to content

Commit b62a3fa

Browse files
committed
Make some error strings more generic
It's undesirable to have SQL commands or configuration options in a translatable error string, so take some of these out.
1 parent c79ca04 commit b62a3fa

File tree

3 files changed

+33
-12
lines changed

3 files changed

+33
-12
lines changed

src/backend/commands/collationcmds.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,19 +250,22 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
250250
if (!collcollate)
251251
ereport(ERROR,
252252
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
253-
errmsg("parameter \"lc_collate\" must be specified")));
253+
errmsg("parameter \"%s\" must be specified",
254+
"lc_collate")));
254255

255256
if (!collctype)
256257
ereport(ERROR,
257258
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
258-
errmsg("parameter \"lc_ctype\" must be specified")));
259+
errmsg("parameter \"%s\" must be specified",
260+
"lc_ctype")));
259261
}
260262
else if (collprovider == COLLPROVIDER_ICU)
261263
{
262264
if (!colliculocale)
263265
ereport(ERROR,
264266
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
265-
errmsg("parameter \"locale\" must be specified")));
267+
errmsg("parameter \"%s\" must be specified",
268+
"locale")));
266269

267270
/*
268271
* During binary upgrade, preserve the locale string. Otherwise,
@@ -416,7 +419,9 @@ AlterCollation(AlterCollationStmt *stmt)
416419
if (collOid == DEFAULT_COLLATION_OID)
417420
ereport(ERROR,
418421
(errmsg("cannot refresh version of default collation"),
419-
errhint("Use ALTER DATABASE ... REFRESH COLLATION VERSION instead.")));
422+
/* translator: %s is an SQL command */
423+
errhint("Use %s instead.",
424+
"ALTER DATABASE ... REFRESH COLLATION VERSION")));
420425

421426
if (!object_ownercheck(CollationRelationId, collOid, GetUserId()))
422427
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_COLLATION,

src/backend/commands/tablecmds.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7701,15 +7701,19 @@ ATExecColumnDefault(Relation rel, const char *colName,
77017701
(errcode(ERRCODE_SYNTAX_ERROR),
77027702
errmsg("column \"%s\" of relation \"%s\" is an identity column",
77037703
colName, RelationGetRelationName(rel)),
7704-
newDefault ? 0 : errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY instead.")));
7704+
/* translator: %s is an SQL ALTER command */
7705+
newDefault ? 0 : errhint("Use %s instead.",
7706+
"ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY")));
77057707

77067708
if (TupleDescAttr(tupdesc, attnum - 1)->attgenerated)
77077709
ereport(ERROR,
77087710
(errcode(ERRCODE_SYNTAX_ERROR),
77097711
errmsg("column \"%s\" of relation \"%s\" is a generated column",
77107712
colName, RelationGetRelationName(rel)),
77117713
newDefault || TupleDescAttr(tupdesc, attnum - 1)->attgenerated != ATTRIBUTE_GENERATED_STORED ? 0 :
7712-
errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION instead.")));
7714+
/* translator: %s is an SQL ALTER command */
7715+
errhint("Use %s instead.",
7716+
"ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION")));
77137717

77147718
/*
77157719
* Remove any old default for the column. We use RESTRICT here for
@@ -13900,7 +13904,9 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
1390013904
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
1390113905
errmsg("\"%s\" is a composite type",
1390213906
NameStr(tuple_class->relname)),
13903-
errhint("Use ALTER TYPE instead.")));
13907+
/* translator: %s is an SQL ALTER command */
13908+
errhint("Use %s instead.",
13909+
"ALTER TYPE")));
1390413910
break;
1390513911
case RELKIND_TOASTVALUE:
1390613912
if (recursing)
@@ -17178,7 +17184,9 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
1717817184
ereport(ERROR,
1717917185
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
1718017186
errmsg("\"%s\" is a composite type", rv->relname),
17181-
errhint("Use ALTER TYPE instead.")));
17187+
/* translator: %s is an SQL ALTER command */
17188+
errhint("Use %s instead.",
17189+
"ALTER TYPE")));
1718217190

1718317191
/*
1718417192
* Don't allow ALTER TABLE .. SET SCHEMA on relations that can't be moved
@@ -17197,7 +17205,9 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
1719717205
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
1719817206
errmsg("cannot change schema of composite type \"%s\"",
1719917207
rv->relname),
17200-
errhint("Use ALTER TYPE instead.")));
17208+
/* translator: %s is an SQL ALTER command */
17209+
errhint("Use %s instead.",
17210+
"ALTER TYPE")));
1720117211
else if (relkind == RELKIND_TOASTVALUE)
1720217212
ereport(ERROR,
1720317213
(errcode(ERRCODE_WRONG_OBJECT_TYPE),

src/backend/commands/typecmds.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,7 +3633,9 @@ RenameType(RenameStmt *stmt)
36333633
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
36343634
errmsg("%s is a table's row type",
36353635
format_type_be(typeOid)),
3636-
errhint("Use ALTER TABLE instead.")));
3636+
/* translator: %s is an SQL ALTER command */
3637+
errhint("Use %s instead.",
3638+
"ALTER TABLE")));
36373639

36383640
/* don't allow direct alteration of array types, either */
36393641
if (IsTrueArrayType(typTup))
@@ -3714,7 +3716,9 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
37143716
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
37153717
errmsg("%s is a table's row type",
37163718
format_type_be(typeOid)),
3717-
errhint("Use ALTER TABLE instead.")));
3719+
/* translator: %s is an SQL ALTER command */
3720+
errhint("Use %s instead.",
3721+
"ALTER TABLE")));
37183722

37193723
/* don't allow direct alteration of array types, either */
37203724
if (IsTrueArrayType(typTup))
@@ -4005,7 +4009,9 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
40054009
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
40064010
errmsg("%s is a table's row type",
40074011
format_type_be(typeOid)),
4008-
errhint("Use ALTER TABLE instead.")));
4012+
/* translator: %s is an SQL ALTER command */
4013+
errhint("Use %s instead.",
4014+
"ALTER TABLE")));
40094015

40104016
if (oldNspOid != nspOid)
40114017
{

0 commit comments

Comments
 (0)