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...
521There is no reason to use PL/pgSQL to write table functionsUsing PL/pgSQL may cause context switching between declarative SQL and procedural PL/pgSQL. Thus use PL/pgSQL only if you truly need some of its constructs. You can create table functions by using SQL.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 11:28MIT License
522FOR UPDATE is not allowed with aggregate functionsImplement explicit locking correctly. Instead of writing, for instance, SELECT Count(*) AS cnt FROM person WHERE person_id=1 FOR UPDATE; one has to write SELECT person_id FROM person WHERE person_id=1 FOR UPDATE;Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 11:23MIT License
523User-defined routines with dynamic SQLFind routines that use dynamic SQL. Make sure that dynamic SQL is indeed needed, i.e., the task cannot be solved with static SQL. Make sure that the routine is protected against attacks that use SQL injection method.GeneralINFORMATION_SCHEMA+system catalog base tables2021-11-04 11:09MIT License
524Perhaps too many input parametersToo many parameters (in this case four or more) could be a sign of not separating concerns and having a routine that has more than one task.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 10:57MIT License
525Consistency of comments of routinesFind user-defined routines that have a comment registered by the COMMENT statement and a comment within the routine body. Make sure that there are no inconsistencies between the comments.GeneralINFORMATION_SCHEMA+system catalog base tables2021-11-04 10:56MIT License
526Functions that have transactional controlFind functions that contain transactional control statements (BEGIN, START TRANSACTION, COMMIT, ROLLBACK, SAVEPOINT) in their body. PostgreSQL does not permit transaction control in functions.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 10:50MIT License
527Flag parametersA Boolean parameter may be used to determine what task to fulfill. In this case the routine has multiple tasks and does not satisfy the separation of concerns principle.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-04 10:48MIT License
528SECURITY 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
529A non-parameterized table function instead of a viewFind table functions that do not have any parameters. Prefer simpler and more portable solutions.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-11-03 21:16MIT License
530search_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
531Are there enough routines that implement database operations?Find user-defined routines that implement database operations (comment refers to an operation) but show these only if there are at least eight such routines. Contracts of database operations are specified in the system analysis documentation. The contracts apply the idea of design by contract in the field of databases.GeneralINFORMATION_SCHEMA+system catalog base tables2021-11-03 20:07MIT License
532User-defined non-trigger routines without parametersFind user-defined non-trigger routines with no parameters.GeneralINFORMATION_SCHEMA+system catalog base tables2021-11-03 20:05MIT License
533Non-foreign key base table columns with the same name have a different set of CHECK constraintsFind non-foreign key base table columns that have the same name but a different set of check constraints. The use of constraints should be consistent and all the necessary constraints must be enforced. "If you do something a certain way, do all similar things in the same way." (Robert C. Martin, Clean Code)Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-31 20:39MIT License
534Do not leave out referential constraints (based on composite keys)Try to find missing foreign key constraints. Find columns of base tables that are not covered by any foreign key constraint but belong to a composite key, do not have an associated sequence generator, and have a name that refers to the possibility that these are used to record some kind of codes or id's. Moreover, there must be at least one other base table that has a column with the same name. Such strategy would find missing constraints in tables that implement many-to-many relationship types but which that are not complete "islands" in terms of missing foreign key constraints.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-31 19:21MIT License
535Too generic names (user-defined types, domains)Find names of user-defined types and domains that contain too generic (noise) words.Problem detectionsystem catalog base tables only2021-10-31 17:41MIT License
536Too generic names (domain constraints)Find domain CHECK constraints that have a too generic name - for instance, the name contains word "data" ) or the name is an abbreviation of the constraint type name (for instance, "chk" or "chk1").Problem detectionINFORMATION_SCHEMA only2021-10-31 17:39MIT License
537Routine body with ordering the query result based on positional referencesFind routines where the query result is sorted based on the column number in the SELECT clause. Such query is sensitive towards changing the order of columns in the SELECT clause, i.e., if one changes the order of columns in the SELECT clause, then one must change the numbers in the ORDER BY clause as well, otherwise the query will produce undesired order of rows.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-31 15:23MIT License
538User-defined routines that use md5 hash for other purposes than generating test dataFind user-defined routines that use md5 hashes for the security purposes. Nowadays such hashes can be calculated too quickly and its use should be avoided at least for hashing passwords. Exclude routines that invoke both md5 function and generate_series function and are thus probably used to generate test data.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-31 15:23MIT License
539Too few rounds in case of calculating the hashFind user-defined routines where gen_salt function is used with the number of rounds that is smaller than 12. The number should be adjusted based on the hardware where the system resides. Password hashing should take at least 250 ms.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-25 17:21MIT License
540PL/pgSQL routine with plain SELECTFind PL/pgSQL that contain a SELECT statement that is not a SELECT … INTO statement. This is not permitted in PL/pgSQL routines.Problem detectionINFORMATION_SCHEMA+system catalog base tables2021-10-25 17:07MIT License