@@ -294,7 +294,7 @@ static char *PLy_procedure_name(PLyProcedure *);
294294static void
295295PLy_elog (int , const char * ,...)
296296__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 );
298298static char * PLy_traceback (int * );
299299
300300static void * PLy_malloc (size_t );
@@ -3551,7 +3551,7 @@ PLy_spi_exception_set(ErrorData *edata)
35513551 if (!spierror )
35523552 goto failure ;
35533553
3554- spidata = Py_BuildValue ("(zzi)" , edata -> hint ,
3554+ spidata = Py_BuildValue ("(zzzi)" , edata -> detail , edata -> hint ,
35553555 edata -> internalquery , edata -> internalpos );
35563556 if (!spidata )
35573557 goto failure ;
@@ -3586,13 +3586,14 @@ PLy_elog(int elevel, const char *fmt,...)
35863586 int xlevel ;
35873587 StringInfoData emsg ;
35883588 PyObject * exc , * val , * tb ;
3589+ char * detail = NULL ;
35893590 char * hint = NULL ;
35903591 char * query = NULL ;
35913592 int position = 0 ;
35923593
35933594 PyErr_Fetch (& exc , & val , & tb );
35943595 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 );
35963597 PyErr_Restore (exc , val , tb );
35973598
35983599 xmsg = PLy_traceback (& xlevel );
@@ -3626,6 +3627,7 @@ PLy_elog(int elevel, const char *fmt,...)
36263627 else
36273628 ereport (elevel ,
36283629 (errmsg ("PL/Python: %s" , xmsg ),
3630+ (detail ) ? errdetail ("%s" , detail ) : 0 ,
36293631 (hint ) ? errhint ("%s" , hint ) : 0 ,
36303632 (query ) ? internalerrquery (query ) : 0 ,
36313633 (position ) ? internalerrposition (position ) : 0 ));
@@ -3650,15 +3652,15 @@ PLy_elog(int elevel, const char *fmt,...)
36503652 * Extract the error data from a SPIError
36513653 */
36523654static 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 )
36543656{
36553657 PyObject * spidata = NULL ;
36563658
36573659 spidata = PyObject_GetAttrString (exc , "spidata" );
36583660 if (!spidata )
36593661 goto cleanup ;
36603662
3661- if (!PyArg_ParseTuple (spidata , "zzi" , hint , query , position ))
3663+ if (!PyArg_ParseTuple (spidata , "zzzi" , detail , hint , query , position ))
36623664 goto cleanup ;
36633665
36643666cleanup :
0 commit comments