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

Go to the source code of this file.

Functions

void PLy_elog (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
 

Function Documentation

void void void pg_attribute_printf ( ,
 
)
void PLy_elog ( int  elevel,
const char *  fmt,
  ... 
)
void void PLy_exception_set ( PyObject *  exc,
const char *  fmt,
  ... 
)
void void void PLy_exception_set_plural ( PyObject *  exc,
const char *  fmt_singular,
const char *  fmt_plural,
unsigned long  n,
  ... 
)
void PLy_exception_set_with_details ( PyObject *  excclass,
ErrorData edata 
)

Definition at line 532 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, NULL, ErrorData::schema_name, set_string_attr(), ErrorData::sqlerrcode, ErrorData::table_name, and unpack_sql_state().

Referenced by PLy_output().

533 {
534  PyObject *args = NULL;
535  PyObject *error = NULL;
536 
537  args = Py_BuildValue("(s)", edata->message);
538  if (!args)
539  goto failure;
540 
541  /* create a new exception with the error message as the parameter */
542  error = PyObject_CallObject(excclass, args);
543  if (!error)
544  goto failure;
545 
546  if (!set_string_attr(error, "sqlstate",
547  unpack_sql_state(edata->sqlerrcode)))
548  goto failure;
549 
550  if (!set_string_attr(error, "detail", edata->detail))
551  goto failure;
552 
553  if (!set_string_attr(error, "hint", edata->hint))
554  goto failure;
555 
556  if (!set_string_attr(error, "query", edata->internalquery))
557  goto failure;
558 
559  if (!set_string_attr(error, "schema_name", edata->schema_name))
560  goto failure;
561 
562  if (!set_string_attr(error, "table_name", edata->table_name))
563  goto failure;
564 
565  if (!set_string_attr(error, "column_name", edata->column_name))
566  goto failure;
567 
568  if (!set_string_attr(error, "datatype_name", edata->datatype_name))
569  goto failure;
570 
571  if (!set_string_attr(error, "constraint_name", edata->constraint_name))
572  goto failure;
573 
574  PyErr_SetObject(excclass, error);
575 
576  Py_DECREF(args);
577  Py_DECREF(error);
578 
579  return;
580 
581 failure:
582  Py_XDECREF(args);
583  Py_XDECREF(error);
584 
585  elog(ERROR, "could not convert error to Python exception");
586 }
char * schema_name
Definition: elog.h:349
static void error(void)
Definition: sql-dyntest.c:147
int sqlerrcode
Definition: elog.h:342
static bool set_string_attr(PyObject *obj, char *attrname, char *str)
Definition: plpy_elog.c:606
char * unpack_sql_state(int sql_state)
Definition: elog.c:2844
char * internalquery
Definition: elog.h:356
#define ERROR
Definition: elog.h:43
char * table_name
Definition: elog.h:350
char * datatype_name
Definition: elog.h:352
char * detail
Definition: elog.h:344
char * column_name
Definition: elog.h:351
#define NULL
Definition: c.h:229
char * hint
Definition: elog.h:346
#define elog
Definition: elog.h:219
char * constraint_name
Definition: elog.h:353
char * message
Definition: elog.h:343

Variable Documentation

PyObject* PLy_exc_fatal

Definition at line 20 of file plpy_elog.c.

Referenced by PLy_add_exceptions(), and PLy_elog().

PyObject* PLy_exc_spi_error