Re: Making the subquery alias optional in the FROM clause

From: Zhihong Yu <zyu(at)yugabyte(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Making the subquery alias optional in the FROM clause
Date: 2022-07-09 11:30:32
Message-ID: CALNJ-vTtWek+n_K0ii2JxOJEMvo0ttDXrT5E798-uf9Dznv1vQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Jul 9, 2022 at 3:28 AM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
wrote:

> On Wed, 6 Jul 2022 at 15:09, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
> wrote:
> >
> > I'll post an update in a little while, but first, I found a bug, which
> > revealed a pre-existing bug in transformLockingClause(). I'll start a
> > new thread for that, since it'd be good to get that resolved
> > independently of this patch.
> >
>
> Attached is an update with the following changes:
>
> * Docs updated as suggested.
> * transformLockingClause() updated to skip subquery and values rtes
> without aliases.
> * eref->aliasname changed to "unnamed_subquery" for subqueries without
> aliases.
>
> Regards,
> Dean
>
Hi,
rtename is assigned at the beginning of the loop:

+ char *rtename = rte->eref->aliasname;

It seems the code would be more readable if you keep the assignment in
else block below:

+ else if (rte->rtekind == RTE_SUBQUERY ||
+ rte->rtekind == RTE_VALUES)
continue;
- rtename = rte->join_using_alias->aliasname;
}
- else
- rtename = rte->eref->aliasname;

because rtename would be assigned in the `rte->rtekind == RTE_JOIN` case.

Cheers

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2022-07-09 12:04:57 Re: Use extended statistics to estimate (Var op Var) clauses
Previous Message Dean Rasheed 2022-07-09 10:28:20 Re: Making the subquery alias optional in the FROM clause