Yana K.
Yana K.

Reputation: 2270

Postgres: org.postgresql.util.PSQLException: ERROR: insufficient data left in message

I read enough to know that this occurs when a string contains some characters that Postgres doesn't like. However, I cannot figure out if there is a way to validate strings before writing them. In particular, I'm doing batch inserts.

insert into foo(col1,col2,col3) values ('a',2,3),('b',4,0),....

My DB is setup like this:

   Name     | Owner  | Encoding | Collate | Ctype | Access privileges
------------+--------+----------+---------+-------+-------------------
 stats      | me     | UTF8     | C       | C     |

Periodically, some bad string will get in and the whole insert will fail(e.g. change���=). I batch up quite a few values in a single insert so I'd like to ideally validate the string rather than bomb the whole insert. Is there a list of which characters are not allowed in a Postgres insert?

Using postgresql-jdbc 9.1-901.jdbc4

Upvotes: 7

Views: 20150

Answers (4)

Auguste
Auguste

Reputation: 11

This means that the types are not matching. In my case, I was trying to insert int where it was supposed to be int64.

Upvotes: 0

Katy
Katy

Reputation: 1157

On my case, I was loading query from an sql file. The problem was due to the encoding. I change it to UTF-8 and it works. Hope that helps !

Upvotes: 0

Rocher Kong
Rocher Kong

Reputation: 106

date type is not match target type.for example int4->int8

Upvotes: 8

Rich
Rich

Reputation: 15465

This message means that your string data has a null character "\0" in it.

I can't find an authoritative cite for this (let me know if you have one).

All other characters are allowed.

Upvotes: 6

Related Questions