diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/tcop/postgres.c | 14 | ||||
-rw-r--r-- | src/backend/utils/error/elog.c | 10 | ||||
-rw-r--r-- | src/include/utils/elog.h | 21 |
3 files changed, 19 insertions, 26 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 00c77b66c74..cb8c23e4b76 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3720,15 +3720,15 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx, /* spell the error message a bit differently depending on context */ if (IsUnderPostmaster) ereport(FATAL, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("invalid command-line argument for server process: %s", argv[optind]), - errhint("Try \"%s --help\" for more information.", progname))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("invalid command-line argument for server process: %s", argv[optind]), + errhint("Try \"%s --help\" for more information.", progname)); else ereport(FATAL, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("%s: invalid command-line argument: %s", - progname, argv[optind]), - errhint("Try \"%s --help\" for more information.", progname))); + errcode(ERRCODE_SYNTAX_ERROR), + errmsg("%s: invalid command-line argument: %s", + progname, argv[optind]), + errhint("Try \"%s --help\" for more information.", progname)); } /* diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 62eef7b71f4..de705c86fa1 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -1116,16 +1116,6 @@ errcontext_msg(const char *fmt,...) * translate it. Instead, each errcontext_msg() call should be preceded by * a set_errcontext_domain() call to specify the domain. This is usually * done transparently by the errcontext() macro. - * - * Although errcontext is primarily meant for use at call sites distant from - * the original ereport call, there are a few places that invoke errcontext - * within ereport. The expansion of errcontext as a comma expression calling - * set_errcontext_domain then errcontext_msg is problematic in this case, - * because the intended comma expression becomes two arguments to errfinish, - * which the compiler is at liberty to evaluate in either order. But in - * such a case, the set_errcontext_domain calls must be selecting the same - * TEXTDOMAIN value that the errstart call did, so order does not matter - * so long as errstart initializes context_domain along with domain. */ int set_errcontext_domain(const char *domain) diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 0a4ef029ceb..4ff69daf3b9 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -91,9 +91,9 @@ /*---------- * New-style error reporting API: to be used in this way: * ereport(ERROR, - * (errcode(ERRCODE_UNDEFINED_CURSOR), - * errmsg("portal \"%s\" not found", stmt->portalname), - * ... other errxxx() fields as needed ...)); + * errcode(ERRCODE_UNDEFINED_CURSOR), + * errmsg("portal \"%s\" not found", stmt->portalname), + * ... other errxxx() fields as needed ...); * * The error level is required, and so is a primary error message (errmsg * or errmsg_internal). All else is optional. errcode() defaults to @@ -101,6 +101,9 @@ * if elevel is WARNING, or ERRCODE_SUCCESSFUL_COMPLETION if elevel is * NOTICE or below. * + * Before Postgres v12, extra parentheses were required around the + * list of auxiliary function calls; that's now optional. + * * ereport_domain() allows a message domain to be specified, for modules that * wish to use a different message catalog from the backend's. To avoid having * one copy of the default text domain per .o file, we define it as NULL here @@ -118,28 +121,28 @@ *---------- */ #ifdef HAVE__BUILTIN_CONSTANT_P -#define ereport_domain(elevel, domain, rest) \ +#define ereport_domain(elevel, domain, ...) \ do { \ pg_prevent_errno_in_scope(); \ if (errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) \ - errfinish rest; \ + __VA_ARGS__, errfinish(0); \ if (__builtin_constant_p(elevel) && (elevel) >= ERROR) \ pg_unreachable(); \ } while(0) #else /* !HAVE__BUILTIN_CONSTANT_P */ -#define ereport_domain(elevel, domain, rest) \ +#define ereport_domain(elevel, domain, ...) \ do { \ const int elevel_ = (elevel); \ pg_prevent_errno_in_scope(); \ if (errstart(elevel_, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) \ - errfinish rest; \ + __VA_ARGS__, errfinish(0); \ if (elevel_ >= ERROR) \ pg_unreachable(); \ } while(0) #endif /* HAVE__BUILTIN_CONSTANT_P */ -#define ereport(elevel, rest) \ - ereport_domain(elevel, TEXTDOMAIN, rest) +#define ereport(elevel, ...) \ + ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__) #define TEXTDOMAIN NULL |