Re: BUG #5184: default tablespace owner is not dumped

Lists: pgsql-bugs
From: "Robert Haas" <robertmhaas(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5184: default tablespace owner is not dumped
Date: 2009-11-13 05:34:20
Message-ID: 200911130534.nAD5YK4D029893@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5184
Logged by: Robert Haas
Email address: robertmhaas(at)gmail(dot)com
PostgreSQL version: CVS HEAD
Operating system: Linux
Description: default tablespace owner is not dumped
Details:

The following command does not change the output of "pg_dumpall":

alter tablespace pg_default owner to bob;

But this one does:

alter tablespace foo owner to bob;

The problem is that we only emit CREATE TABLESPACE commands for non-system
tablespaces. That is correct, but it seems like we might need to emit ALTER
TABLESPACE commands instead for system tablespaces.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5184: default tablespace owner is not dumped
Date: 2009-11-13 06:13:32
Message-ID: 25166.1258092812@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Robert Haas" <robertmhaas(at)gmail(dot)com> writes:
> The following command does not change the output of "pg_dumpall":
> alter tablespace pg_default owner to bob;

I don't think this is a bug. It's one specific aspect of a general
principle that system objects don't get dumped. If they did, using
pg_dump to upgrade across major versions would be somewhere between
impossible and your worst nightmare.

It might be nice if manual changes to system objects got dumped,
but that's really an AI-complete problem --- which properties of
the objects represent manual changes, and how can we know whether
trying to apply those changes to a new system version will work?

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5184: default tablespace owner is not dumped
Date: 2009-11-13 12:29:05
Message-ID: 603c8f070911130429r25c63a32k2abb6e5a5ba35085@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Fri, Nov 13, 2009 at 1:13 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Robert Haas" <robertmhaas(at)gmail(dot)com> writes:
>> The following command does not change the output of "pg_dumpall":
>> alter tablespace pg_default owner to bob;
>
> I don't think this is a bug.  It's one specific aspect of a general
> principle that system objects don't get dumped.  If they did, using
> pg_dump to upgrade across major versions would be somewhere between
> impossible and your worst nightmare.
>
> It might be nice if manual changes to system objects got dumped,
> but that's really an AI-complete problem --- which properties of
> the objects represent manual changes, and how can we know whether
> trying to apply those changes to a new system version will work?

Well, in this particular case, the existence of the default tablespace
seems like something that should not be dumped, but all properties
other than name and location - currently, owner and acl - seem like
they should be dumped. If we don't, then we have the odd situation
that dumping and restoring a database on THE SAME version of
PostgreSQL doesn't produce an equivalent database - you may have
permissions errors where you didn't before, or visca-versa.

I think it would be over the top to suggest that pg_dump has to cope
with modifications that can only occur through manual updates to the
system catalogs, but it seems like anything that can be done using DDL
statements should be handled. It seems a little wonky to admit ALTER
statements against internal Pg names, I agree... I suppose we could
try to define some alternate syntax.

...Robert


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5184: default tablespace owner is not dumped
Date: 2009-11-13 15:08:05
Message-ID: 2585.1258124885@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> I think it would be over the top to suggest that pg_dump has to cope
> with modifications that can only occur through manual updates to the
> system catalogs, but it seems like anything that can be done using DDL
> statements should be handled.

Like, say, DELETE FROM pg_proc?

Basically, if you use superuser powers to fool with the definition of
any system object, it's on your own head whether the result works at all
and whether or how to preserve that change into a new version of
Postgres. I do not think it's part of pg_dump's charter to try to
handle that. In a significant fraction of cases, preserving the change
would be exactly the wrong thing, but there is no way for pg_dump to
know the difference.

regards, tom lane


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5184: default tablespace owner is not dumped
Date: 2009-11-13 15:39:32
Message-ID: 4AFD7DB4.4060103@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Tom Lane wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> I think it would be over the top to suggest that pg_dump has to cope
>> with modifications that can only occur through manual updates to the
>> system catalogs, but it seems like anything that can be done using DDL
>> statements should be handled.
>
> Like, say, DELETE FROM pg_proc?

That's not DDL...

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Pedro Gimeno <pgsql-003(at)personal(dot)formauri(dot)es>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5184: default tablespace owner is not dumped
Date: 2009-11-13 19:35:03
Message-ID: 4AFDB4E7.2090500@personal.formauri.es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Tom Lane wrote:
>
> It might be nice if manual changes to system objects got dumped,
> but that's really an AI-complete problem --- which properties of
> the objects represent manual changes, and how can we know whether
> trying to apply those changes to a new system version will work?

A diff against template0 or template1 could help, I guess.

Bug #3684 is related, though in this case the schema "public" may be
considered a preexisting *user* object.


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5184: default tablespace owner is not dumped
Date: 2009-11-14 02:35:11
Message-ID: 603c8f070911131835j453573e2p8f13310bd2f8e3a5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Fri, Nov 13, 2009 at 10:39 AM, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
> Tom Lane wrote:
>> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>>> I think it would be over the top to suggest that pg_dump has to cope
>>> with modifications that can only occur through manual updates to the
>>> system catalogs, but it seems like anything that can be done using DDL
>>> statements should be handled.
>>
>> Like, say, DELETE FROM pg_proc?
>
> That's not DDL...

Exactly. There's nothing we can do about random changes to system
catalogs, but it seems pretty strange to allow someone to issue an
ALTER TABLESPACE command but then ignore it in pg_dump.

...Robert