Search Postgresql Archives

Problem with binary data transfer format of TEXT in 8.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux