Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 609CB1337B5E for ; Sun, 20 Feb 2011 17:07:55 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 94972-01 for ; Sun, 20 Feb 2011 21:07:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id C7985133740B for ; Sun, 20 Feb 2011 17:07:47 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p1KL7k86010911; Sun, 20 Feb 2011 16:07:46 -0500 (EST) To: Maxim Boguk cc: Robert Haas , pgsql-bugs@postgresql.org Subject: Re: BUG #5798: Some weird error with pl/pgsql procedure In-reply-to: References: <201012210248.oBL2m9sp090535@wwwmaster.postgresql.org> <28329.1298131693@sss.pgh.pa.us> Comments: In-reply-to Maxim Boguk message dated "Mon, 21 Feb 2011 01:25:35 +1300" Date: Sun, 20 Feb 2011 16:07:46 -0500 Message-ID: <10910.1298236066@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/173 X-Sequence-Number: 29445 Maxim Boguk writes: > I tracked virtual tuple from heaptuple.c::slot_getattr down to > execMain.c::ExecUpdate and I think somewhere in this way virtual tuple > should be need to be "materialized" into physical tuple. That happens at the top of ExecUpdate: /* * get the heap tuple out of the tuple table slot, making sure we have a * writable copy */ tuple = ExecMaterializeSlot(slot); I don't see any code path there that could re-virtualize the slot. Do you have any triggers or constraints on the target table? Because those are about the only things that influence this code path at all... > Again I not sure but ExecProcessReturning function seems good candidate to > perform tuple materialization. If ExecProcessReturning were given a virtual slot, materializing it would do no good at all for this problem, because the system columns in the result would be garbage. It has to receive an already materialized slot that contains the right information beforehand. The only reason that retrieving ctid can work at all is that when heap_update is called, "tuple" is pointing at the slot's contained tuple and so setting tuple->t_self changes the contents of the slot. That whole function is completely dependent on the slot contents being physical not virtual, and I don't see anything there that would break it. regards, tom lane