| Goal | 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. |
| Notes | To ensure its results are accurate and readable, the query incorporates several key features. For unique identification of overloaded routines, the output includes not just the schema and routine name, but also its full parameter signature. The query focuses exclusively on user-defined code by excluding any routines that are part of an installed extension. Finally, to improve readability in web browsers, newline characters within the bodies of routines and the definitions of views/materialized views are replaced with HTML tags. |
| Type | Problem detection (Each row in the result could represent a flaw in the design) |
| Reliability | Medium (Medium number of false-positive results) |
| License | MIT License |
| Fixing Suggestion | Be consistent in the use of functions. |
| Data Source | INFORMATION_SCHEMA+system catalog |
| SQL Query |
|
This query belongs to the following collections:
| Name | Description |
|---|---|
| Find problems automatically | Queries, that results point to problems in the database. Each query in the collection produces an initial assessment. However, a human reviewer has the final say as to whether there is a problem or not . |
This query is classified under the following categories:
| Name | Description |
|---|---|
| CHECK constraints | Queries of this category provide information about CHECK constraints. |
| Conformance to SQL standard | Queries of this category provide information about the use of constructs that conform to the SQL standard |
| Derived tables | Queries of this category provide information about the derived tables (views, materialized views), which are used to implement virtual data layer. |
| Inconsistencies | Queries of this catergory provide information about inconsistencies of solving the same problem in different places. |
| Triggers and rules | Queries of this category provide information about triggers and rules in a database. |
| User-defined routines | Queries of this category provide information about the user-defined routines |