From: Peter Wright <pete@flooble.net>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Unqualified name not resolved in function called from materialized view (17.4)
Date: Wed, 12 Mar 2025 08:54:03 +1100
Message-ID: <Z9Cw-_ikmCua_gQD@flooble.net> (raw)
In-Reply-To: <df50dda5bad084ae0e8d8a8077d015a86625396a.camel@cybertec.at>
References: <Z8_4Lf5EKH4ZDwvg@flooble.net>
<df50dda5bad084ae0e8d8a8077d015a86625396a.camel@cybertec.at>
On 11/03 12:58:37, Laurenz Albe wrote:
> On Tue, 2025-03-11 at 19:45 +1100, Peter Wright wrote:
> > PostgreSQL version: 17.4
> > Operating system: Ubuntu 24.04, x86_64, kernel 6.8.0-51-generic
> > Description:
> >
> > Given a file "break_it.sql" containing this SQL:
> >
> > SELECT version();
> > CREATE VIEW things AS SELECT 1 AS id, 'rock' AS thing_name;
> > CREATE FUNCTION num_things() RETURNS INTEGER AS $$ SELECT COUNT(1) FROM things; $$ LANGUAGE SQL STABLE;
> > CREATE MATERIALIZED VIEW thing_report AS SELECT num_things() AS number_of_things;
> >
> > Running the following commands with the environment pointing at a PostgreSQL 17.4 server:
> >
> > psql:break_it.sql:4: ERROR: relation "things" does not exist
> > LINE 1: SELECT COUNT(1) FROM things;
> > ^
> > QUERY: SELECT COUNT(1) FROM things;
> > CONTEXT: SQL function "num_things" during inlining
> >
> >
> > Running the same commands with the environment pointing at a PostgreSQL 16.8
> > server does *not* report an error
>
> That is not a bug, it is intentional.
> See the first entry in the list of incompatibilities
> https://www.postgresql.org/docs/current/release-17.html#RELEASE-17-MIGRATION
Aha! Noted, and thank you.
I spent some time looking for evidence that this was an intentional
change, but apparently didn't look in the most obvious place. <facepalm>
It also seemed counter-intuitive that CREATE MATERIALIZED VIEW would
use a different search path to CREATE VIEW - but makes sense now I know
that materialized view create/refresh are “maintenance operations”.
> You should fix the function.
I will. :-)
> Yours,
> Laurenz Albe
Pete.
--
If at first you don't succeed, you must be a programmer.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: pete@flooble.net, laurenz.albe@cybertec.at, pgsql-bugs@lists.postgresql.org
Subject: Re: Unqualified name not resolved in function called from materialized view (17.4)
In-Reply-To: <Z9Cw-_ikmCua_gQD@flooble.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox