0

According to the docs, there are options to RAISE called TABLE and COLUMN. However , if I explicitly set them, they do not end up in the resulting error message. It seems only DETAIL and HINT are ever used in the error message. How can you get the other options to show up? E.g.:

RAISE EXCEPTION 'invalid_parameter' USING
    DETAIL = FORMAT('The specified user "%s" was not found.', _usr),
    HINT = 'Enter the username of an existing user.',
    COLUMN = 'username',
    TABLE = 'accounts';

Issues an error message:

... ERROR:  invalid_parameter
... DETAIL:  The specified user "aanders" was not found.
... HINT:  Enter the username of an existing user.
... CONTEXT:  PL/pgSQL function _api.find_user(text) line 24 at RAISE
... PL/pgSQL function _api.accounts_update_trigger() line 97 at assignment
... STATEMENT:
...     WITH pg_source AS (...

There is no "TABLE" or "COLUMN" shown.

UPDATE

The key term I needed was "VERBOSITY" - once I searched for that I found duplicate questions, e.g. https://stackoverflow.com/q/41959752/1571426 (not sure if a question on a different forum makes this "duplicate" or not.)

1

It depends on the client-side verbosity. When using psql, issuing

\set VERBOSITY verbose

before calling the statement would caused the error message to include:

TABLE NAME:  accounts
COLUMN NAME:  username

In recent versions of psql, it's also possible to issue \errverbose after the fact to get the last error message reformated in verbose form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.