Re: MERGE regress test

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Teja Mupparti <Tejeswar(dot)Mupparti(at)microsoft(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: MERGE regress test
Date: 2022-11-18 19:08:05
Message-ID: 20221118190805.xq7rw2ija27kltde@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2022-Nov-16, Alvaro Herrera wrote:

> Hmm, good find. As I recall, I was opposed to the idea of throwing an
> error if the WHEN expression writes to the database, and the previous
> implementation had some hole, so I just ripped it out after discussing
> it; but I evidently failed to notice this test case about it.

Ah, I found out what happened, and my memory as usual is betraying me.
This was changed before I was involved with the patch at all: Pavan
changed it between his v18[1] and v19[2]:

if (action->whenqual)
{
- int64 startWAL = GetXactWALBytes();
- bool qual = ExecQual(action->whenqual, econtext);
-
- /*
- * SQL Standard says that WHEN AND conditions must not
- * write to the database, so check we haven't written
- * any WAL during the test. Very sensible that is, since
- * we can end up evaluating some tests multiple times if
- * we have concurrent activity and complex WHEN clauses.
- *
- * XXX If we had some clear form of functional labelling
- * we could use that, if we trusted it.
- */
- if (startWAL < GetXactWALBytes())
- ereport(ERROR,
- (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("cannot write to database within WHEN AND condition")));

This is what Peter Geoghegan had to say about it at the time:

> This needs to go. Apart from the fact that GetXactWALBytes() is buggy
> (it returns int64 for the unsigned type XLogRecPtr), the whole idea
> just seems unnecessary. I don't see why this is any different to using
> a volatile function in a regular UPDATE.

Pavan just forgot to remove the test. I'll do so now.

[1] https://postgr.es/m/CABOikdPFCcgp7=zoN4M=y0TefW4Q9dPAU+Oy5jN5A+hWYdnvNg@mail.gmail.com
[2] https://postgr.es/m/CABOikdOUoaXt1H885TC_cA1LoErEejqdVDZqG62rQkiZPPyg0Q@mail.gmail.com

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"No tengo por qué estar de acuerdo con lo que pienso"
(Carlos Caszeli)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2022-11-18 19:11:50 Re: New docs chapter on Transaction Management and related changes
Previous Message Simon Riggs 2022-11-18 18:54:47 Re: Reducing power consumption on idle servers