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:43
static int elevel
Definition: vacuumlazy.c:143

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 523 of file plpy_elog.c.

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().

524 {
525  PyObject *args = NULL;
526  PyObject *error = NULL;
527 
528  args = Py_BuildValue("(s)", edata->message);
529  if (!args)
530  goto failure;
531 
532  /* create a new exception with the error message as the parameter */
533  error = PyObject_CallObject(excclass, args);
534  if (!error)
535  goto failure;
536 
537  if (!set_string_attr(error, "sqlstate",
538  unpack_sql_state(edata->sqlerrcode)))
539  goto failure;
540 
541  if (!set_string_attr(error, "detail", edata->detail))
542  goto failure;
543 
544  if (!set_string_attr(error, "hint", edata->hint))
545  goto failure;
546 
547  if (!set_string_attr(error, "query", edata->internalquery))
548  goto failure;
549 
550  if (!set_string_attr(error, "schema_name", edata->schema_name))
551  goto failure;
552 
553  if (!set_string_attr(error, "table_name", edata->table_name))
554  goto failure;
555 
556  if (!set_string_attr(error, "column_name", edata->column_name))
557  goto failure;
558 
559  if (!set_string_attr(error, "datatype_name", edata->datatype_name))
560  goto failure;
561 
562  if (!set_string_attr(error, "constraint_name", edata->constraint_name))
563  goto failure;
564 
565  PyErr_SetObject(excclass, error);
566 
567  Py_DECREF(args);
568  Py_DECREF(error);
569 
570  return;
571 
572 failure:
573  Py_XDECREF(args);
574  Py_XDECREF(error);
575 
576  elog(ERROR, "could not convert error to Python exception");
577 }
char * schema_name
Definition: elog.h:399
static void error(void)
Definition: sql-dyntest.c:147
int sqlerrcode
Definition: elog.h:391
static bool set_string_attr(PyObject *obj, char *attrname, char *str)
Definition: plpy_elog.c:597
char * unpack_sql_state(int sql_state)
Definition: elog.c:2941
char * internalquery
Definition: elog.h:406
#define ERROR
Definition: elog.h:43
char * table_name
Definition: elog.h:400
char * datatype_name
Definition: elog.h:402
char * detail
Definition: elog.h:393
char * column_name
Definition: elog.h:401
char * hint
Definition: elog.h:395
#define elog(elevel,...)
Definition: elog.h:228
char * constraint_name
Definition: elog.h:403
char * message
Definition: elog.h:392

Variable Documentation

◆ PLy_exc_error

◆ PLy_exc_fatal

PyObject* PLy_exc_fatal

Definition at line 20 of file plpy_elog.c.

Referenced by PLy_add_exceptions(), and PLy_elog_impl().

◆ PLy_exc_spi_error

PyObject* PLy_exc_spi_error