[Haskell-cafe] HDBC, postgresql, bytestrings and embedded NULLs
iustin at google.com
Fri Jan 7 10:44:55 CET 2011
It seems that (at least) the postgresql bindings do not allow pure
I have a simple table:
debug=# create table test (name bytea);
byteas seems to be the backing type on the DB side for bytestrings.
and then I run this:
main = do
db <- connectPostgreSQL "dbname=debug"
stmt <- prepare db "INSERT INTO test (name) VALUES($1)"
execute stmt [toSql $ pack ]
execute stmt [toSql $ pack [65, 0, 66]]
What happens is that the inserted string is cut-off at the first NULL
value: the first row is empty, and the second row contains just "A".
“When entering bytea values, octets of certain values must be escaped
(but all octet values can be escaped) when used as part of a string
literal in an SQL statement. In general, to escape an octet, convert it
into its three-digit octal value and precede it by two backslashes”, and
continues to list that NULL should be quoted as E'\\000'. However, I
find no such quoting in the HDCB.Postgresql sources.
Anyone else stumbled on this?
More information about the Haskell-Cafe