summaryrefslogtreecommitdiff
path: root/src/pl/plpython/plpython.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2011-01-27 00:35:28 +0200
committerPeter Eisentraut <peter_e@gmx.net>2011-01-27 00:35:28 +0200
commit418df3a5dd94d9f02b895f9c161b2435d61e0729 (patch)
treec4ddad9c1846f5e95119a9bdd51f141e142d5e72 /src/pl/plpython/plpython.c
parentddf8c1682237119bf66949050e223c2151329f4c (diff)
Also save the error detail in SPIError
The temporarily broken plpython_unicode test shows a case where this is used. Do remaining fix-ups on the expected files at the same time.
Diffstat (limited to 'src/pl/plpython/plpython.c')
-rw-r--r--src/pl/plpython/plpython.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/pl/plpython/plpython.c b/src/pl/plpython/plpython.c
index 0b75fe6136f..6bcb4cc049b 100644
--- a/src/pl/plpython/plpython.c
+++ b/src/pl/plpython/plpython.c
@@ -294,7 +294,7 @@ static char *PLy_procedure_name(PLyProcedure *);
static void
PLy_elog(int, const char *,...)
__attribute__((format(printf, 2, 3)));
-static void PLy_get_spi_error_data(PyObject *exc, char **hint, char **query, int *position);
+static void PLy_get_spi_error_data(PyObject *exc, char **detail, char **hint, char **query, int *position);
static char *PLy_traceback(int *);
static void *PLy_malloc(size_t);
@@ -3551,7 +3551,7 @@ PLy_spi_exception_set(ErrorData *edata)
if (!spierror)
goto failure;
- spidata = Py_BuildValue("(zzi)", edata->hint,
+ spidata = Py_BuildValue("(zzzi)", edata->detail, edata->hint,
edata->internalquery, edata->internalpos);
if (!spidata)
goto failure;
@@ -3586,13 +3586,14 @@ PLy_elog(int elevel, const char *fmt,...)
int xlevel;
StringInfoData emsg;
PyObject *exc, *val, *tb;
+ char *detail = NULL;
char *hint = NULL;
char *query = NULL;
int position = 0;
PyErr_Fetch(&exc, &val, &tb);
if (exc != NULL && PyErr_GivenExceptionMatches(val, PLy_exc_spi_error))
- PLy_get_spi_error_data(val, &hint, &query, &position);
+ PLy_get_spi_error_data(val, &detail, &hint, &query, &position);
PyErr_Restore(exc, val, tb);
xmsg = PLy_traceback(&xlevel);
@@ -3626,6 +3627,7 @@ PLy_elog(int elevel, const char *fmt,...)
else
ereport(elevel,
(errmsg("PL/Python: %s", xmsg),
+ (detail) ? errdetail("%s", detail) : 0,
(hint) ? errhint("%s", hint) : 0,
(query) ? internalerrquery(query) : 0,
(position) ? internalerrposition(position) : 0));
@@ -3650,7 +3652,7 @@ PLy_elog(int elevel, const char *fmt,...)
* Extract the error data from a SPIError
*/
static void
-PLy_get_spi_error_data(PyObject *exc, char **hint, char **query, int *position)
+PLy_get_spi_error_data(PyObject *exc, char **detail, char **hint, char **query, int *position)
{
PyObject *spidata = NULL;
@@ -3658,7 +3660,7 @@ PLy_get_spi_error_data(PyObject *exc, char **hint, char **query, int *position)
if (!spidata)
goto cleanup;
- if (!PyArg_ParseTuple(spidata, "zzi", hint, query, position))
+ if (!PyArg_ParseTuple(spidata, "zzzi", detail, hint, query, position))
goto cleanup;
cleanup: