Change some errdetail() to errdetail_internal()
authorAlvaro Herrera
Wed, 28 Sep 2022 15:14:53 +0000 (17:14 +0200)
committerAlvaro Herrera
Wed, 28 Sep 2022 15:14:53 +0000 (17:14 +0200)
This prevents marking the argument string for translation for gettext,
and it also prevents the given string (which is already translated) from
being translated at runtime.

Also, mark the strings used as arguments to check_rolespec_name for
translation.

Backpatch all the way back as appropriate.  None of this is caught by
any tests (necessarily so), so I verified it manually.

src/backend/catalog/dependency.c
src/backend/commands/user.c
src/backend/utils/adt/acl.c
src/backend/utils/adt/jsonfuncs.c
src/common/jsonapi.c

index 3ccbb5ea85ec51abd58930bc924a95abd5649a3f..404ced126b70a56d96964ce8f673e266b001a913 100644 (file)
@@ -1193,14 +1193,14 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
                    (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
                     errmsg("cannot drop %s because other objects depend on it",
                            getObjectDescription(origObject, false)),
-                    errdetail("%s", clientdetail.data),
+                    errdetail_internal("%s", clientdetail.data),
                     errdetail_log("%s", logdetail.data),
                     errhint("Use DROP ... CASCADE to drop the dependent objects too.")));
        else
            ereport(ERROR,
                    (errcode(ERRCODE_DEPENDENT_OBJECTS_STILL_EXIST),
                     errmsg("cannot drop desired object(s) because other objects depend on them"),
-                    errdetail("%s", clientdetail.data),
+                    errdetail_internal("%s", clientdetail.data),
                     errdetail_log("%s", logdetail.data),
                     errhint("Use DROP ... CASCADE to drop the dependent objects too.")));
    }
@@ -1212,7 +1212,7 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
                               "drop cascades to %d other objects",
                               numReportedClient + numNotReportedClient,
                               numReportedClient + numNotReportedClient),
-                errdetail("%s", clientdetail.data),
+                errdetail_internal("%s", clientdetail.data),
                 errdetail_log("%s", logdetail.data)));
    }
    else if (numReportedClient == 1)
index 65bb73395891d54e97ccae4b2e53b303eec15ef8..4621bba00e5c5a4f6ba8d6fe222fe8608e96b847 100644 (file)
@@ -567,7 +567,7 @@ AlterRole(AlterRoleStmt *stmt)
    Oid         roleid;
 
    check_rolespec_name(stmt->role,
-                       "Cannot alter reserved roles.");
+                       _("Cannot alter reserved roles."));
 
    /* Extract options from the statement node tree */
    foreach(option, stmt->options)
@@ -922,7 +922,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
    if (stmt->role)
    {
        check_rolespec_name(stmt->role,
-                           "Cannot alter reserved roles.");
+                           _("Cannot alter reserved roles."));
 
        roletuple = get_rolespec_tuple(stmt->role);
        roleform = (Form_pg_authid) GETSTRUCT(roletuple);
index 67f8b29434ac0367aab3422d67999d0027cba289..a44428da7ae236f8bf3b6fb9d10c7547de5b8e03 100644 (file)
@@ -5226,7 +5226,7 @@ get_rolespec_name(const RoleSpec *role)
 
 /*
  * Given a RoleSpec, throw an error if the name is reserved, using detail_msg,
- * if provided.
+ * if provided (which must be already translated).
  *
  * If node is NULL, no error is thrown.  If detail_msg is NULL then no detail
  * message is provided.
@@ -5247,7 +5247,7 @@ check_rolespec_name(const RoleSpec *role, const char *detail_msg)
                    (errcode(ERRCODE_RESERVED_NAME),
                     errmsg("role name \"%s\" is reserved",
                            role->rolename),
-                    errdetail("%s", detail_msg)));
+                    errdetail_internal("%s", detail_msg)));
        else
            ereport(ERROR,
                    (errcode(ERRCODE_RESERVED_NAME),
index 5fd54b64b56113cb151a94b317185360c6ea4ce5..0364765dc0eb4f3918c064b4ed2fb8424a98b222 100644 (file)
@@ -615,13 +615,13 @@ json_ereport_error(JsonParseErrorType error, JsonLexContext *lex)
        ereport(ERROR,
                (errcode(ERRCODE_UNTRANSLATABLE_CHARACTER),
                 errmsg("unsupported Unicode escape sequence"),
-                errdetail("%s", json_errdetail(error, lex)),
+                errdetail_internal("%s", json_errdetail(error, lex)),
                 report_json_context(lex)));
    else
        ereport(ERROR,
                (errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
                 errmsg("invalid input syntax for type %s", "json"),
-                errdetail("%s", json_errdetail(error, lex)),
+                errdetail_internal("%s", json_errdetail(error, lex)),
                 report_json_context(lex)));
 }
 
index d376ab152d48d9e99e8cb2085f5e0348aced9046..ade13aed3a44a868578b1878a873a306b1e9f0b6 100644 (file)
@@ -1052,7 +1052,7 @@ report_parse_error(JsonParseContext ctx, JsonLexContext *lex)
 }
 
 /*
- * Construct a detail message for a JSON error.
+ * Construct an (already translated) detail message for a JSON error.
  */
 char *
 json_errdetail(JsonParseErrorType error, JsonLexContext *lex)