Re: pg18 bug? SELECT query doesn't work

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Eric Ridge <eebbrr(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg18 bug? SELECT query doesn't work
Date: 2026-01-06 17:00:29
Message-ID: CAKFQuwZS4dO2xJeL7yT-D20J-WR15rCPE9iXta8F9WuFHvxXTA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Tue, Jan 6, 2026 at 9:16 AM Eric Ridge <eebbrr(at)gmail(dot)com> wrote:

> On Jan 6, 2026, at 11:04 AM, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
> wrote:
>
>
> It was an intentional change. You now should be putting set-producing
> functions into the FROM clause of a query or subquery. A lateral join is
> often required.
>
>
> I'm willing to accept that, but I can't find this called out in the
> release notes between 15 and 18.1. I could have overlooked it, of course.
>
> It is very surprising to me that Postgres would intentionally break
> previously-working SELECT statements and that the CTE version is
> inconsistent between "AS MATERIALIZED". The WITH MATERIALIZED docs don't
> mention anything about certain query shapes being incompatible.
>
>
While I haven't dug into the actual specifics of this report in detail, the
change in question happened back in v10.

https://www.postgresql.org/docs/10/release-10.html

The failure to emit an error when it probably should have is likely a bug
in older versions since fixed.

Or, it may be an actual bug. But we did tighten things up here and
encourage/require a non-problematic query form (place set-returning
constructs in the from clause) in some situations now that we did not
before. So I'm willing to presume the error being reported here is valid.

That the behavior depends on the chosen plan and plans differ when you do
and do not materialize a CTE is likewise not surprising. Though as a
practical matter it would be nice if the test was more resilient in face of
different syntactic forms; so bug or not, maybe something could be done to
make the failure more consistent.

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Eric Ridge 2026-01-06 18:10:40 Re: pg18 bug? SELECT query doesn't work
Previous Message Eric Ridge 2026-01-06 16:16:08 Re: pg18 bug? SELECT query doesn't work

Browse pgsql-hackers by date

  From Date Subject
Next Message Xuneng Zhou 2026-01-06 17:04:06 Re: Implement waiting for wal lsn replay: reloaded
Previous Message Heikki Linnakangas 2026-01-06 17:00:23 Re: Reduce build times of pg_trgm GIN indexes