Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Admin > Proposal for re...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 4972 of 5130
Post > Topic >>

Proposal for restoring a dump into a database with a different owner

by postgresql.20.j_random_hacker@[EMAIL PROTECTED] May 10, 2008 at 10:44 PM

Hi,

I have the same problem as Andreas Haumer did in this thread:
http://archives.postgresql.org/pgsql-admin/2008-01/msg00128.php
-- I want
to
be able to easily (i.e. programmatically) copy a database from one place
to
another, changing the owners of all contained objects in the process.

While I very much appreciate Tom Lane's fast and helpful responses to
Andreas on that thread, it doesn't quite address my problem: there is no
simple, automatable 1- or 2-step process that can accomplish this (without
Andreas's (admittedly neat) trick of tem****arily changing the destination
user to superuser status).  The best I've been able to do is hack up a
Perl
script that parses the output of pg_restore -l, directing
superuser-requiring operations to one file and non-superuser-requiring
operations to another; but afterwards the superuser-requiring operations
still have to have the owners of the objects they produce manually
reassigned.

My instincts (which could be wrong...) tell me that this is actually a
fairly common problem.  So, I suggest the following enhancement to
pg_restore: add a --map-users command-line option that accepts the name of
a
file containing two usernames on each line, <from> and <to>.  Then
(provided
-O was not specified) when producing ALTER ... OWNER TO commands, simply
replace every <from> user listed in this file with the corresponding <to>
user.

Another niggle is that the COMMENT ON DATABASE command, produced by
pg_restore when run without the -d option, always refers to the name of
the
original database, which will cause an error if the new DB has a different
name.  It would be nice to have an option (or other means) to remedy this.

It seems to me that these things would be pretty simple to implement and
sufficiently general to tackle this problem neatly, without opening up any
security holes (you would still need to be *some* DB superuser for the
ALTER
.... OWNER TO commands to work).

Does this sound sensible?  If Tom or another high-ranking PostgreSQLer
okays
it in principle, I suppose I could try developing a patch for pg_restore
myself.  (Never done this before but there's a first time for
everything...)

TIA,
Tim White



-- 
Sent via pgsql-admin mailing list (pgsql-admin@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
 




 4 Posts in Topic:
Proposal for restoring a dump into a database with a different o
postgresql.20.j_random_ha  2008-05-10 22:44:39 
Re: Proposal for restoring a dump into a database
bruce@[EMAIL PROTECTED]   2008-06-30 15:50:06 
Re: Proposal for restoring a dump into a database with a differe
tgl@[EMAIL PROTECTED] (T  2008-06-30 16:05:36 
Re: Proposal for restoring a dump into a database with a differe
scott.marlowe@[EMAIL PROT  2008-06-30 14:01:36 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Tue Jul 8 23:26:06 CDT 2008.