|
|
|
|
@ -119,11 +119,11 @@ struct Node; |
|
|
|
|
* ereport_domain() directly, or preferably they can override the TEXTDOMAIN |
|
|
|
|
* macro. |
|
|
|
|
* |
|
|
|
|
* When pg_builtin_integer_constant_p is available and elevel >= ERROR we make |
|
|
|
|
* When pg_integer_constant_p is available and elevel >= ERROR we make |
|
|
|
|
* a call to errstart_cold() instead of errstart(). This version of the |
|
|
|
|
* function is marked with pg_attribute_cold which will coax supporting |
|
|
|
|
* compilers into generating code which is more optimized towards non-ERROR |
|
|
|
|
* cases. Because we use pg_builtin_integer_constant_p() in the condition, |
|
|
|
|
* cases. Because we use pg_integer_constant_p() in the condition, |
|
|
|
|
* when elevel is not a compile-time constant, or if it is, but it's < ERROR, |
|
|
|
|
* the compiler has no need to generate any code for this branch. It can |
|
|
|
|
* simply call errstart() unconditionally. |
|
|
|
|
@ -131,25 +131,25 @@ struct Node; |
|
|
|
|
* If elevel >= ERROR, the call will not return; we try to inform the compiler |
|
|
|
|
* of that via pg_unreachable(). However, no useful optimization effect is |
|
|
|
|
* obtained unless the compiler sees elevel as a compile-time constant, else |
|
|
|
|
* we're just adding code bloat. So, if pg_builtin_integer_constant_p is |
|
|
|
|
* we're just adding code bloat. So, if pg_integer_constant_p is |
|
|
|
|
* available, use that to cause the second if() to vanish completely for |
|
|
|
|
* non-constant cases. We avoid using a local variable because it's not |
|
|
|
|
* necessary and prevents gcc from making the unreachability deduction at |
|
|
|
|
* optlevel -O0. |
|
|
|
|
*---------- |
|
|
|
|
*/ |
|
|
|
|
#ifdef HAVE_PG_BUILTIN_INTEGER_CONSTANT_P |
|
|
|
|
#ifdef HAVE_PG_INTEGER_CONSTANT_P |
|
|
|
|
#define ereport_domain(elevel, domain, ...) \ |
|
|
|
|
do { \
|
|
|
|
|
pg_prevent_errno_in_scope(); \
|
|
|
|
|
if (pg_builtin_integer_constant_p(elevel) && (elevel) >= ERROR ? \
|
|
|
|
|
if (pg_integer_constant_p(elevel) && (elevel) >= ERROR ? \
|
|
|
|
|
errstart_cold(elevel, domain) : \
|
|
|
|
|
errstart(elevel, domain)) \
|
|
|
|
|
__VA_ARGS__, errfinish(__FILE__, __LINE__, __func__); \
|
|
|
|
|
if (pg_builtin_integer_constant_p(elevel) && (elevel) >= ERROR) \
|
|
|
|
|
if (pg_integer_constant_p(elevel) && (elevel) >= ERROR) \
|
|
|
|
|
pg_unreachable(); \
|
|
|
|
|
} while(0) |
|
|
|
|
#else /* !HAVE_PG_BUILTIN_INTEGER_CONSTANT_P */ |
|
|
|
|
#else /* !HAVE_PG_INTEGER_CONSTANT_P */ |
|
|
|
|
#define ereport_domain(elevel, domain, ...) \ |
|
|
|
|
do { \
|
|
|
|
|
const int elevel_ = (elevel); \
|
|
|
|
|
@ -159,7 +159,7 @@ struct Node; |
|
|
|
|
if (elevel_ >= ERROR) \
|
|
|
|
|
pg_unreachable(); \
|
|
|
|
|
} while(0) |
|
|
|
|
#endif /* HAVE_PG_BUILTIN_INTEGER_CONSTANT_P */ |
|
|
|
|
#endif /* HAVE_PG_INTEGER_CONSTANT_P */ |
|
|
|
|
|
|
|
|
|
#define ereport(elevel, ...) \ |
|
|
|
|
ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__) |
|
|
|
|
|