pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ivan Pantić <ivanpantic82@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: pg_restore creates duplicate records when used with --role parameter
Date: Fri, 18 Oct 2019 11:13:36 +0200
Message-ID: <28388.1571390016@sss.pgh.pa.us> (raw)
In-Reply-To: <CC727A06-19E3-4CDD-9EB6-845C5AA14843@getmailspring.com>
References: <CC727A06-19E3-4CDD-9EB6-845C5AA14843@getmailspring.com>

=?utf-8?Q?Ivan_Panti=C4=87?= <ivanpantic82@gmail.com> writes:
> I've created a backup using pg_restore like this:
> x sudo -u postgres pg_dump source_db --format=custom' > /tmp/source_db.db
> I then copied the backup file to the destination server and tried to restore it like this:
> sudo -u postgres psql destination_db -c 'DROP SCHEMA public CASCADE; CREATE SCHEMA public AUTHORIZATION destination_user;'
> sudo -u postgres pg_restore -d destination_db --no-owner --role=destination_user -n public /tmp/source_db.db

> I've recieved this error:
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 2276; 2606 42862 CONSTRAINT price_history price_history_pkey destination_db
> pg_restore: [archiver (db)] could not execute query: ERROR: could not create unique index "price_history_pkey"
> DETAIL: Key (id)=(64) is duplicated.
> Command was: ALTER TABLE ONLY public.price_history
> ADD CONSTRAINT price_history_pkey PRIMARY KEY (id);

FWIW, I could not duplicate this report in several tries.

Usually, the expectation when restoring a dump is that you're restoring
into a totally empty database.  Clearing out just the public schema
isn't that, so I wonder if you left behind something that could affect
this table.  It's not very clear what that could be though :-(.

Anyway, if you can provide a self-contained reproduction case for this,
we'd surely look further.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <28388.1571390016@sss.pgh.pa.us>
Permalink:  ../28388.1571390016@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28388.1571390016@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, ivanpantic82@gmail.com
  Subject: Re: pg_restore creates duplicate records when used with --role parameter
  In-Reply-To: <28388.1571390016@sss.pgh.pa.us>
  References: <CC727A06-19E3-4CDD-9EB6-845C5AA14843@getmailspring.com> <28388.1571390016@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox