From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Piotr Gabriel Kosinski <pg.kosinski@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: Segmentation fault during update inside ExecBRUpdateTriggers
Date: Thu, 15 Aug 2019 18:39:24 -0400
Message-ID: <32545.1565908764@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+hUKGK8dbkY+NC9TSH5heeq5jUQEYMZ1pATVY+CPjWAiSV4TA@mail.gmail.com>
References: <CAFMLSdP0rd7LqC3j-H6Fh51FYSt5A10DDh-3=W4PPc4LLUQ8YQ@mail.gmail.com>
<CA+hUKGK8dbkY+NC9TSH5heeq5jUQEYMZ1pATVY+CPjWAiSV4TA@mail.gmail.com>
Thomas Munro <thomas.munro@gmail.com> writes:
> Right, this happens on REL_11_STABLE but not on master (which rewrote
> the relevant code quite a bit in the "slotification" project).
We should probably trace back why it doesn't happen before v11.
I have a vague memory of having touched this code a year or two
back, so likely this is my fault, but I wonder why it doesn't
fail before.
> In a very quick test, the following change fixes the problem and
> passes regression tests, but I'm not sure if it's the right fix.
> - if (oldtuple != newtuple && oldtuple != slottuple)
> + if (oldtuple != newtuple && oldtuple != slottuple &&
> oldtuple != trigtuple)
My thoughts were headed in the same direction. It looks like the
issue is that the first trigger returns OLD, ie "trigtuple",
which gets assigned to "newtuple", and then the second iteration
of the loop fails to deal with the aliasing.
[ thinks some more... ] Actually, I'm beginning to recall that
we made changes here because v11 plpgsql is capable of actually
returning "trigtuple" where before it would always have made a copy.
If that's accurate, then very likely the bug exists further back
but requires some other PL than plpgsql to manifest.
I'd be inclined to put a test case exercising this into all branches,
even ones not currently showing the bug, because it's clearly a
fragile area.
regards, tom lane
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, thomas.munro@gmail.com, pg.kosinski@gmail.com
Subject: Re: Segmentation fault during update inside ExecBRUpdateTriggers
In-Reply-To: <32545.1565908764@sss.pgh.pa.us>
References: <CAFMLSdP0rd7LqC3j-H6Fh51FYSt5A10DDh-3=W4PPc4LLUQ8YQ@mail.gmail.com> <CA+hUKGK8dbkY+NC9TSH5heeq5jUQEYMZ1pATVY+CPjWAiSV4TA@mail.gmail.com> <32545.1565908764@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