Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fkJCt-00070U-6K for pgsql-bugs@arkaria.postgresql.org; Tue, 31 Jul 2018 01:12:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fkJCq-0000ag-Uc for pgsql-bugs@arkaria.postgresql.org; Tue, 31 Jul 2018 01:12:08 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fkJCq-0000aJ-L5 for pgsql-bugs@lists.postgresql.org; Tue, 31 Jul 2018 01:12:08 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fkJCn-0007Ca-9k for pgsql-bugs@lists.postgresql.org; Tue, 31 Jul 2018 01:12:07 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w6V1C0lU001069; Tue, 31 Jul 2018 10:12:00 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 9CF156386BA; Tue, 31 Jul 2018 10:12:00 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 9197F6386AD; Tue, 31 Jul 2018 10:12:00 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 7772A4009C9; Tue, 31 Jul 2018 10:12:00 +0900 (JST) Subject: Re: Fwd: Problem with a "complex" upsert References: <18795.1529600753@sss.pgh.pa.us> <8da3739d-da24-1125-cab6-b68d6ec1bc6a@lab.ntt.co.jp> <30415.1531256373@sss.pgh.pa.us> From: Amit Langote Message-ID: <2d65f4a8-9a15-7ab6-cb39-d7347deaacd5@lab.ntt.co.jp> Date: Tue, 31 Jul 2018 10:11:51 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Peter Geoghegan , Tom Lane Cc: Mario De Frutos Dieguez , PostgreSQL mailing lists X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018/07/31 7:53, Peter Geoghegan wrote: > On Tue, Jul 10, 2018 at 1:59 PM, Tom Lane wrote: >>> I tried debugging why that happens and concluded that rewriteTargetView >>> fails to *completely* account for the fact that the view's column's may >>> have different attribute numbers than the underlying table that the DO >>> UPDATE action will be applied to. Especially, even if the view's Vars are >>> replaced with those corresponding underlying base table's columns, the >>> TargetEntry's into which those Vars are contained are not refreshed, that >>> is, their resnos don't match varattnos. >> >>> I created a patch that seems to fix the issue, which also adds a >>> representative test in updatable_view.sql. >> >> Hm. I looked at this patch a bit. While the onConflictSet change looks >> reasonable, I find the exclRelTlist change fishy. Shouldn't those resnos >> correspond to the exclRelTlist's *own* vars, independently of what is or >> isn't in the view_targetlist? And why is it OK to ignore failure to find >> a match? > > Any update on this, Amit? I would like to get this one out of the way soon. This has slipped my mind. I will look into updating the patch today. Thanks, Amit