From 66239168f6c8cd4f40d1f306bedc251c8c3b738d Mon Sep 17 00:00:00 2001 From: Ivan Vakhrushev Date: Tue, 10 Dec 2024 09:54:50 +0400 Subject: [PATCH] [TABLES_WITHOUT_DESCRIPTION] Consider to skip partitions of table (#64) * Skip partitions * Skip partitions --- sql/columns_without_description.sql | 13 +++++++------ sql/tables_without_description.sql | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sql/columns_without_description.sql b/sql/columns_without_description.sql index ff4d0e4..3d941ba 100644 --- a/sql/columns_without_description.sql +++ b/sql/columns_without_description.sql @@ -8,17 +8,18 @@ -- Finds columns that don't have a description. -- See also https://www.postgresql.org/docs/current/sql-comment.html select - t.oid::regclass::text as table_name, + pc.oid::regclass::text as table_name, col.attname::text as column_name, col.attnotnull as column_not_null from - pg_catalog.pg_class t - inner join pg_catalog.pg_namespace nsp on nsp.oid = t.relnamespace - inner join pg_catalog.pg_attribute col on col.attrelid = t.oid + pg_catalog.pg_class pc + inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace + inner join pg_catalog.pg_attribute col on col.attrelid = pc.oid where - t.relkind = 'r' and + pc.relkind in ('r', 'p') and + not pc.relispartition and col.attnum > 0 and /* to filter out system columns such as oid, ctid, xmin, xmax, etc. */ not col.attisdropped and - (col_description(t.oid, col.attnum) is null or length(trim(col_description(t.oid, col.attnum))) = 0) and + (col_description(pc.oid, col.attnum) is null or length(trim(col_description(pc.oid, col.attnum))) = 0) and nsp.nspname = :schema_name_param::text order by table_name, column_name; diff --git a/sql/tables_without_description.sql b/sql/tables_without_description.sql index 069b6d9..0662e5c 100644 --- a/sql/tables_without_description.sql +++ b/sql/tables_without_description.sql @@ -13,7 +13,8 @@ from pg_catalog.pg_class pc inner join pg_catalog.pg_namespace nsp on nsp.oid = pc.relnamespace where - pc.relkind = 'r' and + pc.relkind in ('r', 'p') and + not pc.relispartition and (obj_description(pc.oid) is null or length(trim(obj_description(pc.oid))) = 0) and nsp.nspname = :schema_name_param::text order by table_name;