pgsql: Fix pg_restore's direct-to-database mode for INSERT-style table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix pg_restore's direct-to-database mode for INSERT-style table
Date: 2012-01-06 18:05:09
Message-ID: E1RjEA9-0003NK-GM@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix pg_restore's direct-to-database mode for INSERT-style table data.

In commit 6545a901aaf84cb05212bb6a7674059908f527c3, I removed the mini SQL
lexer that was in pg_backup_db.c, thinking that it had no real purpose
beyond separating COPY data from SQL commands, which purpose had been
obsoleted by long-ago fixes in pg_dump's archive file format.
Unfortunately this was in error: that code was also used to identify
command boundaries in INSERT-style table data, which is run together as a
single string in the archive file for better compressibility. As a result,
direct-to-database restores from archive files made with --inserts or
--column-inserts fail in our latest releases, as reported by Dick Visser.

To fix, restore the mini SQL lexer, but simplify it by adjusting the
calling logic so that it's only required to cope with INSERT-style table
data, not arbitrary SQL commands. This allows us to not have to deal with
SQL comments, E'' strings, or dollar-quoted strings, none of which have
ever been emitted by dumpTableData_insert.

Also, fix the lexer to cope with standard-conforming strings, which was the
actual bug that the previous patch was meant to solve.

Back-patch to all supported branches. The previous patch went back to 8.2,
which unfortunately means that the EOL release of 8.2 contains this bug,
but I don't think we're doing another 8.2 release just because of that.

Branch
------
REL8_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/a86448e868b918018785295ed9091b5694067b24

Modified Files
--------------
src/bin/pg_dump/pg_backup_archiver.c | 16 +++---
src/bin/pg_dump/pg_backup_archiver.h | 25 +++++++++-
src/bin/pg_dump/pg_backup_db.c | 90 +++++++++++++++++++++++++++++++++-
src/bin/pg_dump/pg_dump.c | 8 +++
4 files changed, 130 insertions(+), 9 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-01-06 18:31:53 pgsql: Fix typo, pg_types_date.h => pgtypes_date.h.
Previous Message Andrew Dunstan 2012-01-06 16:13:40 Re: [COMMITTERS] pgsql: Fix breakage from earlier plperl fix.