Re: i have a big trouble - Mailing list pgsql-sql

From Tom Lane
Subject Re: i have a big trouble
Date
Msg-id 12386.980351143@sss.pgh.pa.us
Whole thread Raw
In response to i have a big trouble  (Sandis Jerics <sandis@mediaparks.lv>)
List pgsql-sql
Sandis Jerics <sandis@mediaparks.lv> writes:
> www_mod_lv=> \copy news from '/home/sites/www.mod.lv/web/news.sql'
> \.
> ERROR:  copy: line 2, pg_atoi: error in "
> At the international humanitarian mission of KFOR the Latvian unit participates with 10 soldiers from the National
ArmedForces. The KFOR Latvian contingent  - Military Police and medical units - will operate within the contingent of
UK. "
 

Notice that the complaint is from pg_atoi, so the problem is that the
given text is being taken as an integer field --- that is, as the start
of a new row of data.  I suspect what is happening is that the embedded
newlines in your text column are getting munged up so that they look
like ordinary newlines (end of a data row) to COPY.

A newline that is part of the data, and not a row separator, has to be
represented as a backslash followed by a newline (\n) character.
Anything that messes this up will confuse COPY.  One theory that comes
to mind is that you edited the dump file with an editor that converts
Unix-style newlines (\n) to DOS-style (\r\n).  Then your embedded
newlines would become backslash \r \n ... in other words, a quoted \r
followed by a regular end-of-row marker.
        regards, tom lane


pgsql-sql by date:

Previous
From: Attila Kevei
Date:
Subject: select returns no line
Next
From: Tom Lane
Date:
Subject: Re: How to change the ownership of the table?