@@ -294,7 +294,7 @@ static char *PLy_procedure_name(PLyProcedure *);
294
294
static void
295
295
PLy_elog (int ,const char * ,...)
296
296
__attribute__((format (printf ,2 ,3 )));
297
- static void PLy_get_spi_error_data (PyObject * exc ,char * * hint ,char * * query ,int * position );
297
+ static void PLy_get_spi_error_data (PyObject * exc ,char * * detail , char * * hint ,char * * query ,int * position );
298
298
static char * PLy_traceback (int * );
299
299
300
300
static void * PLy_malloc (size_t );
@@ -3551,7 +3551,7 @@ PLy_spi_exception_set(ErrorData *edata)
3551
3551
if (!spierror )
3552
3552
gotofailure ;
3553
3553
3554
- spidata = Py_BuildValue ("(zzi)" ,edata -> hint ,
3554
+ spidata = Py_BuildValue ("(zzzi)" , edata -> detail ,edata -> hint ,
3555
3555
edata -> internalquery ,edata -> internalpos );
3556
3556
if (!spidata )
3557
3557
gotofailure ;
@@ -3586,13 +3586,14 @@ PLy_elog(int elevel, const char *fmt,...)
3586
3586
int xlevel ;
3587
3587
StringInfoData emsg ;
3588
3588
PyObject * exc ,* val ,* tb ;
3589
+ char * detail = NULL ;
3589
3590
char * hint = NULL ;
3590
3591
char * query = NULL ;
3591
3592
int position = 0 ;
3592
3593
3593
3594
PyErr_Fetch (& exc ,& val ,& tb );
3594
3595
if (exc != NULL && PyErr_GivenExceptionMatches (val ,PLy_exc_spi_error ))
3595
- PLy_get_spi_error_data (val ,& hint ,& query ,& position );
3596
+ PLy_get_spi_error_data (val ,& detail , & hint ,& query ,& position );
3596
3597
PyErr_Restore (exc ,val ,tb );
3597
3598
3598
3599
xmsg = PLy_traceback (& xlevel );
@@ -3626,6 +3627,7 @@ PLy_elog(int elevel, const char *fmt,...)
3626
3627
else
3627
3628
ereport (elevel ,
3628
3629
(errmsg ("PL/Python: %s" ,xmsg ),
3630
+ (detail ) ?errdetail ("%s" ,detail ) :0 ,
3629
3631
(hint ) ?errhint ("%s" ,hint ) :0 ,
3630
3632
(query ) ?internalerrquery (query ) :0 ,
3631
3633
(position ) ?internalerrposition (position ) :0 ));
@@ -3650,15 +3652,15 @@ PLy_elog(int elevel, const char *fmt,...)
3650
3652
* Extract the error data from a SPIError
3651
3653
*/
3652
3654
static void
3653
- PLy_get_spi_error_data (PyObject * exc ,char * * hint ,char * * query ,int * position )
3655
+ PLy_get_spi_error_data (PyObject * exc ,char * * detail , char * * hint ,char * * query ,int * position )
3654
3656
{
3655
3657
PyObject * spidata = NULL ;
3656
3658
3657
3659
spidata = PyObject_GetAttrString (exc ,"spidata" );
3658
3660
if (!spidata )
3659
3661
gotocleanup ;
3660
3662
3661
- if (!PyArg_ParseTuple (spidata ,"zzi" ,hint ,query ,position ))
3663
+ if (!PyArg_ParseTuple (spidata ,"zzzi" , detail ,hint ,query ,position ))
3662
3664
gotocleanup ;
3663
3665
3664
3666
cleanup :