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:333

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

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

Variable Documentation

◆ PLy_exc_error

◆ PLy_exc_fatal

PyObject* PLy_exc_fatal

Definition at line 16 of file plpy_elog.c.

Referenced by PLy_add_exceptions(), and PLy_elog_impl().

◆ PLy_exc_spi_error

PyObject* PLy_exc_spi_error