Re: Relation 0 does not exist

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Relation 0 does not exist
Date: 2002-09-26 15:39:09
Message-ID: 4624.1033054749@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk> writes:
>> Anyway the quickest fix seems to be to manually drop the triggers
>> and reconstruct the FK relationships with ALTER TABLE ADD FOREIGN KEY
>> commands. If that seems too messy to do by hand, you can wait till
>> I've got a pg_dump patch to do it for you.

> Just a note on output. Before I had

> \d trans...
> Indexes: firsttimei_idx btree (firsttimei),
> srcpeername_idx btree (sourcepeername)
> Triggers: RI_ConstraintTrigger_14413070,
> RI_ConstraintTrigger_14413073

> after drop trigger/alter table add foreign key:

> \d trans
> Indexes: firsttimei_idx btree (firsttimei),
> srcpeername_idx btree (sourcepeername)
> Foreign Key constraints: $1 FOREIGN KEY (meter_id) REFERENCES meter(id) MATCH FULL ON UPDATE NO ACTION ON DELETE NO ACTION,
> $2 FOREIGN KEY (stats_id) REFERENCES stats(id) MATCH FULL ON UPDATE NO ACTION ON DELETE NO ACTION

> I take it the difference is because before tgconstrrelid was zero, and now
> it isn't?

No, the difference is that now there is a pg_constraint entry for the
foreign-key relationship, and the system understands that the triggers
exist to implement that FK constraint so it doesn't show them separately.
Before they were just random triggers and \d didn't have any special
knowledge about them.

The main advantage of having the pg_constraint entry is that you can
ALTER TABLE DROP CONSTRAINT to get rid of the FK constraint (and the
triggers of course). No more manual mucking with triggers.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Copeland 2002-09-26 15:41:37 Re: [HACKERS] Performance while loading data and indexing
Previous Message Patrick Welche 2002-09-26 15:31:01 Re: Relation 0 does not exist

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Copeland 2002-09-26 15:41:37 Re: [HACKERS] Performance while loading data and indexing
Previous Message Patrick Welche 2002-09-26 15:31:01 Re: Relation 0 does not exist