Thread: pgsql: Convert the reg* input functions to report (most) errors softly.

pgsql: Convert the reg* input functions to report (most) errors softly.

From
Tom Lane
Date:
Convert the reg* input functions to report (most) errors softly.

This is not really complete, but it catches most cases of practical
interest.  The main omissions are:

* regtype, regprocedure, and regoperator parse type names by
calling the main grammar, so any grammar-detected syntax error
will still be a hard error.  Also, if one includes a type
modifier in such a type specification, errors detected by the
typmodin function will be hard errors.

* Lookup errors are handled just by passing missing_ok = true
to the relevant catalog lookup function.  Because we've used
quite a restrictive definition of "missing_ok", this means that
edge cases such as "the named schema exists, but you lack
USAGE permission on it" are still hard errors.

It would make sense to me to replace most/all missing_ok
parameters with an escontext parameter and then allow these
additional lookup failure cases to be trapped too.  But that's
a job for some other day.

Discussion: https://postgr.es/m/3342239.1671988406@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/858e776c84f48841e7e16fba7b690b76e54f3675

Modified Files
--------------
src/backend/catalog/objectaddress.c   |   5 +-
src/backend/parser/parse_type.c       |  50 ++++---
src/backend/tsearch/dict_thesaurus.c  |   4 +-
src/backend/utils/adt/misc.c          |   2 +-
src/backend/utils/adt/regproc.c       | 269 +++++++++++++++++++++++-----------
src/backend/utils/adt/tsvector_op.c   |   2 +-
src/backend/utils/cache/ts_cache.c    |  31 +++-
src/backend/utils/fmgr/funcapi.c      |   2 +-
src/include/parser/parse_type.h       |   5 +-
src/include/utils/regproc.h           |   2 +-
src/pl/plperl/plperl.c                |   2 +-
src/pl/plpgsql/src/pl_gram.y          |   2 +-
src/pl/plpython/plpy_spi.c            |   2 +-
src/pl/tcl/pltcl.c                    |   5 +-
src/test/regress/expected/regproc.out | 125 +++++++++++++++-
src/test/regress/sql/regproc.sql      |  23 +++
16 files changed, 403 insertions(+), 128 deletions(-)