Re: How to restore a dump containing CASTs into a database with a new user? - Mailing list pgsql-general

From Christophe Pettus
Subject Re: How to restore a dump containing CASTs into a database with a new user?
Date
Msg-id D9A7BBE5-3AE4-4AE6-A267-853704EF84E9@thebuild.com
Whole thread Raw
In response to Re: How to restore a dump containing CASTs into a database with a new user?  (Thorsten Schöning <tschoening@am-soft.de>)
Responses Re: How to restore a dump containing CASTs into a database with a new user?
List pgsql-general

> On Jul 19, 2020, at 22:13, Thorsten Schöning <tschoening@am-soft.de> wrote:
> Does Postgres support that in an easy way, without the need to reverse
> engineer an otherwise unknown the schema?

It is straight-forward enough to determine the user-created objects in the schema, and then alter their ownership.  For
newobjects, you can set default permissions appropriately. 

> That seems very complicated when one simply wants to restore a
> backup into a newly created database.

The complication is arising because you are trying to do two things at the same time: Restore the backup, and use that
toalter the permissions as a batch.  That's not straight-forward in the case where you have user-defined CASTs.  You
shouldalter the ownership of the user-defined objects, and that will allow you to dump and restore the database, if you
stillneed to. 

> Additionally, who owns types on which level in the end? To
> successfully restore, I needed to change ownership of type "inet" to
> one new user.

No, you don't, and you (probably) can't change the ownership of "inet".  "inet" is a built-in type.  The issue is that
youhave user-defined objects which are owned by the user "postgres"; you should change those to the user that you want,
leavingthe CASTs owned by "postgres". 

--
-- Christophe Pettus
   xof@thebuild.com




pgsql-general by date:

Previous
From: Thorsten Schöning
Date:
Subject: Re: How to restore a dump containing CASTs into a database with a new user?
Next
From: RAJAMOHAN
Date:
Subject: Steps required for increasing disk size in EC2 instance with minimal downtime