| Goal | These triggers should be enabled because otherwise some important functionality regarding constraints like enforcing referential integrity does not work. |
|---|---|
| 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) |
| Fixing Suggestion | Enable all the triggers of the table. |
| Data Source | system catalog only |
| SQL Query |
|
SQL statements that help generate fixes for the identified problem.
SELECT format('ALTER TABLE %1$I.%2$I ENABLE TRIGGER ALL;', n.nspname, c.relname) AS statements
FROM pg_catalog.pg_namespace n INNER JOIN pg_catalog.pg_class c
ON n.oid = c.relnamespace
WHERE (n.nspname, c.relname) IN
(SELECT n.nspname, c.relname
FROM pg_catalog.pg_namespace n INNER JOIN pg_catalog.pg_class c
ON n.oid = c.relnamespace INNER JOIN pg_catalog.pg_trigger t
ON c.oid = t.tgrelid LEFT JOIN pg_catalog.pg_constraint pc
ON t.tgconstraint=pc.oid
WHERE t.tgenabled='D' AND t.tgisinternal=TRUE)
ORDER BY n.nspname, c.relname;Enable all the triggers of the table.
| SQL Query to Generate Fix | Description |
|---|---|
| Enable all the triggers of the table. |
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:
Relationships between tables
Queries of this category provide information about how database tables are connected to each other and whether such connections have been explicitly defined and whether it has been done correctly.
Triggers and rules
Queries of this category provide information about triggers and rules in a database.
Unused implementation elements
Queries of this catergory provide information about the database objects that are not used.
| Name | Description |
|---|---|
| Relationships between tables | Queries of this category provide information about how database tables are connected to each other and whether such connections have been explicitly defined and whether it has been done correctly. |
| Triggers and rules | Queries of this category provide information about triggers and rules in a database. |
| Unused implementation elements | Queries of this catergory provide information about the database objects that are not used. |
Further reading and related materials:
| Reference |
|---|
| Factor, P.: SQL Code Smells. Redgate, http://assets.red-gate.com/community/books/sql-code-smells.pdf, last accessed 2019/12/29 (Enabling NOCHECK on referential integrity constraints) |