]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Change some errdetail() to errdetail_internal()
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 28 Sep 2022 15:14:53 +0000 (17:14 +0200)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
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/publicationcmds.c
src/backend/commands/user.c
src/backend/utils/adt/acl.c
src/backend/utils/adt/jsonfuncs.c
src/common/jsonapi.c

index 71b8505b3221fb53fead3050762acfd40edc74a4..85e2a902a2c5e11d2f2698157e4674f4a858870c 100644 (file)
@@ -1190,14 +1190,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.")));
        }
@@ -1208,7 +1208,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 d2ed70ee3dd0defbb096fe73da27106ddc0bab77..473c72eae515f074ab884ec222b5cffc5aaa5f69 100644 (file)
@@ -580,7 +580,7 @@ check_simple_rowfilter_expr_walker(Node *node, ParseState *pstate)
                ereport(ERROR,
                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                 errmsg("invalid publication WHERE expression"),
-                                errdetail("%s", errdetail_msg),
+                                errdetail_internal("%s", errdetail_msg),
                                 parser_errposition(pstate, exprLocation(node))));
 
        return expression_tree_walker(node, check_simple_rowfilter_expr_walker,
index 984305ba31cf1798b4b64e448a02904ffed9ad9f..cba8e1979b6c6507e0963f5276982f1943771a09 100644 (file)
@@ -521,7 +521,7 @@ AlterRole(ParseState *pstate, 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)
@@ -835,7 +835,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 772c04155c32de64401f34c309a04933ac33e842..5b7236abc98a31d5a3a926bbd646807d90dd3db8 100644 (file)
@@ -5309,7 +5309,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.
@@ -5330,7 +5330,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 177b1c5e3f29f069db248184cc0d1b582b17757f..ccc327957581cfdfa7f9c1adc31cc614ad344d1f 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 98e4ef09426ac7eb2c18bd91551abaf106951939..90abe2687f471ba6d2331d29ffd41ab9d3b79064 100644 (file)
@@ -1057,11 +1057,11 @@ extract_token(JsonLexContext *lex)
 }
 
 /*
- * Construct a detail message for a JSON error.
+ * Construct an (already translated) detail message for a JSON error.
  *
  * Note that the error message generated by this routine may not be
  * palloc'd, making it unsafe for frontend code as there is no way to
- * know if this can be safery pfree'd or not.
+ * know if this can be safely pfree'd or not.
  */
 char *
 json_errdetail(JsonParseErrorType error, JsonLexContext *lex)