PostgreSQL Source Code  git master
plpy_elog.h
Go to the documentation of this file.
1 /*
2  * src/pl/plpython/plpy_elog.h
3  */
4 
5 #ifndef PLPY_ELOG_H
6 #define PLPY_ELOG_H
7 
8 #include "plpython.h"
9 
10 /* global exception classes */
11 extern PyObject *PLy_exc_error;
12 extern PyObject *PLy_exc_fatal;
13 extern PyObject *PLy_exc_spi_error;
14 
15 /*
16  * PLy_elog()
17  *
18  * See comments at elog() about the compiler hinting.
19  */
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 */
36 
37 extern PGDLLEXPORT void PLy_elog_impl(int elevel, const char *fmt,...) pg_attribute_printf(2, 3);
38 
39 extern PGDLLEXPORT void PLy_exception_set(PyObject *exc, const char *fmt,...) pg_attribute_printf(2, 3);
40 
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);
43 
44 extern PGDLLEXPORT void PLy_exception_set_with_details(PyObject *excclass, ErrorData *edata);
45 
46 #endif /* PLPY_ELOG_H */
#define PGDLLEXPORT
Definition: c.h:1289
static void const char * fmt
PyObject * PLy_exc_error
Definition: plpy_elog.c:15
PyObject * PLy_exc_spi_error
Definition: plpy_elog.c:17
PGDLLEXPORT void PGDLLEXPORT void PLy_exception_set(PyObject *exc, const char *fmt,...) pg_attribute_printf(2
PGDLLEXPORT void PGDLLEXPORT void PGDLLEXPORT void pg_attribute_printf(3, 5)
PGDLLEXPORT void PGDLLEXPORT void PGDLLEXPORT void PLy_exception_set_plural(PyObject *exc, const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(2
PyObject * PLy_exc_fatal
Definition: plpy_elog.c:16
PGDLLEXPORT void PLy_elog_impl(int elevel, const char *fmt,...) pg_attribute_printf(2
PGDLLEXPORT void PLy_exception_set_with_details(PyObject *excclass, ErrorData *edata)
Definition: plpy_elog.c:504