Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtkou-0003em-Ec for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Feb 2019 03:02:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gtkot-00083r-3w for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Feb 2019 03:02:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gtkos-00083j-QS for pgsql-bugs@lists.postgresql.org; Wed, 13 Feb 2019 03:02:42 +0000 Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gtkoo-0002Yy-Up; Wed, 13 Feb 2019 03:02:41 +0000 Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x1D32ZpU002445; Wed, 13 Feb 2019 12:02:36 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id E6CA2EA78D2; Wed, 13 Feb 2019 12:02:35 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id DC14BEA789A; Wed, 13 Feb 2019 12:02:35 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id D678340065A; Wed, 13 Feb 2019 12:02:35 +0900 (JST) Subject: Re: BUG #15623: Inconsistent use of default for updatable view References: <15623-5d67a46788ec8b7f@postgresql.org> <952caeff-2cc7-6db9-1f2b-418442b51045@lab.ntt.co.jp> From: Amit Langote Message-ID: Date: Wed, 13 Feb 2019 12:02:25 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 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: Dean Rasheed , Amit Langote Cc: Roger Curley , pgsql-bugs@lists.postgresql.org, PG Bug reporting form X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Dean, On 2019/02/12 19:33, Dean Rasheed wrote: > On Sun, 10 Feb 2019 at 11:18, Dean Rasheed wrote: >> On Sun, 10 Feb 2019 at 00:48, Dean Rasheed wrote: >>> However, this is still not the end of the story, because it doesn't >>> fix the fact that, if the view has a DO ALSO rule on it, single-row >>> inserts behave differently from multi-row inserts. In that case, each >>> insert becomes 2 inserts, and defaults need to be treated differently >>> in each of the 2 queries. That's going to need a little more thought. >>> >> >> Here's an updated patch to handle that case. >> >> In case it's not obvious, I'm not intending to try to get this into >> next week's updates -- more time is needed to be sure of this fix. > > So I did some more testing of this and I'm reasonably happy that this > now fixes the originally reported issue of inconsistent handling of > DEFAULTS in multi-row VALUES lists vs single-row ones. I tested > various other scenarios involving conditional/unconditional > also/instead rules, and I didn't find any other surprises. Attached is > an updated patch with improved comments, and a little less code > duplication. Thanks for updating the patch. I can't really comment on all of the changes that that you made considering various cases, but became curious if the single-row and multi-row inserts cases could share the code that determines if the DEFAULT item be replaced by the target-relation-specified default or NULL? IOW, is there some reason why we can't avoid the special handling for the multi-row (RTE_VALUES) case? Thanks, Amit