pgdump tar bug (PG 9.2)

From: Asif Naeem <asif(dot)naeem(at)enterprisedb(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: pgdump tar bug (PG 9.2)
Date: 2012-06-11 12:46:03
Message-ID: CACDUQd_0GJpVHxJqLE-B4jJMe-NntMMVbp3xn94F4as6KLxQow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

With the following test case pgdump creates a corrupt tar file i.e.

CREATE DATABASE dump_test;
> \c dump_test
> CREATE TABLE test_table1 (int1 int);
> INSERT INTO test_table1 (SELECT * FROM generate_series(1, 1000));
> \! pg_dump -F t -f dump_test.tar dump_test

Debugging shows that pg_dump tries to fopen tar file with "w" option that
corrupts already opened archive file i.e.

_CloseArchive() -> RestoreArchive() -> SetOutput() -> fopen(filename,
> PG_BINARY_W);

man fopen

> ...
> ...
> w
> Truncate file to zero length or create text file for writing. The
> stream is positioned at the beginning of the file.

This issue is caused by addition of the following code in function
_CloseArchive() i.e.

> memcpy(ropt, AH->ropt, sizeof(RestoreOptions));

It was intruduced by recent patch is as following i.e.

> commit 4317e0246c645f60c39e6572644cff1cb03b4c65
> Author: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> Date: Tue May 29 23:22:14 2012 -0400
> Rewrite --section option to decouple it from --schema-only/--data-only.

PFA patch. Thanks.

Best Regards,
Muhammad Asif Naeem

Attachment Content-Type Size
pg_backup_tar.c.patch.pg application/octet-stream 425 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2012-06-11 13:01:52 Re: pg_basebackup --xlog compatibility break
Previous Message Amit Kapila 2012-06-11 09:30:58 Re: WIP patch for Todo Item : Provide fallback_application_name in contrib/pgbench, oid2name, and dblink