Unix Technical Forum

In pg_dump "no owner" mode don't dump owner names in comments

This is a discussion on In pg_dump "no owner" mode don't dump owner names in comments within the Pgsql Patches forums, part of the PostgreSQL category; --> This fixes pg_dump so that when using the '-O' no owners option it does not print the owner name ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Patches

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 01:03 AM
Christopher Kings-Lynne
 
Posts: n/a
Default In pg_dump "no owner" mode don't dump owner names in comments

This fixes pg_dump so that when using the '-O' no owners option it does
not print the owner name in the object comment.

eg:

--
-- Name: actor; Type: TABLE; Schema: public; Owner: chriskl; Tablespace:
--

Becomes:

--
-- Name: actor; Type: TABLE; Schema: public; Owner: -; Tablespace:
--

This makes it far easier to do 'user independent' dumps. Especially for
distribution to third parties.

Chris

Index: src/bin/pg_dump/pg_backup_archiver.c
================================================== =================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.117
diff -c -r1.117 pg_backup_archiver.c
*** src/bin/pg_dump/pg_backup_archiver.c 15 Oct 2005 02:49:38 -0000 1.117
--- src/bin/pg_dump/pg_backup_archiver.c 21 Nov 2005 07:19:39 -0000
***************
*** 2404,2410 ****
ahprintf(AH, "-- %sName: %s; Type: %s; Schema: %s; Owner: %s",
pfx, te->tag, te->desc,
te->namespace ? te->namespace : "-",
! te->owner);
if (te->tablespace)
ahprintf(AH, "; Tablespace: %s", te->tablespace);
ahprintf(AH, "\n");
--- 2404,2410 ----
ahprintf(AH, "-- %sName: %s; Type: %s; Schema: %s; Owner: %s",
pfx, te->tag, te->desc,
te->namespace ? te->namespace : "-",
! ropt->noOwner ? "-" : te->owner);
if (te->tablespace)
ahprintf(AH, "; Tablespace: %s", te->tablespace);
ahprintf(AH, "\n");


---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 01:03 AM
Tom Lane
 
Posts: n/a
Default Re: In pg_dump "no owner" mode don't dump owner names in comments

Christopher Kings-Lynne <chriskl@familyhealth.com.au> writes:
> This fixes pg_dump so that when using the '-O' no owners option it does
> not print the owner name in the object comment.


Why is that a good idea?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-18-2008, 01:04 AM
Christopher Kings-Lynne
 
Posts: n/a
Default Re: In pg_dump "no owner" mode don't dump owner names in

>>This fixes pg_dump so that when using the '-O' no owners option it does
>>not print the owner name in the object comment.

>
> Why is that a good idea?


At the moment I want to dump sample databases for a project. I don't
want my name or username appearing anywhere in them. I dump without
owners or privileges since they're irrelevant and will refer to users
that just don't exist.

So, at the moment I need to run the dumps through sed to remove the
reference to the owner usernames in the dumps, otherwise everyone can
see half the users in our database...

Chris


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-18-2008, 01:19 AM
Bruce Momjian
 
Posts: n/a
Default Re: In pg_dump "no owner" mode don't dump owner names in comments


Patch applied. Thanks.

---------------------------------------------------------------------------


Christopher Kings-Lynne wrote:
> This fixes pg_dump so that when using the '-O' no owners option it does
> not print the owner name in the object comment.
>
> eg:
>
> --
> -- Name: actor; Type: TABLE; Schema: public; Owner: chriskl; Tablespace:
> --
>
> Becomes:
>
> --
> -- Name: actor; Type: TABLE; Schema: public; Owner: -; Tablespace:
> --
>
> This makes it far easier to do 'user independent' dumps. Especially for
> distribution to third parties.
>
> Chris


> Index: src/bin/pg_dump/pg_backup_archiver.c
> ================================================== =================
> RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v
> retrieving revision 1.117
> diff -c -r1.117 pg_backup_archiver.c
> *** src/bin/pg_dump/pg_backup_archiver.c 15 Oct 2005 02:49:38 -0000 1.117
> --- src/bin/pg_dump/pg_backup_archiver.c 21 Nov 2005 07:19:39 -0000
> ***************
> *** 2404,2410 ****
> ahprintf(AH, "-- %sName: %s; Type: %s; Schema: %s; Owner: %s",
> pfx, te->tag, te->desc,
> te->namespace ? te->namespace : "-",
> ! te->owner);
> if (te->tablespace)
> ahprintf(AH, "; Tablespace: %s", te->tablespace);
> ahprintf(AH, "\n");
> --- 2404,2410 ----
> ahprintf(AH, "-- %sName: %s; Type: %s; Schema: %s; Owner: %s",
> pfx, te->tag, te->desc,
> te->namespace ? te->namespace : "-",
> ! ropt->noOwner ? "-" : te->owner);
> if (te->tablespace)
> ahprintf(AH, "; Tablespace: %s", te->tablespace);
> ahprintf(AH, "\n");


>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq


--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:39 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com