pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thorsten Schöning <tschoening@am-soft.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: How to restore a dump containing CASTs into a database with a new user?
Date: Mon, 20 Jul 2020 07:13:16 +0200
Message-ID: <1097194106.20200720071316@am-soft.de> (raw)
In-Reply-To: <B84FCC25-E4EE-4441-9788-9324FD9E0D2B@thebuild.com>
References: <1566481610.20200719202547@am-soft.de>
	<206414.1595183867@sss.pgh.pa.us>
	<1834098334.20200719215112@am-soft.de>
	<229216.1595191074@sss.pgh.pa.us>
	<929298897.20200719232557@am-soft.de>
	<B84FCC25-E4EE-4441-9788-9324FD9E0D2B@thebuild.com>

Guten Tag Christophe Pettus,
am Sonntag, 19. Juli 2020 um 23:38 schrieben Sie:

> In this case, you may need to change the ownership of the various
> objects directly in the database, rather than using dump/restore as
> a way of changing ownership all at once.

Does Postgres support that in an easy way, without the need to reverse
engineer an otherwise unknown the schema?

What I've read it does not, one always needs to know which objects are
used, needs to additionally handle newly created objects not used yet
etc. That seems very complicated when one simply wants to restore a
backup into a newly created database.

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. Is that per database restored into or for the whole
cluster now? Because I easily have multiple of the same databases for
different tenants and all those tenants are individual users which
would need to own that type "inet" to be able to restore their
individual databases.

> This is not infrequent
> when you have an existing database in which a superuser owns everything

In my setup it only seems to be necessary for the CASTs, everything
else seems to be properly reowned how I restore. And that approach
seems much easier than rewoning individual objects.

So depending on who owns the type "inet" on which level in the end,
Postgres could reown those types automatically during restores as
well. Looking at the provided arguments and used commands, it's very
clear what the user wants.

OTOH, if that type is owned on a higher level than the restored
database itself only, that seems to be a design issue. Because that
would prevent other users owning that type for their individual
databases as well.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail: Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow






view thread (14+ messages)  latest in thread

Message-ID: <1097194106.20200720071316@am-soft.de>
Permalink:  ../1097194106.20200720071316@am-soft.de/
Also on:    postgresql.org/message-id/1097194106.20200720071316@am-soft.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tschoening@am-soft.de
  Subject: Re: How to restore a dump containing CASTs into a database with a new user?
  In-Reply-To: <1097194106.20200720071316@am-soft.de>
  References: <1566481610.20200719202547@am-soft.de> <206414.1595183867@sss.pgh.pa.us> <1834098334.20200719215112@am-soft.de> <229216.1595191074@sss.pgh.pa.us> <929298897.20200719232557@am-soft.de> <B84FCC25-E4EE-4441-9788-9324FD9E0D2B@thebuild.com> <1097194106.20200720071316@am-soft.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox