Re: BUG #19001: PostgreSQL 17: CREATE MATERIALIZED VIEW fails with STABLE function using JSONB LATERAL joins
Laurenz Albe <laurenz.albe@cybertec.at>
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: cgopal@onezero.com, pgsql-bugs@lists.postgresql.org
Date: 2025-07-29T15:34:21Z
Lists: pgsql-bugs
On Tue, 2025-07-29 at 13:55 +0000, PG Bug reporting form wrote: > PostgreSQL version: 17.5 > Operating system: Debian (Docker - postgres:latest) on WSL2 / Window > Description: > > In PostgreSQL 17, I’m encountering an error when creating a MATERIALIZED > VIEW that uses a STABLE function returning jsonb, followed by LATERAL joins > using jsonb_each() and jsonb_to_record(). > > The view creation fails with: > ERROR: relation "test_table" does not exist > > However, the referenced table does exist, and the function used in the view > creation runs fine standalone. > > The same view definition works correctly in PostgreSQL 13 That must be a consequence of the tightened security, see the first entry in https://www.postgresql.org/docs/current/release-17.html#RELEASE-17-MIGRATION Your function is not defined correctly. Set a "search_path" like this: ALTER FUNCTION yourfunc SET search_path = schema_containing_test_table; Yours, Laurenz Albe