Filter Queries

Found 1056 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 the relatively small amount of data in the system catalog of a database.

#541. Insufficient number of user-defined triggers+rules

INFORMATION_SCHEMA+system catalog base tables

This query assesses the extent of active logic implementation within the database schema. It verifies that there are at least 3 user-defined triggers or rewrite rules present in the database. These objects represent automated tasks that for example enforce complex integrity constraints. Meeting this threshold indicates a baseline competency in utilizing PostgreSQL's event-driven capabilities.

Problem detection License: MIT (opens in new tab)

#542. Insufficient number of user-defined triggers+rules (based on number of tasks)

INFORMATION_SCHEMA+system catalog base tables

This query assesses the extent of active logic implementation within the database schema. It verifies that there are user-defined triggers or rewrite rules present for at least 3 tasks. These objects represent automated tasks that for example enforce complex integrity constraints. Meeting this threshold indicates a baseline competency in utilizing PostgreSQL's event-driven capabilities.

Problem detection License: MIT (opens in new tab)

#543. Insufficient number of user-defined views

INFORMATION_SCHEMA only

This query assesses the use of abstraction layers within the database schema. It verifies that there are at least 4 user-defined views present. Views are essential for simplifying complex queries, restricting data access, and presenting specific data perspectives to applications. Meeting this threshold indicates a sufficient implementation of data abstraction and query encapsulation.

Problem detection License: MIT (opens in new tab)

#544. Insufficient routine privileges

INFORMATION_SCHEMA+system catalog base tables

You must give rights to use routines to the users/roles that correspond to applications.

Problem detection License: MIT (opens in new tab)

#545. Insufficient view privileges

INFORMATION_SCHEMA+system catalog base tables

You must give privileges to use views to the users/roles that correspond to applications

Problem detection License: MIT (opens in new tab)

#546. Intra-object inconsistency in string concatenation methods

INFORMATION_SCHEMA+system catalog base tables

This query detects internal inconsistency within individual database objects (user-defined routines, views, materialized views). It flags objects that utilize both the standard concatenation operator (||) and variadic concatenation functions (concat() or concat_ws()) within the same definition body. Mixing null-unsafe operators (||) with null-safe functions (concat) in a single routine suggests a lack of coherent logic or an incomplete refactoring effort, potentially leading to confusing behavior regarding NULL handling.

Problem detection License: MIT (opens in new tab)

#547. Invalid character class

INFORMATION_SCHEMA+system catalog base tables

PostgreSQL regular expressions do not have character classes word and letter.

Problem detection License: MIT (opens in new tab)

#548. Invalid explicit locking with aggregate functions

INFORMATION_SCHEMA+system catalog base tables

This query identifies SQL statements that attempt to apply explicit row locking (e.g., FOR SHARE, FOR UPDATE) to the result of an aggregate function (e.g., COUNT(*)). This is a semantic error because locking clauses operate on specific physical rows, whereas aggregate functions return a derived scalar value that is decoupled from the underlying row versions. To correctly enforce a lock, the query must select the specific columns (typically the primary key) of the target rows, rather than a computed aggregate.

Problem detection License: MIT (opens in new tab)

#549. Invalid use of the case insensitive search modifier in regular expressions

INFORMATION_SCHEMA+system catalog base tables

Find regular expression patterns that use (?i) modifier in any other place than at the beginning of the pattern or (?-i) in any place of the pattern. Such use of the modifiers is not supported by PostgreSQL.

Problem detection License: MIT (opens in new tab)

#550. Invocation of a system-defined routine without providing any arguments

INFORMATION_SCHEMA+system catalog base tables

Find user-defined routines that contain an invocation of a system-defined function without providing any argument. The query considers all aggregate functions as well as some popular scalar functions.

Problem detection License: MIT (opens in new tab)

#551. Invocation of PL/pgSQL functions from the subqueries of derived tables

INFORMATION_SCHEMA+system catalog base tables

Find derived tables that subqueries invoke a PL/pgSQL function. Avoid context switch that is caused by the invocation of PL/pgSQL functions from the subqueries of derived tables.

Problem detection License: MIT (opens in new tab)

