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

From: Chris Cleveland <ccleveland(at)dieselpoint(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: "Type does not exist" error when returning array of type in non-public schema
Date: 2025-02-06 16:46:41
Message-ID: CABSN6VeVYOEQ440umD0OgQRV9SAT4uUMkXWB-n-PScA9kkt7fw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2025-02-06 17:07:00 Re: "Type does not exist" error when returning array of type in non-public schema
Previous Message Nathan Bossart 2025-02-06 16:33:35 Re: [PATCH] SVE popcount support