Re: [POC]Enable tuple change partition caused by BEFORE TRIGGER

From: Ashutosh Bapat <ashutosh(dot)bapat(at)2ndquadrant(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, "movead(dot)li(at)highgo(dot)ca" <movead(dot)li(at)highgo(dot)ca>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Amit Langote <amitlangote09(at)gmail(dot)com>, Ahsan Hadi <ahsan(dot)hadi(at)gmail(dot)com>
Subject: Re: [POC]Enable tuple change partition caused by BEFORE TRIGGER
Date: 2020-08-27 06:04:45
Message-ID: CAG-ACPXNynSRzFEDkd0L6--5S2=nkcsO_ekmf16HzMp+JbqSew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 26 Aug 2020 at 22:47, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
wrote:

>
> What this is saying to me is that we'd need to make sure to run the
> final target partition's AFTER triggers, not the original target
> partition.

Agreed.

> But I'm not 100% about running the BEFORE triggers. Maybe
> one way to address this is to check whether the BEFORE triggers in the
> new target partition are clones; if so then they would have run in the
> original target partition and so must not be run, but otherwise they
> have to.
>

This will work as long as the two BEFORE ROW triggers have the same effect.
Consider two situations resulting in inserting identical rows 1. row that
the before row trigger has redirected to a new partition, say part2 2. a
row inserted directly into the part2 - if both these rows are identical
before the BEFORE ROW triggers have been applied, they should remain
identical while inserting into part2. Any divergence might be problematic
for the application.

--
Best Wishes,
Ashutosh

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuro Yamada 2020-08-27 06:13:09 Re: list of extended statistics on psql
Previous Message Amit Kapila 2020-08-27 05:45:54 Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions