Re: Making the subquery alias optional in the FROM clause

2023-10-02 Thread Tom Lane
Dean Rasheed writes: > On Mon, 2 Oct 2023 at 01:01, Tom Lane wrote: >> Yeah, that's exposing more of the implementation than we really want. > Note that this isn't a new issue, specific to unnamed subqueries. The > same thing happens for unnamed joins: True, and we've had few complaints about

Re: Making the subquery alias optional in the FROM clause

2023-10-02 Thread Dean Rasheed
On Mon, 2 Oct 2023 at 01:01, Tom Lane wrote: > > Erwin Brandstetter writes: > > On Mon, 2 Oct 2023 at 00:33, Dean Rasheed wrote: > >> The only place that exposes the eref's made-up relation name is the > >> existing query deparsing code in ruleutils.c, which uniquifies it and > >> generates SQL

Re: Making the subquery alias optional in the FROM clause

2023-10-01 Thread Tom Lane
Erwin Brandstetter writes: > On Mon, 2 Oct 2023 at 00:33, Dean Rasheed wrote: >> The only place that exposes the eref's made-up relation name is the >> existing query deparsing code in ruleutils.c, which uniquifies it and >> generates SQL spec-compliant output. For example: > I ran into one

Re: Making the subquery alias optional in the FROM clause

2023-10-01 Thread Erwin Brandstetter
On Mon, 2 Oct 2023 at 00:33, Dean Rasheed wrote: > The only place that exposes the eref's made-up relation name is the > existing query deparsing code in ruleutils.c, which uniquifies it and > generates SQL spec-compliant output. For example: > I ran into one other place: error messages.

Re: Making the subquery alias optional in the FROM clause

2022-07-14 Thread Tom Lane
Dean Rasheed writes: > 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. This looks good

Re: Making the subquery alias optional in the FROM clause

2022-07-09 Thread Zhihong Yu
On Sat, Jul 9, 2022 at 5:18 AM Dean Rasheed wrote: > On Sat, 9 Jul 2022 at 12:24, Zhihong Yu wrote: > > > > It seems the code would be more readable if you keep the assignment in > else block below: > > > > + else if (rte->rtekind == RTE_SUBQUERY || > > +

Re: Making the subquery alias optional in the FROM clause

2022-07-09 Thread Dean Rasheed
On Sat, 9 Jul 2022 at 12:24, Zhihong Yu wrote: > > 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) >

Re: Making the subquery alias optional in the FROM clause

2022-07-09 Thread Zhihong Yu
On Sat, Jul 9, 2022 at 3:28 AM Dean Rasheed wrote: > On Wed, 6 Jul 2022 at 15:09, Dean Rasheed > 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

Re: Making the subquery alias optional in the FROM clause

2022-07-09 Thread Dean Rasheed
On Wed, 6 Jul 2022 at 15:09, Dean Rasheed 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. >

Re: Making the subquery alias optional in the FROM clause

2022-07-06 Thread Dean Rasheed
On Tue, 5 Jul 2022 at 19:00, Tom Lane wrote: > > Dean Rasheed writes: > > This was discussed previously in [1], and there seemed to be general > > consensus in favour of it, but no new patch emerged. > > As I said in that thread, I'm not super enthused about this, but I was > clearly in the

Re: Making the subquery alias optional in the FROM clause

2022-07-05 Thread Tom Lane
Dean Rasheed writes: > This was discussed previously in [1], and there seemed to be general > consensus in favour of it, but no new patch emerged. As I said in that thread, I'm not super enthused about this, but I was clearly in the minority so I think it should go forward. > Attached is a

Re: Making the subquery alias optional in the FROM clause

2022-06-28 Thread Isaac Morland
On Tue, 28 Jun 2022 at 00:32, Julien Rouhaud wrote: > As to forcing SQL-complaint queries, that ship sailed a long time ago: > > Postgres allows but does not enforce the use of SQL-compliant queries, > and > > many of its important features are extensions anyway, so forcing SQL > > compliant

Re: Making the subquery alias optional in the FROM clause

2022-06-27 Thread Julien Rouhaud
Hi, On Mon, Jun 27, 2022 at 12:03:20PM -0400, Isaac Morland wrote: > On Mon, 27 Jun 2022 at 11:12, Julien Rouhaud wrote: > > > More generally, I'm -0.5 on the feature. > > I prefer to force using SQL-compliant queries, and also not take bad > > habits. > > > > As to forcing SQL-complaint

Re: Making the subquery alias optional in the FROM clause

2022-06-27 Thread Dean Rasheed
On Mon, 27 Jun 2022 at 19:43, David G. Johnston wrote: > > On Mon, Jun 27, 2022 at 11:25 AM Dean Rasheed > wrote: >> >> On Mon, 27 Jun 2022 at 16:12, Julien Rouhaud wrote: >> > >> > It doesn't play that well if you have something called subquery though: >> > >> > [example that changes a

Re: Making the subquery alias optional in the FROM clause

2022-06-27 Thread David G. Johnston
On Mon, Jun 27, 2022 at 11:25 AM Dean Rasheed wrote: > On Mon, 27 Jun 2022 at 16:12, Julien Rouhaud wrote: > > > > It doesn't play that well if you have something called subquery though: > > > > [example that changes a user-provided alias] > > > > While the output is a valid query, it's not

Re: Making the subquery alias optional in the FROM clause

2022-06-27 Thread Dean Rasheed
On Mon, 27 Jun 2022 at 16:12, Julien Rouhaud wrote: > > It doesn't play that well if you have something called subquery though: > > [example that changes a user-provided alias] > > While the output is a valid query, it's not nice that it's replacing a > user provided alias with another one (or

Re: Making the subquery alias optional in the FROM clause

2022-06-27 Thread Isaac Morland
On Mon, 27 Jun 2022 at 11:12, Julien Rouhaud wrote: > More generally, I'm -0.5 on the feature. > I prefer to force using SQL-compliant queries, and also not take bad > habits. > As to forcing SQL-complaint queries, that ship sailed a long time ago: Postgres allows but does not enforce the use

Re: Making the subquery alias optional in the FROM clause

2022-06-27 Thread Julien Rouhaud
On Mon, Jun 27, 2022 at 9:49 PM Dean Rasheed wrote: > > This was discussed previously in [1], and there seemed to be general > consensus in favour of it, but no new patch emerged. > > Attached is a patch that takes the approach of not generating an alias > at all, which seems to be neater and

Making the subquery alias optional in the FROM clause

2022-06-27 Thread Dean Rasheed
This was discussed previously in [1], and there seemed to be general consensus in favour of it, but no new patch emerged. Attached is a patch that takes the approach of not generating an alias at all, which seems to be neater and simpler, and less code than trying to generate a unique alias. It