From d84a7b290f866b3f16cbefb0fca31b69ebace98a Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 28 Sep 2022 17:14:53 +0200 Subject: [PATCH] Change some errdetail() to errdetail_internal() 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 | 6 +++--- src/backend/commands/publicationcmds.c | 2 +- src/backend/commands/user.c | 4 ++-- src/backend/utils/adt/acl.c | 4 ++-- src/backend/utils/adt/jsonfuncs.c | 4 ++-- src/common/jsonapi.c | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index 39768fa22b..7f3e64b5ae 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -1192,14 +1192,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."))); } @@ -1210,7 +1210,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) diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c index 59e032adc4..8514ebfe91 100644 --- a/src/backend/commands/publicationcmds.c +++ b/src/backend/commands/publicationcmds.c @@ -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, diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 265a48af7e..04a18d4a42 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -576,7 +576,7 @@ AlterRole(ParseState *pstate, AlterRoleStmt *stmt) GrantRoleOptions popt; check_rolespec_name(stmt->role, - "Cannot alter reserved roles."); + _("Cannot alter reserved roles.")); /* Extract options from the statement node tree */ foreach(option, stmt->options) @@ -910,7 +910,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); diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index fd71a9b13e..4fac402e5b 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -5291,7 +5291,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. @@ -5312,7 +5312,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), diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c index 82c43617d8..fd0d355789 100644 --- a/src/backend/utils/adt/jsonfuncs.c +++ b/src/backend/utils/adt/jsonfuncs.c @@ -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))); } diff --git a/src/common/jsonapi.c b/src/common/jsonapi.c index cfc025749c..873357aa02 100644 --- a/src/common/jsonapi.c +++ b/src/common/jsonapi.c @@ -1079,11 +1079,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) -- 2.39.5