#552. IS DISTINCT FROM should be used instead of <> in WHEN clauses

INFORMATION_SCHEMA only

Use a right predicate in trigger condition in order to ensure that the trigger executes always when it has to but not more often. IS DISTINCT FROM treats NULL as if it was a known value, rather than unknown. It would be relevant if a column that is referenced in the action condition is optional, i.e., permits NULLs.

Problem detection License: MIT (opens in new tab)

#553. Is does not return a boolean

INFORMATION_SCHEMA+system catalog base tables

This query identifies user-defined SQL and PL/pgSQL routines (excluding triggers) that exhibit a semantic inconsistency between their name and return type. It flags non-trigger routines whose names begin with a predicate prefix (e.g., is_, has_, can_, on_) but whose defined return type is not BOOLEAN. Such a mismatch violates the principle of self-documenting code, as the name creates a strong expectation of a TRUE/FALSE return value, which the routine's signature then contradicts.

Problem detection License: MIT (opens in new tab)

#554. IS NOT DISTINCT FROM in derived tables

INFORMATION_SCHEMA+system catalog base tables

Avoid using IS NOT DISTINCT FROM because it makes the query planner to avoid using an index.

Problem detection License: MIT (opens in new tab)

#555. IS NOT DISTINCT FROM in routines

INFORMATION_SCHEMA+system catalog base tables

Avoid using IS NOT DISTINCT FROM because it makes the query planner to avoid using an index.

Problem detection License: MIT (opens in new tab)

#556. IS NULL check is probably not needed

INFORMATION_SCHEMA only

Find CHECK constraints that refer only to mandatory columns but the Boolean expression has IS NULL condition.

Problem detection License: MIT (opens in new tab)

#557. JSON type instead of JSONB type

INFORMATION_SCHEMA only

