Unix Technical Forum

Re: [GENERAL] strange error when inserting via a SRF into a table with a foreign key constraint

This is a discussion on Re: [GENERAL] strange error when inserting via a SRF into a table with a foreign key constraint within the pgsql Hackers forums, part of the PostgreSQL category; --> "Merlin Moncure" <mmoncure@gmail.com> writes: > I got the error mesage, > ERROR: could not find relation 19693 among query ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-12-2008, 05:15 AM
Tom Lane
 
Posts: n/a
Default Re: [GENERAL] strange error when inserting via a SRF into a table with a foreign key constraint

"Merlin Moncure" <mmoncure@gmail.com> writes:
> I got the error mesage,
> ERROR: could not find relation 19693 among query result relations,


Oooh, that's an interesting one. The stack trace from the error call
is

#0 errfinish (dummy=0) at elog.c:313
#1 0x356584 in elog_finish (elevel=1073815392,
fmt=0xcc130 "could not find relation %u among query result relations")
at elog.c:939
#2 0x1ef59c in afterTriggerInvokeEvents (events=0x400ec508, firing_id=0,
estate=0x40109be8, delete_ok=1 '\001') at trigger.c:2331
#3 0x1ef9dc in AfterTriggerEndQuery (estate=0x40109be8) at trigger.c:2556
#4 0x211878 in postquel_end (es=0x40105e18) at functions.c:404
#5 0x211a38 in postquel_execute (es=0x40105e18, fcinfo=0x7b03ba40,
fcache=0x401049b8, resultcontext=0x4007c4e0) at functions.c:479
#6 0x211c68 in fmgr_sql (fcinfo=0x7b03ba40) at functions.c:639
#7 0x2097b4 in ExecMakeFunctionResult (fcache=0x40104280,
econtext=0x40104108, isNull=0x40104932 "", isDone=0x401049a0)
at execQual.c:1057
....

What the heck is it doing trying to fire triggers from inside the SQL
function, which is merely doing a SELECT? It looks to me like we need
to rethink where the AfterTriggerBeginQuery and AfterTriggerEndQuery
calls are in functions.c. I think what is happening is that control
returns from the SQL function after obtaining its first result row,
with the trigger stack still at level one (inside the function), and
so the first AFTER INSERT event gets queued as being something inside
the function.

8.0 has the same bug although the manifestation is different. Not
sure about 7.4 --- this test case doesn't work for lack of
generate_series.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 08:48 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com