The list of all the queries

Perhaps updating of modification time is missing

Query goal: 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.
Notes about the query: Find routines with SQL-standard body that use a table that has a column for modification time. From these routines find such that contain a UPDATE statement but the routine does not use the modification time column nor does it contain a reference to a current timestamp function.
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 routine_table AS (SELECT DISTINCT t.table_schema, t.table_name, rtu.routine_schema, rtu.routine_name, rtu.specific_name,
pg_get_function_identity_arguments(translate(substring(rtu.specific_name,'_[0-9]+$'),'_','')::int::oid) AS parameters, 
pg_get_functiondef(translate(substring(rtu.specific_name,'_[0-9]+$'),'_','')::int::oid) AS routine_source, r.routine_type
FROM information_schema.tables AS t INNER JOIN information_schema.routine_column_usage AS rtu USING (table_schema, table_name)
INNER JOIN information_schema.routines AS r USING (specific_schema, specific_name) 
WHERE t.table_type = 'BASE TABLE' 
AND (t.table_schema, t.table_name) IN (SELECT table_schema, table_name
FROM INFORMATION_SCHEMA.columns
WHERE column_name~*'(muutm|update|change)'
AND data_type~*'(timestamp|date)')
AND t.table_schema NOT IN (SELECT schema_name
FROM INFORMATION_SCHEMA.schemata
WHERE schema_name<>'public' AND
schema_owner='postgres' AND schema_name IS NOT NULL))
SELECT table_schema, table_name, routine_schema, routine_name, parameters, routine_source, routine_type
FROM routine_table
WHERE routine_source~*'UPDATE[[:space:]].*SET[[:space:]]'
AND routine_source!~*'(localtimestamp|current_timestamp|now\(\))'
AND (routine_schema, specific_name) NOT IN (SELECT specific_schema, specific_name
FROM INFORMATION_SCHEMA.routine_column_usage INNER JOIN INFORMATION_SCHEMA.columns USING (table_schema, table_name, column_name)
WHERE column_name~*'(muutm|update|change)'
AND data_type~*'(timestamp|date)')
ORDER BY table_schema, table_name, routine_schema, routine_name;

Categories where the query belongs to

Category nameCategory description
Result quality depends on namesQueries of this category use names (for instance, column names) to try to guess the meaning of a database object. Thus, the goodness of names determines the number of false positive and false negative results.
User-defined routinesQueries of this category provide information about the user-defined routines

The list of all the queries