Re: BUG #19001: PostgreSQL 17: CREATE MATERIALIZED VIEW fails with STABLE function using JSONB LATERAL joins - Mailing list pgsql-bugs

From Laurenz Albe
Subject Re: BUG #19001: PostgreSQL 17: CREATE MATERIALIZED VIEW fails with STABLE function using JSONB LATERAL joins
Date
Msg-id 713b3a6c6bbac7329b7d58038d47b5361d3ff2e4.camel@cybertec.at
Whole thread Raw
In response to BUG #19001: PostgreSQL 17: CREATE MATERIALIZED VIEW fails with STABLE function using JSONB LATERAL joins  (PG Bug reporting form <noreply@postgresql.org>)
List 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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #19001: PostgreSQL 17: CREATE MATERIALIZED VIEW fails with STABLE function using JSONB LATERAL joins
Next
From: PG Bug reporting form
Date:
Subject: BUG #19002: `pg_isready` unexpectedly succeeds on incorrect `--dbname` and/or `--username`