Re: PostgreSQL : bug (ou not) in CTE Common Table Expressions or Subqueries in the FROM Clause

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: PALAYRET Jacques <jacques(dot)palayret(at)meteo(dot)fr>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: PostgreSQL : bug (ou not) in CTE Common Table Expressions or Subqueries in the FROM Clause
Date: 2022-03-22 15:26:23
Message-ID: CAApHDvpULAMZ8JKX1zz12gqtXhCi+r9178pGq4C0ODjK9ZFvtA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 23 Mar 2022 at 04:03, PALAYRET Jacques
<jacques(dot)palayret(at)meteo(dot)fr> wrote:
> For example, in Oracle it is not possible to have a SELECT statement without a FROM clause (using DUAL table), so maybe " ambiguous " columns are not handled in the same way.

But if your original complaint, the column was not ambiguous. The CTE
had no column named "id".

I really highly recommend that you write queries giving each relation
a short alias then make a habit to always prefix your column names
with the alias. If you don't do this then you can have all sorts of
problems when you one day want to start dropping old unused columns
out of your tables. If you alias these then dropping the columns will
properly cause queries that reference these columns to ERROR. Without
aliases, your queries might just start doing something you don't want
them to do and you might not realise that for a very long time.

David

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2022-03-23 04:19:37 Re: Can you install/run postgresql on a FIPS enabled host?
Previous Message PALAYRET Jacques 2022-03-22 15:03:17 Re: PostgreSQL : bug (ou not) in CTE Common Table Expressions or Subqueries in the FROM Clause