Skip site navigation (1) Skip section navigation (2)

Re: pg_upgrade fails for non-postgres user

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade fails for non-postgres user
Date: 2011-02-01 10:01:46
Message-ID: AANLkTinSjUPo0zQLznEeYDBTnO1-oyYRJEyJ3EDwds-g@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Tue, Feb 1, 2011 at 02:25, Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> Magnus Hagander wrote:
>> I just tried doing pg_upgrade on a database when logged in as user
>> "mha" rather than "postgres" on my system. And it failed. Even though
>> the db was initialized with superuser "mha". The reason for this was
>> that pg_upgrade tried to connect to the database "mha" (hardcoded to
>> be the db username), and that certainly didn't exist.
>>
>> When that was fixed, I realized the psql command to create the
>> datanbases connect to database "template1" only to immediately switch
>> to database "postgres", which also seems rather pointless.
>>
>> Attach patch makes it connect to the "postgres" database instead of
>> $USER, and then also changes the psql command to actually use it.
>>
>> I know way too little about pg_upgrade to tell if this is fully safe,
>> but it does fix the problem in my installation.
>
> I have found that this problem only affects PG 9.1 and is not part of
> released PG 9.0 because we don't restore pg_authid in 9.0 (we don't need
> to because we have no pg_largeobject_metadata table in PG 8.4).

Ah, that explains why we haven't seen reports on this before.


> I have applied a modified version of your patch to always retore into
> the 'postgres' database rather than the OS user.  I thought we created
> an os-user-named database, but it seems that database is always called
> 'postgres' but is owned by the OS user.  That seems kind of
> inconsistent, but no matter.

The whole reason for the postgres database is to provide a
*predictable* name for people and tools to connect to, and possibly
store things in. template1 works reasonably well for "connect to", but
not for "store in" - because it gets duplicated out to all new
databases after that.

Which is also why it's a good reason to have it the default fo
r"connect to" either - because people will create object there by
mistake, and then get it duplicated out to all new databases.



-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

In response to

Responses

pgsql-hackers by date

Next:From: Nicolas BarbierDate: 2011-02-01 10:05:17
Subject: Re: bad links in messages from commits
Previous:From: Jeff DavisDate: 2011-02-01 09:56:38
Subject: Re: SSI patch version 14

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group