Filter Queries

Found 1053 queries.

  • All the queries about database objects contain a subcondition to exclude from the result information about the system catalog.
  • Although the statements use SQL constructs (common table expressions; NOT in subqueries) that could cause performance problems in case of large datasets it shouldn't be a problem in case of relatively small amount of data, which is in the system catalog of a database.
  • Statistics about the catalog content and project home in GitHub that has additional information.

#761. Perhaps the type of a base table column/domain should be temporal (deadlines)

INFORMATION_SCHEMA only

Find base table columns that name refers to the possibility that there are registered deadlines but the column does not have a temporal type.

Problem detection License: MIT (opens in new tab)

#762. Perhaps the type of a base table column/domain should be VARCHAR (based on column names)

INFORMATION_SCHEMA only

Find base table columns that have CHAR type, where character maximum length is bigger than 1 and the name of the column does not refer to the possibility that the column holds some kind of codes or flags or hash values.

Problem detection License: MIT (opens in new tab)

#763. Perhaps the type of a base table column should be an integer type (based on column names)

INFORMATION_SCHEMA only

Find columns of base tables where the name of the column has prefix or suffix "id" or has the name "id" but the column does not have an integer type or uuid type. A convention is to use the phrase "id" in the names of surrogate key columns.

Problem detection License: MIT (opens in new tab)

#764. Perhaps the type of a base table column should be BOOLEAN (based on enumerated types)

INFORMATION_SCHEMA+system catalog base tables

Find base table columns that have an enumerated type that seems to emulate Boolean type.

Problem detection License: MIT (opens in new tab)

#765. Perhaps the type of a base table column should be XML, JSON, or JSONB (based on column names)

INFORMATION_SCHEMA only

Find base table columns that name refers to the possibility that these are used to register XML/JSON values. Find the columns that do not have an appropriate data type (xml, json, jsonb). One shouldn't use columns with a textual type to register such data.

Problem detection License: MIT (opens in new tab)

#766. Perhaps the type of a parameter should be BOOLEAN (based on parameter names)

INFORMATION_SCHEMA+system catalog base tables

Find routine parameters that based on the name seem to hold truth values. Find parameters that name starts with "is_" or "has_" or "can_" or "on_" and that do not have Boolean type.

Problem detection License: MIT (opens in new tab)

#767. Perhaps too many different prefixes in the names of database objects that have the same type

INFORMATION_SCHEMA+system catalog base tables

One should be consistent in naming, including in the use of prefixes. If you use prefix in the name of a database object, then it should refer to the type of the database object. Do not use different prefixes in the names of database objects that have the same type. Find types of database objects in case of which there are different prefixes in different names.

Problem detection License: MIT (opens in new tab)

#768. Perhaps too many different suffixes in the names of database objects that have the same type

INFORMATION_SCHEMA+system catalog base tables

One should be consistent in naming, including in the use of suffixes. If you use sufix in the name of a database object, then it should refer to the type of the database object. Do not use different suffixes in the names of database objects that have the same type. Find types of database objects in case of which there are different suffixes in different names.

Problem detection License: MIT (opens in new tab)

#769. Perhaps too many input parameters

INFORMATION_SCHEMA+system catalog base tables

Too 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 detection License: MIT (opens in new tab)

#770. Perhaps too many square brackets

INFORMATION_SCHEMA+system catalog base tables

Character classes are surrounded by two pairs of square brackets.

Problem detection License: MIT (opens in new tab)

#771. Perhaps too many subconditions in a CHECK constraint

INFORMATION_SCHEMA only

Find check constraints of base table and foreign table columns that are either associated with more than one column and have at least one AND operation or are associated with exactly one column and have two or more AND operations.

Problem detection License: MIT (opens in new tab)

#772. Perhaps unnecessary DECLARE section in a PL/pgSQL routine

INFORMATION_SCHEMA+system catalog base tables

Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the only task seems to be raising an exception. The query excludes the cases where the error message is constructed dynamically, i.e., in this case using a variable maybe justifiable.

Problem detection License: MIT (opens in new tab)

#773. Perhaps unnecessary DECLARE section in a PL/pgSQL routine (2)

INFORMATION_SCHEMA+system catalog base tables

Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the keyword DECLARE is followed by BEGIN, i.e., the DECLARE section is empty.

Problem detection License: MIT (opens in new tab)

#774. Perhaps unnecessary privileges to use the database

system catalog base tables only

Find as to whether a database user (except postgres), who is not a superuser, has Create (C) or Temporary (T) privileges to use the database.

Problem detection License: MIT (opens in new tab)

#775. Perhaps updating of modification time is missing

INFORMATION_SCHEMA+system catalog base tables

Find routines with SQL-standard body that seem to update data in a table that has a column for modification time but the routine does not seem to update the modification time while updating the row and the table does not seem to have an UPDATE trigger that changes the modification time.

Problem detection License: MIT (opens in new tab)

#776. Personal names are unique

system catalog base tables only

Find all primary key and unique constraints of base tables that involve at least one column with personal names. Personal names are not unique and these cannot be (usually) used to guarantee uniqueness. Either one has declared a superkey instead of candidate key (i.e., the key contains a column that is not needed for uniqueness) or the key columns have been found incorrectly.

Problem detection License: MIT (opens in new tab)

#777. PL/pgSQL functions with consecutive RETURN clauses

INFORMATION_SCHEMA+system catalog base tables

Find PL/pgSQL functions with consecutive RETURN clauses. Only the first RETURN will be used, others are unnecessary.

