1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

Improve the recently-added support for properly pluralized error messages

by extending the ereport() API to cater for pluralization directly.  This
is better than the original method of calling ngettext outside the elog.c
code because (1) it avoids double translation, which wastes cycles and in
the worst case could give a wrong result; and (2) it avoids having to use
a different coding method in PL code than in the core backend.  The
client-side uses of ngettext are not touched since neither of these concerns
is very pressing in the client environment.  Per my proposal of yesterday.
This commit is contained in:
Tom Lane
2009-06-04 18:33:08 +00:00
parent fd416db406
commit 76d4abf2d9
17 changed files with 292 additions and 102 deletions

View File

@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/elog.h,v 1.99 2009/01/06 16:39:52 tgl Exp $
* $PostgreSQL: pgsql/src/include/utils/elog.h,v 1.100 2009/06/04 18:33:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -106,8 +106,8 @@
(errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain) ? \
(errfinish rest) : (void) 0)
#define ereport(level, rest) \
ereport_domain(level, TEXTDOMAIN, rest)
#define ereport(elevel, rest) \
ereport_domain(elevel, TEXTDOMAIN, rest)
#define TEXTDOMAIN NULL
@ -132,6 +132,14 @@ errmsg_internal(const char *fmt,...)
the supplied arguments. */
__attribute__((format(printf, 1, 2)));
extern int
errmsg_plural(const char *fmt_singular, const char *fmt_plural,
unsigned long n, ...)
/* This extension allows gcc to check the format string for consistency with
the supplied arguments. */
__attribute__((format(printf, 1, 4)))
__attribute__((format(printf, 2, 4)));
extern int
errdetail(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with
@ -144,6 +152,14 @@ errdetail_log(const char *fmt,...)
the supplied arguments. */
__attribute__((format(printf, 1, 2)));
extern int
errdetail_plural(const char *fmt_singular, const char *fmt_plural,
unsigned long n, ...)
/* This extension allows gcc to check the format string for consistency with
the supplied arguments. */
__attribute__((format(printf, 1, 4)))
__attribute__((format(printf, 2, 4)));
extern int
errhint(const char *fmt,...)
/* This extension allows gcc to check the format string for consistency with