Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lnjFj-0001dZ-Ir for pgsql-bugs@arkaria.postgresql.org; Mon, 31 May 2021 14:50:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lnjFi-0005z2-3j for pgsql-bugs@arkaria.postgresql.org; Mon, 31 May 2021 14:50:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1lnjFh-0005yt-Qw for pgsql-bugs@lists.postgresql.org; Mon, 31 May 2021 14:50:49 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1lnjFg-0002tu-7F for pgsql-bugs@lists.postgresql.org; Mon, 31 May 2021 14:50:49 +0000 Received: by mail-ed1-x536.google.com with SMTP id i13so13749751edb.9 for ; Mon, 31 May 2021 07:50:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Wi15+Ec4e0kCEStQghDXNeXwN8ZqIRFtXWedAq8K3VE=; b=NkqIHXq7KyOcyLfyrG2mLH8P624HmEmaKMCTv2aYDO3Onzx0BntEpPVjECArC0+DsA 0YIxzDaRvjD796kA3NraPekxYkyPwvFuCpwGupBE5Vd+MMsy1/COH2jcFaEzxIq7NQfi r7atIPwqg2lyoBLaTu7Pz07bYVuxlpVte36+E1DORpPq5cIcbxX+iJXuGxhaSecl7tf1 nK9TMRstI94KDBNtJORfvnTCNzqRFfoNhUKAHDk9W28fB2gcIB2PrmIkDbm4X2gbP2H+ M1q7oIgy05zqpzGZtZjEKs8yVHVQoENFBr6fN2GdX3Z/pc9GIOQs9dt4hqlpKbUcg988 FBLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Wi15+Ec4e0kCEStQghDXNeXwN8ZqIRFtXWedAq8K3VE=; b=Rfyxbg7GgaWVrNS3B7ereZnVYhPDw9Gqv2I0wlNxg6kGn8ftg5uo8L8CV9JU3OCMsu o8m6BYov+6/7/i8fVHDkIZgP5gC3D8kI7aNi3zTkZts7bM35FVSHHCmIjYhd7ezH4G7F Jd65U+xoyRp8UP99BRwlmYniJfwRB8ZAEC8v2K4/1YwaqqQJWZeNMQvgVKpwgMKm7XW5 9rUyw4VkCzlaqkeMwp9i/0jwrsSUP9uNxduPDJWsbbsgF4mCXFsGRf5nMlv0yYI83enq nOhMJm2LCvlbz74oH/kkXO6s59qvTh8yRgNgD99EijnI1qFVN4U4AWSX6Z3zmEOZJI6a Gw0w== X-Gm-Message-State: AOAM532S3etrAy+ju36efdNj21KYdZj5uSPB5Hs5GP6k5mBiRw2MnjUz tcBQCTDFuOroV+dJNIWudAs= X-Google-Smtp-Source: ABdhPJz1gSkUV+gQCB/8h3PIC8nhOkX2kNF03IrJo4/DB88eUB6kvpnhNDqzu7VuYLod2eGcBpS4rQ== X-Received: by 2002:a05:6402:4310:: with SMTP id m16mr25923645edc.279.1622472647069; Mon, 31 May 2021 07:50:47 -0700 (PDT) Received: from localhost (dslb-178-012-047-165.178.012.pools.vodafone-ip.de. [178.12.47.165]) by smtp.gmail.com with ESMTPSA id r17sm6981712edt.33.2021.05.31.07.50.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 May 2021 07:50:46 -0700 (PDT) Date: Mon, 31 May 2021 16:51:31 +0200 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Tom Lane Cc: "Poot, Bas (B.J.)" , "pgsql-bugs@lists.postgresql.org" Subject: Re: XX000: unknown type of jsonb container. Message-ID: <20210531145131.b34sjhhgj7xkq36w@localhost> References: <534fca83789c4a378c7de379e9067d4f@politie.nl> <20210407181105.lmi7hgifwzs3eeee@localhost> <20210413161500.kufk4iyrmcmhhbrc@localhost> <20210423151505.lxx5ti7ivcza3xqw@localhost> <2433209.1622416353@sss.pgh.pa.us> <2491424.1622422768@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2491424.1622422768@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Sun, May 30, 2021 at 08:59:28PM -0400, Tom Lane wrote: > > Of course, it's not like the planner has never heard of that restriction. > The problem occurs because what arrives at createplan.c looks like > > ProjectionPath > ProjectionPath > SortPath > SeqScanPath > > that is, we've got *two* redundant ProjectionPaths, and the logic in > createplan.c that is supposed to decide whether we can skip generating > a projecting Result node for a ProjectionPath gets confused and > decides we don't need any Result, rather than deciding we need one > Result. > > Maybe we could work around that, but having two stacked ProjectionPaths > is just silly, so the attached patch deals with this problem by making > sure we don't do that. > > The place where that happens in the example reported in this thread is > apply_projection_to_path, which somebody kluged up to the point where > it'd create this situation just below a Gather/GatherMerge node. > So I first tried to fix it there, and for safety added an Assert to > create_projection_path saying that its input wasn't a ProjectionPath. > > The Assert blew up the regression tests. The same thing is happening > in other places, and only by luck have we not noticed any bad effects. > > So the attached fixes it by stripping any input ProjectionPath in > create_projection_path, instead. Thanks for looking into this. I don't see any problems with the suggested patch, so +1. > This test case only fails back to v13, as does the original example. > I suspect we should back-patch the code change further though, > since create_projection_plan will be just as confused by such cases > in earlier branches. That would be my assumption as well.