PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
plpy_elog.h File Reference
#include "plpython.h"
Include dependency graph for plpy_elog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PLy_elog(elevel, ...)
 

Functions

PGDLLEXPORT void PLy_elog_impl (int elevel, const char *fmt,...) pg_attribute_printf(2
 
PGDLLEXPORT void PGDLLEXPORT void PLy_exception_set (PyObject *exc, const char *fmt,...) pg_attribute_printf(2
 
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
 
PGDLLEXPORT void PGDLLEXPORT void PGDLLEXPORT void pg_attribute_printf (3, 5)
 
PGDLLEXPORT void PLy_exception_set_with_details (PyObject *excclass, ErrorData *edata)
 

Variables

PyObject * PLy_exc_error
 
PyObject * PLy_exc_fatal
 
PyObject * PLy_exc_spi_error
 

Macro Definition Documentation

◆ PLy_elog

#define PLy_elog (   elevel,
  ... 
)
Value:
do { \
const int elevel_ = (elevel); \
PLy_elog_impl(elevel_, __VA_ARGS__); \
if (elevel_ >= ERROR) \
pg_unreachable(); \
} while(0)
#define ERROR
Definition: elog.h:39

Definition at line 28 of file plpy_elog.h.

Function Documentation

◆ pg_attribute_printf()

PGDLLEXPORT void PGDLLEXPORT void PGDLLEXPORT void pg_attribute_printf ( ,
 
)

◆ PLy_elog_impl()

PGDLLEXPORT void PLy_elog_impl ( int  elevel,
const char *  fmt,
  ... 
)

◆ PLy_exception_set()

PGDLLEXPORT void PGDLLEXPORT void PLy_exception_set ( PyObject *  exc,
const char *  fmt,
  ... 
)

◆ PLy_exception_set_plural()

PGDLLEXPORT void PGDLLEXPORT void PGDLLEXPORT void PLy_exception_set_plural ( PyObject *  exc,
const char *  fmt_singular,
const char *  fmt_plural,
unsigned long  n,
  ... 
)

◆ PLy_exception_set_with_details()

PGDLLEXPORT void PLy_exception_set_with_details ( PyObject *  excclass,
ErrorData edata 
)

Definition at line 504 of file plpy_elog.c.

505 {
506  PyObject *args = NULL;
507  PyObject *error = NULL;
508 
509  args = Py_BuildValue("(s)", edata->message);
510  if (!args)
511  goto failure;
512 
513  /* create a new exception with the error message as the parameter */
514  error = PyObject_CallObject(excclass, args);
515  if (!error)
516  goto failure;
517 
518  if (!set_string_attr(error, "sqlstate",
519  unpack_sql_state(edata->sqlerrcode)))
520  goto failure;
521 
522  if (!set_string_attr(error, "detail", edata->detail))
523  goto failure;
524 
525  if (!set_string_attr(error, "hint", edata->hint))
526  goto failure;
527 
528  if (!set_string_attr(error, "query", edata->internalquery))
529  goto failure;
530 
531  if (!set_string_attr(error, "schema_name", edata->schema_name))
532  goto failure;
533 
534  if (!set_string_attr(error, "table_name", edata->table_name))
535  goto failure;
536 
537  if (!set_string_attr(error, "column_name", edata->column_name))
538  goto failure;
539 
540  if (!set_string_attr(error, "datatype_name", edata->datatype_name))
541  goto failure;
542 
543  if (!set_string_attr(error, "constraint_name", edata->constraint_name))
544  goto failure;
545 
546  PyErr_SetObject(excclass, error);
547 
548  Py_DECREF(args);
549  Py_DECREF(error);
550 
551  return;
552 
553 failure:
554  Py_XDECREF(args);
555  Py_XDECREF(error);
556 
557  elog(ERROR, "could not convert error to Python exception");
558 }
char * unpack_sql_state(int sql_state)
Definition: elog.c:3169
#define elog(elevel,...)
Definition: elog.h:225
static bool set_string_attr(PyObject *obj, char *attrname, char *str)
Definition: plpy_elog.c:578
static void error(void)
Definition: sql-dyntest.c:147
char * schema_name
Definition: elog.h:447
char * internalquery
Definition: elog.h:454
int sqlerrcode
Definition: elog.h:439
char * datatype_name
Definition: elog.h:450
char * detail
Definition: elog.h:441
char * table_name
Definition: elog.h:448
char * message
Definition: elog.h:440
char * hint
Definition: elog.h:443
char * constraint_name
Definition: elog.h:451
char * column_name
Definition: elog.h:449

References generate_unaccent_rules::args, ErrorData::column_name, ErrorData::constraint_name, ErrorData::datatype_name, ErrorData::detail, elog, ERROR, error(), ErrorData::hint, ErrorData::internalquery, ErrorData::message, ErrorData::schema_name, set_string_attr(), ErrorData::sqlerrcode, ErrorData::table_name, and unpack_sql_state().

Referenced by PLy_output().

Variable Documentation

◆ PLy_exc_error

◆ PLy_exc_fatal

PyObject* PLy_exc_fatal
extern

Definition at line 16 of file plpy_elog.c.

Referenced by PLy_add_exceptions(), and PLy_elog_impl().

◆ PLy_exc_spi_error