pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru>
To: Michael Paquier <michael.paquier@gmail.com>
Cc: Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>
Cc: Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>
Cc: Dilip Kumar <dilipbalaut@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Bug in ExecModifyTable function and trigger issues for foreign tables
Date: Wed, 17 May 2017 11:54:37 +0300
Message-ID: <20170517115437.710dedb9@wp.localdomain> (raw)
In-Reply-To: <CAB7nPqR3JNuWfoUxYH_rVbGA=Oy=iJN0wyvubS_H6h7tX=LsWQ@mail.gmail.com>
References: <20170514150525.0346ba72@postgrespro.ru>
	<CAFiTN-v_WOycpycrh2c_TpzVU=yOjMNWwHnUYYxccK-fOaWjpw@mail.gmail.com>
	<CAFiTN-vx1pYKbtkFdX9srL+dghCJdZ9-DgRb57oDs5GuCDCD2Q@mail.gmail.com>
	<20170515121638.0c076bcc@wp.localdomain>
	<CAFjFpRfQ1pkCjNQFVOP_BPJfc7OR3596nqVVFBgAiDEZqB4Azg@mail.gmail.com>
	<20170515165455.545dd3d6@wp.localdomain>
	<CAFjFpRcQudmKYU4PJRN1-wp5K4aksupSoVpcRVAzES_49T=Vng@mail.gmail.com>
	<20170516150516.1b616230@wp.localdomain>
	<CAFjFpReeA3G3-U-FsR79zx_xFBVZc73hhWcH4OVWMb+ZFViRQg@mail.gmail.com>
	<dbf4b9ff-b0be-2396-7c79-d5763ae8a034@lab.ntt.co.jp>
	<20170516172600.291220dc@wp.localdomain>
	<CAB7nPqR3JNuWfoUxYH_rVbGA=Oy=iJN0wyvubS_H6h7tX=LsWQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On Wed, 17 May 2017 15:28:24 +0900
Michael Paquier <michael.paquier@gmail.com> wrote:

> On Tue, May 16, 2017 at 11:26 PM, Ildus Kurbangaliev
> <i.kurbangaliev@postgrespro.ru> wrote:
> > On Tue, 16 May 2017 21:36:11 +0900
> > Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp> wrote:  
> >> On 2017/05/16 21:11, Ashutosh Bapat wrote:  
> >> > On Tue, May 16, 2017 at 5:35 PM, Ildus Kurbangaliev
> >> > <i.kurbangaliev@postgrespro.ru> wrote:  
> >>  
> >> >> I agree. Maybe this issue should be added to Postgresql Open
> >> >> Items? I think there should be some complex solution that fixes
> >> >> not only triggers for foreign tables at table partitioning, but
> >> >> covers other possible not working cases.  
> >>  
> >> > I doubt if this is an open item, since DMLs on foreign tables are
> >> > supported since 9.3 and support to add foreign tables to
> >> > inheritance was added back in 9.5.  
> >>
> >> I think this issue was introduced by the latter, so that was my
> >> fault.
> >>
> >> One approach I came up with to fix this issue is to rewrite the
> >> targetList entries of an inherited UPDATE/DELETE properly using
> >> rewriteTargetListUD, when generating a plan for each child table in
> >> inheritance_planner.  Attached is a WIP patch for that.  Maybe I am
> >> missing something, though.  
> 
> Could this patch include some regression tests to see at what extent
> it has been tested? We surely don't want to see that broken again in
> the future as well. (Nit: I did not look at the patch in details yet)
> 
> > I tested the patch, looks good.  
> 
> What kind of tests did you do?

I tested update triggers for foreign table when regular table is a
parent and foreign table is a child. Case like this:

explain verbose update parent set val = random();
                                  QUERY PLAN
-------------------------------------------------------------------------------
 Update on public.parent  (cost=0.00..258.63 rows=5535 width=10)
   Update on public.parent
   Update on public.child1
   Foreign Update on public.ftable // we have triggers on ftable here

> 
>                   junkfilter = resultRelInfo->ri_junkFilter;
> +                 tupleid = NULL;
>                   estate->es_result_relation_info = resultRelInfo;
> Er, what is that?

That fixes the bug when tupleid from regular tuple is used to get
oldtuple for triggers of foreign table.

-- 
---
Ildus Kurbangaliev
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (43+ messages)  latest in thread

Message-ID: <20170517115437.710dedb9@wp.localdomain>
Permalink:  ../20170517115437.710dedb9@wp.localdomain/
Also on:    postgresql.org/message-id/20170517115437.710dedb9@wp.localdomain

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: i.kurbangaliev@postgrespro.ru, michael.paquier@gmail.com, fujita.etsuro@lab.ntt.co.jp, ashutosh.bapat@enterprisedb.com, dilipbalaut@gmail.com
  Subject: Re: Bug in ExecModifyTable function and trigger issues for foreign tables
  In-Reply-To: <20170517115437.710dedb9@wp.localdomain>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox