pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Maxim Boguk <maxim.boguk@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5798: Some weird error with pl/pgsql procedure
Date: Sun, 20 Feb 2011 16:07:46 -0500
Message-ID: <10910.1298236066@sss.pgh.pa.us> (raw)
In-Reply-To: <AANLkTi=MLmN9pwmXat=GtrnwmNKixy_a8kFXDJY5BhRW@mail.gmail.com>
References: <201012210248.oBL2m9sp090535@wwwmaster.postgresql.org>
	<AANLkTinq4ET1h3n7RznWVDTmMQBzBNnp=GvM=2zKDxa+@mail.gmail.com>
	<AANLkTi==2o9JPJwwfOsL2CnFpcw1YYy_AY_qCiKtg05W@mail.gmail.com>
	<AANLkTinzR3KOumGE_FBiBu8PWU=33guLrZW78qC+2KrV@mail.gmail.com>
	<AANLkTinvd10Qxzmnhn4881kZfqacZ4WpW2Vvt-peY=A6@mail.gmail.com>
	<28329.1298131693@sss.pgh.pa.us>
	<AANLkTimQ1qCbiUZJcA8h9BSFHvqaxygTk+nSV-i09s1p@mail.gmail.com>
	<AANLkTi=MLmN9pwmXat=GtrnwmNKixy_a8kFXDJY5BhRW@mail.gmail.com>

Maxim Boguk <maxim.boguk@gmail.com> 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



view thread (17+ messages)  latest in thread

Message-ID: <10910.1298236066@sss.pgh.pa.us>
Permalink:  ../10910.1298236066@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10910.1298236066@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, maxim.boguk@gmail.com, robertmhaas@gmail.com
  Subject: Re: BUG #5798: Some weird error with pl/pgsql procedure
  In-Reply-To: <10910.1298236066@sss.pgh.pa.us>
  References: <201012210248.oBL2m9sp090535@wwwmaster.postgresql.org> <AANLkTinq4ET1h3n7RznWVDTmMQBzBNnp=GvM=2zKDxa+@mail.gmail.com> <AANLkTi==2o9JPJwwfOsL2CnFpcw1YYy_AY_qCiKtg05W@mail.gmail.com> <AANLkTinzR3KOumGE_FBiBu8PWU=33guLrZW78qC+2KrV@mail.gmail.com> <AANLkTinvd10Qxzmnhn4881kZfqacZ4WpW2Vvt-peY=A6@mail.gmail.com> <28329.1298131693@sss.pgh.pa.us> <AANLkTimQ1qCbiUZJcA8h9BSFHvqaxygTk+nSV-i09s1p@mail.gmail.com> <AANLkTi=MLmN9pwmXat=GtrnwmNKixy_a8kFXDJY5BhRW@mail.gmail.com> <10910.1298236066@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox