Patch: forcing object owner in TOC file - Mailing list pgsql-hackers

From Piotr Gasidło
Subject Patch: forcing object owner in TOC file
Date
Msg-id CAF8akQs30LDagtWf604pyk1RNd=k61fjn1xRTe4+JGrZ7XrAAw@mail.gmail.com
Whole thread Raw
Responses Re: Patch: forcing object owner in TOC file  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Hello,

I've created small patch which allows me easily change owner during
pg_restore with backup in custom format (-Fc).
This simplifies migration when users on new server are different that
ones in backup file.

First, I get TOC file:

pg_restore -Fc -l mybackup.custom > mybackup.toc

Then, I can alter owner of any object by adding username after TOC Id,
for ex. changing this:

173; 1259 25139 TABLE public data quaker

into this:

173 quaker1; 1259 25139 TABLE public data quaker

By above line I forced quaker1 to be owner of public.data table after restore.

Then I do normal restore using modified TOC:

$ pg_restore -Fc mybackup.custom -L mybackup.toc -d quaker
pg_restore: [archiver] WARNING: altering owner for TABLE data to quaker1

and have public.data TABLE owned by quaker1 user.

Patch attached.

--
Piotr Gasidło

Attachment

pgsql-hackers by date:

Previous
From: Noah Misch
Date:
Subject: Re: Visual Studio 2012 RC
Next
From: Pavel Stehule
Date:
Subject: Re: proposal - assign result of query to psql variable