Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ts7YB-00FYWz-Cp for pgsql-bugs@arkaria.postgresql.org; Tue, 11 Mar 2025 21:54:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ts7Y9-007oXQ-8m for pgsql-bugs@arkaria.postgresql.org; Tue, 11 Mar 2025 21:54:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ts7Y9-007oXD-0W for pgsql-bugs@lists.postgresql.org; Tue, 11 Mar 2025 21:54:09 +0000 Received: from flooble.net ([96.126.96.250]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ts7Y5-002JWT-0C for pgsql-bugs@lists.postgresql.org; Tue, 11 Mar 2025 21:54:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=flooble.net; s=202307; t=1741730043; bh=fog+ZvW5LA8OrsizmeZ4dx1PPp/VSff56lQgkJAhBNk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iJke7MOZNDmEjeqnlLtVFGZpLfuj7iXswxnxu2M7toT9lryyKxYnoxt7XCHFayl6B tWu6H5v2wc4K+wTNgiFaqGbtdf8MvyV/m+1mYe5Ehc/bmUHfxiMhaeqH3rjqqZuqsj MpDp3gWwSV5jGGJQtenTlZA8gLlH+Jmp8br3nD+6iPG1dK7/pCiymDdjU7FoIxGpec +FHBKbmjoFTWOQtnU0vpHSvTBFq22mL0N5TRxvO2LVqEwbjaHgVRzKeLV+WzrAVhpO C/SArWathbHOwJHJyAxkReYeolPs78pa/827ieemBWhhn9/VUg/ot6DZukvkbh7jcG eWUvd7s/Sttrg== Received: by flooble.net (Postfix, from userid 1000) id EAC4F154DA; Wed, 12 Mar 2025 08:54:03 +1100 (AEDT) Date: Wed, 12 Mar 2025 08:54:03 +1100 From: Peter Wright To: Laurenz Albe Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Unqualified name not resolved in function called from materialized view (17.4) Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: Sender: Peter Wright List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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: > >=20 > > Given a file "break_it.sql" containing this SQL: > >=20 > > SELECT version(); > > CREATE VIEW things AS SELECT 1 AS id, 'rock' AS thing_name; > > CREATE FUNCTION num_things() RETURNS INTEGER AS $$ SELECT COUNT(1) FR= OM things; $$ LANGUAGE SQL STABLE; > > CREATE MATERIALIZED VIEW thing_report AS SELECT num_things() AS numbe= r_of_things; > >=20 > > Running the following commands with the environment pointing at a Postg= reSQL 17.4 server: > >=20 > > 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 > >=20 > >=20 > > Running the same commands with the environment pointing at a PostgreSQL= 16.8 > > server does *not* report an error >=20 > 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-MIGRAT= ION 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. 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 =E2=80=9Cmaintenance operations= =E2=80=9D. > You should fix the function. I will. :-) > Yours, > Laurenz Albe Pete. --=20 If at first you don't succeed, you must be a programmer.