diff options
author | Tom Lane | 2004-11-21 21:17:07 +0000 |
---|---|---|
committer | Tom Lane | 2004-11-21 21:17:07 +0000 |
commit | 35f49941337827c6361af1939b582368022733e2 (patch) | |
tree | d6abe814f92c44c1abf0c6f1193f799167d588ce /doc/src | |
parent | a3b663dfea25944bc59d7524e04e6c5f848b66d2 (diff) |
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.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plperl.sgml | 12 | ||||
-rw-r--r-- | doc/src/sgml/pltcl.sgml | 26 | ||||
-rw-r--r-- | doc/src/sgml/release.sgml | 11 |
3 files changed, 32 insertions, 17 deletions
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 @@ <!-- -$PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.31 2004/11/19 23:22:54 tgl Exp $ +$PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.32 2004/11/21 21:17:01 tgl Exp $ --> <chapter id="plperl"> @@ -219,9 +219,13 @@ $nrows = $rv->{processed}; Emit a log or error message. Possible levels are <literal>DEBUG</>, <literal>LOG</>, <literal>INFO</>, <literal>NOTICE</>, <literal>WARNING</>, and <literal>ERROR</>. - <literal>ERROR</> raises an error condition: further execution - of the function is abandoned, and the current transaction is - aborted. + <literal>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 <literal>die</> command. + The other levels simply report the message to the system log + and/or client. </para> </listitem> </varlistentry> 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 @@ <!-- -$PostgreSQL: pgsql/doc/src/sgml/pltcl.sgml,v 2.31 2004/09/20 22:48:25 tgl Exp $ +$PostgreSQL: pgsql/doc/src/sgml/pltcl.sgml,v 2.32 2004/11/21 21:17:02 tgl Exp $ --> <chapter id="pltcl"> @@ -449,17 +449,19 @@ SELECT 'doesn''t' AS ret <term><function>elog</> <replaceable>level</replaceable> <replaceable>msg</replaceable></term> <listitem> <para> - Emits a log or error message. Possible levels are - <literal>DEBUG</>, <literal>LOG</>, <literal>INFO</>, - <literal>NOTICE</>, <literal>WARNING</>, <literal>ERROR</>, and - <literal>FATAL</>. Most simply emit the given message just like - the <literal>elog</> C function. <literal>ERROR</> - raises an error condition: further execution of the function is - abandoned, and the current transaction is aborted. - <literal>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 + <literal>DEBUG</>, <literal>LOG</>, <literal>INFO</>, + <literal>NOTICE</>, <literal>WARNING</>, <literal>ERROR</>, and + <literal>FATAL</>. Most simply emit the given message just like + the <literal>elog</> C function. <literal>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 <literal>error</> command. + <literal>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.) </para> </listitem> </varlistentry> 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 @@ <!-- -$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.309 2004/11/20 21:44:24 tgl Exp $ +$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.310 2004/11/21 21:17:02 tgl Exp $ --> <appendix id="release"> @@ -1686,6 +1686,15 @@ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.309 2004/11/20 21:44:24 tgl Exp </para> </listitem> + <listitem> + <para> + 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 <literal>catch</>. + Formerly, it was not possible to catch such errors. + </para> + </listitem> + </itemizedlist> </sect3> |