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 1fldnl-0005yA-Cm for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Aug 2018 17:23:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fldni-0003lq-8Y for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Aug 2018 17:23:42 +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 1fldnh-0003lj-Ou for pgsql-hackers@lists.postgresql.org; Fri, 03 Aug 2018 17:23:41 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fldna-0004z2-69 for pgsql-hackers@postgresql.org; Fri, 03 Aug 2018 17:23:40 +0000 Received: by mail-lj1-x234.google.com with SMTP id p10-v6so5559853ljg.2 for ; Fri, 03 Aug 2018 10:23:33 -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=LVrBR67OY+wC01fEX9MQb93vvey8gfe2H/ok78PPDVA=; b=P0SU5bW9qB3D16mI7hxuLOzQPiUwa6tz7Des7AFO99RA39tAgxWuXs7ZPBHnanLZp1 JUnto0rW0rJlMVYH3eUW8OmPseb7LZoOjY8Oiz5On3FG+esxY4F9qaXdmzyWaNC7SX94 12cdLvfRFww1rLBtOFEfGGRbz+dkefXxDkW3xOoOF1L6hYtaehRqaqh2+Z8hZeNWtM1Q 8POb7Ch9Ew2SV/ULTakUzToQc1lmioscSlE6cimmuZjFw0FN8KKcwY9lTTBGpR01Aqiy +stidHLwEyrk951jp9o9//lwdcmgCayAQ/Knw2USB+ynOnk97JQo7uzFYRC747JYilS8 z0hg== 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=LVrBR67OY+wC01fEX9MQb93vvey8gfe2H/ok78PPDVA=; b=BX0ugRnKb1PXyi8+sBoQZoK6IyS2N3ojsg2otOQhs6MbWn73uJtuxWa4JwskJYf4E/ 3C9zZK1gp4fYZF/eqz92Ju5w2bkCNin9ptACxE2Mf+L+4G897ocfQmSPcYFQUm5DWkVy pXP6BmLxMVTaJleG+v21A/6UVAFWvVZlcALk5jLTv7KwYsD475uStG1EcFisa4dLEnPQ /1d5XYiImDDPbdSYSJo09MbZhG2MdI7U3ctZ0rYMgX3Jsx/j4aUZtsv0jRIm3tY1WmhT WfYm27ZF1J3o/Tg9Mvox2E9ZNuF/Kn39JUlXfvL9qen6TlKeogDgnb+Bsu6MQihLzyyU aM1A== X-Gm-Message-State: AOUpUlHT9JF6DMDbUslvqWD07hVHEyQgtORfk32/4Fi1GeTzOJR0JMST DW0Hy7TGPWxWkoR1p3mOW0CAVMLiDsRl2OARIME= X-Google-Smtp-Source: AAOMgpfe8q4ynm05t1B3BLPzpSVgwdAu8PBBux3AJ8qHu4LOvgzXLZEeRR1VqSPTPnLlvbUhf6eS0wDjNNMHNCwmVc0= X-Received: by 2002:a2e:4619:: with SMTP id t25-v6mr4939367lja.96.1533317011293; Fri, 03 Aug 2018 10:23:31 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:e508:0:0:0:0:0 with HTTP; Fri, 3 Aug 2018 10:23:29 -0700 (PDT) In-Reply-To: <13665.1533306968@sss.pgh.pa.us> 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> <12308.1533305221@sss.pgh.pa.us> <13665.1533306968@sss.pgh.pa.us> From: Robert Haas Date: Fri, 3 Aug 2018 13:23:29 -0400 Message-ID: Subject: Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled. To: Tom Lane Cc: Etsuro Fujita , Andres Freund , Ashutosh Bapat , Rajkumar Raghuwanshi , pgsql-hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Aug 3, 2018 at 10:36 AM, Tom Lane wrote: > Anyway, what I'm basically suggesting is that we just disable support for > PWJ in the problematic cases in v11. As long as PWJ isn't even on by > default, that's not much of a loss. Obviously we'll want to fix it in the > future, but the hour grows late for v11, and I think either of these > patches would need quite a bit more work to be committable. That's not my first choice, but I'm OK with it. >> There are definitely some things not to like about this approach. In >> particular, I definitely agree that treating a converted whole-row >> reference specially is not very nice. It feels like it might be >> substantially cleaner to be able to represent this idea as a single >> node rather than a combination of ConvertRowtypeExpr and var with >> varattno = 0. Perhaps in the future we ought to consider either (a) >> trying to use a RowExpr for this rather than ConvertRowtypeExpr or (b) >> inventing a new WholeRowExpr node that stores two RTIs, one for the >> relation that's generating the whole-row reference and the other for >> the relation that is controlling the column ordering of the result or >> (c) allowing a Var to represent a whole-row expression that has to >> produce its outputs according to the ordering of some other RTE. But >> I don't think it's wise or necessary to whack that around just to fix >> this bug; it is refactoring or improvement work best left to a future >> release. > > I agree with all of that except your conclusion that it's unnecessary > to do it to fix this bug. I find that entirely unsupported and over- > optimistic, especially in view of the number of iterations Ashutosh > went through trying to fix the fallout from not making a clear > distinction. I don't think that the question of how a converted whole-row expr can really make a difference between being able to fix this bug and not being able to fix this bug. It's just a representational choice. If we decide that a converted whole-row expr is represented as ConvertRowTypeExpr on top of a Var, then we have to check for that. If we revise the representation to use a Var node directly, or to use a new WholeRowVar node, then we'll just need to check for those things instead. I think that the shape of the fix itself does not change. Moreover, it's pretty much a 1:1 mapping. It's not like, say, replacing plans with paths in the whole upper half of the planner, where the representation is different enough that things that would have been very difficult to manage in the old representation become relatively simple in the new one. It's basically just a question of how you spell it. Writing a test for ConvertRowTypeExpr atop Var and using it a bunch of places is not beautiful, and it's certainly going to be marginally slower than a direct test for WholeRowVar or some other representation that bundles the whole thing into one node, but I think it should work just fine, and the representation can be revised later in a separate patch once we agree on an approach. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company