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.
#501. User-defined routines with dynamic SQL that are potential targets of the SQL injection attack
INFORMATION_SCHEMA+system catalog base tablesFind routines that have at least one input parameter, use dynamic SQL but do not escape the input arguments at all.
#502. Meaningless terms in routines
INFORMATION_SCHEMA+system catalog base tablesFind routines that subquery contains terms "foo", "bar", "foobar", or "baz".
#503. User-defined routines with dynamic SQL
INFORMATION_SCHEMA+system catalog base tablesFind routines that use dynamic SQL. Make sure that dynamic SQL is indeed needed, i.e., the task cannot be solved with static SQL. Make sure that the routine is protected against attacks that use SQL injection method.
#504. Perhaps inconsistent use of temporal functions
INFORMATION_SCHEMA+system catalog base tablesFind routines that use temporal functions CURRENT_TIMESTAMP, LOCALTIMESTAMP, or now() that is inconsistent with the default values of the columns that are used by the routine, e.g., function uses a column with the default value LOCALTIMESTAMP but the routine uses function CURRENT_TIMESTAMP or now().
#505. Something is still to do in routines
INFORMATION_SCHEMA+system catalog base tablesFind routines where comments contain TODO phrase.
#506. Do not refer to the table schema in the references to columns
INFORMATION_SCHEMA+system catalog base tablesFind routines where in SELECT or UPDATE statements references to columns are prefixed with references to the table schema. Referring to schema in this context bloats the code.
#507. Routine body with ordering the query result based on positional references
INFORMATION_SCHEMA+system catalog base tablesFind 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.
#508. Routines that can be invoked with a variable number of arguments
INFORMATION_SCHEMA+system catalog base tablesFind 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.
#509. Prefer Polymorphism to If/Else or Switch/Case
INFORMATION_SCHEMA+system catalog base tablesFind routines with IF/ELSE or SWITCH/CASE statements. If your routine has a multipart IF/CASE statement, then perhaps it has multiple tasks and it violates the separation of concerns and single responsibilities principles.
#510. Prefer Polymorphism to If/Else or Switch/Case (2)
INFORMATION_SCHEMA+system catalog base tablesFind routines with multiple raise exception commands. Perhaps it has multiple tasks and it violates the separation of concerns and single responsibilities principles.
#511. Perhaps updating of modification time is missing
INFORMATION_SCHEMA+system catalog base tablesFind 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.
#512. User-defined routines with the same parameters (same name and type) regardless of the order of parameters
INFORMATION_SCHEMA+system catalog base tablesFind routines with the same parameters (same name and type) regardless of the order of parameters. Make sure that there is no accidental duplication. The query helps users to group together routines that probably have related tasks.
#513. Perhaps a reference to the variable OLD is missing
INFORMATION_SCHEMA+system catalog base tablesFind row level before delete triggers that only task is not to raise an exception and where the variable OLD is not used in the trigger routine outside the RETURN clause.
#514. ROW level BEFORE triggers that do not return a row if a check succeeds
INFORMATION_SCHEMA+system catalog base tablesFind 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.
#515. ROW level BEFORE UPDATE triggers that do not return the new row
INFORMATION_SCHEMA+system catalog base tablesFind row level BEFORE UPDATE triggers that do not return the new row version. Exclude triggers that raise WARNING/EXCEPTION.
#516. Perhaps incorrect WHEN clause
INFORMATION_SCHEMA onlyFind row level triggers that have action condition (WHEN clause) but the Boolean expression in its specifications does not refer to neither NEW nor OLD variable.
#517. Incorrect password hash update
INFORMATION_SCHEMA+system catalog base tablesFind row level update triggers that incorrectly implement update of password hash. It should not be that the new password hash is calculated based on the existing hash.
#518. Rules with the same name in different schemas
system catalog base tables onlyFind 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.
#519. PUBLIC has the USAGE privilege of a schema
INFORMATION_SCHEMA+system catalog base tablesFind schemas where PUBLIC has the usage privilege.
#520. All non-unique indexes
INFORMATION_SCHEMA+system catalog base tablesFind secondary indexes that have been created in the database.
| # | Name(activate to sort ascending) | Goal(sorted ascending, activate to sort descending) | Type(activate to sort ascending) | Data source(activate to sort ascending) | Last update(activate to sort ascending) | License | Actions |
|---|---|---|---|---|---|---|---|
| 501 | User-defined routines with dynamic SQL that are potential targets of the SQL injection attack | Find routines that have at least one input parameter, use dynamic SQL but do not escape the input arguments at all. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 502 | Meaningless terms in routines | Find routines that subquery contains terms "foo", "bar", "foobar", or "baz". | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 503 | User-defined routines with dynamic SQL | Find routines that use dynamic SQL. Make sure that dynamic SQL is indeed needed, i.e., the task cannot be solved with static SQL. Make sure that the routine is protected against attacks that use SQL injection method. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 504 | Perhaps inconsistent use of temporal functions | Find routines that use temporal functions CURRENT_TIMESTAMP, LOCALTIMESTAMP, or now() that is inconsistent with the default values of the columns that are used by the routine, e.g., function uses a column with the default value LOCALTIMESTAMP but the routine uses function CURRENT_TIMESTAMP or now(). | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 505 | Something is still to do in routines | Find routines where comments contain TODO phrase. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 506 | Do not refer to the table schema in the references to columns | Find routines where in SELECT or UPDATE statements references to columns are prefixed with references to the table schema. Referring to schema in this context bloats the code. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 507 | 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 | |
| 508 | 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 | |
| 509 | Prefer Polymorphism to If/Else or Switch/Case | Find routines with IF/ELSE or SWITCH/CASE statements. If your routine has a multipart IF/CASE statement, then perhaps it has multiple tasks and it violates the separation of concerns and single responsibilities principles. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 510 | Prefer Polymorphism to If/Else or Switch/Case (2) | Find routines with multiple raise exception commands. Perhaps it has multiple tasks and it violates the separation of concerns and single responsibilities principles. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 511 | 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 | |
| 512 | User-defined routines with the same parameters (same name and type) regardless of the order of parameters | Find routines with the same parameters (same name and type) regardless of the order of parameters. Make sure that there is no accidental duplication. The query helps users to group together routines that probably have related tasks. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 513 | Perhaps a reference to the variable OLD is missing | Find row level before delete triggers that only task is not to raise an exception and where the variable OLD is not used in the trigger routine outside the RETURN clause. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 514 | 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 | |
| 515 | 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 | |
| 516 | Perhaps incorrect WHEN clause | Find row level triggers that have action condition (WHEN clause) but the Boolean expression in its specifications does not refer to neither NEW nor OLD variable. | Problem detection | INFORMATION_SCHEMA only | MIT (opens in new tab) | View | |
| 517 | Incorrect password hash update | Find row level update triggers that incorrectly implement update of password hash. It should not be that the new password hash is calculated based on the existing hash. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 518 | 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 | |
| 519 | PUBLIC has the USAGE privilege of a schema | Find schemas where PUBLIC has the usage privilege. | Problem detection | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View | |
| 520 | All non-unique indexes | Find secondary indexes that have been created in the database. | General | INFORMATION_SCHEMA+system catalog base tables | MIT (opens in new tab) | View |