Thread: \copy problem

\copy problem

From
Jose Soares
Date:
Hi all,

I have a problem using \copy to load data into tables.

I have to load data into a table that contains data type fields with
NULL values.
I tried using \N but it doesn't work.
What can I do to insert a null into a data field?

To arrive this conclusion I had to try many solutions because I cannot
understand
the \copy error messages..

What about to have the row number and the error type instead of that...
hygea=> \copy movimentazioni from 4;
pqReadData() --  read() failed: errno=32
Broken pipe
PQendcopy: resetting connection
Copy failed.

Comments!

Jose'

Re: [HACKERS] \copy problem

From
Peter Eisentraut
Date:
On 1999-12-16, Jose Soares mentioned:

> I have a problem using \copy to load data into tables.
>
> I have to load data into a table that contains data type fields with
> NULL values.
> I tried using \N but it doesn't work.
> What can I do to insert a null into a data field?

Works for me. I also just messed with that part in the devel sources the
other day and I don't see a reason why it wouldn't. Perhaps you could run
the COPY command instead (and make sure the file is accessible to the
server process) or simply run a COPY FROM STDIN; and enter a few things by
hand and see what you get.

> the \copy error messages..
>
> What about to have the row number and the error type instead of that...
> hygea=> \copy movimentazioni from 4;
> pqReadData() --  read() failed: errno=32
> Broken pipe
> PQendcopy: resetting connection
> Copy failed.

When the backend sends garbage it cannot possibly send the error
message. The error was that the read from the connection failed. Of course
one could argue why that is ... Hmm.

--
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden



Re: [HACKERS] \copy problem

From
Jose Soares
Date:
Sorry Peter, I don't say you any thing, I'm using psql on win95.

1. I see psql for Linux requires \N only for data fields with null
values other fields (char,int,etc)
   doesn't need \N. Why ?
2. psql for M$Windows95 has a different behavior. For example I can't
insert date fields even using \N

I tried to load a file by changing every NULL value of date fields with
\N and it works
on Linux psql, but Win95 psql shows me the following message:
pqReadData() -- read() failed: errno=0
No error
PQendcopy: resetting connection
Copy failed.

Any ideas ?



Peter Eisentraut wrote:
>
> On 1999-12-16, Jose Soares mentioned:
>
> > I have a problem using \copy to load data into tables.
> >
> > I have to load data into a table that contains data type fields with
> > NULL values.
> > I tried using \N but it doesn't work.
> > What can I do to insert a null into a data field?
>
> Works for me. I also just messed with that part in the devel sources the
> other day and I don't see a reason why it wouldn't. Perhaps you could run
> the COPY command instead (and make sure the file is accessible to the
> server process) or simply run a COPY FROM STDIN; and enter a few things by
> hand and see what you get.
>
> > the \copy error messages..
> >
> > What about to have the row number and the error type instead of that...
> > hygea=> \copy movimentazioni from 4;
> > pqReadData() --  read() failed: errno=32
> > Broken pipe
> > PQendcopy: resetting connection
> > Copy failed.
>
> When the backend sends garbage it cannot possibly send the error
> message. The error was that the read from the connection failed. Of course
> one could argue why that is ... Hmm.
>
> --
> Peter Eisentraut                  Sernanders väg 10:115
> peter_e@gmx.net                   75262 Uppsala
> http://yi.org/peter-e/            Sweden
>
> ************