From 35f49941337827c6361af1939b582368022733e2 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 21 Nov 2004 21:17:07 +0000 Subject: Fix plperl and pltcl error handling per my previous proposal. SPI operations are now run as subtransactions, so that errors in them can be reported as ordinary Perl or Tcl errors and caught by the normal error handling convention of those languages. Also do some minor code cleanup in pltcl.c: extract a large chunk of duplicated code in pltcl_SPI_execute and pltcl_SPI_execute_plan into a shared subroutine. --- doc/src/sgml/plperl.sgml | 12 ++++++++---- doc/src/sgml/pltcl.sgml | 26 ++++++++++++++------------ doc/src/sgml/release.sgml | 11 ++++++++++- 3 files changed, 32 insertions(+), 17 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml index 7893d263775..7642f50ca45 100644 --- a/doc/src/sgml/plperl.sgml +++ b/doc/src/sgml/plperl.sgml @@ -1,5 +1,5 @@ @@ -219,9 +219,13 @@ $nrows = $rv->{processed}; Emit a log or error message. Possible levels are DEBUG, LOG, INFO, NOTICE, WARNING, and ERROR. - ERROR raises an error condition: further execution - of the function is abandoned, and the current transaction is - aborted. + ERROR + raises an error condition; if this is not trapped by the surrounding + Perl code, the error propagates out to the calling query, causing + the current transaction or subtransaction to be aborted. This + is effectively the same as the Perl die command. + The other levels simply report the message to the system log + and/or client. diff --git a/doc/src/sgml/pltcl.sgml b/doc/src/sgml/pltcl.sgml index 09f8f82eaa4..b454c6a45f8 100644 --- a/doc/src/sgml/pltcl.sgml +++ b/doc/src/sgml/pltcl.sgml @@ -1,5 +1,5 @@ @@ -449,17 +449,19 @@ SELECT 'doesn''t' AS ret elog level msg - Emits a log or error message. Possible levels are - DEBUG, LOG, INFO, - NOTICE, WARNING, ERROR, and - FATAL. Most simply emit the given message just like - the elog C function. ERROR - raises an error condition: further execution of the function is - abandoned, and the current transaction is aborted. - FATAL aborts the transaction and causes the current - session to shut down. (There is probably no good reason to use - this error level in PL/Tcl functions, but it's provided for - completeness.) + Emits a log or error message. Possible levels are + DEBUG, LOG, INFO, + NOTICE, WARNING, ERROR, and + FATAL. Most simply emit the given message just like + the elog C function. ERROR + raises an error condition; if this is not trapped by the surrounding + Tcl code, the error propagates out to the calling query, causing + the current transaction or subtransaction to be aborted. This + is effectively the same as the Tcl error command. + FATAL aborts the transaction and causes the current + session to shut down. (There is probably no good reason to use + this error level in PL/Tcl functions, but it's provided for + completeness.) diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml index e0d58a0ee0a..39f6f763c9b 100644 --- a/doc/src/sgml/release.sgml +++ b/doc/src/sgml/release.sgml @@ -1,5 +1,5 @@ @@ -1686,6 +1686,15 @@ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.309 2004/11/20 21:44:24 tgl Exp + + + In PL/Tcl, SPI commands are now run in subtransactions. If an error + occurs, the subtransaction is cleaned up and the error is reported + as an ordinary Tcl error, which can be trapped with catch. + Formerly, it was not possible to catch such errors. + + + -- cgit v1.2.3