pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHow to drop an <unnamed> trigger
4+ messages / 2 participants
[nested] [flat]
* How to drop an <unnamed> trigger
@ 2001-03-08 15:42 Frank Joerdens <frank@joerdens.de>
2001-03-08 16:06 ` Re: How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
0 siblings, 1 reply; 4+ messages in thread
From: Frank Joerdens @ 2001-03-08 15:42 UTC (permalink / raw)
To: pgsql-sql
I've created quite a few foreign key constraints in the database that I
am currently working on, and now that I've altered the structure and
dropped a table that had a foreign key reference to a couple of other
tables, I need to get rid of those foreign keys (they weren't dropped
automagically with the table), as I get errors on trying to update those
tables.
Trouble is that the foreign keys show up in a schema dump as <unnamed>
triggers (AFAIK there is no other way to display foreign key
constraints) which I don't know how to drop. Here's an example:
\connect - frank
--
-- TOC Entry ID 56 (OID 52367)
--
-- Name: "RI_ConstraintTrigger_52366" Type: TRIGGER Owner: frank
--
CREATE CONSTRAINT TRIGGER "<unnamed>" AFTER DELETE ON "index" NOT
DEFERRABLE INITIALLY IMMEDIATE FOR EACH ROW EXECUTE PROCEDURE
"RI_FKey_cascade_del" ('<unnamed>', 'legende', 'index', 'UNSPECIFIED',
'platz', 'id');
I tried dropping it with
=# drop trigger RI_ConstraintTrigger_52366 on index;
which fails with
ERROR: DropTrigger: there is no trigger ri_constrainttrigger_52366 on
relation index
What to do? And more broadly, what's the recommended way to deal with
this in general? Avoid creating <unnamed> triggers by always creating named
foreign keys with something like
ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address)
REFERENCES addresses(address) MATCH FULL;
(from Bruce's book)?
Regards, Frank
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: How to drop an <unnamed> trigger
2001-03-08 15:42 How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
@ 2001-03-08 16:06 ` Frank Joerdens <frank@joerdens.de>
2001-03-08 16:51 ` Re: Re: How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
0 siblings, 1 reply; 4+ messages in thread
From: Frank Joerdens @ 2001-03-08 16:06 UTC (permalink / raw)
To: pgsql-sql
On Thu, Mar 08, 2001 at 04:42:46PM +0100, Frank Joerdens wrote:
> I've created quite a few foreign key constraints in the database that I
> am currently working on, and now that I've altered the structure and
> dropped a table that had a foreign key reference to a couple of other
> tables, I need to get rid of those foreign keys (they weren't dropped
> automagically with the table), as I get errors on trying to update those
> tables.
Just an idea: Is it safe to just delete the corresponding row in
pg_trigger?
Regards, Frank
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Re: How to drop an <unnamed> trigger
2001-03-08 15:42 How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
2001-03-08 16:06 ` Re: How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
@ 2001-03-08 16:51 ` Frank Joerdens <frank@joerdens.de>
2001-03-08 17:50 ` Re: Re: How to drop an <unnamed> trigger Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Frank Joerdens @ 2001-03-08 16:51 UTC (permalink / raw)
To: Frank Joerdens <frank@joerdens.de>; +Cc: pgsql-sql
On Thu, Mar 08, 2001 at 05:06:29PM +0100, Frank Joerdens wrote:
> On Thu, Mar 08, 2001 at 04:42:46PM +0100, Frank Joerdens wrote:
> > I've created quite a few foreign key constraints in the database that I
> > am currently working on, and now that I've altered the structure and
> > dropped a table that had a foreign key reference to a couple of other
> > tables, I need to get rid of those foreign keys (they weren't dropped
> > automagically with the table), as I get errors on trying to update those
> > tables.
>
> Just an idea: Is it safe to just delete the corresponding row in
> pg_trigger?
No, it ain't: After deleting the rows corresponding to the offending
triggers in pg_trigger, I can't vacuum, or dump.
- Frank
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Re: How to drop an <unnamed> trigger
2001-03-08 15:42 How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
2001-03-08 16:06 ` Re: How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
2001-03-08 16:51 ` Re: Re: How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
@ 2001-03-08 17:50 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2001-03-08 17:50 UTC (permalink / raw)
To: Frank Joerdens <frank@joerdens.de>; +Cc: pgsql-sql
Frank Joerdens <frank@joerdens.de> writes:
>> Just an idea: Is it safe to just delete the corresponding row in
>> pg_trigger?
> No, it ain't: After deleting the rows corresponding to the offending
> triggers in pg_trigger, I can't vacuum, or dump.
You need to adjust the reltriggers counts in the associated pg_class
entries, too.
regards, tom lane
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2001-03-08 17:50 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-08 15:42 How to drop an <unnamed> trigger Frank Joerdens <frank@joerdens.de>
2001-03-08 16:06 ` Frank Joerdens <frank@joerdens.de>
2001-03-08 16:51 ` Frank Joerdens <frank@joerdens.de>
2001-03-08 17:50 ` Tom Lane <tgl@sss.pgh.pa.us>
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