Re: Getting "insufficient data left in message" on copy with binary

From: Gordon Shannon <gordo169(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting "insufficient data left in message" on copy with binary
Date: 2009-09-04 03:05:21
Message-ID: 25287583.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane-2 wrote:
>
> Gordon Shannon <gordo169(at)gmail(dot)com> writes:
>
>> ERROR: insufficient data left in message
>> CONTEXT: COPY mytable, line 1, column provider_id
>
>> Anybody seen this?
>
> No. Can you extract a self-contained test case?
>

Got it. The problem was a combination of 2 mis-matched data types.
Consider this test case:

----------------begin-------------------

drop table if exists bar;
drop table if exists foo;

create table foo (
system_id smallint,
credibility real not null
);

insert into foo ( system_id, credibility) values (1,1);

copy foo to '/tmp/repeat.dat' with binary;

create table bar (
system_id int,
credibility numeric(10,9) not null
);

copy bar from '/tmp/repeat.dat' with binary;

copy bar from '/var/lib/pgsql/backups/repeat.dat' with binary;
psql:repeat:19: ERROR: insufficient data left in message
CONTEXT: COPY bar, line 1, column system_id

--------------end-----------------

It's interesting to note that I get this error only when there are 2 bad
fields.
If I fix only the numeric field, I get "incorrect binary data format" on the
int field.
If I fix only the smallint field, I get "invalid length in external
"numeric" value on the real field.

So, my fault, and the fix is obvious. But it does seem like a less than
ideal error message.

Also, maybe a sentence like this would be helpful on the COPY page: "Be
careful that the data types match from 'copy to' to 'copy from'. There is
no implicit conversion done in binary mode..." or some such?

Cheers

--
View this message in context: http://www.nabble.com/Getting-%22insufficient-data-left-in-message%22-on-copy-with-binary-tp25282935p25287583.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gordon Shannon 2009-09-04 03:43:38 Got could not truncate directory "pg_multixact/offsets": apparent wraparound
Previous Message Scott Marlowe 2009-09-04 02:24:44 Re: How do I store tables on a remote host?