From: | Julien Rouhaud <rjuju123(at)gmail(dot)com> |
---|---|
To: | Isaac Morland <isaac(dot)morland(at)gmail(dot)com> |
Cc: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Making the subquery alias optional in the FROM clause |
Date: | 2022-06-28 04:32:44 |
Message-ID: | 20220628043244.ibro57hwbn5ifgsm@jrouhaud |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Mon, Jun 27, 2022 at 12:03:20PM -0400, Isaac Morland wrote:
> On Mon, 27 Jun 2022 at 11:12, Julien Rouhaud <rjuju123(at)gmail(dot)com> 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 of SQL-compliant queries, and
> many of its important features are extensions anyway, so forcing SQL
> compliant queries is out of the question (although I could see the utility
> of a mode where it warns or errors on non-compliant queries, at least in
> principle).
Sure, but it doesn't mean that we should support even more non-compliant syntax
without any restraint. In this case, I don't see much benefit as it's not
solving performance problem or something like that.
> As to bad habits, I'm having trouble understanding. Why do you think
> leaving the alias off a subquery is a bad habit (assuming it were allowed)?
I think It's a bad habit because as far as I can see it's not supported on
mysql or sqlserver.
> If the name is never used, why are we required to supply it?
I'm not saying that I'm thrilled having to do so, but it's also not a huge
trouble. And since it's required I have the habit to automatically put some
random alias if I'm writing some one shot query that indeed doesn't need to use
the alias.
But similarly, I many times relied on the fact that writable CTE are executed
even if not explicitly referenced. So by the same argument shouldn't we allow
something like this?
WITH (INSERT INTO t SELECT * pending WHERE ts < now())
SELECT now() AS last_processing_time;
From | Date | Subject | |
---|---|---|---|
Next Message | John Naylor | 2022-06-28 04:38:09 | Re: WIP Patch: Add a function that returns binary JSONB as a bytea |
Previous Message | John Naylor | 2022-06-28 04:17:42 | Re: [PoC] Improve dead tuple storage for lazy vacuum |