Expose object name error fields in PL/pgSQL.
Noah Misch <noah@leadboat.com>
Expose object name error fields in PL/pgSQL. Specifically, permit attaching them to the error in RAISE and retrieving them from a caught error in GET STACKED DIAGNOSTICS. RAISE enforces nothing about the content of the fields; for its purposes, they are just additional string fields. Consequently, clarify in the protocol and libpq documentation that the usual relationships between error fields, like a schema name appearing wherever a table name appears, are not universal. This freedom has other applications; consider a FDW propagating an error from an RDBMS having no schema support. Back-patch to 9.3, where core support for the error fields was introduced. This prevents the confusion of having a release where libpq exposes the fields and PL/pgSQL does not. Pavel Stehule, lexical revisions by Noah Misch.
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/libpq.sgml | modified | +22 −17 |
| doc/src/sgml/plpgsql.sgml | modified | +36 −0 |
| doc/src/sgml/protocol.sgml | modified | +16 −11 |
| src/pl/plpgsql/src/pl_exec.c | modified | +79 −19 |
| src/pl/plpgsql/src/pl_funcs.c | modified | +25 −0 |
| src/pl/plpgsql/src/pl_gram.y | modified | +55 −0 |
| src/pl/plpgsql/src/plpgsql.h | modified | +12 −2 |
| src/pl/plpgsql/src/pl_scanner.c | modified | +10 −0 |
| src/test/regress/expected/plpgsql.out | modified | +34 −0 |
| src/test/regress/sql/plpgsql.sql | modified | +32 −0 |