| Goal | This query identifies PL/pgSQL routines that invoke RAISE EXCEPTION and specify multiple columns within the COLUMN error context clause. This is an anti-pattern because PostgreSQL's column diagnostic field is designed to hold a single column identifier. Providing a list of columns in this field breaks standard error parsing, making it difficult for client applications to map the error to a specific user interface field. |
|---|---|
| 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, update the USING COLUMN clause to specify only the single most relevant column responsible for the error. If the error genuinely involves multiple columns (such as a cross-column validation failure), use a table-level CONSTRAINT name instead, and list all the involved columns clearly within the DETAIL clause (e.g., USING DETAIL = 'Validation failed for columns: col1, col2').
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: