Rename a database that has connections

From: Mark Kirkwood <mark(dot)kirkwood(at)catalyst(dot)net(dot)nz>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Rename a database that has connections
Date: 2011-11-22 03:13:13
Message-ID: 4ECB1349.30603@catalyst.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I've been helping out several customers recently who all seem to be
wrestling with the same issue: wanting to update/refresh non-production
databases from the latest corresponding prod version. Typically they
have (fairly complex) scripts that at some point attempt to restore a
dump into new database and then rename the to-be-retired db out of the
way and rename the newly restored one to take over.

In many cases such scripts would be simplified if a database could be
renamed without requiring its connections terminated. I've been asked
several times if this could be added... so I've caved in a done a patch
that allows this.

The default behavior is unchanged - it is required to specify an
additional trailing FORCE keyword to elicit the more brutal behavior.
Note that existing connections to the renamed database are unaffected,
but obviously SELECT current_database() returns the new name (in the
next transaction).

regards

Mark

Attachment Content-Type Size
rename-force.patch.1 text/plain 7.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2011-11-22 03:17:45 Re: strange nbtree corruption report
Previous Message Bruce Momjian 2011-11-22 02:41:53 Re: Removing postgres -f command line option