Skip site navigation (1) Skip section navigation (2)

pg_restore --clean vs. large object

From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pg_restore --clean vs. large object
Date: 2009-05-18 08:10:13
Message-ID: 20090518165424.068D.52131E4D@oss.ntt.co.jp (view raw or flat)
Thread:
Lists: pgsql-hackers
Hi,

Since pg_restore --clean doesn't delete existing large objects,
restoring to an existing database with "pg_restore --clean -1"
would fail if backup archive contains large objects. Some DBAs
complain to the behavior because they expect all existing data
conflicting with backup archive will be deleted automatically.

I'd like to improve the behavior if it is not intentional.
The attached is a patch to execute lo_unlink() before lo_create()
in pg_restore. To avoid transaction rollbacks, I added a test
whether the large object exists with an EXISTS query.

    SELECT CASE WHEN EXISTS
        (SELECT 1 FROM pg_catalog.pg_largeobject WHERE loid = %u)
      THEN lo_unlink(%u) END;

Comments welcome.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

Attachment: pg_restore_clean_lo.patch
Description: application/octet-stream (5.2 KB)

Responses

pgsql-hackers by date

Next:From: Pavel StehuleDate: 2009-05-18 12:09:50
Subject: problem with polymorphic functions and implicit casting
Previous:From: Rodrigo E. De León PlicetDate: 2009-05-18 04:45:18
Subject: Re: WAL dump tool

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group