Problem detection License: MIT (opens in new tab)

#778. PL/pgSQL functions without the RETURN clause

INFORMATION_SCHEMA+system catalog base tables

The return value of a function cannot be left undefined. If control reaches the end of the top-level block of the function without hitting a RETURN statement, a run-time error will occur. This restriction does not apply to functions with output parameters and functions returning void, however. In those cases a RETURN statement is automatically executed if the top-level block finishes. It also does not apply to trigger functions that only task is to raise an exception.

Problem detection License: MIT (opens in new tab)

#779. PL/pgSQL routines that use a cursor

INFORMATION_SCHEMA+system catalog base tables

Working with sets of rows rather than processing each row separately is more effective.

General License: MIT (opens in new tab)

#780. PL/pgSQL routine with plain SELECT

INFORMATION_SCHEMA+system catalog base tables

Find PL/pgSQL that contain a SELECT statement that is not a SELECT … INTO statement. This is not permitted in PL/pgSQL routines.

Problem detection License: MIT (opens in new tab)
# Name Goal Type Data source Last update (sorted descending) License Actions
761 Perhaps the type of a base table column/domain should be temporal (deadlines) Find base table columns that name refers to the possibility that there are registered deadlines but the column does not have a temporal type. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
762 Perhaps the type of a base table column/domain should be VARCHAR (based on column names) Find base table columns that have CHAR type, where character maximum length is bigger than 1 and the name of the column does not refer to the possibility that the column holds some kind of codes or flags or hash values. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
763 Perhaps the type of a base table column should be an integer type (based on column names) Find columns of base tables where the name of the column has prefix or suffix "id" or has the name "id" but the column does not have an integer type or uuid type. A convention is to use the phrase "id" in the names of surrogate key columns. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
764 Perhaps the type of a base table column should be BOOLEAN (based on enumerated types) Find base table columns that have an enumerated type that seems to emulate Boolean type. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
765 Perhaps the type of a base table column should be XML, JSON, or JSONB (based on column names) Find base table columns that name refers to the possibility that these are used to register XML/JSON values. Find the columns that do not have an appropriate data type (xml, json, jsonb). One shouldn't use columns with a textual type to register such data. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
766 Perhaps the type of a parameter should be BOOLEAN (based on parameter names) Find routine parameters that based on the name seem to hold truth values. Find parameters that name starts with "is_" or "has_" or "can_" or "on_" and that do not have Boolean type. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
767 Perhaps too many different prefixes in the names of database objects that have the same type One should be consistent in naming, including in the use of prefixes. If you use prefix in the name of a database object, then it should refer to the type of the database object. Do not use different prefixes in the names of database objects that have the same type. Find types of database objects in case of which there are different prefixes in different names. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
768 Perhaps too many different suffixes in the names of database objects that have the same type One should be consistent in naming, including in the use of suffixes. If you use sufix in the name of a database object, then it should refer to the type of the database object. Do not use different suffixes in the names of database objects that have the same type. Find types of database objects in case of which there are different suffixes in different names. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
769 Perhaps too many input parameters Too 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
770 Perhaps too many square brackets Character classes are surrounded by two pairs of square brackets. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
771 Perhaps too many subconditions in a CHECK constraint Find check constraints of base table and foreign table columns that are either associated with more than one column and have at least one AND operation or are associated with exactly one column and have two or more AND operations. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
772 Perhaps unnecessary DECLARE section in a PL/pgSQL routine Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the only task seems to be raising an exception. The query excludes the cases where the error message is constructed dynamically, i.e., in this case using a variable maybe justifiable. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
773 Perhaps unnecessary DECLARE section in a PL/pgSQL routine (2) Find PL/pgSQL routines that perhaps unnecessarily contain DECLARE section. More specifically, find routines with the DECLARE section where the keyword DECLARE is followed by BEGIN, i.e., the DECLARE section is empty. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
774 Perhaps unnecessary privileges to use the database Find as to whether a database user (except postgres), who is not a superuser, has Create (C) or Temporary (T) privileges to use the database. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
775 Perhaps updating of modification time is missing Find routines with SQL-standard body that seem to update data in a table that has a column for modification time but the routine does not seem to update the modification time while updating the row and the table does not seem to have an UPDATE trigger that changes the modification time. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
776 Personal names are unique Find all primary key and unique constraints of base tables that involve at least one column with personal names. Personal names are not unique and these cannot be (usually) used to guarantee uniqueness. Either one has declared a superkey instead of candidate key (i.e., the key contains a column that is not needed for uniqueness) or the key columns have been found incorrectly. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
777 PL/pgSQL functions with consecutive RETURN clauses Find PL/pgSQL functions with consecutive RETURN clauses. Only the first RETURN will be used, others are unnecessary. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
778 PL/pgSQL functions without the RETURN clause The return value of a function cannot be left undefined. If control reaches the end of the top-level block of the function without hitting a RETURN statement, a run-time error will occur. This restriction does not apply to functions with output parameters and functions returning void, however. In those cases a RETURN statement is automatically executed if the top-level block finishes. It also does not apply to trigger functions that only task is to raise an exception. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
779 PL/pgSQL routines that use a cursor Working with sets of rows rather than processing each row separately is more effective. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
780 PL/pgSQL routine with plain SELECT Find PL/pgSQL that contain a SELECT statement that is not a SELECT … INTO statement. This is not permitted in PL/pgSQL routines. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)