From: Andrei Lepikhov <lepihov@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18576: Using EXPLAIN (VERBOSE) in information_schema.element_types returns ERROR: failed to find plan for
Date: Mon, 19 Aug 2024 13:23:51 +0200
Message-ID: <332f0e30-f90a-4e47-b668-b53f649c244f@gmail.com> (raw)
In-Reply-To: <2799439.1723217127@sss.pgh.pa.us>
References: <18576-9feac34e132fea9e@postgresql.org>
<CAMbWs49gOeyotM7riJ-q_NgLgfA6-3z7DffnR71kSyaHTkh2ig@mail.gmail.com>
<2336091.1723137115@sss.pgh.pa.us>
<2493069.1723149304@sss.pgh.pa.us>
<CAMbWs4_Au2i+p2MbZ8nNB_QQXrFy65CXNeJL11j2WJbNW18fHQ@mail.gmail.com>
<2548861.1723174234@sss.pgh.pa.us>
<2799439.1723217127@sss.pgh.pa.us>
On 9/8/2024 17:25, Tom Lane wrote:
> I wrote:
>> Richard Guo <guofenglinux@gmail.com> writes:
>>> Agreed. Do you think it would be helpful to add some assertions to
>>> verify the plan type?
>
>> I thought about that but didn't experiment with it. I wonder whether
>> it'd just make the code more fragile. Still, it might be useful to
>> verify that things are happening as we expect.
>
> After sleeping on it, I elected to add the Asserts as suggested,
> except in v12 where they'd have had to look different. That's
> not strictly a matter of laziness: v12's next release will be its
> last, and I've been burned often enough to become very hesitant
> about pushing even slightly-questionable code into an EOL release.
Thanks for pushing this!
But could you change this code a little bit?
I reported this issue a year ago. At that time, it was triggered by the
CustomScan node [1]. I haven't found the solution there [2]. Your code
looks like a good tradeoff, and if you slightly change the code (like in
the attachment), it allows CustomScan to survive such cases.
[1]
https://www.postgresql.org/message-id/3933834e-b657-4ad1-bf4e-5f3fbba7ba14%40app.fastmail.com
[2]
https://www.postgresql.org/message-id/0cbbd87e-1b57-4b7e-9825-19a6fb2f8670%40postgrespro.ru
--
regards, Andrei Lepikhov
Attachments:minor_fix.diff (text/plain, 1.2K) downloaddiff --git a/contrib/Makefile b/contrib/Makefileindex abd780f277..c68aa7be00 100644--- a/contrib/Makefile+++ b/contrib/Makefile@@ -6,6 +6,7 @@ include $(top_builddir)/src/Makefile.global
SUBDIRS = \
amcheck \
+ pg_extension \
auth_delay \
auto_explain \
basic_archive \
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.cindex 4039ee0df7..2728e35105 100644--- a/src/backend/utils/adt/ruleutils.c+++ b/src/backend/utils/adt/ruleutils.c@@ -7914,7 +7914,8 @@ get_name_for_var_field(Var *var, int fieldno,
{
char *dummy_name = palloc(32);
- Assert(dpns->plan && IsA(dpns->plan, Result));+ Assert(dpns->plan && (IsA(dpns->plan, Result) ||+ IsA(dpns->plan, CustomScan)));
snprintf(dummy_name, 32, "f%d", fieldno);
return dummy_name;
}
@@ -8045,7 +8046,8 @@ get_name_for_var_field(Var *var, int fieldno,
{
char *dummy_name = palloc(32);
- Assert(dpns->plan && IsA(dpns->plan, Result));+ Assert(dpns->plan && (IsA(dpns->plan, Result) ||+ IsA(dpns->plan, CustomScan)));
snprintf(dummy_name, 32, "f%d", fieldno);
return dummy_name;
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: lepihov@gmail.com, tgl@sss.pgh.pa.us, guofenglinux@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18576: Using EXPLAIN (VERBOSE) in information_schema.element_types returns ERROR: failed to find plan for
In-Reply-To: <332f0e30-f90a-4e47-b668-b53f649c244f@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox