"Type does not exist" error when returning array of type in non-public schema - Mailing list pgsql-hackers

From Chris Cleveland
Subject "Type does not exist" error when returning array of type in non-public schema
Date
Msg-id CABSN6VeVYOEQ440umD0OgQRV9SAT4uUMkXWB-n-PScA9kkt7fw@mail.gmail.com
Whole thread Raw
Responses Re: "Type does not exist" error when returning array of type in non-public schema
Re: "Type does not exist" error when returning array of type in non-public schema
List pgsql-hackers

I'm developing a Postgres extension that gets installed in its own schema, "rdb". It creates its own type, "token", and has a function that returns an array of that type. When I SELECT the function in psql, I get an ERROR: type "token" does not exist

It's a search_path problem. If I call SET search_path TO "$user", public, rdb; everything works fine.

The trouble is that I can't expect those who install the extension to type that command, nor do I wish to ALTER DATABASE SET search_path=... to change the global search path, because that might cause problems in an unknown environment. (It's already done strange things to my environment).

Oddly, when the function returns just the type itself, not an array of them, it works fine. In other words, this works:

CREATE FUNCTION my_func ... RETURNS Token ...

but this fails:

CREATE FUNCTION my_func ... RETURNS Token[] ...

No amount of fiddling with the syntax seems to help. RETURN rdb.Token[], RETURN "rdb.Token"[], RETURN "rdb.Token[]" all fail.

This problem is happening in pg17. Haven't tried other versions.

Is there a solution here?


--
Chris Cleveland
312-339-2677 mobile

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: [PATCH] SVE popcount support
Next
From: "David G. Johnston"
Date:
Subject: Re: "Type does not exist" error when returning array of type in non-public schema