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 1fZvQ6-0005Qg-Vv for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Jul 2018 09:46:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fZvQ4-0005YG-T1 for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Jul 2018 09:46:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fZvQ4-0005Y8-MJ for pgsql-hackers@lists.postgresql.org; Mon, 02 Jul 2018 09:46:52 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fZvQ0-00055t-Q5 for pgsql-hackers@postgresql.org; Mon, 02 Jul 2018 09:46:52 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w629kjAc027160; Mon, 2 Jul 2018 18:46:45 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 83D5A63935E; Mon, 2 Jul 2018 18:46:45 +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 7885E639394; Mon, 2 Jul 2018 18:46:45 +0900 (JST) Received: from [IPv6:::1] (unknown [129.60.241.75]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 72D03400216; Mon, 2 Jul 2018 18:46:45 +0900 (JST) Message-ID: <5B39F47B.10707@lab.ntt.co.jp> Date: Mon, 02 Jul 2018 18:46:35 +0900 From: Etsuro Fujita User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 MIME-Version: 1.0 Subject: Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled. References: <5AE84FBF.3040905@lab.ntt.co.jp> <5AF2E09F.9060208@lab.ntt.co.jp> <5AF440C2.3040805@lab.ntt.co.jp> <5AF59415.10309@lab.ntt.co.jp> <5AFC0865.8050802@lab.ntt.co.jp> <5AFD6580.5090308@lab.ntt.co.jp> <5AFE81CC.8000508@lab.ntt.co.jp> <5B17C5EC.1090602@lab.ntt.co.jp> <5B1E5071.1000704@lab.ntt.co.jp> <5B23A964.9020800@lab.ntt.co.jp> <5B28FB19.3090809@lab.ntt.co.jp> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-CC-Mail-RelayStamp: 1 To: Robert Haas Cc: Ashutosh Bapat , Rajkumar Raghuwanshi , pgsql-hackers X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk (2018/06/22 23:58), Robert Haas wrote: > I think this approach is going to run into trouble if the level at > which we have to apply the ConvertRowTypeExpr happens not to be a > projection-capable node. Actually, the level we have to do that would be a child rel of a partitioned table or a child join of a partitionwise join, so the plan node would be a scan or join plan unless the child rel or child join is itself partitioned, in which case the plan node would be Append/MergeAppend and the proposed patch recursively would apply that conversion to child plans for the Append/MergeAppend). > And, in general, it seems to me that we want > to produce the right outputs at the lowest possible level of the plan > tree. For instance, suppose that one of the relations being scanned > is not parallel-safe but the others are. Then, we could end up with a > plan like this: > > Append > -> Seq Scan on temp_rela > -> Gather > -> Parallel Seq Scan on thing1 > -> Gather > -> Parallel Seq Scan on thing2 > > If a projection is required to convert the row type expression, we > certainly want that to get pushed below the Gather, not to happen at > the Gather level itself. IIUC, we currently don't consider such a plan for partition-wise join; we'll only consider gathering partial paths for the parent appendrel. So, I'm not sure we need to take into account that when applying the ConvertRowtypeExpr. Maybe I'm missing something, though. > We certainly don't want it to happen at the > Append level, which can't even handle it. I think so too. Best regards, Etsuro Fujita