Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uTJMq-002mxd-4y for pgsql-bugs@arkaria.postgresql.org; Sun, 22 Jun 2025 12:00:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uTJMl-00CfC9-S3 for pgsql-bugs@arkaria.postgresql.org; Sun, 22 Jun 2025 12:00:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uTJMl-00CfC0-H3 for pgsql-bugs@lists.postgresql.org; Sun, 22 Jun 2025 12:00:08 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uTJMj-003T5A-2t for pgsql-bugs@lists.postgresql.org; Sun, 22 Jun 2025 12:00:07 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-45348bff79fso37181015e9.2 for ; Sun, 22 Jun 2025 05:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750593602; x=1751198402; darn=lists.postgresql.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=MJP5J/RlYyDuUg0xQkRaffgQ7TIUf8Q28EpHJchRQ0w=; b=NYQkZC96Zprj9yXh3Ac6cYr+ejH1V+4q7CheHkFL/BCFeHO4EkgC/5lEMIWVuCi6aD yt+rCkKjgETIGMYQAyPVBuKAXQkM1smIT4d3MafafeT+wW8lk6pYhAGSax3tVOFPc4CT vWK0fPeTlwcliPB+Y/lVDqZAJBMl+oeRFAf/UByt9XZi8LJOhDn3l+fqs3BuxNGHPYs2 /NFd3OcJ/yZJymYSKoYotIKnWUy4LPUuT3B8cvjDMuoR6yNHxB7Dsa+MoD5yrthE0kwv htzrMNSL3f2YQ1XQwQp3EWnHae/jfWgXY/OOWJ7cyLm4J18LaSAQw0zsWFhHKlLlds7+ ec5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750593602; x=1751198402; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=MJP5J/RlYyDuUg0xQkRaffgQ7TIUf8Q28EpHJchRQ0w=; b=ZsXl3NnInavZ6zHsyXbXcogD//RyHxRTF87qyKZhKTru3VBUs6slL1OVgahfBs2H+3 OFZ1vhb6mIQrc7jL6UcT8xyHf2UMaLy5DyGdYei29EQG1RslXqod1+waRz+IAHf3y1Hg gBuFXf+TypcXKLpQf+SmHJ73jjfkWwxBACFy2H0F02LiGg+CNXhx4sWC9r0kp4hnl2NM aQfeumkPYO0OYpcPBuYqZkfIiCS5rwIi5MaIfrsVpAgsJjfKm3Q4CyvCCXqx3TOLBl4I U/jZ7tyQSVeAFJtmcv63dTSq5iLB8pQKdko26TjQ8nQiwJ5xioz4bd2ZoLxgsgNu6N8w g+Cg== X-Gm-Message-State: AOJu0YxNK7P4aINmbXWmwsjN2aeTOMUkXE4IDI6YdxQbfwFM/TQW39Zw eurOu7mV1CtCjl81PE4VRfktuNOxeE2nG+iHAZNZxSR1pDrYgVc1MLf36GjXWgt+ X-Gm-Gg: ASbGncteJxbkGGBU35K5RzhgZXfp15fUh9sbWTYSmHVRofUCMPDoChh6De+3P+R08MQ 1L0usSZBWHeZV+28mwmFZpezJENKL2S7Fao6eScoZB5+HnIw2awrI+CTEDDGL7ACre37VIDatR0 veH4HomXHt74hHsUG1j1TEZSnXxVWeIxCK8dHCSFAJD30NmFUlmM/rqaqtQwAlb8pX50PfBSzkc EtvaJeysYGW6xXVlKxM1wEK/sJaZuEdzyO6i8eubWILxTDQc9qmRLWbQzSqSl2EMwQySXES0OxE L6chWaIehCYwxs5o0cGTimAUOrwARPopBk2kyiwuV7iJzb63rGVoilaae30TLRiX8A== X-Google-Smtp-Source: AGHT+IETTwcxBerlGNEevHvz9H1urJV4wwW28Q5DbzN+Mnm2NUlP9yNHhpcuxPjM3FXWPGy0+MeH6Q== X-Received: by 2002:adf:9d8c:0:b0:3a4:d6ed:8e00 with SMTP id ffacd0b85a97d-3a6d13178c2mr5788075f8f.33.1750593602315; Sun, 22 Jun 2025 05:00:02 -0700 (PDT) Received: from [192.168.0.50] ([89.149.120.224]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a6d117c073sm6928626f8f.58.2025.06.22.05.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Jun 2025 05:00:01 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------YXoSzJEKmpuskJ3yCOsw4JG0" Message-ID: <837b0dce-b2f3-4811-bccf-f42e8985d6e2@gmail.com> Date: Sun, 22 Jun 2025 15:00:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #18953: Planner fails to build plan for complex query with LATERAL references To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org, Richard Guo References: <18953-1c9883a9d4afeb30@postgresql.org> <1268645.1749765012@sss.pgh.pa.us> <1499514.1749848324@sss.pgh.pa.us> <527134.1750087495@sss.pgh.pa.us> <835659.1750177751@sss.pgh.pa.us> Content-Language: en-US From: Alexander Lakhin In-Reply-To: <835659.1750177751@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------YXoSzJEKmpuskJ3yCOsw4JG0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello Tom, 17.06.2025 19:29, Tom Lane wrote: > So I'm inclined to leave that code as I had it. It's notationally > a bit simpler and it doesn't require assuming that we can ignore > the path's required_outer marking at this stage. If I'm wrong, > someone will eventually find a counterexample and we can fix it > then; the changes won't be large. Please look at the following (simplified version of a query generated by SQLsmith), which produces errors after a16ef313f2: CREATE TABLE t(b bool); ANALYZE t; SELECT 1 FROM t INNER JOIN (SELECT (SELECT true) AS c FROM t, LATERAL (SELECT b LIMIT 1)) ON true RIGHT JOIN (SELECT true) ON true, LATERAL (SELECT b WHERE c LIMIT 1) WHERE t.b; ERROR:  XX000: unrecognized node type: 22 LOCATION:  ExecInitExprRec, execExpr.c:2665 Or a slight variation: SELECT 1 FROM t INNER JOIN (SELECT (SELECT true) AS c FROM t, LATERAL (SELECT 1 LIMIT 1)) ON true RIGHT JOIN (SELECT true) ON true, LATERAL (SELECT b WHERE c LIMIT 1) WHERE t.b; ERROR:  XX000: failed to assign all NestLoopParams to plan nodes LOCATION:  create_plan, createplan.c:372 Best regards, Alexander --------------YXoSzJEKmpuskJ3yCOsw4JG0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello Tom,

