Re: Re: [GENERAL] pg_dump behaves differently for different archive formats

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Re: [GENERAL] pg_dump behaves differently for different archive formats
Date: 2014-07-28 13:56:04
Message-ID: 32504.1406555764@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> writes:
> I thought that changing the dump format for this would be too
> much trouble, so I came up with the attached.

> It assumes that custom- or tar-format archives are written by pg_dump
> and cannot contain arbitrary SQL statements, which allows me to get away
> with very simple parsing.

I don't think this can be trusted in the least. To begin with, where'd
you get the idea dumps cannot contain "arbitrary SQL statements"? CREATE
RULE at least could contain some pretty weird stuff. This thing doesn't
look like it's even bothering to count nested parentheses, so it will
certainly fail on a multi-statement rule. I believe you're also at risk
of SQL injection attacks from failing to account for multibyte characters
in non-ASCII-safe client encodings.

While those specific problems could no doubt be fixed, I object to the
entire concept of assuming that what pg_dump emits is always going to be
trivially parsable. If we are to go down this path, I think we have to
replicate what psql is doing to identify statement boundaries ... and
as I mentioned upthread, that's rather a lot of code :-(

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message François Beausoleil 2014-07-28 14:09:04 Pairwise array sum aggregate function?
Previous Message Albe Laurenz 2014-07-28 13:18:09 Re: [GENERAL] pg_dump behaves differently for different archive formats

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2014-07-28 14:30:34 Re: building pdfs
Previous Message Albe Laurenz 2014-07-28 13:18:09 Re: [GENERAL] pg_dump behaves differently for different archive formats