"In general, most applications should prefer to store JSON data as jsonb, unless there are quite specialized needs, such as legacy assumptions about ordering of object keys." (https://www.postgresql.org/docs/current/datatype-json.html)

Problem detection License: MIT (opens in new tab)

#558. LEAKPROOF routines that are perhaps not leakproof

INFORMATION_SCHEMA+system catalog base tables

You should not give wrong information to the database management system.

Problem detection License: MIT (opens in new tab)

#559. Length and char_length functions are used within the same expression

INFORMATION_SCHEMA+system catalog base tables

This query identifies expressions that use both the length() and char_length() functions, which is a strong indicator of a logical flaw. Since these functions are functional synonyms in PostgreSQL (both returning the character count), an expression that compares their results (e.g., length(col) > char_length(col)) may be either tautological or will always evaluate to false. Such code is typically written under the mistaken assumption that length() returns bytes, a behavior seen in other database management systems.

Problem detection License: MIT (opens in new tab)

#560. Lifecycle not initiated

INFORMATION_SCHEMA+system catalog base tables

Find non-primary key and non-unique base table foreign key columns that name refers to the possibility that these are used to register references to a state classifier. The column must belong to a foreign key and does not have a default value.

Problem detection License: MIT (opens in new tab)
# Name(activate to sort ascending) Goal(activate to sort ascending) Type(sorted ascending, activate to sort descending) Data source(activate to sort ascending) Last update(activate to sort ascending) License Actions
541 Insufficient number of user-defined triggers+rules This query assesses the extent of active logic implementation within the database schema. It verifies that there are at least 3 user-defined triggers or rewrite rules present in the database. These objects represent automated tasks that for example enforce complex integrity constraints. Meeting this threshold indicates a baseline competency in utilizing PostgreSQL's event-driven capabilities. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
542 Insufficient number of user-defined triggers+rules (based on number of tasks) This query assesses the extent of active logic implementation within the database schema. It verifies that there are user-defined triggers or rewrite rules present for at least 3 tasks. These objects represent automated tasks that for example enforce complex integrity constraints. Meeting this threshold indicates a baseline competency in utilizing PostgreSQL's event-driven capabilities. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
543 Insufficient number of user-defined views This query assesses the use of abstraction layers within the database schema. It verifies that there are at least 4 user-defined views present. Views are essential for simplifying complex queries, restricting data access, and presenting specific data perspectives to applications. Meeting this threshold indicates a sufficient implementation of data abstraction and query encapsulation. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
544 Insufficient routine privileges You must give rights to use routines to the users/roles that correspond to applications. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
545 Insufficient view privileges You must give privileges to use views to the users/roles that correspond to applications Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
546 Intra-object inconsistency in string concatenation methods This query detects internal inconsistency within individual database objects (user-defined routines, views, materialized views). It flags objects that utilize both the standard concatenation operator (||) and variadic concatenation functions (concat() or concat_ws()) within the same definition body. Mixing null-unsafe operators (||) with null-safe functions (concat) in a single routine suggests a lack of coherent logic or an incomplete refactoring effort, potentially leading to confusing behavior regarding NULL handling. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
547 Invalid character class PostgreSQL regular expressions do not have character classes word and letter. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
548 Invalid explicit locking with aggregate functions This query identifies SQL statements that attempt to apply explicit row locking (e.g., FOR SHARE, FOR UPDATE) to the result of an aggregate function (e.g., COUNT(*)). This is a semantic error because locking clauses operate on specific physical rows, whereas aggregate functions return a derived scalar value that is decoupled from the underlying row versions. To correctly enforce a lock, the query must select the specific columns (typically the primary key) of the target rows, rather than a computed aggregate. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
549 Invalid use of the case insensitive search modifier in regular expressions Find regular expression patterns that use (?i) modifier in any other place than at the beginning of the pattern or (?-i) in any place of the pattern. Such use of the modifiers is not supported by PostgreSQL. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
550 Invocation of a system-defined routine without providing any arguments Find user-defined routines that contain an invocation of a system-defined function without providing any argument. The query considers all aggregate functions as well as some popular scalar functions. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
551 Invocation of PL/pgSQL functions from the subqueries of derived tables Find derived tables that subqueries invoke a PL/pgSQL function. Avoid context switch that is caused by the invocation of PL/pgSQL functions from the subqueries of derived tables. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
552 IS DISTINCT FROM should be used instead of <> in WHEN clauses Use a right predicate in trigger condition in order to ensure that the trigger executes always when it has to but not more often. IS DISTINCT FROM treats NULL as if it was a known value, rather than unknown. It would be relevant if a column that is referenced in the action condition is optional, i.e., permits NULLs. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
553 Is does not return a boolean This query identifies user-defined SQL and PL/pgSQL routines (excluding triggers) that exhibit a semantic inconsistency between their name and return type. It flags non-trigger routines whose names begin with a predicate prefix (e.g., is_, has_, can_, on_) but whose defined return type is not BOOLEAN. Such a mismatch violates the principle of self-documenting code, as the name creates a strong expectation of a TRUE/FALSE return value, which the routine's signature then contradicts. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
554 IS NOT DISTINCT FROM in derived tables Avoid using IS NOT DISTINCT FROM because it makes the query planner to avoid using an index. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
555 IS NOT DISTINCT FROM in routines Avoid using IS NOT DISTINCT FROM because it makes the query planner to avoid using an index. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
556 IS NULL check is probably not needed Find CHECK constraints that refer only to mandatory columns but the Boolean expression has IS NULL condition. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
557 JSON type instead of JSONB type "In general, most applications should prefer to store JSON data as jsonb, unless there are quite specialized needs, such as legacy assumptions about ordering of object keys." (https://www.postgresql.org/docs/current/datatype-json.html) Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
558 LEAKPROOF routines that are perhaps not leakproof You should not give wrong information to the database management system. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
559 Length and char_length functions are used within the same expression This query identifies expressions that use both the length() and char_length() functions, which is a strong indicator of a logical flaw. Since these functions are functional synonyms in PostgreSQL (both returning the character count), an expression that compares their results (e.g., length(col) > char_length(col)) may be either tautological or will always evaluate to false. Such code is typically written under the mistaken assumption that length() returns bytes, a behavior seen in other database management systems. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
560 Lifecycle not initiated Find non-primary key and non-unique base table foreign key columns that name refers to the possibility that these are used to register references to a state classifier. The column must belong to a foreign key and does not have a default value. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)