Re: OIDs depending data -- how to dump/restore?

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: "fkater(at)googlemail(dot)com" <fkater(at)googlemail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: OIDs depending data -- how to dump/restore?
Date: 2010-03-14 20:22:38
Message-ID: 201003141322.38870.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sunday 14 March 2010 1:09:37 pm fkater(at)googlemail(dot)com wrote:
> Adrian Klaver:
> > > AFAIK the dump/restore does not rebuild the original OID
> > > values, so all relations built accross OIDs fail.
> > >
> > > (1)
> > > Is there a way to keep the original OID values somehow?
> >
> > From here:
> > http://www.postgresql.org/docs/8.4/interactive/app-pgdump.html
> >
> > -o
> > --oids
> >
> > Dump object identifiers (OIDs) as part of the data for every table.
> > Use this option if your application references the OID columns in some
> > way (e.g., in a foreign key constraint). Otherwise, this option should
> > not be used.
>
> Thanks, but the problem is *restoring* OIDs afterwards,
> isn't it? AFAIK the OIDs being restored are not the same
> values as the ones being saved, so my internal relations to
> those OIDs are all mixed up after a restore.
>
> I'd be happy if someone told me that this was wrong. :-)

Be happy then. If you do not specify the -o switch the oids are created on
demand when the dump file is restored and you get the situation you describe.
By specifying the -o switch you tell pg_dump to preserve the OIDS used in the
original database. This is why the following is mentioned in the above
description:

"Use this option if your application references the OID columns in some
way (e.g., in a foreign key constraint)."

>
> Felix

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Carlo Stonebanks 2010-03-15 00:07:24 $libdir/plugins/plugin_debugger.dll
Previous Message Gordon Shannon 2010-03-14 20:11:50 Re: unexplained autovacuum to prevent wraparound