diff options
author | Neil Conway <neilc@samurai.com> | 2005-06-10 16:23:11 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2005-06-10 16:23:11 +0000 |
commit | d46bc444ac0f2b4c027e624c10bc8d49ffbe2a2f (patch) | |
tree | a67d32556ae2e472c90963ee5ec63992c4e50149 /doc/src | |
parent | 1a61896189c54dbbb63973d45f59c73fd2f4b44c (diff) |
Implement two new special variables in PL/PgSQL: SQLSTATE and SQLERRM.
These contain the SQLSTATE and error message of the current exception,
respectively. They are scope-local variables that are only defined
in exception handlers (so attempting to reference them outside an
exception handler is an error). Update the regression tests and the
documentation.
Also, do some minor related cleanup: export an unpack_sql_state()
function from the backend and use it to unpack a SQLSTATE into a
string, and add a free_var() function to pl_exec.c
Original patch from Pavel Stehule, review by Neil Conway.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plpgsql.sgml | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index d96c123e21c..c043c78fea3 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1,5 +1,5 @@ <!-- -$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.70 2005/06/07 02:47:15 neilc Exp $ +$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.71 2005/06/10 16:23:09 neilc Exp $ --> <chapter id="plpgsql"> @@ -2110,6 +2110,17 @@ END; don't use <literal>EXCEPTION</> without need. </para> </tip> + + <para> + Within an exception handler, the <varname>SQLSTATE</varname> + variable contains the error code that corresponds to the + exception that was raised (refer to <xref + linkend="errcodes-table"> for a list of possible error + codes). The <varname>SQLERRM</varname> variable contains the + error message associated with the exception. These variables are + undefined outside exception handlers. + </para> + <example id="plpgsql-upsert-example"> <title>Exceptions with UPDATE/INSERT</title> <para> |