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-25 22:26:22
Message-ID: 28663.1032992782@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:
>> 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?

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 ...

> I was inserting meter_id=411, stats_id=currval('stats_id_seq')
> meter.id=411 exists. Hard to tell about the other one.. Still don't see
> why this ever worked..

I'm confused about that too. The trigger failure is definitely
happening after we insert the row, so currval() must have gotten done
before reaching this point. So *something* is executing a nextval()
before we get to the point of evaluating the currval(). You got any
defaults on the table that might do it?

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Patrick Welche 2002-09-25 22:28:21 Re: Relation 0 does not exist
Previous Message Patrick Welche 2002-09-25 22:13:16 Re: Relation 0 does not exist

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-09-25 22:27:59 Re: Bug in PL/pgSQL GET DIAGNOSTICS?
Previous Message Bruce Momjian 2002-09-25 22:21:49 Re: Bug in PL/pgSQL GET DIAGNOSTICS?