pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru>
To: 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>
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: Bug in ExecModifyTable function and trigger issues for foreign tables
Date: Thu, 15 Jun 2017 18:05:48 +0300
Message-ID: <20170615180548.5e142ddc@wp.localdomain> (raw)
In-Reply-To: <a31f779e-9cb8-1ea5-71a6-bca6adbfa6a4@lab.ntt.co.jp>
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>
	<f62d1797-2817-0f2e-eb7b-38da40504c8d@lab.ntt.co.jp>
	<a31f779e-9cb8-1ea5-71a6-bca6adbfa6a4@lab.ntt.co.jp>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

On Mon, 5 Jun 2017 17:25:27 +0900
Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp> wrote:

> On 2017/06/02 18:10, Etsuro Fujita wrote:
> > On 2017/05/16 21:36, Etsuro Fujita wrote:  
> >> 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.  
> > 
> > While updating the patch, I noticed the patch rewrites the UPDATE 
> > targetList incorrectly in some cases; rewrite_inherited_tlist I
> > added to adjust_appendrel_attrs (1) removes all junk items from the
> > targetList and (2) adds junk items for the child table using
> > rewriteTargetListUD, but it's wrong to drop all junk items in cases
> > where there are junk items for some other reasons than
> > rewriteTargetListUD.  Consider junk items containing MULTIEXPR
> > SubLink.  One way I came up with to fix this is to change (1) to
> > only remove junk items with resname; since junk items added by
> > rewriteTargetListUD should have resname (note: we would need
> > resname to call ExecFindJunkAttributeInTlist at execution time!)
> > while other junk items wouldn't have resname (see
> > transformUpdateTargetList), we could correctly replace junk items
> > added by rewriteTargetListUD for the parent with ones for the
> > child, by that change.  I might be missing something, though.
> > Comments welcome.  
> 
> I updated the patch that way.  Please find attached an updated
> version.
> 
> Other changes:
> * Moved the initialization for "tupleid" I added in ExecModifyTable
> as discussed before, which I think is essentially the same as
> proposed by Ildus in [1], since I think that would be more consistent
> with "oldtuple".
> * Added regression tests.
> 
> Anyway I'll add this to the next commitfest.
> 
> Best regards,
> Etsuro Fujita
> 
> [1] 
> https://www.postgresql.org/message-id/20170514150525.0346ba72%40postgrespro.ru

Checked the latest patch. Looks good.
Shouldn't this patch be backported to 9.6 and 10beta? The bug
affects them too.

-- 
---
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: <20170615180548.5e142ddc@wp.localdomain>
Permalink:  ../20170615180548.5e142ddc@wp.localdomain/
Also on:    postgresql.org/message-id/20170615180548.5e142ddc@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, fujita.etsuro@lab.ntt.co.jp, ashutosh.bapat@enterprisedb.com, dilipbalaut@gmail.com, robertmhaas@gmail.com
  Subject: Re: Bug in ExecModifyTable function and trigger issues for foreign tables
  In-Reply-To: <20170615180548.5e142ddc@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