pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-bugs@postgresql.org
Cc: Maxim Boguk <maxim.boguk@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: BUG #5798: Some weird error with pl/pgsql procedure
Date: Mon, 21 Feb 2011 16:07:38 -0500
Message-ID: <5977.1298322458@sss.pgh.pa.us> (raw)
In-Reply-To: <26057.1298311836@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>
	<AANLkTi=H3wOXQ+vx7mJEVkw5o=GcRiLbyTWBmUKLwb0b@mail.gmail.com>
	<26057.1298311836@sss.pgh.pa.us>

I wrote:
> [ theory about cause of bug #5798 ]

Attached is a proposed patch against HEAD to fix this problem.  It's a
bit hard to *prove* that it fixes the problem, since there's no easy way
to force the collision of palloc addresses.  But I think it will.

The patch changes the signature of ExecBRUpdateTriggers so that it takes
and returns a TupleTableSlot instead of a HeapTuple.  This essentially
just moves the troublesome code (the "if (newtuple != tuple)" block)
from ExecUpdate to the bottom of ExecBRUpdateTriggers.  It solves the
problem because in the case where ExecBRUpdateTriggers clobbers the
contents of the junkfilter's output slot, it can immediately update the
tuple pointer that will later be compared to see if the trigger(s)
replaced the tuple.

I chose to change ExecBRInsertTriggers, ExecIRInsertTriggers, and
ExecIRUpdateTriggers to also take and return TupleTableSlots.   These
functions don't have a bug AFAICS, but it seems better that they all
retain similar APIs.

I'm not sure whether to back-patch all four changes or limit the patch
to changing ExecBRUpdateTriggers in the back branches.  Any thoughts
about that?

			regards, tom lane

view thread (17+ messages)  latest in thread

Message-ID: <5977.1298322458@sss.pgh.pa.us>
Permalink:  ../5977.1298322458@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/5977.1298322458@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: <5977.1298322458@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> <AANLkTi=H3wOXQ+vx7mJEVkw5o=GcRiLbyTWBmUKLwb0b@mail.gmail.com> <26057.1298311836@sss.pgh.pa.us> <5977.1298322458@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