The list of all the queries

The number of SQL-language routines with different types of bodies

Query goal: Find for each user schema that contain a SQL-language routine how many of these have the body that is string literal and how many have the body (possible starting from PostgreSQL 14) that is parsed at the routine definition time. Try to be consistent, i.e., use the same solution in case of all the routines.
Notes about the query: The query does not work before PostgreSQL 14.
Query type: Sofware measure (Numeric values (software measures) about the database)
Query license: MIT License
Data source: INFORMATION_SCHEMA+system catalog
SQL query: Click on query to copy it

SELECT 
  pg_namespace.nspname AS routine_schema, 
 Count(*) FILTER (WHERE prosqlbody IS NULL) AS number_of_sql_routines_where_body_is_literal,
 Count(*) FILTER (WHERE prosqlbody IS NOT NULL) AS number_of_sql_routines_where_body_is_sql_body
FROM 
  pg_catalog.pg_proc, 
  pg_catalog.pg_namespace,
  pg_catalog.pg_language
WHERE 
  pg_proc.pronamespace = pg_namespace.oid
AND pg_proc.prolang = pg_language.oid
AND pg_language.lanname='sql'
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)
AND NOT EXISTS (SELECT 1
FROM pg_catalog.pg_depend d 
WHERE EXISTS (SELECT 1 FROM pg_catalog.pg_extension e WHERE d.refobjid=e.oid) AND
d.objid=pg_proc.oid)
GROUP BY pg_namespace.nspname;

Collections where the query belongs to

Collection nameCollection description
Find problems by overviewQueries that results point to different aspects of database that might have problems. A human reviewer has to decide based on the results as to whether there are problems 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
User-defined routinesQueries of this category provide information about the user-defined routines

Reference materials for further reading

Reference
https://www.cybertec-postgresql.com/en/better-sql-functions-in-postgresql-v14/

The list of all the queries