Catalog of PostgreSQL queries for finding information about a PostgreSQL database and its design problems

AND
AND
AND
ANDFrom where does the query gets its information?
AND
AND

There are 961 queries.

Seq nrNameGoalTypeData sourceLast updateLicense...
721Routines with type castingMake sure that your parameters have appropriate types in order to avoid unnecessary type casting.GeneralINFORMATION_SCHEMA+system catalog base tables2021-11-04 12:42MIT License
722ROW-level BEFORE and INSTEAD OF triggers with RETURN NULLSuch triggers effectively cancel data modification. It might be correct but could also be a mistake. "Row-level triggers fired BEFORE can return null to signal the trigger manager to skip the rest of the operation for this row (i.e., subsequent triggers are not fired, and the INSERT/UPDATE/DELETE does not occur for this row). " (PostgreSQL documentation) "INSTEAD OF triggers (which are always row-level triggers, and may only be used on views) can return null to signal that they did not perform any updates, and that the rest of the operation for this row should be skipped (i.e., subsequent triggers are not fired, and the row is not counted in the rows-affected status for the surrounding INSERT/UPDATE/DELETE). " (PostgreSQL documentation)Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
723ROW level BEFORE DELETE and INSTEAD OF DELETE triggers that procedures refer to the row variable NEWDo not write incorrect code. Variable NEW: "Data type RECORD; variable holding the new database row for INSERT/UPDATE operations in row-level triggers. This variable is null in statement-level triggers and for DELETE operations." (PostgreSQL documentation)Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-12-20 14:25MIT License
724ROW level BEFORE INSERT and INSTEAD OF INSERT triggers that procedures refer to the row variable OLDDo not write incorrect code. Variable OLD: "Data type RECORD; variable holding the old database row for UPDATE/DELETE operations in row-level triggers. This variable is null in statement-level triggers and for INSERT operations." (PostgreSQL documentation)Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-12-20 14:22MIT License
725ROW level BEFORE triggers that do not return a row if a check succeedsFind ROW level BEFORE triggers that check a condition based on other rows, raise an exception but do not return the row if the condition check succeeds, i.e., exception is not raised.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-12-31 17:29MIT License
726ROW level BEFORE triggers with RAISE EXCEPTION but without RETURN NULLAlthough RAISE EXCEPTION stops the execution it would be a good style to still return. In this case the return should bring back NULL, i.e., the row will not be processed furtherProblem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
727ROW level BEFORE UPDATE triggers that do not return the new rowFind row level BEFORE UPDATE triggers that do not return the new row version. Exclude triggers that raise WARNING/EXCEPTION.Problem detectionINFORMATION_SCHEMA+system catalog base tables2022-12-08 15:59MIT License
728Rules with the same name in different schemasFind rule names that are used in a database in more than one schema. Different things should have different names. But here different rules have the same name. Also make sure that this is not a duplication.Generalsystem catalog base tables only2020-11-06 14:51MIT License
729Rules with the same name within the same schemaFind names of rules that are used within the same schema more than once. Give different triggers different names.Problem detectionsystem catalog base tables only2021-02-25 17:30MIT License
730search_path should not be between quotation marksWrite security definer functions securely. Give to the DBMS correctly information about the sequence of schemas that constitute the search path. You shouldn't write search path value between quotation marks or apostrophes. Thus, instead of writing SET search_path = "public, pg_temp"; or SET search_path = 'public, pg_temp'; you should write SET search_path = public, pg_temp;Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-03 21:10MIT License
731SECURITY DEFINER procedures cannot end transactionsYou cannot use COMMIT and ROLLBACK in a SECURITY DEFINER procedure. Procedures appeared in PostgreSQL 11.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 12:12MIT License
732SECURITY INVOKER routines that access dataFind SECURITY INVOKER routines that read rows from a table, add rows to a table, update rows in a table, or delete rows from a table. Better to have for these purposes SECURITY DEFINER routines, which make it possible to give to the users privileges to only execute routines without having rights to access their underlying tables.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 10:44MIT License
733SELECT * in a routine bodySELECT statement should list the columns not use SELECT * to return data from all the columns. Firstly, it ensures, that the query asks only data that is really needed by the routine. It means less data that the DBMS has to fetch and pass to the routine. It could also mean that the DBMS can answer to a query based on an index without reading table blocks. Secondly, it documents the data that is returned by the query. The query does not consider objects that are a part of an extension.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 15:03MIT License
734Sequences that are not owned by a table columnFind sequence generators that are not owned by a table column, i.e., if one drops the table or the column, then the sequence generator stays in place.Problem detectionsystem catalog base tables only2023-10-06 14:40MIT License
735SET DEFAULT compensatory action is unsuitableFind foreign keys with SET DEFAULT compensatory action where the foreign key column does not have a default value. Compensatory actions cannot make changes that violate integrity constraints in a database. SET DEFAULT means that there shoud be a default value at the foreign key column.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
736SET NULL compensatory action is unsuitableFind foreign key constraints that use a SET NULL compensating action but a foreign key column is mandatory, i.e., does not permit NULLs. Compensatory actions cannot make changes that violate integrity constraints in a database. SET NULL cannot put NULL to a mandatory column (delete a foreign key value).Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-02-25 17:30MIT License
737Set operations that do not remove duplicate rows in derived tablesFind derived tables (views and materialized views) that use a set theoretic operation (union, except or intersect) in a manner that does not remove duplicate rows and thus can produce a multiset not a set. Make sure that it is what is needed.GeneralINFORMATION_SCHEMA+system catalog base tables2020-12-10 13:32MIT License
738Short cycle (columns)Find cases where two candidate keys of the same table that are also foreign keys reference to each other.Problem detectionsystem catalog base tables only2021-11-28 02:08MIT License
739Short cycles (tables)Find pairs of tables that have both a mandatory (NOT NULL) and not defrerrable foreign key that references to the other table. Such cycles can involve more than two tables but the query detects only cycles with two tables.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-27 20:52MIT License
740Should the time zone be recorded in case of time or not?Find all the base table columns that have the type time without time zone or time with time zone. Return the data only if there is at least one column with the type time without time zone and one column with the type time with time zone.Problem detectionINFORMATION_SCHEMA only2021-02-25 17:29MIT License