Re: PG10 transition tables, wCTEs and multiple operations on the same table

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Kevin Grittner <kgrittn(at)gmail(dot)com>
Cc: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PG10 transition tables, wCTEs and multiple operations on the same table
Date: 2017-06-06 00:58:22
Message-ID: CAMsr+YFB3bi5u=FQLUX2JCBL+0XgxFZ3dXY5effi-aOahEox7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 4 June 2017 at 06:41, Kevin Grittner <kgrittn(at)gmail(dot)com> wrote:
> On Fri, Jun 2, 2017 at 8:46 PM, Thomas Munro
> <thomas(dot)munro(at)enterprisedb(dot)com> wrote:
>
>> So, afterTriggers.query_stack is used to handle the reentrancy that
>> results from triggers running further statements that might fire
>> triggers. It isn't used for dealing with extra ModifyTable nodes that
>> can appear in a plan because of wCTEs. Could it also be used for that
>> purpose? I think that would only work if it is the case that each
>> ModifyTable node begin and then runs to completion (ie no interleaving
>> of wCTE execution) and then its AS trigger fires, which I'm not sure
>> about.
>
> I don't think we want to commit to anything that depends on a CTE
> creating an optimization fence, although *maybe* that would be OK in
> the case of DML as a CTE. That's a pretty special case; I'm not
> sure whether the standard discusses it.

It's definitely fine to require a fence for wCTEs. They're an
extension to the standard, and it's pretty much necessary that we not
pull up / push down across them since we don't want to affect the
side-effects (row changes). If there are any cases where it's safe,
they'll take some careful thought.

It's only standard CTEs (SELECT-based) that I think matter for the
optimisation fence behaviour.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2017-06-06 01:07:24 Re: logical replication and PANIC during shutdown checkpoint in publisher
Previous Message Andres Freund 2017-06-06 00:47:14 Re: logical replication and PANIC during shutdown checkpoint in publisher