Обсуждение: BUG #18813: Materialized view creation regression when inlining recursive SQL function
BUG #18813: Materialized view creation regression when inlining recursive SQL function
От
PG Bug reporting form
Дата:
The following bug has been logged on the website:
Bug reference: 18813
Logged by: Olivier Jolly
Email address: zeograd@gmail.com
PostgreSQL version: 17.3
Operating system: Debian 12.2 (official docker images)
Description:
Hi,
I've encountered an error when creating a materialized view as I updated
its body by introducing a recursive function.
On postgreSQL 16, it works as expected: the materialized view is created and
works as intended.
Starting from posgreSQL 17.0, the materialized view created failed with the
error message
ERROR: function jsonb_recursive_merge(jsonb, jsonb) does not exist
LINE 9: ELSE jsonb_recursive_merge(va::jsonb, vb:...
^
HINT: No function matches the given name and argument types. You might need
to add explicit type casts.
CONTEXT: SQL function "jsonb_recursive_merge" during inlining
postgreSQL 17.3 also returns the same error.
A somewhat minimal .sql script triggering the error (as well as reproducible
CLI invocations and results from the execution in 16.7, 17.0 and 17.3
official docker images) is available on
https://gitlab.com/-/snippets/4807302
I would expect that postgreSQL 17.x allows creating my materialized view
like it did in postgreSQL 16.7
Thanks in advance for your help,
Olivier
On Sun, 2025-02-16 at 15:49 +0000, PG Bug reporting form wrote: > I've encountered an error when creating a materialized view as I updated > its body by introducing a recursive function. > > On postgreSQL 16, it works as expected: the materialized view is created and > works as intended. > Starting from posgreSQL 17.0, the materialized view created failed with the > error message > > ERROR: function jsonb_recursive_merge(jsonb, jsonb) does not exist > LINE 9: ELSE jsonb_recursive_merge(va::jsonb, vb:... > ^ > HINT: No function matches the given name and argument types. You might need > to add explicit type casts. > CONTEXT: SQL function "jsonb_recursive_merge" during inlining > > postgreSQL 17.3 also returns the same error. That's not a bug, that's expected: https://www.postgresql.org/docs/current/release-17.html#RELEASE-17-MIGRATION Change functions to use a safe search_path during maintenance operations (Jeff Davis) So that's actually a bug in your function definition. Fix it by running ALTER FUNCTION ... SET search_path = schema_containing_function; Make sure that the schema does *not* have CREATE privileges for PUBLIC... Yours, Laurenz Albe -- *E-Mail Disclaimer* Der Inhalt dieser E-Mail ist ausschliesslich fuer den bezeichneten Adressaten bestimmt. Wenn Sie nicht der vorgesehene Adressat dieser E-Mail oder dessen Vertreter sein sollten, so beachten Sie bitte, dass jede Form der Kenntnisnahme, Veroeffentlichung, Vervielfaeltigung oder Weitergabe des Inhalts dieser E-Mail unzulaessig ist. Wir bitten Sie, sich in diesem Fall mit dem Absender der E-Mail in Verbindung zu setzen. *CONFIDENTIALITY NOTICE & DISCLAIMER *This message and any attachment are confidential and may be privileged or otherwise protected from disclosure and solely for the use of the person(s) or entity to whom it is intended. If you have received this message in error and are not the intended recipient, please notify the sender immediately and delete this message and any attachment from your system. If you are not the intended recipient, be advised that any use of this message is prohibited and may be unlawful, and you must not copy this message or attachment or disclose the contents to any other person.
Re: BUG #18813: Materialized view creation regression when inlining recursive SQL function
От
Olivier Jolly
Дата:
Le 16/02/2025 à 17:24, Laurenz Albe a écrit : > On Sun, 2025-02-16 at 15:49 +0000, PG Bug reporting form wrote: >> I've encountered an error when creating a materialized view as I updated >> its body by introducing a recursive function. >> >> On postgreSQL 16, it works as expected: the materialized view is created and >> works as intended. >> Starting from posgreSQL 17.0, the materialized view created failed with the >> error message >> >> ERROR: function jsonb_recursive_merge(jsonb, jsonb) does not exist >> LINE 9: ELSE jsonb_recursive_merge(va::jsonb, vb:... >> ^ >> HINT: No function matches the given name and argument types. You might need >> to add explicit type casts. >> CONTEXT: SQL function "jsonb_recursive_merge" during inlining >> >> postgreSQL 17.3 also returns the same error. > That's not a bug, that's expected: > https://www.postgresql.org/docs/current/release-17.html#RELEASE-17-MIGRATION > > Change functions to use a safe search_path during maintenance operations (Jeff Davis) > > So that's actually a bug in your function definition. > Fix it by running > > ALTER FUNCTION ... SET search_path = schema_containing_function; > > Make sure that the schema does *not* have CREATE privileges for PUBLIC... > Many thanks for the fast on point answer. I had read this part of the release note, but did not think it would apply to functions defined in PUBLIC (as it was part of the default search_path) ALTER FUNCTION ... SET search_path = public; fixed my script in 17.x, indeed. Thanks a lot, sorry for not finding out by myself. Take care, Olivier