Add errhint_plural() function and make use of it
Similar to existing errmsg_plural() and errdetail_plural(). Some errhint() calls hadn't received the proper plural treatment yet.
This commit is contained in:
parent
287d2a97c1
commit
91c5a8caaa
@ -282,6 +282,14 @@ ereport(ERROR,
|
|||||||
<function>errmsg</function>.
|
<function>errmsg</function>.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<function>errhint_plural(const char *fmt_singular, const char *fmt_plural,
|
||||||
|
unsigned long n, ...)</function> is like <function>errhint</function>, but with
|
||||||
|
support for various plural forms of the message.
|
||||||
|
For more information see <xref linkend="nls-guidelines"/>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<function>errcontext(const char *msg, ...)</function> is not normally called
|
<function>errcontext(const char *msg, ...)</function> is not normally called
|
||||||
|
@ -417,7 +417,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
|||||||
func_signature_string(funcname, nargs,
|
func_signature_string(funcname, nargs,
|
||||||
argnames,
|
argnames,
|
||||||
actual_arg_types)),
|
actual_arg_types)),
|
||||||
errhint("There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
|
errhint_plural("There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
|
||||||
|
"There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
|
||||||
|
catDirectArgs,
|
||||||
NameListToString(funcname),
|
NameListToString(funcname),
|
||||||
catDirectArgs, numDirectArgs),
|
catDirectArgs, numDirectArgs),
|
||||||
parser_errposition(pstate, location)));
|
parser_errposition(pstate, location)));
|
||||||
@ -446,7 +448,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
|||||||
func_signature_string(funcname, nargs,
|
func_signature_string(funcname, nargs,
|
||||||
argnames,
|
argnames,
|
||||||
actual_arg_types)),
|
actual_arg_types)),
|
||||||
errhint("There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
|
errhint_plural("There is an ordered-set aggregate %s, but it requires %d direct argument, not %d.",
|
||||||
|
"There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
|
||||||
|
catDirectArgs,
|
||||||
NameListToString(funcname),
|
NameListToString(funcname),
|
||||||
catDirectArgs, numDirectArgs),
|
catDirectArgs, numDirectArgs),
|
||||||
parser_errposition(pstate, location)));
|
parser_errposition(pstate, location)));
|
||||||
@ -485,7 +489,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
|
|||||||
func_signature_string(funcname, nargs,
|
func_signature_string(funcname, nargs,
|
||||||
argnames,
|
argnames,
|
||||||
actual_arg_types)),
|
actual_arg_types)),
|
||||||
errhint("There is an ordered-set aggregate %s, but it requires at least %d direct arguments.",
|
errhint_plural("There is an ordered-set aggregate %s, but it requires at least %d direct argument.",
|
||||||
|
"There is an ordered-set aggregate %s, but it requires at least %d direct arguments.",
|
||||||
|
catDirectArgs,
|
||||||
NameListToString(funcname),
|
NameListToString(funcname),
|
||||||
catDirectArgs),
|
catDirectArgs),
|
||||||
parser_errposition(pstate, location)));
|
parser_errposition(pstate, location)));
|
||||||
|
@ -1166,6 +1166,29 @@ errhint(const char *fmt,...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* errhint_plural --- add a hint error message text to the current error,
|
||||||
|
* with support for pluralization of the message text
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
errhint_plural(const char *fmt_singular, const char *fmt_plural,
|
||||||
|
unsigned long n,...)
|
||||||
|
{
|
||||||
|
ErrorData *edata = &errordata[errordata_stack_depth];
|
||||||
|
MemoryContext oldcontext;
|
||||||
|
|
||||||
|
recursion_depth++;
|
||||||
|
CHECK_STACK_DEPTH();
|
||||||
|
oldcontext = MemoryContextSwitchTo(edata->assoc_context);
|
||||||
|
|
||||||
|
EVALUATE_MESSAGE_PLURAL(edata->domain, hint, false);
|
||||||
|
|
||||||
|
MemoryContextSwitchTo(oldcontext);
|
||||||
|
recursion_depth--;
|
||||||
|
return 0; /* return value does not matter */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* errcontext_msg --- add a context error message text to the current error
|
* errcontext_msg --- add a context error message text to the current error
|
||||||
*
|
*
|
||||||
|
@ -188,6 +188,9 @@ extern int errdetail_plural(const char *fmt_singular, const char *fmt_plural,
|
|||||||
|
|
||||||
extern int errhint(const char *fmt,...) pg_attribute_printf(1, 2);
|
extern int errhint(const char *fmt,...) pg_attribute_printf(1, 2);
|
||||||
|
|
||||||
|
extern int errhint_plural(const char *fmt_singular, const char *fmt_plural,
|
||||||
|
unsigned long n,...) pg_attribute_printf(1, 4) pg_attribute_printf(2, 4);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* errcontext() is typically called in error context callback functions, not
|
* errcontext() is typically called in error context callback functions, not
|
||||||
* within an ereport() invocation. The callback function can be in a different
|
* within an ereport() invocation. The callback function can be in a different
|
||||||
|
@ -57,7 +57,7 @@ BACKEND_COMMON_GETTEXT_TRIGGERS = \
|
|||||||
$(FRONTEND_COMMON_GETTEXT_TRIGGERS) \
|
$(FRONTEND_COMMON_GETTEXT_TRIGGERS) \
|
||||||
errmsg errmsg_plural:1,2 \
|
errmsg errmsg_plural:1,2 \
|
||||||
errdetail errdetail_log errdetail_plural:1,2 \
|
errdetail errdetail_log errdetail_plural:1,2 \
|
||||||
errhint \
|
errhint errhint_plural:1,2 \
|
||||||
errcontext \
|
errcontext \
|
||||||
XactLockTableWait:4 \
|
XactLockTableWait:4 \
|
||||||
MultiXactIdWait:6 \
|
MultiXactIdWait:6 \
|
||||||
@ -66,7 +66,7 @@ BACKEND_COMMON_GETTEXT_FLAGS = \
|
|||||||
$(FRONTEND_COMMON_GETTEXT_FLAGS) \
|
$(FRONTEND_COMMON_GETTEXT_FLAGS) \
|
||||||
errmsg:1:c-format errmsg_plural:1:c-format errmsg_plural:2:c-format \
|
errmsg:1:c-format errmsg_plural:1:c-format errmsg_plural:2:c-format \
|
||||||
errdetail:1:c-format errdetail_log:1:c-format errdetail_plural:1:c-format errdetail_plural:2:c-format \
|
errdetail:1:c-format errdetail_log:1:c-format errdetail_plural:1:c-format errdetail_plural:2:c-format \
|
||||||
errhint:1:c-format \
|
errhint:1:c-format errhint_plural:1:c-format errhint_plural:2:c-format \
|
||||||
errcontext:1:c-format
|
errcontext:1:c-format
|
||||||
|
|
||||||
FRONTEND_COMMON_GETTEXT_FILES = $(top_srcdir)/src/common/logging.c
|
FRONTEND_COMMON_GETTEXT_FILES = $(top_srcdir)/src/common/logging.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user