Re: [HACKERS] MERGE SQL Statement for PG11

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Pavan Deolasee <pavan(dot)deolasee(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] MERGE SQL Statement for PG11
Date: 2018-03-08 14:52:19
Message-ID: CA+TgmoZVSGP0tz+R-JMguARFeQo5JBXngw=--_SAPSNO2CmTSg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 8, 2018 at 7:54 AM, Pavan Deolasee <pavan(dot)deolasee(at)gmail(dot)com> wrote:
>> > + /*
>> > + * 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 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.
>
> I removed this code since it was wrong. We might want to add some basic
> checks for existence of volatile functions in the WHEN or SET clauses. But I
> agree, it's no different than regular UPDATEs. So may be not a big deal.

I just caught up on this thread. I'm definitely glad to see that code
go because, wow, that is all kinds of wrong. I don't see a real need
to add any kind of replacement check, either. Prohibiting volatile
functions here doesn't seem likely to accomplish anything useful. It
seems like the most we'd want to do is mention this the documentation
somehow, and I'm not even sure we really need to do that much.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shinoda, Noriyoshi 2018-03-08 14:52:41 RE: unique indexes on partitioned tables
Previous Message Jeevan Chalke 2018-03-08 14:32:22 Re: [HACKERS] Partition-wise aggregation/grouping