diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-03-25 16:54:52 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-03-25 16:54:52 -0400 |
commit | cd37bb78599dcf24cd22a124ce9174b5e2a76880 (patch) | |
tree | f04472f34be85e8a2c7f458c708d8eaaacfcb8dd /doc/src | |
parent | fb8d2a7f57d87102f0a95025fbf1cad9c341739b (diff) |
Improve PL/Tcl errorCode facility by providing decoded name for SQLSTATE.
We don't really want to encourage people to write numeric SQLSTATEs in
programs; that's unreadable and error-prone. Copy plpgsql's infrastructure
for converting between SQLSTATEs and exception names shown in Appendix A,
and modify examples in tests and documentation to do it that way.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/pltcl.sgml | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/doc/src/sgml/pltcl.sgml b/doc/src/sgml/pltcl.sgml index 1ff9b96fa52..805cc89dc99 100644 --- a/doc/src/sgml/pltcl.sgml +++ b/doc/src/sgml/pltcl.sgml @@ -813,14 +813,16 @@ CREATE EVENT TRIGGER tcl_a_snitch ON ddl_command_start EXECUTE PROCEDURE tclsnit word is <literal>POSTGRES</literal>, the second word is the Postgres version number, and additional words are field name/value pairs providing detailed information about the error. - Fields <varname>message</> and <varname>SQLSTATE</> (the error code - shown in <xref linkend="errcodes-appendix">) are always supplied. + Fields <varname>SQLSTATE</>, <varname>condition</>, + and <varname>message</> are always supplied + (the first two represent the error code and condition name as shown + in <xref linkend="errcodes-appendix">). Fields that may be present include <varname>detail</>, <varname>hint</>, <varname>context</>, <varname>schema</>, <varname>table</>, <varname>column</>, <varname>datatype</>, <varname>constraint</>, <varname>statement</>, <varname>cursor_position</>, - <varname>filename</>, <varname>lineno</> and + <varname>filename</>, <varname>lineno</>, and <varname>funcname</>. </para> @@ -832,7 +834,7 @@ CREATE EVENT TRIGGER tcl_a_snitch ON ddl_command_start EXECUTE PROCEDURE tclsnit if {[catch { spi_exec $sql_command }]} { if {[lindex $::errorCode 0] == "POSTGRES"} { array set errorArray $::errorCode - if {$errorArray(SQLSTATE) == "42P01"} { # UNDEFINED_TABLE + if {$errorArray(condition) == "undefined_table"} { # deal with missing table } else { # deal with some other type of SQL error |