BUG #1249: pg_restore doesnt handle restoring databases not created as a superuser - Mailing list pgsql-bugs

From PostgreSQL Bugs List
Subject BUG #1249: pg_restore doesnt handle restoring databases not created as a superuser
Date
Msg-id 20040910191440.D923C5A1144@www.postgresql.com
Whole thread Raw
Responses Re: BUG #1249: pg_restore doesnt handle restoring databases not created as a superuser  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      1249
Logged by:          William Schaub

Email address:      talon@cosmic-cow.net

PostgreSQL version: 7.4.3

Operating system:   Slackware 10 (Linux 2.4.27)

Description:        pg_restore doesnt handle restoring databases not created
as a superuser

Details:

PostgreSQL 7.4.5 (and possibly many versions before)

When restoring databases with pg_restore with the -C
option it will connect to template1, set authorization to
the user that created the database and then reconnect
as the user that created the database to the new database. this is where the
trouble starts, from here on
it trys to set authorization back to the superuser to
do grant and revoke. this will cause the restore to fail.

I have prepared a patch to force reconnects to be
done as the superuser specified in the -S option if
-S if given, otherwise the current behavior is used

Since pg_restore seems to use set authorization to go back to the database
owner before it creates any objects my patch seems safe to me, but i would
like to
know if it causes problems elseware.

it can be found at http://talon.home.cosmic-cow.net/pg_restore.patch

By the way your web form doesnt list 7.4.5 as an available version in the
PostgreSQL version drop down list.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: PosgreSQL is crashing with a signal 11 - Bug?
Next
From: "PostgreSQL Bugs List"
Date:
Subject: BUG #1250: compilation fails in src/backend/storage/lmgr/s_lock.c