restoring an object to a different name

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: restoring an object to a different name
Date: 2011-10-03 22:59:09
Message-ID: 4E8A3E3D.4030804@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


This is a subject that has come up recently, and I can think of a number
of use cases for it.

However, there are lots of wrinkles. For example, the names of objects
appear in LOTS of places, and making sure we caught them all might be
quite tricky. Say you have a table x that inherits a,b, and c, and you
decide to restore with b renamed. Now x will have a dependency on b
recorded, but finding b in the opaque sql string that is stored for the
creation of x is not going to be easy (don't anyone mention regexes here
- this is not a good case for their use IMNSHO, much as I love them).

One idea I came up with was to set up the SQL using OIDS instead of
names as placeholders, and then replacing the OIDS with the right name
at run time. So if we want to restore something with a different name,
we'd just change the stored name in the node where it's defined and the
new name would then be picked up everywhere it's used (might need a
<catalog_oid, object_oid> pair, but the idea would be the same).

Does anyone else have anything better? I don't think this is something
that can be achieved cleanly with a small patch.

cheers

andrew

PS, if you want to see what info pg_restore actually has available in a
dump file, you might like to use my little utility at
<https://gist.github.com/1258232>.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2011-10-03 23:07:31 Re: Should we get rid of custom_variable_classes altogether?
Previous Message Bruce Momjian 2011-10-03 22:45:16 Re: Bug with pg_ctl -w/wait and config-only directories