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.

#501. Inconsistent time zone and precision usage in case of registering times

INFORMATION_SCHEMA only

Find as to whether different data types (with and without timezone) and precisions are used in case of registering times in different columns.

Problem detection License: MIT (opens in new tab)

#502. Inconsistent time zone and precision usage in case of registering timestamps

INFORMATION_SCHEMA only

Find as to whether different data types (with and without timezone) and precisions are used in case of registering timestamps in different columns.

Problem detection License: MIT (opens in new tab)

#503. Inconsistent two-column CHECK constraints

system catalog base tables only

This query identifies inconsistencies in two-column CHECK constraints across the database. Specifically, it flags cases where different tables share the exact same pair of columns, but the logical expressions governing them differ. For example, one table might enforce last_change_time >= reg_time, while another strictly enforces last_change_time > reg_time. Highlighting these discrepancies helps ensure uniform data validation rules.

Problem detection License: MIT (opens in new tab)

#504. Inconsistent usage of string concatenation methods within or accross different database objects

INFORMATION_SCHEMA+system catalog base tables

This query audits the database schema to assess the consistency of string concatenation practices. It identifies the concurrent usage of multiple disparate methods for joining text: the standard concatenation operator (||) and the variadic functions concat() and concat_ws(). While each method has specific use cases (e.g., concat for null safety), indiscriminate mixing of these techniques across similar contexts indicates a lack of coding standards. The output facilitates a review to enforce a more uniform approach where appropriate.

Problem detection License: MIT (opens in new tab)

#505. Inconsistent use of casting syntax in routines

INFORMATION_SCHEMA+system catalog base tables

Find as to whether PL/pgSQL routines and SQL routines that do not have SQL-standard body use different syntax for casting (cast function vs :: operator).

Problem detection License: MIT (opens in new tab)

#506. Inconsistent use of functions and procedures

INFORMATION_SCHEMA+system catalog base tables

Find as to whether the database has both procedures as well as functions that do not return a value (i.e., return VOID). Such routines are generally used to modify data in the database. The support of procedures was added to PostgreSQL 11.

Problem detection License: MIT (opens in new tab)

#507. Inconsistent use of gratuitous context in the names of non-foreign key and non-primary key columns

INFORMATION_SCHEMA+system catalog base tables

This query validates column naming conventions. It returns a row only for tables that have an inconsistent mix of column naming styles—specifically, where some columns (that are not part of a primary or foreign key) are prefixed with the table name and others are not.

Problem detection License: MIT (opens in new tab)

#508. Inconsistent use of length and char_length functions

INFORMATION_SCHEMA+system catalog base tables

This query identifies inconsistent usage of string length functions within the database. Although length() and char_length() are functional synonyms in PostgreSQL (both returning the character count), mixing them violates clean coding principles. The query checks if both variants are present in the codebase, flagging a lack of standardization. Enforcing a single choice (typically the SQL-standard char_length or character_length) improves code maintainability and readability.

Problem detection License: MIT (opens in new tab)

#509. Inconsistent use of older and newer join syntax in the subqueries of derived tables

INFORMATION_SCHEMA+system catalog base tables

Find as to whether the subqueries of derived tables use both older join syntax (join condition in the where clause) and newer syntax (join condition in the from clause).

Problem detection License: MIT (opens in new tab)

#510. Inconsistent use of plural and singular in column names in the context of a relationship (English version)

INFORMATION_SCHEMA+system catalog base tables

Find foreign key constraints that cover one column in case of which the name of refererenced/referencing column is in plural and the name of referencing/refererenced column is in singular.

Problem detection License: MIT (opens in new tab)

#511. Inconsistent use of plural and singular in table names in the context of a relationship (English version)

INFORMATION_SCHEMA+system catalog base tables

Find foreign key constraints in case of which the name of one of the tables is in plural and the name of another table is in singular.

Problem detection License: MIT (opens in new tab)

#512. Inconsistent use of plural and singular in table names in the context of a relationship (Estonian version)

INFORMATION_SCHEMA+system catalog base tables

Find foreign key constraints in case of which the name of one of the tables is in plural and the name of another table is in singular.

Problem detection License: MIT (opens in new tab)

#513. Inconsistent use of session_user and current_user functions

INFORMATION_SCHEMA+system catalog base tables

