Re: BUG #3795: pg_dump is mis-dumping columns containing line breaks

Lists: pgsql-bugs
From: "Lou Duchez" <lou(at)paprikash(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3795: pg_dump is mis-dumping columns containing line breaks
Date: 2007-12-02 20:01:41
Message-ID: 200712022001.lB2K1fZ3015321@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 3795
Logged by: Lou Duchez
Email address: lou(at)paprikash(dot)com
PostgreSQL version: 8.3 beta 3
Operating system: Windows 2003
Description: pg_dump is mis-dumping columns containing line breaks
Details:

Hello,

My copy of PostgreSQL has standard_conforming_strings set to "on", and when
I attempt to pg_dump tables that have strings containing CR/LFs, the data
dumps in a format that psql cannot then reload. The CR/LFs are preceded by
a backslash ("\") in the dump but are not themselves "escaped" -- so instead
of looking like this:

line 1\nline2\nline3

it looks like this:

line 1\
line 2\
line 3

And psql seems to be unable to handle data in that format.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Lou Duchez" <lou(at)paprikash(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3795: pg_dump is mis-dumping columns containing line breaks
Date: 2007-12-02 21:29:54
Message-ID: 24725.1196630994@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"Lou Duchez" <lou(at)paprikash(dot)com> writes:
> My copy of PostgreSQL has standard_conforming_strings set to "on", and when
> I attempt to pg_dump tables that have strings containing CR/LFs, the data
> dumps in a format that psql cannot then reload.

It works fine here. Please provide a *complete* example of what you
are doing.

regards, tom lane


From: lou(at)paprikash(dot)com
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3795: pg_dump is mis-dumping columns containing line breaks
Date: 2007-12-02 22:52:52
Message-ID: 4752F0F4.23452.1DF08399@lou.paprikash.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

> "Lou Duchez" <lou(at)paprikash(dot)com> writes:
> > My copy of PostgreSQL has standard_conforming_strings set to "on", and when
> > I attempt to pg_dump tables that have strings containing CR/LFs, the data
> > dumps in a format that psql cannot then reload.
>
> It works fine here. Please provide a *complete* example of what you
> are doing.
>
> regards, tom lane
>

Hello,

Here is a complete example. I have two Windows servers, one with PostgreSQL 8.2.5, the
other with 8.3 beta 3. Both have standard_conforming_strings set to "on". My "test"
database is UTF8 on each server. I perform the following steps on each server:

1) Using pgAdmin III version 1.8, I create a table in my "test" database:

CREATE TABLE testtable
(
column1 character varying(200) DEFAULT '',
PRIMARY KEY (column1)
) WITH (OIDS=FALSE);

2) Again using pgAdmin, I add two rows to the table:

insert into testtable (column1) values ('This
is
a
multi
row
string'),
('This
is
another
multi
row
string');

3) Then I run the following pg_dump command:

pg_dump -U postgres -E LATIN1 -t testtable testdatabase

The two versions of PostgreSQL produce slightly different results. 8.2.5 generates the
following "COPY" command:

COPY testtable (column1) FROM stdin;
This\nis\na\nmulti\nrow\nstring
This\nis\nanother\nmulti\nrow\nstring
\.

8.3 beta 3 generates the following "COPY" command:

COPY testtable (column1) FROM stdin;
This\
is\
a\
multi\
row\
string
This\
is\
another\
multi\
row\
string
\.

The 8.3 version, with the unescaped line breaks, confuses the heck out of psql.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: lou(at)paprikash(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3795: pg_dump is mis-dumping columns containing line breaks
Date: 2007-12-02 23:24:09
Message-ID: 26218.1196637849@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

lou(at)paprikash(dot)com writes:
> The two versions of PostgreSQL produce slightly different results.

Yeah, that's an intentional change.

> The 8.3 version, with the unescaped line breaks, confuses the heck out
> of psql.

Works fine for me --- I can load either dump file into either version of
psql.

Maybe your test case involves letting Windows mangle the line endings?

regards, tom lane


From: Jorge Godoy <jgodoy(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3795: pg_dump is mis-dumping columns containing line breaks
Date: 2007-12-03 00:11:04
Message-ID: 200712022211.04815.jgodoy@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Em Sunday 02 December 2007 21:24:09 Tom Lane escreveu:
> lou(at)paprikash(dot)com writes:
> > The two versions of PostgreSQL produce slightly different results.
>
> Yeah, that's an intentional change.
>
> > The 8.3 version, with the unescaped line breaks, confuses the heck out
> > of psql.
>
> Works fine for me --- I can load either dump file into either version of
> psql.
>
> Maybe your test case involves letting Windows mangle the line endings?

Another things to pay attention: if the database is utf-8, why is he
specifying LATIN1 on the command line?

--
Jorge Godoy <jgodoy(at)gmail(dot)com>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: lou(at)paprikash(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3795: pg_dump is mis-dumping columns containing line breaks
Date: 2007-12-03 00:14:14
Message-ID: 29593.1196640854@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

I wrote:
> Maybe your test case involves letting Windows mangle the line endings?

On reflection, I'm sure that's exactly what's happening. I now remember
that one of the reasons for the old dump behavior was to make COPY data
a bit safer against line-ending mangling. I've reverted this rather
ill-advised change in behavior, and added a note in the code to
hopefully prevent anyone from making the same mistake again.

regards, tom lane