Fix header inclusion order in c.h.
[pgsql.git] / src / pl / plpython / plpy_elog.h
blobdc65f2f6ee29b38444743846c5fb67a0d9fbbf7f
1 /*
2 * src/pl/plpython/plpy_elog.h
3 */
5 #ifndef PLPY_ELOG_H
6 #define PLPY_ELOG_H
8 #include "plpython.h"
10 /* global exception classes */
11 extern PyObject *PLy_exc_error;
12 extern PyObject *PLy_exc_fatal;
13 extern PyObject *PLy_exc_spi_error;
16 * PLy_elog()
18 * See comments at elog() about the compiler hinting.
20 #ifdef HAVE__BUILTIN_CONSTANT_P
21 #define PLy_elog(elevel, ...) \
22 do { \
23 PLy_elog_impl(elevel, __VA_ARGS__); \
24 if (__builtin_constant_p(elevel) && (elevel) >= ERROR) \
25 pg_unreachable(); \
26 } while(0)
27 #else /* !HAVE__BUILTIN_CONSTANT_P */
28 #define PLy_elog(elevel, ...) \
29 do { \
30 const int elevel_ = (elevel); \
31 PLy_elog_impl(elevel_, __VA_ARGS__); \
32 if (elevel_ >= ERROR) \
33 pg_unreachable(); \
34 } while(0)
35 #endif /* HAVE__BUILTIN_CONSTANT_P */
37 extern PGDLLEXPORT void PLy_elog_impl(int elevel, const char *fmt,...) pg_attribute_printf(2, 3);
39 extern PGDLLEXPORT void PLy_exception_set(PyObject *exc, const char *fmt,...) pg_attribute_printf(2, 3);
41 extern PGDLLEXPORT void PLy_exception_set_plural(PyObject *exc, const char *fmt_singular, const char *fmt_plural,
42 unsigned long n,...) pg_attribute_printf(2, 5) pg_attribute_printf(3, 5);
44 extern PGDLLEXPORT void PLy_exception_set_with_details(PyObject *excclass, ErrorData *edata);
46 #endif /* PLPY_ELOG_H */