From: | Robert Haas <robertmhaas(at)gmail(dot)com> |
---|---|
To: | Richard Guo <guofenglinux(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-10-06 19:13:59 |
Message-ID: | CA+TgmoaDN-RN==sZkLbemGp+QDLkyHgBAz0e28QwKxxuiNkwog@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Sep 29, 2025 at 9:59 PM Richard Guo <guofenglinux(at)gmail(dot)com> wrote:
> 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 studied your patch in more detail today and I find that you are
correct. It doesn't do what I thought it did. However, it also doesn't
guarantee uniqueness. Here is an example:
robert.haas=# explain select (select random() limit 1), (select
random() limit 2) from (select * from pg_class limit 1) expr_1;
WARNING: choose_plan_name for name "expr" returns "expr_1"
WARNING: choose_plan_name for name "expr" returns "expr_2"
WARNING: choose_plan_name for name "expr_1" returns "expr_1"
QUERY PLAN
-------------------------------------------------------------------------
Subquery Scan on expr_1 (cost=0.03..0.08 rows=1 width=16)
InitPlan expr_1
-> Limit (cost=0.00..0.01 rows=1 width=8)
-> Result (cost=0.00..0.01 rows=1 width=8)
InitPlan expr_2
-> Limit (cost=0.00..0.01 rows=1 width=8)
-> Result (cost=0.00..0.01 rows=1 width=8)
-> Limit (cost=0.00..0.04 rows=1 width=240)
-> Seq Scan on pg_class (cost=0.00..18.16 rows=416 width=240)
(9 rows)
When I originally looked at the patch, I believed that the use of
atoi() without sanity checking was going to cause the sorts of
problems I was mentioning. That was wrong, since you never let a
user-specified name leak directly into the list, but only names to
which your code has added a numeric suffix. But that also means that
you don't get conflicts between names that, in reality, should
conflict.
--
Robert Haas
EDB: http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Nathan Bossart | 2025-10-06 19:16:46 | Re: get rid of RM_HEAP2_ID |
Previous Message | Kirill Reshke | 2025-10-06 19:02:21 | Re: GiST nitpicks I want to discuss (and maybe eventually fix) |