Query goal: | Find parameters that have the same name as the routine. The names may have different uppercase/lowercase characters. Make sure that the naming style is consistent. |
Notes about the query: | The query does not consider objects that are a part of an extension. There could be multiple routines with the same name but with different parameters in the same schema (overloading). Thus, for the unique identification of the routine it is necessary to present also its parameters in addition to the schema name and routine name. |
Query type: | Problem detection (Each row in the result could represent a flaw in the design) |
Query reliability: | Medium (Medium number of false-positive results) |
Query license: | MIT License |
Data source: | INFORMATION_SCHEMA+system catalog |
SQL query: | Click on query to copy it
WITH params AS (SELECT specific_schema AS routine_schema, regexp_replace(specific_name,'_[0-9]*$','') AS routine_name, pg_get_function_identity_arguments(translate(substring(specific_name,'_[0-9]+$'),'_','')::int::oid) AS parameters, parameter_name, ordinal_position, data_type FROM information_schema.parameters WHERE specific_schema NOT IN (SELECT schema_name FROM INFORMATION_SCHEMA.schemata WHERE schema_name<>'public' AND schema_owner='postgres' AND schema_name IS NOT NULL) AND NOT EXISTS (SELECT 1 FROM pg_catalog.pg_depend d inner join pg_catalog.pg_proc pc ON d.objid=pc.oid WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_extension e WHERE d.refobjid=e.oid) AND pc.proname || '_' || pc.oid = parameters.specific_name)) SELECT routine_schema, routine_name, parameters, parameter_name, ordinal_position, data_type FROM params WHERE parameter_name ILIKE routine_name ORDER BY routine_schema, routine_name, parameters, ordinal_position; |
Collection name | Collection 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 . |
Lexicon bad smells and linguistic antipatterns | Queries made to find the occurrences of lexicon bad smells and linguistic antipatterns |
Category name | Category description |
---|---|
Inconsistencies | Queries of this catergory provide information about inconsistencies of solving the same problem in different places. |
Naming | Queries of this category provide information about the style of naming. |
User-defined routines | Queries of this category provide information about the user-defined routines |
Reference |
---|
Smell "Whole-part": Abebe, S.L., Haiduc, S., Tonella, P., Marcus, A., 2011. The effect of lexicon bad smells on concept location in source code. In 2011 IEEE 11th International Working Conference on Source Code Analysis and Manipulation (pp. 125-134). IEEE. |