From: | Gracjan Polak <gracjanpolak(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Problem with binary data transfer format of TEXT in 8.4 |
Date: | 2011-12-01 11:50:20 |
Message-ID: | CAChsM3RavKEntGLwCvwrF705EYBFZmMXuDKpem+hedjM8Xj7FQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all,
(Please redirect me to correct place if there is one).
I'm trying to implement proper binary data transfer in
Database.HDBC.PostgreSQL Haskell library. This library is a wrapper around
libpq.
I sorted out how to use paramFormats[] param of PQexecParams. I sorted out
how to retrieve and properly unescape binary data when received with
PQunescapeBytea.
Due to architecture of wrapper library I'm unable to make a difference
between strings and binary data. It is all ByteString all over the place.
CREATE TABLE test( str TEXT, bytes BYTEA );
Works:
INSERT INTO test(bytes) VALUES (?)
with ["anything"]
SELECT bytes FROM test
returns ["anything"] correctly
Does not work:
INSERT INTO test(str) VALUES (?)
with ["anything"] sometimes fails with:
user error (SQL error: SqlError {seState = "08P01", seNativeError = 7,
seErrorMsg = "execute: PGRES_FATAL_ERROR: ERROR: insufficient data left in
message\n"})
So it seems to me that putting string into database with binary format
requires something more than just encoding it as UTF8 and stating its
length in paramLengths[].
So the question is:
How do I transfer strings in binary format?
Note: I do not need binary format of anything else but UTF-8 encoded TEXT.
Note 2: I leave paramTypes[] as NULL.
Versions:
PostgreSQL 8.4
MacOSX 10.6
postgresql, bound to client: 8.4.9
Proxied driver: postgresql, bound to version: 3
Connected to server version: 80409
--
Gracjan
From | Date | Subject | |
---|---|---|---|
Next Message | tamanna madaan | 2011-12-01 11:57:50 | Re: psql query gets stuck indefinitely |
Previous Message | Adarsh Sharma | 2011-12-01 11:46:51 | How to get Place Names from Lat Lon |