Filter 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.
#241. AND takes precedence over OR
INFORMATION_SCHEMA+system catalog base tablesMake sure that Boolean expressions take into account precedence rules of Boolean operators. AND operator has precedence over OR operator.
#242. A non-parameterized table function instead of a view
INFORMATION_SCHEMA+system catalog base tablesFind table functions that do not have any parameters. Prefer simpler and more portable solutions.
#243. A predefine character class has been incorrectly specified
INFORMATION_SCHEMA+system catalog base tablesFind regular expressions where a predefined character class is incorrectly specified, e.g. [digit] instead of [:digit:].
#244. Are the passwords hashed?
INFORMATION_SCHEMA+system catalog base tablesFind base table columns that name refers to the possibility that these are used to register passwords. Return a value from each such column. Make sure that the password is not registered as open text.
#245. Are there enough routines that implement database operations?
INFORMATION_SCHEMA+system catalog base tablesFind 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.
#246. A routine is invoked only once
INFORMATION_SCHEMA+system catalog base tablesFind user-defined routines that are invoked by exactly one user-defined routine.
#247. A setter does not update a table
INFORMATION_SCHEMA+system catalog base tablesFind user-defined non-trigger SQL and PL/pgSQL routines that name starts with "set" (but not with "setting") but do not contain a UPDATE statement.
#248. A state machine is implemented with the help of an enumeration type
INFORMATION_SCHEMA+system catalog base tablesFind implementations of state machines that uses an enumeration type.
#249. A table has the same name as a routine
INFORMATION_SCHEMA+system catalog base tablesFind table names that are the same as some routine name. Use different names to avoid confusion.
#250. At most one row is permitted in a table (based on check constraints)
INFORMATION_SCHEMA+system catalog base tablesFind base tables and foreign tables where based on a check constraint, a key constraint, and a NOT NULL constraint can be at most one row. Make sure that this is the real intent behind the constraint, not a mistake. Find tables where a check constraint permits only one possible value in a column, the column has NOT NULL constraint, and constitutes a key, i.e., has the PRIMARY KEY or UNIQUE constraint.
#251. At most one row is permitted in a table (based on enumeration types)
INFORMATION_SCHEMA+system catalog base tablesFind base tables and foreign tables where based on the type of a column, a key constraint, and a NOT NULL constraint can be at most one row. Make sure that this is the real intent behind the constraint, not a mistake. Find tables where a column has an enumeration type with exactly one value, the column has NOT NULL constraint, and constitutes a key, i.e., has the PRIMARY KEY or UNIQUE constraint.
#252. Authentication routines vulnerable to timing attacks
INFORMATION_SCHEMA+system catalog base tablesThis query identifies SQL and PL/pgSQL authentication routines that are vulnerable to user enumeration via timing attacks. When verifying user credentials, if a routine returns FALSE immediately upon determining that an account does not exist, an attacker can measure execution latency to confirm valid usernames. Because cryptographic password hashing (such as crypt() using bcrypt) is intentionally slow, hashing only for existing users creates an observable timing discrepancy. The query inspects boolean routines handling credentials (accepting 2 or 3 parameters) and flags those that fail to implement a dummy hash fallback—such as pairing a static bcrypt hash with COALESCE—to ensure uniform, constant-time execution.
#253. Avoid using length function
INFORMATION_SCHEMA+system catalog base tablesThis query identifies all expressions that use the non-standard length() function. Although length() is a functional synonym for char_length() in PostgreSQL, its use is discouraged for two primary reasons: char_length() is the SQL-standard function, and length() has different semantics in other database systems (e.g., returning byte length in MySQL). To enhance code portability and prevent semantic ambiguity for developers, this query flags all instances of length() to encourage standardization on the char_length() function.
#254. Base table column of personal names does not restrict the maximum character length
INFORMATION_SCHEMA+system catalog base tablesThis query identifies base table columns that, based on their name, are presumed to store personal names but lack an explicit maximum length constraint. It operates on a heuristic, flagging columns with names like first_name, surname, etc., that are defined with unbounded textual types (e.g., text, varchar) and have no corresponding CHECK constraint to limit their length (e.g., char_length(col) <= n). The absence of such a limit is a design flaw that can introduce usability issues in front-end applications and create potential security vulnerabilities related to excessive data submission.
#255. Base table column of surrogate key values does not have an integer data type (based on column names)
INFORMATION_SCHEMA+system catalog base tablesFind base table columns that belong to a primary key, unique, or foreign key constraint and that name refers to the possibility that these are used to hold surrogate key values. Find the columns where the data type of the column is not an integer type or uuid.
#256. Base table columns permitting e-mail addresses without @ sign
INFORMATION_SCHEMA+system catalog base tablesFind non-foreign key base table columns that name refers to the possibility that these are used to register e-mail addresses. Find the columns that do not have any simple CHECK constraint that contains @ sign. A simple check constraint covers a single column. In this case registration of e-mail addresses without @ is most probably not prohibited.
#257. Base table columns permitting empty strings and strings that consist of only whitespace characters (2)
INFORMATION_SCHEMA+system catalog base tablesThis query identifies non-foreign key columns with a textual data type that lack essential validation. It specifically targets columns that are missing both of the following fundamental checks:
- A constraint to prohibit the insertion of empty or whitespace-only strings.
- A constraint to enforce a character set or format policy (e.g., via a regular expression).
The absence of such comprehensive validation increases the risk of poor data quality and potential application-level bugs.
#258. Base table columns permitting negative prices/quantity
INFORMATION_SCHEMA+system catalog base tablesFind non-foreign key base table columns that name refers to the possibility that these are used to register prices/quantities. Find the columns that do not have any simple CHECK constraints, i.e., a constraint that covers only this column. In this case registration of negative price/quantity is most probably not prohibited.
#259. Base table columns permitting temporal values that may be outside the range of logical values
INFORMATION_SCHEMA+system catalog base tablesFind base tables columns with temporal types (date and timestamp) that do not belong to a foreign key and that do not have any associated simple CHECK constraints, i.e., constraint that involves only one column. For instance, in the column registration_time that does not have any associated CHECK constraints could be values '1200-01-01 00:00' or '5900-12-31 00:00'. Rows with these values most probably represent wrong propositions and the system should restrict registration of such data.
#260. Base table columns permitting URLs without a protocol
INFORMATION_SCHEMA+system catalog base tablesFind non-foreign key base table columns that name refers to the possibility that these are used to register URLs. Find the columns that do not have any simple CHECK constraint that references to a protocol. A simple check constraint covers a single column. In this case registration of URLs without a protocol is most probably not prohibited.
| # | Name(activate to sort ascending) | Goal(activate to sort ascending) | Type(activate to sort ascending) | Data source(sorted ascending, activate to sort descending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 241 | AND takes precedence over OR | Make sure that Boolean expressions take into account precedence rules of Boolean operators. AND operator has precedence over OR operator. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 242 | A non-parameterized table function instead of a view | Find table functions that do not have any parameters. Prefer simpler and more portable solutions. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 243 | A predefine character class has been incorrectly specified | Find regular expressions where a predefined character class is incorrectly specified, e.g. [digit] instead of [:digit:]. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 244 | Are the passwords hashed? | Find base table columns that name refers to the possibility that these are used to register passwords. Return a value from each such column. Make sure that the password is not registered as open text. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 245 | Are 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. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 246 | A routine is invoked only once | Find user-defined routines that are invoked by exactly one user-defined routine. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 247 | A setter does not update a table | Find user-defined non-trigger SQL and PL/pgSQL routines that name starts with "set" (but not with "setting") but do not contain a UPDATE statement. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 248 | A state machine is implemented with the help of an enumeration type | Find implementations of state machines that uses an enumeration type. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 249 | A table has the same name as a routine | Find table names that are the same as some routine name. Use different names to avoid confusion. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 250 | At most one row is permitted in a table (based on check constraints) | Find base tables and foreign tables where based on a check constraint, a key constraint, and a NOT NULL constraint can be at most one row. Make sure that this is the real intent behind the constraint, not a mistake. Find tables where a check constraint permits only one possible value in a column, the column has NOT NULL constraint, and constitutes a key, i.e., has the PRIMARY KEY or UNIQUE constraint. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 251 | At most one row is permitted in a table (based on enumeration types) | Find base tables and foreign tables where based on the type of a column, a key constraint, and a NOT NULL constraint can be at most one row. Make sure that this is the real intent behind the constraint, not a mistake. Find tables where a column has an enumeration type with exactly one value, the column has NOT NULL constraint, and constitutes a key, i.e., has the PRIMARY KEY or UNIQUE constraint. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 252 | Authentication routines vulnerable to timing attacks | This query identifies SQL and PL/pgSQL authentication routines that are vulnerable to user enumeration via timing attacks. When verifying user credentials, if a routine returns FALSE immediately upon determining that an account does not exist, an attacker can measure execution latency to confirm valid usernames. Because cryptographic password hashing (such as crypt() using bcrypt) is intentionally slow, hashing only for existing users creates an observable timing discrepancy. The query inspects boolean routines handling credentials (accepting 2 or 3 parameters) and flags those that fail to implement a dummy hash fallback—such as pairing a static bcrypt hash with COALESCE—to ensure uniform, constant-time execution. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 253 | Avoid using length function | This query identifies all expressions that use the non-standard length() function. Although length() is a functional synonym for char_length() in PostgreSQL, its use is discouraged for two primary reasons: char_length() is the SQL-standard function, and length() has different semantics in other database systems (e.g., returning byte length in MySQL). To enhance code portability and prevent semantic ambiguity for developers, this query flags all instances of length() to encourage standardization on the char_length() function. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 254 | Base table column of personal names does not restrict the maximum character length | This query identifies base table columns that, based on their name, are presumed to store personal names but lack an explicit maximum length constraint. It operates on a heuristic, flagging columns with names like first_name, surname, etc., that are defined with unbounded textual types (e.g., text, varchar) and have no corresponding CHECK constraint to limit their length (e.g., char_length(col) <= n). The absence of such a limit is a design flaw that can introduce usability issues in front-end applications and create potential security vulnerabilities related to excessive data submission. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 255 | Base table column of surrogate key values does not have an integer data type (based on column names) | Find base table columns that belong to a primary key, unique, or foreign key constraint and that name refers to the possibility that these are used to hold surrogate key values. Find the columns where the data type of the column is not an integer type or uuid. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 256 | Base table columns permitting e-mail addresses without @ sign | Find non-foreign key base table columns that name refers to the possibility that these are used to register e-mail addresses. Find the columns that do not have any simple CHECK constraint that contains @ sign. A simple check constraint covers a single column. In this case registration of e-mail addresses without @ is most probably not prohibited. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 257 | Base table columns permitting empty strings and strings that consist of only whitespace characters (2) | This query identifies non-foreign key columns with a textual data type that lack essential validation. It specifically targets columns that are missing both of the following fundamental checks:
The absence of such comprehensive validation increases the risk of poor data quality and potential application-level bugs. |
Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 258 | Base table columns permitting negative prices/quantity | Find non-foreign key base table columns that name refers to the possibility that these are used to register prices/quantities. Find the columns that do not have any simple CHECK constraints, i.e., a constraint that covers only this column. In this case registration of negative price/quantity is most probably not prohibited. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 259 | Base table columns permitting temporal values that may be outside the range of logical values | Find base tables columns with temporal types (date and timestamp) that do not belong to a foreign key and that do not have any associated simple CHECK constraints, i.e., constraint that involves only one column. For instance, in the column registration_time that does not have any associated CHECK constraints could be values '1200-01-01 00:00' or '5900-12-31 00:00'. Rows with these values most probably represent wrong propositions and the system should restrict registration of such data. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 260 | Base table columns permitting URLs without a protocol | Find non-foreign key base table columns that name refers to the possibility that these are used to register URLs. Find the columns that do not have any simple CHECK constraint that references to a protocol. A simple check constraint covers a single column. In this case registration of URLs without a protocol is most probably not prohibited. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View |