aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/parse_func.c24
-rw-r--r--src/backend/utils/error/elog.c23
-rw-r--r--src/include/utils/elog.h3
-rw-r--r--src/nls-global.mk4
4 files changed, 43 insertions, 11 deletions
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index debef1d14fb..baac089d689 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -417,9 +417,11 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
func_signature_string(funcname, nargs,
argnames,
actual_arg_types)),
- errhint("There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
- NameListToString(funcname),
- catDirectArgs, numDirectArgs),
+ 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),
+ catDirectArgs, numDirectArgs),
parser_errposition(pstate, location)));
}
else
@@ -446,9 +448,11 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
func_signature_string(funcname, nargs,
argnames,
actual_arg_types)),
- errhint("There is an ordered-set aggregate %s, but it requires %d direct arguments, not %d.",
- NameListToString(funcname),
- catDirectArgs, numDirectArgs),
+ 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),
+ catDirectArgs, numDirectArgs),
parser_errposition(pstate, location)));
}
else
@@ -485,9 +489,11 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
func_signature_string(funcname, nargs,
argnames,
actual_arg_types)),
- errhint("There is an ordered-set aggregate %s, but it requires at least %d direct arguments.",
- NameListToString(funcname),
- catDirectArgs),
+ 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),
+ catDirectArgs),
parser_errposition(pstate, location)));
}
}
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index e729ebece7b..9e4ea1b345a 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -1167,6 +1167,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
*
* Unlike other cases, multiple calls are allowed to build up a stack of
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index b59651289e4..9acb57a27b5 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -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_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
* within an ereport() invocation. The callback function can be in a different
diff --git a/src/nls-global.mk b/src/nls-global.mk
index 30b40ffe2ab..53129f0a04e 100644
--- a/src/nls-global.mk
+++ b/src/nls-global.mk
@@ -57,7 +57,7 @@ BACKEND_COMMON_GETTEXT_TRIGGERS = \
$(FRONTEND_COMMON_GETTEXT_TRIGGERS) \
errmsg errmsg_plural:1,2 \
errdetail errdetail_log errdetail_plural:1,2 \
- errhint \
+ errhint errhint_plural:1,2 \
errcontext \
XactLockTableWait:4 \
MultiXactIdWait:6 \
@@ -66,7 +66,7 @@ BACKEND_COMMON_GETTEXT_FLAGS = \
$(FRONTEND_COMMON_GETTEXT_FLAGS) \
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 \
- errhint:1:c-format \
+ errhint:1:c-format errhint_plural:1:c-format errhint_plural:2:c-format \
errcontext:1:c-format
FRONTEND_COMMON_GETTEXT_FILES = $(top_srcdir)/src/common/logging.c