| Goal | This query identifies PL/pgSQL routines that use the RAISE EXCEPTION statement but fail to provide additional error context, such as ERRCODE, DETAIL, HINT, SCHEMA, TABLE, or CONSTRAINT. Defining these supplementary clauses is a best practice in PL/pgSQL, as it provides developers and client applications with essential diagnostic information for robust error handling. |
|---|---|
| Type | Problem detection Each row in the result could represent a flaw in the design |
| Reliability | High Few or no false-positive results |
| License | MIT (opens in new tab) |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
Fixing Suggestion
To resolve this issue, enhance the RAISE EXCEPTION statements in your routines by adding ERRCODE, DETAIL, HINT, SCHEMA, TABLE, and CONSTRAINT clauses. Including this supplementary information provides better context for debugging and allows client applications to handle errors more effectively.
Collections
This query belongs to the following collections:
Find problems automatically
Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not .
| Name | Description |
|---|---|
| Find problems automatically | Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not . |
Categories
This query is classified under the following categories:
Triggers and rules
Queries of this category provide information about triggers and rules in a database.
User-defined routines
Queries of this category provide information about the user-defined routines
| Name | Description |
|---|---|
| Triggers and rules | Queries of this category provide information about triggers and rules in a database. |
| User-defined routines | Queries of this category provide information about the user-defined routines |
Further reading and related materials: