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 1qqDJF-008cyl-DR for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Oct 2023 14:02:06 +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 1qqDJC-007yhK-CQ for pgsql-bugs@arkaria.postgresql.org; Tue, 10 Oct 2023 14:02:03 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qqDJB-007yhB-Ur for pgsql-bugs@lists.postgresql.org; Tue, 10 Oct 2023 14:02:03 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qqDJ7-000xcw-H0 for pgsql-bugs@lists.postgresql.org; Tue, 10 Oct 2023 14:02:01 +0000 Received: from [10.4.15.8] (unknown [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.rybakina@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id E722AE203CF; Tue, 10 Oct 2023 17:01:54 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1696946515; bh=kJ14hjFED42sob44pBEabyHuoo7+cn57zht4uuuo5G0=; h=Message-ID:Date:User-Agent:From:Subject:To:Cc:References: In-Reply-To:From; b=FiXGw1mq1OWEI/oUfVW+vpb/uAxQs+pdPtvhFBYKdJYCB1onHbP/UvQZVHWhzZWRM E5gMwSuoZD6zbmJsder2GYVgUlDeDLmiZaT+lyANefnMeoJ+T6/xT2vnfkgxlSMstw ZHvvKRMbmZTbSA+O1fLguix+87BvohOw4XwnNyuFdsREKFtaaUTNfTveCz6IuMQamN UNtm2OhMk78j6A08tZlAH5LJJ7DfCGg7sifq5IyYAULosDC5wSju2qUZmeoH1JoFEf tb7UWieVctqwCJ4Yena+KO9ZqPnE5w+zpCJ0FOzIZxnoDn4K0yNfM3VNjcwip0uZRH Dfu0sSM6V1nZg== Content-Type: multipart/alternative; boundary="------------fMeiClYh2OPYj6nDsIkEoiCA" Message-ID: Date: Tue, 10 Oct 2023 17:01:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: "a.rybakina" Subject: Re: EXPLAIN Verbose issue - custom_scan_tlist can directly refer CTE and Subquery To: Lepikhov Andrei Cc: pgsql-bugs@lists.postgresql.org, =?UTF-8?B?0JTQsNC80LjRgCDQkdC10LvRj9C7?= =?UTF-8?B?0L7Qsg==?= , Richard Guo , Andrei Lepikhov References: <0cbbd87e-1b57-4b7e-9825-19a6fb2f8670@postgrespro.ru> Content-Language: en-US In-Reply-To: <0cbbd87e-1b57-4b7e-9825-19a6fb2f8670@postgrespro.ru> 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. --------------fMeiClYh2OPYj6nDsIkEoiCA Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 09.10.2023 11:41, Andrei Lepikhov wrote: > After some attempts to resolve this issue, I must admit that we should > add a non-trivial method in the CustomScan node interface, which would > be called in the ruleutils code. > I guess it is too much for such a rare situation. So maybe just add a > documentation entry on this thing and set a couple of assertions on > early detection of problems?. > In the attachment - is an offer on how to change the code. > Hi! I have studied the problem and I agree with your suggestion to disable the possibility of explaining subqueries in CustomNode for now. So far I can only find information about HashJoin and ValueScan, but I expected that this is not what is needed. (gdb) p *((Plan *)(cscan->custom_plans->elements[0].ptr_value))->lefttree $29 = {type = T_ValuesScan, startup_cost = 0, total_cost = 0.025000000000000001, plan_rows = 2, plan_width = 4, parallel_aware = false, parallel_safe = true, async_capable = false, plan_node_id = 0,   targetlist = 0x560fc9979398, qual = 0x0, lefttree = 0x0, righttree = 0x0, initPlan = 0x0, extParam = 0x0, allParam = 0x0} (gdb) p *((Plan *)(cscan->custom_plans->elements[0].ptr_value)) $30 = {type = T_HashJoin, startup_cost = 0.050000000000000003, total_cost = 0.10250000000000001, plan_rows = 2, plan_width = 32, parallel_aware = false, parallel_safe = false, async_capable = false,   plan_node_id = 0, targetlist = 0x560fc9979208, qual = 0x0, lefttree = 0x560fc9979438, righttree = 0x560fc9979958, initPlan = 0x0, extParam = 0x0, allParam = 0x0} (gdb) p *((Plan *)(cscan->custom_plans->elements[0].ptr_value))->righttree $31 = {type = T_Hash, startup_cost = 0.025000000000000001, total_cost = 0.025000000000000001, plan_rows = 2, plan_width = 32, parallel_aware = false, parallel_safe = false, async_capable = false,   plan_node_id = 0, targetlist = 0x560fc9979518, qual = 0x0, lefttree = 0x560fc9979698, righttree = 0x0, initPlan = 0x0, extParam = 0x0, allParam = 0x0} (gdb) p *((Plan *)(cscan->custom_plans->elements[0].ptr_value))->lefttree $32 = {type = T_ValuesScan, startup_cost = 0, total_cost = 0.025000000000000001, plan_rows = 2, plan_width = 4, parallel_aware = false, parallel_safe = true, async_capable = false, plan_node_id = 0,   targetlist = 0x560fc9979398, qual = 0x0, lefttree = 0x0, righttree = 0x0, initPlan = 0x0, extParam = 0x0, allParam = 0x0} --------------fMeiClYh2OPYj6nDsIkEoiCA Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit On 09.10.2023 11:41, Andrei Lepikhov wrote:
After some attempts to resolve this issue, I must admit that we should add a non-trivial method in the CustomScan node interface, which would be called in the ruleutils code.
I guess it is too much for such a rare situation. So maybe just add a documentation entry on this thing and set a couple of assertions on early detection of problems?.
In the attachment - is an offer on how to change the code.

Hi!

I have studied the problem and I agree with your suggestion to disable the possibility of explaining subqueries in CustomNode for now.

So far I can only find information about HashJoin and ValueScan, but I expected that this is not what is needed.

(gdb) p *((Plan *)(cscan->custom_plans->elements[0].ptr_value))->lefttree
$29 = {type = T_ValuesScan, startup_cost = 0, total_cost = 0.025000000000000001, plan_rows = 2, plan_width = 4, parallel_aware = false, parallel_safe = true, async_capable = false, plan_node_id = 0,
  targetlist = 0x560fc9979398, qual = 0x0, lefttree = 0x0, righttree = 0x0, initPlan = 0x0, extParam = 0x0, allParam = 0x0}
(gdb) p *((Plan *)(cscan->custom_plans->elements[0].ptr_value))
$30 = {type = T_HashJoin, startup_cost = 0.050000000000000003, total_cost = 0.10250000000000001, plan_rows = 2, plan_width = 32, parallel_aware = false, parallel_safe = false, async_capable = false,
  plan_node_id = 0, targetlist = 0x560fc9979208, qual = 0x0, lefttree = 0x560fc9979438, righttree = 0x560fc9979958, initPlan = 0x0, extParam = 0x0, allParam = 0x0}
(gdb) p *((Plan *)(cscan->custom_plans->elements[0].ptr_value))->righttree
$31 = {type = T_Hash, startup_cost = 0.025000000000000001, total_cost = 0.025000000000000001, plan_rows = 2, plan_width = 32, parallel_aware = false, parallel_safe = false, async_capable = false,
  plan_node_id = 0, targetlist = 0x560fc9979518, qual = 0x0, lefttree = 0x560fc9979698, righttree = 0x0, initPlan = 0x0, extParam = 0x0, allParam = 0x0}
(gdb) p *((Plan *)(cscan->custom_plans->elements[0].ptr_value))->lefttree
$32 = {type = T_ValuesScan, startup_cost = 0, total_cost = 0.025000000000000001, plan_rows = 2, plan_width = 4, parallel_aware = false, parallel_safe = true, async_capable = false, plan_node_id = 0,
  targetlist = 0x560fc9979398, qual = 0x0, lefttree = 0x0, righttree = 0x0, initPlan = 0x0, extParam = 0x0, allParam = 0x0}
--------------fMeiClYh2OPYj6nDsIkEoiCA--