1 /* 2 * src/pl/plpython/plpy_elog.h 3 */ 4 5 #ifndef PLPY_ELOG_H 6 #define PLPY_ELOG_H 7 8 /* global exception classes */ 9 extern PyObject *PLy_exc_error; 10 extern PyObject *PLy_exc_fatal; 11 extern PyObject *PLy_exc_spi_error; 12 13 /* 14 * PLy_elog() 15 * 16 * See comments at elog() about the compiler hinting. 17 */ 18 #ifdef HAVE__VA_ARGS 19 #ifdef HAVE__BUILTIN_CONSTANT_P 20 #define PLy_elog(elevel, ...) \ 21 do { \ 22 PLy_elog_impl(elevel, __VA_ARGS__); \ 23 if (__builtin_constant_p(elevel) && (elevel) >= ERROR) \ 24 pg_unreachable(); \ 25 } while(0) 26 #else /* !HAVE__BUILTIN_CONSTANT_P */ 27 #define PLy_elog(elevel, ...) \ 28 do { \ 29 const int elevel_ = (elevel); \ 30 PLy_elog_impl(elevel_, __VA_ARGS__); \ 31 if (elevel_ >= ERROR) \ 32 pg_unreachable(); \ 33 } while(0) 34 #endif /* HAVE__BUILTIN_CONSTANT_P */ 35 #else /* !HAVE__VA_ARGS */ 36 #define PLy_elog PLy_elog_impl 37 #endif /* HAVE__VA_ARGS */ 38 39 extern void PLy_elog_impl(int elevel, const char *fmt,...) pg_attribute_printf(2, 3); 40 41 extern void PLy_exception_set(PyObject *exc, const char *fmt,...) pg_attribute_printf(2, 3); 42 43 extern void PLy_exception_set_plural(PyObject *exc, const char *fmt_singular, const char *fmt_plural, 44 unsigned long n,...) pg_attribute_printf(2, 5) pg_attribute_printf(3, 5); 45 46 extern void PLy_exception_set_with_details(PyObject *excclass, ErrorData *edata); 47 48 #endif /* PLPY_ELOG_H */ 49