From: | Richard Guo <guofenglinux(at)gmail(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alexandra Wang <alexandra(dot)wang(dot)oss(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "bruce(at)momjian(dot)us" <bruce(at)momjian(dot)us>, lepihov(at)gmail(dot)com |
Subject: | Re: plan shape work |
Date: | 2025-09-30 01:59:10 |
Message-ID: | CAMbWs48Bn1FkiBt0nvwGzM-xs9-0jbCAhbExNg3WX3Nj1=+9SA@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Sep 29, 2025 at 11:12 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Mon, Sep 29, 2025 at 4:52 AM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> > It seems no one has attempted to code up the approach I suggested, so
> > I went ahead and did it; please see the attached PoC patch. It's just
> > a proof of concept to show what I have in mind, so please excuse the
> > lack of comments and necessary assertions for now.
> I think that if there are subqueries named expr_1 and expr_3, this
> will assign the name expr_4 next, whereas the previous patch assigns
> the name expr_2. That might not be a bug, but it's different and I
> don't like it as well.
>
> I also think that if there are subqueries named expr_1a and expr_2a,
> this will assign the name expr_3 next, whereas the previous patch
> assigns the name expr_1. I would consider that a clear bug.
>
> Your code will also see expr_01 and decide that the next name should
> be expr_2 rather than expr_1. I don't think that's right, either.
>
> I also think that it's a bug that your function sometimes returns a
> value different from the one it appends to canon_names.
I don't think any of the bugs you described upthread exist in the PoC
patch. The patch ensures that all names stored in glob->subplanNames
are canonicalized to the format "$basename_$suffixnum". If no numeric
suffix is required, the name is stored with a "_0" suffix. This
guarantees a clear distinction between the base name and the numeric
suffix for all names stored in the list. (Please note that this
canonicalization applies only to how names are stored internally, not
to user-visible names. So no user-visible behavior change here.)
I don't really see how uncanonicalized names like expr_1a, expr_2a, or
expr_01 would appear in the subplanNames list to begin with. Perhaps
you're referring to user-supplied subquery aliases? In that case, the
patch deliberately avoids matching expr to those names, since it only
compares the base name. As a result, it would assign expr_1 as the
next name, which is the expected behavior.
This PoC patch passes all the regression tests, which at least, IMHO,
suggests that it avoids such basic bugs.
However, since both you and Tom feel this proposal doesn't make
sense, I'll withdraw it. Apologies for any trouble this has caused.
- Richard
From | Date | Subject | |
---|---|---|---|
Next Message | Yugo Nagata | 2025-09-30 02:01:58 | Re: Prevent internal error at concurrent CREATE OR REPLACE FUNCTION |
Previous Message | Masahiko Sawada | 2025-09-30 01:58:11 | Re: POC: enable logical decoding when wal_level = 'replica' without a server restart |