Find as to whether both functions session_user and current_user are used in the database.

Problem detection License: MIT (opens in new tab)

#514. Incorrect characterization of a user-defined routine as an "immutable" routine

INFORMATION_SCHEMA+system catalog base tables

Find immutable routines that contain SELECT statements from a database (including SELECT .. FOR UPDATE), INSERT, UPDATE, DELETE, or LOCK statement. The DBMS should get a correct background information about the behaviour of a routine. Immutable routines should not have side effects and should also not ask data from a database because it could change over time. Immutable routines cannot lock tables or its specific rows.

Problem detection License: MIT (opens in new tab)

#515. Incorrect characterization of a user-defined routine as a "stable" routine

INFORMATION_SCHEMA+system catalog base tables

Find stable routines that contain INSERT, UPDATE, DELETE, SELECT … FOR UPDATE, or LOCK statement. The DBMS should get a correct background information about the behaviour of a routine. Stable routines cannot modify data in a database, lock tables, or its specific rows.

Problem detection License: MIT (opens in new tab)

#516. Incorrect check of NULLs

INFORMATION_SCHEMA+system catalog base tables

Find the use of =NULL and <>NULL in case of table level check constraints, domain level check constraints, WHEN clauses of triggers, WHERE clauses of rules, subqueries of derived tables, and bodies of routines. Write correct code. In order to determine as to whether a value is missing or not one has to use the IS [NOT] NULL predicate. NULL is the marker in SQL that denotes a missing value. Although it is often called "NULL value", one cannot treat it as an ordinary value, i.e., use it in comparisons as a value.

Problem detection License: MIT (opens in new tab)

#517. Incorrect comparison operator

INFORMATION_SCHEMA+system catalog base tables

Find PL/pgSQL routines that use comparison operators =< or =>.

Problem detection License: MIT (opens in new tab)

#518. Incorrect data type (based on default values)

INFORMATION_SCHEMA only

Find columns of base tables that have the default value CURRENT_USER or SESSION_USER but the data type is CHAR or TEXT.

Problem detection License: MIT (opens in new tab)

#519. Incorrect field size (based on default values)

INFORMATION_SCHEMA only

This query identifies a potential schema mismatch regarding data precision. It flags base table columns that default to CURRENT_USER or SESSION_USER but define a character length differing from the PostgreSQL standard identifier limit (typically 63 bytes, defined by NAMEDATALEN - 1).

Risk (Length < 63): Poses a hard runtime failure risk if a username exceeds the defined length. Inefficiency (Length > 63): Indicates imprecise modeling, as the stored value can technically never exceed the system limit.

Problem detection License: MIT (opens in new tab)

#520. Incorrect field size (based on default values) (2)

INFORMATION_SCHEMA only

This query identifies potential schema discrepancies related to column sizing. It flags text columns in base tables where the static default value is unusually short—specifically, less than half the column's maximum allowed capacity.

