From: | Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> |
---|---|
To: | Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Shohei Mochizuki <shohei(dot)mochizuki(at)toshiba(dot)co(dot)jp>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: BEFORE UPDATE trigger on postgres_fdw table not work |
Date: | 2019-06-10 12:04:05 |
Message-ID: | CAPmGK17cnPGJZHoVwkAACHXEUjenwnyxvsMB=mD5bWUcfvnrHQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, May 28, 2019 at 3:40 PM Etsuro Fujita <etsuro(dot)fujita(at)gmail(dot)com> wrote:
> On Tue, May 28, 2019 at 12:54 PM Amit Langote
> <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> wrote:
> > On 2019/05/27 22:02, Tom Lane wrote:
> > > Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> writes:
> > >> On 2019/05/27 10:52, Shohei Mochizuki wrote:
> > >>> I noticed returning a modified record in a row-level BEFORE UPDATE trigger
> > >>> on postgres_fdw foreign tables do not work. Attached patch fixes this issue.
> > >>> This is because current fdw code adds only columns to RemoteSQL that were
> > >>> explicitly targets of the UPDATE as follows.
> > >
> > >> Yeah. So, the trigger execution correctly modifies the existing tuple
> > >> fetched from the remote server, but those changes are then essentially
> > >> discarded by postgres_fdw, that is, postgresExecForeignModify().
>
> > > Perhaps, if the table has relevant BEFORE triggers, we should just abandon
> > > our attempts to optimize away fetching/storing all columns? It seems like
> > > another potential hazard here is a trigger needing to read a column that
> > > is not mentioned in the SQL query.
>
> > So, the only problem here is the optimizing away of storing all columns,
> > which the Mochizuki-san's patch seems enough to fix.
Yeah, I think so too, because in UPDATE, we fetch all columns from the
remote (even if the target table doesn't have relevant triggers).
> Will look into the patch after returning from PGCon, unless somebody wants to.
I'll look into the patch more closely tomorrow. Sorry for the delay.
As I said in another email today, I felt a bit under the weather last
week.
Best regards,
Etsuro Fujita
From | Date | Subject | |
---|---|---|---|
Next Message | Asim R P | 2019-06-10 12:35:25 | Re: POC: Cleaning up orphaned files using undo logs |
Previous Message | Daniel Gustafsson | 2019-06-10 11:57:25 | Re: GiST limits on contrib/cube with dimension > 100? |