From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Amit Langote <amitlangote09@gmail.com>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Fixing findDependentObjects()'s dependency on scan order (regressions in DROP diagnostic messages)
Date: Sat, 9 Feb 2019 12:56:13 -0300
Message-ID: <20190209155613.GA2091@alvherre.pgsql> (raw)
In-Reply-To: <16446.1549697160@sss.pgh.pa.us>
On 2019-Feb-09, Tom Lane wrote:
> Amit Langote <amitlangote09@gmail.com> writes:
> > On Sat, Feb 9, 2019 at 9:41 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >> +1. The best solution would presumably be to go through the normal
> >> object deletion mechanism; though possibly there's a reason that
> >> won't work given you're already inside some other DDL.
>
> > Maybe:
> > - CatalogTupleDelete(trigrel, &trigtup->t_self);
> > + RemoveTriggerById(trgform->oid)?
>
> No, that's still the back end of the deletion machinery, and in particular
> it would fail to clean pg_depend entries for the trigger. Going in by the
> front door would use performDeletion(). (See deleteOneObject() to get
> an idea of what's being possibly missed out here.)
This patch I think does the right thing.
--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
[text/x-diff] fix-trigger-drop.patch (1.3K, ../20190209155613.GA2091@alvherre.pgsql/2-fix-trigger-drop.patch)
download | inline diff:
commit 7031ce2b1f79a2e03b29ac896f0a008b0621d654
Author: Alvaro Herrera <alvherre@alvh.no-ip.org>
AuthorDate: Sat Feb 9 12:31:25 2019 -0300
CommitDate: Sat Feb 9 12:53:00 2019 -0300
fix trigger drop
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.cindex 910e5deaa3f..923866b7e11 100644--- a/src/backend/commands/tablecmds.c+++ b/src/backend/commands/tablecmds.c@@ -8024,17 +8024,21 @@ CloneFkReferencing(Relation pg_constraint, Relation parentRel,
while ((trigtup = systable_getnext(scan)) != NULL)
{
Form_pg_trigger trgform = (Form_pg_trigger) GETSTRUCT(trigtup);
+ ObjectAddress trigger;
if (trgform->tgconstrrelid != fk->conrelid)
continue;
if (trgform->tgrelid != fk->confrelid)
continue;
- deleteDependencyRecordsForClass(TriggerRelationId,- HeapTupleGetOid(trigtup),- ConstraintRelationId,- DEPENDENCY_INTERNAL);- CatalogTupleDelete(trigrel, &trigtup->t_self);+ deleteDependencyRecordsFor(TriggerRelationId,+ HeapTupleGetOid(trigtup),+ false);+ /* make dependency deletion visible to performDeletion */+ CommandCounterIncrement();+ ObjectAddressSet(trigger, TriggerRelationId,+ HeapTupleGetOid(trigtup));+ performDeletion(&trigger, DROP_RESTRICT, 0);
}
systable_endscan(scan);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: alvherre@2ndquadrant.com, tgl@sss.pgh.pa.us, amitlangote09@gmail.com, pg@bowt.ie
Subject: Re: Fixing findDependentObjects()'s dependency on scan order (regressions in DROP diagnostic messages)
In-Reply-To: <20190209155613.GA2091@alvherre.pgsql>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox