Fix behavior when raising plpy.Fatal()
authorPeter Eisentraut
Mon, 7 Mar 2011 21:01:54 +0000 (23:01 +0200)
committerPeter Eisentraut
Mon, 7 Mar 2011 21:47:43 +0000 (23:47 +0200)
It should cause a elog(FATAL) error, and it fact it was simply causing
a elog(ERROR).

Jan Urbański

src/pl/plpython/plpython.c

index 43d332de209d0a40253ccdb3dec1a497763ef39f..1f8c27f632a994e68c4f5e9a98678d4a9c00feaa 100644 (file)
@@ -4381,8 +4381,13 @@ PLy_elog(int elevel, const char *fmt,...)
    int         position = 0;
 
    PyErr_Fetch(&exc, &val, &tb);
-   if (exc != NULL && PyErr_GivenExceptionMatches(val, PLy_exc_spi_error))
-       PLy_get_spi_error_data(val, &detail, &hint, &query, &position);
+   if (exc != NULL)
+   {
+       if (PyErr_GivenExceptionMatches(val, PLy_exc_spi_error))
+           PLy_get_spi_error_data(val, &detail, &hint, &query, &position);
+       else if (PyErr_GivenExceptionMatches(val, PLy_exc_fatal))
+           elevel = FATAL;
+   }
    PyErr_Restore(exc, val, tb);
 
    xmsg = PLy_traceback(&xlevel);