17.06.2025 19:29, Tom Lane wrote:
So I'm inclined to leave that code as I had it.  It's notationally
a bit simpler and it doesn't require assuming that we can ignore
the path's required_outer marking at this stage.  If I'm wrong,
someone will eventually find a counterexample and we can fix it
then; the changes won't be large.

Please look at the following (simplified version of a query generated by
SQLsmith), which produces errors after a16ef313f2:
CREATE TABLE t(b bool); ANALYZE t;

SELECT 1 FROM t
INNER JOIN (SELECT (SELECT true) AS c FROM t, LATERAL (SELECT b LIMIT 1)) ON true
RIGHT JOIN (SELECT true) ON true,
LATERAL (SELECT b WHERE c LIMIT 1)
WHERE t.b;
ERROR:  XX000: unrecognized node type: 22
LOCATION:  ExecInitExprRec, execExpr.c:2665

Or a slight variation:
SELECT 1 FROM t
INNER JOIN (SELECT (SELECT true) AS c FROM t, LATERAL (SELECT 1 LIMIT 1)) ON true
RIGHT JOIN (SELECT true) ON true,
LATERAL (SELECT b WHERE c LIMIT 1)
WHERE t.b;
ERROR:  XX000: failed to assign all NestLoopParams to plan nodes
LOCATION:  create_plan, createplan.c:372

Best regards,
Alexander
--------------YXoSzJEKmpuskJ3yCOsw4JG0--