PostgreSQL Source Code  git master
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

void PLy_elog_impl (int elevel, const char *fmt,...) pg_attribute_printf(2
 
void void PLy_exception_set (PyObject *exc, const char *fmt,...) pg_attribute_printf(2
 
void void void PLy_exception_set_plural (PyObject *exc, const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(2
 
void void void pg_attribute_printf (3, 5)
 
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:33

Definition at line 28 of file plpy_elog.h.

Function Documentation

◆ pg_attribute_printf()

void void void pg_attribute_printf ( ,
 
)

◆ PLy_elog_impl()

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

◆ PLy_exception_set()

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

◆ PLy_exception_set_plural()

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

◆ PLy_exception_set_with_details()

void PLy_exception_set_with_details ( PyObject *  excclass,
ErrorData edata 
)

Definition at line 507 of file plpy_elog.c.

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

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