Problem detection License: MIT (opens in new tab)
# Name Goal Type (sorted ascending) Data source Last update License Actions
501 Inconsistent time zone and precision usage in case of registering times Find as to whether different data types (with and without timezone) and precisions are used in case of registering times in different columns. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
502 Inconsistent time zone and precision usage in case of registering timestamps Find as to whether different data types (with and without timezone) and precisions are used in case of registering timestamps in different columns. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
503 Inconsistent two-column CHECK constraints This query identifies inconsistencies in two-column CHECK constraints across the database. Specifically, it flags cases where different tables share the exact same pair of columns, but the logical expressions governing them differ. For example, one table might enforce last_change_time >= reg_time, while another strictly enforces last_change_time > reg_time. Highlighting these discrepancies helps ensure uniform data validation rules. Problem detection system catalog base tables only MIT (opens in new tab) View (opens in new tab)
504 Inconsistent usage of string concatenation methods within or accross different database objects This query audits the database schema to assess the consistency of string concatenation practices. It identifies the concurrent usage of multiple disparate methods for joining text: the standard concatenation operator (||) and the variadic functions concat() and concat_ws(). While each method has specific use cases (e.g., concat for null safety), indiscriminate mixing of these techniques across similar contexts indicates a lack of coding standards. The output facilitates a review to enforce a more uniform approach where appropriate. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
505 Inconsistent use of casting syntax in routines Find as to whether PL/pgSQL routines and SQL routines that do not have SQL-standard body use different syntax for casting (cast function vs :: operator). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
506 Inconsistent use of functions and procedures Find as to whether the database has both procedures as well as functions that do not return a value (i.e., return VOID). Such routines are generally used to modify data in the database. The support of procedures was added to PostgreSQL 11. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
507 Inconsistent use of gratuitous context in the names of non-foreign key and non-primary key columns This query validates column naming conventions. It returns a row only for tables that have an inconsistent mix of column naming styles—specifically, where some columns (that are not part of a primary or foreign key) are prefixed with the table name and others are not. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
508 Inconsistent use of length and char_length functions This query identifies inconsistent usage of string length functions within the database. Although length() and char_length() are functional synonyms in PostgreSQL (both returning the character count), mixing them violates clean coding principles. The query checks if both variants are present in the codebase, flagging a lack of standardization. Enforcing a single choice (typically the SQL-standard char_length or character_length) improves code maintainability and readability. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
509 Inconsistent use of older and newer join syntax in the subqueries of derived tables Find as to whether the subqueries of derived tables use both older join syntax (join condition in the where clause) and newer syntax (join condition in the from clause). Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
510 Inconsistent use of plural and singular in column names in the context of a relationship (English version) Find foreign key constraints that cover one column in case of which the name of refererenced/referencing column is in plural and the name of referencing/refererenced column is in singular. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
511 Inconsistent use of plural and singular in table names in the context of a relationship (English version) Find foreign key constraints in case of which the name of one of the tables is in plural and the name of another table is in singular. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
512 Inconsistent use of plural and singular in table names in the context of a relationship (Estonian version) Find foreign key constraints in case of which the name of one of the tables is in plural and the name of another table is in singular. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
513 Inconsistent use of session_user and current_user functions Find as to whether both functions session_user and current_user are used in the database. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
514 Incorrect characterization of a user-defined routine as an "immutable" routine Find immutable routines that contain SELECT statements from a database (including SELECT .. FOR UPDATE), INSERT, UPDATE, DELETE, or LOCK statement. The DBMS should get a correct background information about the behaviour of a routine. Immutable routines should not have side effects and should also not ask data from a database because it could change over time. Immutable routines cannot lock tables or its specific rows. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
515 Incorrect characterization of a user-defined routine as a "stable" routine Find stable routines that contain INSERT, UPDATE, DELETE, SELECT … FOR UPDATE, or LOCK statement. The DBMS should get a correct background information about the behaviour of a routine. Stable routines cannot modify data in a database, lock tables, or its specific rows. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
516 Incorrect check of NULLs Find the use of =NULL and <>NULL in case of table level check constraints, domain level check constraints, WHEN clauses of triggers, WHERE clauses of rules, subqueries of derived tables, and bodies of routines. Write correct code. In order to determine as to whether a value is missing or not one has to use the IS [NOT] NULL predicate. NULL is the marker in SQL that denotes a missing value. Although it is often called "NULL value", one cannot treat it as an ordinary value, i.e., use it in comparisons as a value. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
517 Incorrect comparison operator Find PL/pgSQL routines that use comparison operators =< or =>. Problem detection INFORMATION_SCHEMA+system catalog base tables MIT (opens in new tab) View (opens in new tab)
518 Incorrect data type (based on default values) Find columns of base tables that have the default value CURRENT_USER or SESSION_USER but the data type is CHAR or TEXT. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
519 Incorrect field size (based on default values) This query identifies a potential schema mismatch regarding data precision. It flags base table columns that default to CURRENT_USER or SESSION_USER but define a character length differing from the PostgreSQL standard identifier limit (typically 63 bytes, defined by NAMEDATALEN - 1).

Risk (Length < 63): Poses a hard runtime failure risk if a username exceeds the defined length. Inefficiency (Length > 63): Indicates imprecise modeling, as the stored value can technically never exceed the system limit.
Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)
520 Incorrect field size (based on default values) (2) This query identifies potential schema discrepancies related to column sizing. It flags text columns in base tables where the static default value is unusually short—specifically, less than half the column's maximum allowed capacity. Problem detection INFORMATION_SCHEMA only MIT (opens in new tab) View (opens in new tab)