WITH tsv_columns AS (SELECT table_schema, table_name, column_name, ordinal_position
FROM INFORMATION_SCHEMA.columns
WHERE (table_schema, table_name) IN (SELECT table_schema, table_name
FROM INFORMATION_SCHEMA.tables WHERE table_type='BASE TABLE')
AND data_type='tsvector'
AND 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)),
tsv_columns_generated AS (SELECT table_schema, table_name, column_name
FROM INFORMATION_SCHEMA.columns
WHERE (table_schema, table_name) IN (SELECT table_schema, table_name
FROM INFORMATION_SCHEMA.tables WHERE table_type='BASE TABLE')
AND data_type='tsvector'
AND is_generated='ALWAYS'
AND 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)),
tr AS (SELECT
n.nspname AS trigger_schema,
c.relname AS trigger_table
FROM pg_namespace n,
pg_class c,
pg_trigger t,
pg_proc p,
pg_namespace np
WHERE n.oid = c.relnamespace
AND c.oid = t.tgrelid
AND t.tgfoid=p.oid
AND p.pronamespace=np.oid
AND NOT t.tgisinternal
AND NOT pg_is_other_temp_schema(n.oid)
AND c.relkind IN ('r','p')
AND p.proname~*'^tsvector_update_trigger')
SELECT table_schema, table_name, column_name
FROM tsv_columns AS tsv
WHERE NOT EXISTS (SELECT *
FROM tsv_columns_generated AS tsvg
WHERE tsvg.table_schema=tsv.table_schema
AND tsvg.table_name=tsv.table_name
AND tsvg.column_name=tsv.column_name)
AND NOT EXISTS (SELECT *
FROM tr
WHERE tr.trigger_schema=tsv.table_schema
AND tr.trigger_table=tsv.table_name)
ORDER BY table_schema, table_name, ordinal_position;