The list of all the queries

Overloading may cause runtime error

Query goal: Routines in the same schema that have the same name and that have parameters with different types or different number of parameters are not considered to be in conflict at the creation time. However, if defaults are provided in the definition of parameters, then these routines might be conflict during runtime.
Notes about the query: Refers to the column pg_proc.prokind and thus works starting from PostgreSQL 11. In case of parameters the query takes into account that "All input parameters following a parameter with a default value must have default values as well." (PostgreSQL documentation) Expression proargtypes[0:(pronargs - pronargdefaults)-1] finds parameters (their types) that do not have a default value.
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
Fixing suggestion: Delete default values of parameters or rename the routines in order to prevent overloading.
Data source: INFORMATION_SCHEMA+system catalog
SQL query: Click on query to copy it

WITH routines AS (SELECT 
  pg_proc.oid AS routine_oid,
  pg_namespace.nspname AS routine_schema, 
  pg_proc.proname AS routine_name,    
  CASE WHEN pg_proc.prokind='f' THEN 'FUNCTION'
  WHEN pg_proc.prokind='p' THEN 'PROCEDURE'
  WHEN pg_proc.prokind='a' THEN 'AGGREGATE FUNCTION'
  WHEN pg_proc.prokind='w' THEN 'WINDOW FUNCTION' END AS routine_type,
  proargtypes[0:(pronargs - pronargdefaults)-1] AS parameters_without_defaults,
  pg_get_function_arguments(pg_proc.oid) AS parameters
FROM 
  pg_catalog.pg_proc, 
  pg_catalog.pg_namespace
WHERE 
pg_proc.pronamespace = pg_namespace.oid AND
pg_proc.proname NOT IN ('f_assume_you_must_use_files', 'f_check_format_comma_separated_list', 'f_check_password', 'f_default_value_with_no_match') AND 
pg_namespace.nspname NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL))
SELECT  a.routine_type AS routine_type, a.routine_schema AS r1_schema, a.routine_name AS r1_routine_name, a.parameters AS r1_params,
b.routine_schema AS r2_schema, b.routine_name AS r2_routine_name, b.parameters AS r2_params
FROM routines AS a, routines AS b
WHERE a.routine_oid>b.routine_oid AND
a.routine_schema=b.routine_schema AND
a.routine_name=b.routine_name AND
a.parameters_without_defaults=b.parameters_without_defaults AND
a.routine_type=b.routine_type
ORDER BY a.routine_schema, a.routine_name, b.routine_schema, b.routine_name;

Collections where the query belongs to

Collection nameCollection description
Find problems automaticallyQueries, 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 .

Categories where the query belongs to

Category nameCategory description
Does not work in some earlier PostgreSQL versionQueries of this category provide information that was not available in some earlier PostgreSQL version
OverloadingQueries of this category provide information about overloading of routines.
User-defined routinesQueries of this category provide information about the user-defined routines

The list of all the queries