Re: BUG #18242: pg_dump with non-superuser from pg14 to pg15 fails on ALTER FUNCTION

From: Aksel Allas <allasaksel(at)gmail(dot)com>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18242: pg_dump with non-superuser from pg14 to pg15 fails on ALTER FUNCTION
Date: 2023-12-12 11:47:31
Message-ID: CABnLe_DK6awc1RWVPHbSC4hihQ_d1QDTQgMNvQrmT3e-bC9zug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

We get the following error:

psql:schema.psql:81: ERROR: permission denied for schema public
on the command `ALTER FUNCTION "public"."get_current_user"() OWNER TO
"application_user";`

Question is how to handle schema dump (without manually changing dump) when
we don't have access to superuser e.g. in cloud environments

If I add `GRANT CREATE ON SCHEMA public TO application_user` in source
database, then it appears at the end of the dump and after ALTER FUNCTION.

On Tue, Dec 12, 2023 at 1:27 PM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 18242
> Logged by: Aksel Allas
> Email address: aksel(dot)allas(at)pactum(dot)com
> PostgreSQL version: 15.5
> Operating system: Debian/GNU Linux 12
> Description:
>
> Please see
>
> https://github.com/AkselAllas/pg_dump-alter-function-problem-with-non-superuser
> for reproduction steps in dockerized environment.
>
> The gist is that:
>
> When making a dump from PostgreSQL 14 and using it in PostgreSQL 15 with a
> user that has no superuser access (e.g. cloud environments), then we run
> into the following line from
> https://www.postgresql.org/docs/15/sql-alterfunction.html
>
> > To alter the owner, you must also be a direct or indirect member of the
> new owning role, and that role must have CREATE privilege on the function's
> schema.
>
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2023-12-12 12:01:38 Re: BUG #18240: Undefined behaviour in cash_mul_flt8() and friends
Previous Message PG Bug reporting form 2023-12-12 10:43:17 BUG #18242: pg_dump with non-superuser from pg14 to pg15 fails on ALTER FUNCTION