Re: Relation 0 does not exist

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

On Wed, Sep 25, 2002 at 06:26:22PM -0400, Tom Lane wrote:
> Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk> writes:
> >> Could you try setting a breakpoint at elog() to capture the stack trace
> >> leading up to the error?
>
> > #0 elog (lev=15, fmt=0x821133b "statement: %s") at elog.c:114
> > #1 0x81812db in elog (lev=20, fmt=0x8196b02 "Relation %u does not exist")
> > at elog.c:438
> > #2 0x80791a2 in relation_open (relationId=0, lockmode=2) at heapam.c:474
> > #3 0x8079329 in heap_open (relationId=0, lockmode=2) at heapam.c:602
> > #4 0x816d94b in RI_FKey_check (fcinfo=0xbfbfc884) at ri_triggers.c:212
> > #5 0x816dee1 in RI_FKey_check_ins (fcinfo=0xbfbfc884) at ri_triggers.c:506
>
> Hm. Apparently tgconstrrelid is 0 in the pg_trigger row for your ON
> INSERT trigger --- can you confirm that by looking in pg_trigger?

Even more entertaining: tgconstrrelid=0 for all rows in pg_trigger.

> Next question is how it got that way. Did you create this table from a
> dump, and if so do you still have the dump file? I'm wondering exactly
> what SQL command was used to create the trigger ...

Originally it was created with

create table meter (
id serial primary key,
...
create table stats (
id serial primary key,
...
create table trans (
meter_id integer references meter(id),
stats_id integer references stats(id),
...

then dumped with the v7.3 pg_dumpall which generated:

ALTER TABLE ONLY meter
ADD CONSTRAINT meter_pkey PRIMARY KEY (id);

ALTER TABLE ONLY stats
ADD CONSTRAINT stats_pkey PRIMARY KEY (id);

--
-- TOC entry 117 (OID 8658004)
-- Name: RI_ConstraintTrigger_8658003; Type: TRIGGER; Schema: ; Owner: prlw1
--

CREATE CONSTRAINT TRIGGER "<unnamed>"
AFTER INSERT OR UPDATE ON trans
NOT DEFERRABLE INITIALLY IMMEDIATE
FOR EACH ROW
EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'trans', 'meter', 'UNSPE
CIFIED', 'meter_id', 'id');

--
-- TOC entry 113 (OID 8658006)
-- Name: RI_ConstraintTrigger_8658005; Type: TRIGGER; Schema: ; Owner: prlw1
--

CREATE CONSTRAINT TRIGGER "<unnamed>"
AFTER DELETE ON meter
NOT DEFERRABLE INITIALLY IMMEDIATE
FOR EACH ROW
EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'trans', 'meter', 'UN
SPECIFIED', 'meter_id', 'id');

--
-- TOC entry 114 (OID 8658008)
-- Name: RI_ConstraintTrigger_8658007; Type: TRIGGER; Schema: ; Owner: prlw1
--

CREATE CONSTRAINT TRIGGER "<unnamed>"
AFTER UPDATE ON meter
NOT DEFERRABLE INITIALLY IMMEDIATE
FOR EACH ROW
EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'trans', 'meter', 'UN
SPECIFIED', 'meter_id', 'id');

--
-- TOC entry 118 (OID 8658010)
-- Name: RI_ConstraintTrigger_8658009; Type: TRIGGER; Schema: ; Owner: prlw1
--

CREATE CONSTRAINT TRIGGER "<unnamed>"
AFTER INSERT OR UPDATE ON trans
NOT DEFERRABLE INITIALLY IMMEDIATE
FOR EACH ROW
EXECUTE PROCEDURE "RI_FKey_check_ins" ('<unnamed>', 'trans', 'stats', 'UNSPE
CIFIED', 'stats_id', 'id');

--
-- TOC entry 115 (OID 8658012)
-- Name: RI_ConstraintTrigger_8658011; Type: TRIGGER; Schema: ; Owner: prlw1
--

CREATE CONSTRAINT TRIGGER "<unnamed>"
AFTER DELETE ON stats
NOT DEFERRABLE INITIALLY IMMEDIATE
FOR EACH ROW
EXECUTE PROCEDURE "RI_FKey_noaction_del" ('<unnamed>', 'trans', 'stats', 'UN
SPECIFIED', 'stats_id', 'id');

--
-- TOC entry 116 (OID 8658014)
-- Name: RI_ConstraintTrigger_8658013; Type: TRIGGER; Schema: ; Owner: prlw1
--

CREATE CONSTRAINT TRIGGER "<unnamed>"
AFTER UPDATE ON stats
NOT DEFERRABLE INITIALLY IMMEDIATE
FOR EACH ROW
EXECUTE PROCEDURE "RI_FKey_noaction_upd" ('<unnamed>', 'trans', 'stats', 'UN
SPECIFIED', 'stats_id', 'id');

Cheers,

Patrick

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Clift 2002-09-26 09:56:34 Re: [HACKERS] Performance while loading data and indexing
Previous Message Martijn van Oosterhout 2002-09-26 09:54:48 Re: [HACKERS] Performance while loading data and indexing

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Clift 2002-09-26 09:56:34 Re: [HACKERS] Performance while loading data and indexing
Previous Message Martijn van Oosterhout 2002-09-26 09:54:48 Re: [HACKERS] Performance while loading data and indexing