From 2e1e37f702b219325ad0b368a7aee4748da4938b Mon Sep 17 00:00:00 2001 From: Oleg Volchkov Date: Thu, 5 Mar 2026 12:08:25 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4?= =?UTF-8?q?=D0=B0=D1=85=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D0=B8=20=D1=81?= =?UTF-8?q?=D1=85=D0=B5=D0=BC=D1=8B=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86?= =?UTF-8?q?=20=D0=B2=20=D0=9F=D0=BE=D1=81=D1=82=D0=B3=D1=80=D0=B5=D1=81?= =?UTF-8?q?=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA=D1=83=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=B8=20=D0=BC=D0=B0=D1=82=D0=B5=D1=80=D0=B8=D0=B0?= =?UTF-8?q?=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B5=D0=B4=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/console/commands/pgsql.p | 52 +++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/lib/console/commands/pgsql.p b/lib/console/commands/pgsql.p index 1ebaff8..fb1c6fd 100644 --- a/lib/console/commands/pgsql.p +++ b/lib/console/commands/pgsql.p @@ -211,7 +211,7 @@ pfConsoleCommandWithSubcommands } @table_schema[aArgs;aSwitches] -## aArgs.1 — имя таблицы +## aArgs.1 — имя таблицы или представления ^if(!def $aArgs.1){ ^self.usage[] ^return[] @@ -224,9 +224,23 @@ pfConsoleCommandWithSubcommands ^if(!^self.CSQL.int{ select count(*) - from information_schema.tables - where table_schema not in ('pg_catalog', 'information_schema') - and table_name = '^taint[$aArgs.1]' + from + ( + select tablename + from pg_tables + where schemaname not in ('pg_catalog', 'information_schema') + and tablename = '^taint[$aArgs.1]' + union + select matviewname + from pg_matviews + where schemaname not in ('pg_catalog', 'information_schema') + and matviewname = '^taint[$aArgs.1]' + union + select viewname + from pg_views + where schemaname not in ('pg_catalog', 'information_schema') + and viewname = '^taint[$aArgs.1]' + ) }){ ^self.print[Table "$aArgs.1" not found.] ^return[] @@ -257,23 +271,31 @@ pfConsoleCommandWithSubcommands } @tables[aArgs;aSwitches] -## aArgs.1 — префикс таблиц +## aArgs.1 — префикс таблиц или представлений $lPrefix[^aArgs.1.trim[]] $lTables[^self.CSQL.hash{ - select table_name, - table_catalog, - table_schema - from information_schema.tables - where table_schema not in ('pg_catalog', 'information_schema') - ^if(def $aArgs.1){ - and table_name like '^taint[$aArgs.1]%' - } - order by table_schema, table_name + select * from ( + select tablename as table_name, schemaname as table_schema, 'T' as kind + from pg_tables + where schemaname not in ('pg_catalog', 'information_schema') + and tablename like '^taint[$aArgs.1]%' + union + select matviewname as table_name, schemaname as table_schema, 'M' as kind + from pg_matviews + where schemaname not in ('pg_catalog', 'information_schema') + and matviewname like '^taint[$aArgs.1]%' + union + select viewname as table_name, schemaname as table_schema, 'V' as kind + from pg_views + where schemaname not in ('pg_catalog', 'information_schema') + and viewname like '^taint[$aArgs.1]%' + ) + order by table_schema, table_name }] ^if($lTables){ ^self.print[Found ^lTables._count[] tables^if(def $lPrefix){ starts with "$lPrefix"}:] ^lTables.foreach[name;v]{ - ^self.print[— ^if($v.table_schema ne "public"){${v.table_schema}.}$name] + ^self.print[— ^if($v.table_schema ne "public"){${v.table_schema}.}$name [$v.kind]] } }{ ^self.print[Tables not found.]