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 1fkwpA-0003K3-4e for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Aug 2018 19:30:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fkwp8-0002H2-41 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Aug 2018 19:30:18 +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 1fkwp7-0002GQ-RC for pgsql-hackers@lists.postgresql.org; Wed, 01 Aug 2018 19:30:17 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fkwp0-0006Os-Gu for pgsql-hackers@postgresql.org; Wed, 01 Aug 2018 19:30:17 +0000 Received: by mail-lf1-x129.google.com with SMTP id a134-v6so14127820lfe.6 for ; Wed, 01 Aug 2018 12:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=S0Cfk6vVmIujwAF7wdHBtI75oHGekxAObYlL3qb7ASc=; b=jJtWoqK/ecsaNfOVdD4nHKGfQ0yuqMSY4W9wATz8Hek4SKsTsrh24aA67/R6ZPRU6h g5FlsdNVdxhPPeqlyAVkm4V2f9uFmZSdV2GCedDseAFPkJ81g43srWy6NW/lqsfuewkA 1shR4kijBPEjZrS0LVn2dhk+/q6XnmesS3OVVC1E/oYHjuTpq5uhF8hBEYqXbw+JOaTG 4oIrvw4v7IM2LfL8rBEAL3HdO+iuXBzKvC90THTcJUGxz/R3HLcQX70RdK1GvBJnLatj iCpHJ7AoIl9SDPdNq9VcA6lcO48NMJOr8Gz1kUqqvjQ6aNGKxnXpDVHeJcHIFLAQ9BaV N3Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=S0Cfk6vVmIujwAF7wdHBtI75oHGekxAObYlL3qb7ASc=; b=OZDT7VC6ILEW1/Ght/oF/7RuMnfzwp7I84RStBJvZ86EWhHXDgFvW7H+O1AeE+OBUs OhlS/qF+Pl7YKjNDUMOxMAOrfMuyz4xdZEzn0JL5BsTg9PlM7oTeVhPSkF3HGw6Ms2Pm 0wJCW/KcdRPkVprniaA7jQX8bSsbC8UNfkypGZlplz/Osis+nynwpUl/dvDmIeLr8Cav 3x2LZsgNeJZ1I6SRxezcJ6jzjUYr0l8nsG0TOoLIDLWVIGIgQZPGJ4xXy8zYC4qo2Rwb jtMV2C0bb+bxQepw1GLumbNdrmt277PMiFVZPBbpCqxUW/R60t/RtVTrmMH8OJkWVKhT HEEg== X-Gm-Message-State: AOUpUlFxA9GER+M4shzx0k4Bsck++JnKim5005VxNk0YcKdEXMBZICPd UNdsVZvT2oUagFVTJwpSRBenPu/Fos0J0HbdKQg= X-Google-Smtp-Source: AAOMgpctkhl5Ghefitpxb/crPfqzmv0cRzWu1ThLwxJOpZmLA9Cjfo23STWlK7RpeWMs60+uJcSZqU+rz0mefyT9hLs= X-Received: by 2002:a19:8f10:: with SMTP id r16-v6mr16154094lfd.92.1533151809310; Wed, 01 Aug 2018 12:30:09 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:e508:0:0:0:0:0 with HTTP; Wed, 1 Aug 2018 12:30:07 -0700 (PDT) In-Reply-To: <5B619D23.4010000@lab.ntt.co.jp> References: <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> <20180703163519.tsigyic5xefunv74@alap3.anarazel.de> <5B3C2A4E.5030901@lab.ntt.co.jp> <5B4F2BE9.3000304@lab.ntt.co.jp> <5B55886F.5090906@lab.ntt.co.jp> <5B5712C8.9030404@lab.ntt.co.jp> <5B59BA55.30200@lab.ntt.co.jp> <5B619D23.4010000@lab.ntt.co.jp> From: Robert Haas Date: Wed, 1 Aug 2018 15:30:07 -0400 Message-ID: Subject: Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled. To: Etsuro Fujita Cc: Andres Freund , Ashutosh Bapat , Rajkumar Raghuwanshi , pgsql-hackers , Tom Lane Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Aug 1, 2018 at 7:44 AM, Etsuro Fujita wrote: > I updated the patch that way. Updated patch attached. I fixed a bug and > did a bit of cleanups as well. Looking this over from a technical point of view, I think it's better than what you proposed before but I still don't agree with the approach. I don't think there is any getting around the fact that converted whole-row vars are going to result in some warts. Ashutosh inserted most of the necessary warts in the original partition-wise join patch, but missed some cases in postgres_fdw; his approach is, basically, to add the matching warts there. Your approach is to rip out all of those warts and insert different ones. You've simplified build_tlist_index_other_vars() and add_placeholders_to_joinrel() and build_joinrel_tlist() to basically what they were before partition-wise join went in. On the other hand, RelOptInfo grows three new fields, set_append_rel_size() ends up more complicated than it was before when you include the node code added in the build_childrel_tlist function it calls, build_child_joinrel() has a different set of complications, and most importantly create_append_path() and create_merge_append_path() now do surgery on their input paths that knows specifically about the converted-whole-row var case. I would be glad to be rid of the stuff that you're ripping out, but in terms of complexity, I don't think we really come out ahead with the stuff you're adding. I'm also still concerned about the design. In your old approach, you were creating the paths with with the wrong target list and then fixing it when you turned the paths into a plan. In your new approach, you're still creating the paths with the wrong target list, but now you're fixing it when you put an Append or MergeAppend path on top of them. I still think it's a bad idea to have anything other than the correct paths in the target list from the beginning. For one thing, what happens if no Append or MergeAppend is ever put on top of them? One way that can happen today is partition-wise aggregate, although I haven't been able to demonstrate a bug, so maybe that's covered somehow. But in general, with your approach, any code that looks at the tlist for a child-join has to know that the tlist is to be used as-is *except that* ConvertRowtypeExpr may need to be inserted. I think that special case could be easy to overlook, and it seems pretty arbitrary. A tlist is a list of arbitrary expressions to be produced; with this patch, we'd end up with the tlist being the list of expressions to be produced in every case *except for* child-joins containing whole-row-vars. I just can't get behind a strange exception like that. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company