Hi, For each of the logging functions (see elog.c) there is an associated XXX_internal function which is equivalent to its partner, but doesn't translate the fmt message parameter.
errmsg errmsg_internal - same as errmsg, but doesn't translate the fmt string errdetail errdetail_internal - same but errdetail, doesn't translate the fmt string errhint errhint_internal - no such thing ??? I noticed today that there is no 'errhint_internal' function partner for the 'errhint' function. Now, it might seem that hints are always intended for user output so of course, you'll always want them translated.... but there are some calls to this function (like below) where the actual hint message is already built and translated before %s parameter substitution, so AFAICT translation aka gettext lookup of just a "%s" format string doesn't really achieve anything. $ grep -r . -e 'errhint("%s"' | grep .c: ./contrib/dblink/dblink.c: message_hint ? errhint("%s", message_hint) : 0, ./contrib/postgres_fdw/connection.c: message_hint ? errhint("%s", message_hint) : 0, ./src/backend/commands/vacuum.c: hintmsg ? errhint("%s", _(hintmsg)) : 0)); ./src/backend/commands/tablecmds.c: (wentry->kind != '\0') ? errhint("%s", _(wentry->drophint_msg)) : 0)); ./src/backend/commands/tablecmds.c: errhint("%s", _(view_updatable_error)))); ./src/backend/commands/view.c: errhint("%s", _(view_updatable_error)))); ./src/backend/utils/misc/guc.c: hintmsg ? errhint("%s", _(hintmsg)) : 0)); ./src/backend/utils/misc/guc.c: hintmsg ? errhint("%s", _(hintmsg)) : 0)); ./src/backend/utils/misc/guc.c: hintmsg ? errhint("%s", _(hintmsg)) : 0)); ./src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./src/pl/plpgsql/src/pl_exec.c: (err_hint != NULL) ? errhint("%s", err_hint) : 0, ./src/pl/plpython/plpy_elog.c: (hint) ? errhint("%s", hint) : 0, ./src/pl/plpython/plpy_plpymodule.c: (hint != NULL) ? errhint("%s", hint) : 0, ./tmp.txt:src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./tmp.txt:src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./tmp.txt:src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./tmp.txt:src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ./tmp.txt:src/backend/utils/misc/guc.c: errhint("%s", GUC_check_errhint_string) : 0)); ~ I wondered if such code as in those examples might prefer to call errhint_internal to avoid making an unnecessary gettext lookup of "%s". OTOH, was an errhint_internal function deliberately omitted because calling a superfluous gettext was not considered important enough to bother? ====== Also, quite similar to this question --- I found a bunch of errmsg and errdetail calls where the fmt string is just "%s". Are those correct, or should those really be using the XXX_internal version of the function instead? $ grep -r . -e 'errmsg("%s"' | grep .c: ./contrib/pgcrypto/px.c: errmsg("%s", px_strerror(err)))); ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))), ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))), ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))), ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))), ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))), ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))), ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))), ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))))); ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))))); ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))))); ./src/pl/plperl/plperl.c: errmsg("%s", strip_trailing_ws(sv2cstr(ERRSV))))); ./src/pl/tcl/pltcl.c: errmsg("%s", emsg), ./src/pl/tcl/pltcl.c: errmsg("%s", UTF_U2E(Tcl_GetString(objv[2]))))); $ grep -r . -e '\serrdetail("%s"' | grep .c: ./src/backend/executor/execExprInterp.c: errdetail("%s", jsestate->escontext.error_data->message))); ./src/backend/executor/execExprInterp.c: errdetail("%s", jsestate->escontext.error_data->message))); ====== Kind Regards, Peter Smith. Fujitsu Australia