]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Make some error strings more generic
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 20 Oct 2023 20:52:15 +0000 (22:52 +0200)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 20 Oct 2023 20:52:15 +0000 (22:52 +0200)
It's undesirable to have SQL commands or configuration options in a
translatable error string, so take some of these out.

src/backend/commands/collationcmds.c
src/backend/commands/tablecmds.c
src/backend/commands/typecmds.c

index efb8b4d289f8eb20def78c6febe12afb385bfa86..4088481b9c7e05ec0512b5e49d66d89125a1d058 100644 (file)
@@ -250,19 +250,22 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
                        if (!collcollate)
                                ereport(ERROR,
                                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                                errmsg("parameter \"lc_collate\" must be specified")));
+                                                errmsg("parameter \"%s\" must be specified",
+                                                               "lc_collate")));
 
                        if (!collctype)
                                ereport(ERROR,
                                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                                errmsg("parameter \"lc_ctype\" must be specified")));
+                                                errmsg("parameter \"%s\" must be specified",
+                                                               "lc_ctype")));
                }
                else if (collprovider == COLLPROVIDER_ICU)
                {
                        if (!colliculocale)
                                ereport(ERROR,
                                                (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-                                                errmsg("parameter \"locale\" must be specified")));
+                                                errmsg("parameter \"%s\" must be specified",
+                                                               "locale")));
 
                        /*
                         * During binary upgrade, preserve the locale string. Otherwise,
@@ -416,7 +419,9 @@ AlterCollation(AlterCollationStmt *stmt)
        if (collOid == DEFAULT_COLLATION_OID)
                ereport(ERROR,
                                (errmsg("cannot refresh version of default collation"),
-                                errhint("Use ALTER DATABASE ... REFRESH COLLATION VERSION instead.")));
+               /* translator: %s is an SQL command */
+                                errhint("Use %s instead.",
+                                                "ALTER DATABASE ... REFRESH COLLATION VERSION")));
 
        if (!object_ownercheck(CollationRelationId, collOid, GetUserId()))
                aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_COLLATION,
index f516a5056180f5f6fe67ba22f76a1656a727844e..b089441ff0d7c920758fd0fac617d6d408fbb798 100644 (file)
@@ -7701,7 +7701,9 @@ ATExecColumnDefault(Relation rel, const char *colName,
                                (errcode(ERRCODE_SYNTAX_ERROR),
                                 errmsg("column \"%s\" of relation \"%s\" is an identity column",
                                                colName, RelationGetRelationName(rel)),
-                                newDefault ? 0 : errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY instead.")));
+               /* translator: %s is an SQL ALTER command */
+                                newDefault ? 0 : errhint("Use %s instead.",
+                                                                                 "ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY")));
 
        if (TupleDescAttr(tupdesc, attnum - 1)->attgenerated)
                ereport(ERROR,
@@ -7709,7 +7711,9 @@ ATExecColumnDefault(Relation rel, const char *colName,
                                 errmsg("column \"%s\" of relation \"%s\" is a generated column",
                                                colName, RelationGetRelationName(rel)),
                                 newDefault || TupleDescAttr(tupdesc, attnum - 1)->attgenerated != ATTRIBUTE_GENERATED_STORED ? 0 :
-                                errhint("Use ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION instead.")));
+               /* translator: %s is an SQL ALTER command */
+                                errhint("Use %s instead.",
+                                                "ALTER TABLE ... ALTER COLUMN ... DROP EXPRESSION")));
 
        /*
         * 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
                                        (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                         errmsg("\"%s\" is a composite type",
                                                        NameStr(tuple_class->relname)),
-                                        errhint("Use ALTER TYPE instead.")));
+                       /* translator: %s is an SQL ALTER command */
+                                        errhint("Use %s instead.",
+                                                        "ALTER TYPE")));
                        break;
                case RELKIND_TOASTVALUE:
                        if (recursing)
@@ -17178,7 +17184,9 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
                ereport(ERROR,
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 errmsg("\"%s\" is a composite type", rv->relname),
-                                errhint("Use ALTER TYPE instead.")));
+               /* translator: %s is an SQL ALTER command */
+                                errhint("Use %s instead.",
+                                                "ALTER TYPE")));
 
        /*
         * 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,
                                        (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                         errmsg("cannot change schema of composite type \"%s\"",
                                                        rv->relname),
-                                        errhint("Use ALTER TYPE instead.")));
+                       /* translator: %s is an SQL ALTER command */
+                                        errhint("Use %s instead.",
+                                                        "ALTER TYPE")));
                else if (relkind == RELKIND_TOASTVALUE)
                        ereport(ERROR,
                                        (errcode(ERRCODE_WRONG_OBJECT_TYPE),
index 216482095d2b58c5c4769cf896e7381151cf207d..430ec671e6efdf3ce7eb9a616db13825757dce95 100644 (file)
@@ -3633,7 +3633,9 @@ RenameType(RenameStmt *stmt)
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 errmsg("%s is a table's row type",
                                                format_type_be(typeOid)),
-                                errhint("Use ALTER TABLE instead.")));
+               /* translator: %s is an SQL ALTER command */
+                                errhint("Use %s instead.",
+                                                "ALTER TABLE")));
 
        /* don't allow direct alteration of array types, either */
        if (IsTrueArrayType(typTup))
@@ -3714,7 +3716,9 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 errmsg("%s is a table's row type",
                                                format_type_be(typeOid)),
-                                errhint("Use ALTER TABLE instead.")));
+               /* translator: %s is an SQL ALTER command */
+                                errhint("Use %s instead.",
+                                                "ALTER TABLE")));
 
        /* don't allow direct alteration of array types, either */
        if (IsTrueArrayType(typTup))
@@ -4005,7 +4009,9 @@ AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
                                (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                 errmsg("%s is a table's row type",
                                                format_type_be(typeOid)),
-                                errhint("Use ALTER TABLE instead.")));
+               /* translator: %s is an SQL ALTER command */
+                                errhint("Use %s instead.",
+                                                "ALTER TABLE")));
 
        if (oldNspOid != nspOid)
        {