On 2018-Jun-28, Peter Eisentraut wrote:

> On 6/27/18 23:01, Alvaro Herrera wrote:
> > Another angle is that we're already in beta3 and there may be concerns
> > about altering catalog definition this late in the cycle.  Anybody?
> > Maybe psql can just match tgisinternal triggers by name, and if one
> > match occurs then we assume it's a clone that should be listed as a
> > partition trigger.
> 
> Couldn't psql chase the pg_depend links to find inherited triggers?

Yeah, I thought this would be exceedingly ugly, but apparently it's not
*that* bad -- see the attached patch, which relies on the fact that
triggers don't otherwise depend on other triggers.  We don't use this
technique elsewhere in psql though.

I admit I'm inclined to go this route mostly because it's simpler.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index e5b3c1ebf9..6e08515857 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -2713,7 +2713,11 @@ describeOneTableDetails(const char *schemaname,
                                                   pset.sversion >= 80300 ?
                                                   "t.tgconstraint <> 0 AS 
tgisinternal" :
                                                   "false AS tgisinternal"), 
oid);
-               if (pset.sversion >= 90000)
+               if (pset.sversion >= 110000)
+                       appendPQExpBuffer(&buf, "(NOT t.tgisinternal OR 
(t.tgisinternal AND t.tgenabled = 'D') \n"
+                                                         "    OR EXISTS 
(SELECT 1 FROM pg_catalog.pg_depend WHERE objid = t.oid \n"
+                                                         "        AND 
refclassid = 'pg_catalog.pg_trigger'::regclass))");
+               else if (pset.sversion >= 90000)
                        /* display/warn about disabled internal triggers */
                        appendPQExpBuffer(&buf, "(NOT t.tgisinternal OR 
(t.tgisinternal AND t.tgenabled = 'D'))");
                else if (pset.sversion >= 80300)

Reply via email to