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.

#821. Routine body with ordering the query result based on positional references

INFORMATION_SCHEMA+system catalog base tables

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

#822. Routines that can be invoked with a variable number of arguments

INFORMATION_SCHEMA+system catalog base tables

Find routines with a VARIADIC parameter. These are routines that take as input an undefined number of arguments where the argument that is an undefined number are all of the same type and are the last input arguments.

General License: MIT (opens in new tab)

#823. Routines with INSERT statements that are sensitive towards the order of columns

INFORMATION_SCHEMA+system catalog base tables

INSERT statements shouldn't be sensitive towards the order of columns. If one changes the order of columns in a table then these statements must be rewritten. Otherwise the code will not work or works incorrectly.

Problem detection License: MIT (opens in new tab)

#824. Routines without an action

INFORMATION_SCHEMA+system catalog base tables

Find routines that body does not contain any action.

Problem detection License: MIT (opens in new tab)

#825. Routines with the same name and parameters in different schemas

INFORMATION_SCHEMA+system catalog base tables

Find user-defined routines with the same name and parameters (including the order of parameters) in different schemas.

General License: MIT (opens in new tab)

#826. Routines with type casting

INFORMATION_SCHEMA+system catalog base tables

Make sure that your parameters have appropriate types in order to avoid unnecessary type casting.

General License: MIT (opens in new tab)

#827. ROW level BEFORE DELETE and INSTEAD OF DELETE triggers that procedures refer to the row variable NEW

INFORMATION_SCHEMA+system catalog base tables

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

#828. ROW level BEFORE INSERT and INSTEAD OF INSERT triggers that procedures refer to the row variable OLD

INFORMATION_SCHEMA+system catalog base tables

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

#829. ROW level BEFORE triggers that do not return a row if a check succeeds

INFORMATION_SCHEMA+system catalog base tables

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

#830. ROW level BEFORE triggers with RAISE EXCEPTION but without RETURN NULL

INFORMATION_SCHEMA+system catalog base tables

Although 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 further

Problem detection License: MIT (opens in new tab)

#831. ROW level BEFORE UPDATE triggers that do not return the new row

INFORMATION_SCHEMA+system catalog base tables

Find row level BEFORE UPDATE triggers that do not return the new row version. Exclude triggers that raise WARNING/EXCEPTION.

Problem detection License: MIT (opens in new tab)

#832. Rules with the same name in different schemas

system catalog base tables only

Find 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.

General License: MIT (opens in new tab)

#833. Rules with the same name within the same schema

system catalog base tables only

Find names of rules that are used within the same schema more than once. Give different triggers different names.

Problem detection License: MIT (opens in new tab)

#834. search_path should not be between quotation marks

INFORMATION_SCHEMA+system catalog base tables

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

#835. SECURITY DEFINER procedures cannot end transactions

INFORMATION_SCHEMA+system catalog base tables

You cannot use COMMIT and ROLLBACK in a SECURITY DEFINER procedure. Procedures appeared in PostgreSQL 11.

Problem detection License: MIT (opens in new tab)

#836. SECURITY INVOKER routines that access data

INFORMATION_SCHEMA+system catalog base tables

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

#837. SELECT * in a routine body

INFORMATION_SCHEMA+system catalog base tables

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

#838. Sequences that are not owned by a table column

system catalog base tables only

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

#839. SET DEFAULT compensatory action is unsuitable

INFORMATION_SCHEMA+system catalog base tables

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

#840. SET NULL compensatory action is unsuitable

INFORMATION_SCHEMA+system catalog base tables

Find 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 detection License: MIT (opens in new tab)
# Name Goal Type Data source Last update (sorted descending) License Actions
821 Routine body with ordering the query result based on positional references Find 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
822 Routines that can be invoked with a variable number of arguments Find routines with a VARIADIC parameter. These are routines that take as input an undefined number of arguments where the argument that is an undefined number are all of the same type and are the last input arguments. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
823 Routines with INSERT statements that are sensitive towards the order of columns INSERT statements shouldn't be sensitive towards the order of columns. If one changes the order of columns in a table then these statements must be rewritten. Otherwise the code will not work or works incorrectly. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
824 Routines without an action Find routines that body does not contain any action. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
825 Routines with the same name and parameters in different schemas Find user-defined routines with the same name and parameters (including the order of parameters) in different schemas. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
826 Routines with type casting Make sure that your parameters have appropriate types in order to avoid unnecessary type casting. General INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
827 ROW level BEFORE DELETE and INSTEAD OF DELETE triggers that procedures refer to the row variable NEW Do 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
828 ROW level BEFORE INSERT and INSTEAD OF INSERT triggers that procedures refer to the row variable OLD Do 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
829 ROW level BEFORE triggers that do not return a row if a check succeeds Find 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
830 ROW level BEFORE triggers with RAISE EXCEPTION but without RETURN NULL Although 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 further Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
831 ROW level BEFORE UPDATE triggers that do not return the new row Find row level BEFORE UPDATE triggers that do not return the new row version. Exclude triggers that raise WARNING/EXCEPTION. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
832 Rules with the same name in different schemas Find 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. General system catalog base tables only MIT (opens in new tab) View (opens in new tab)
833 Rules with the same name within the same schema Find names of rules that are used within the same schema more than once. Give different triggers different names. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
834 search_path should not be between quotation marks Write 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
835 SECURITY DEFINER procedures cannot end transactions You cannot use COMMIT and ROLLBACK in a SECURITY DEFINER procedure. Procedures appeared in PostgreSQL 11. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
836 SECURITY INVOKER routines that access data Find 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
837 SELECT * in a routine body SELECT 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
838 Sequences that are not owned by a table column Find 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 detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
839 SET DEFAULT compensatory action is unsuitable Find 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
840 SET NULL compensatory action is unsuitable Find 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 detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)