Re: [GENERAL] bytea insert difference between 8.3 and 9.x

2012-06-19 Thread McKay
Merlin Moncure-2 wrote > > m_connection.prepare("INSERT INTO foo(x) VALUES($1)") ("bytea", > pqxx::prepare::treat_binary); > I have the same problem. I can't get accsess to pqxx::prepare::treat_binary. And m_connection.prepare(...) two arguments only. What i mist? -- View this message in cont

Re: [GENERAL] bytea insert difference between 8.3 and 9.x

2011-09-26 Thread Merlin Moncure
On Mon, Sep 26, 2011 at 8:50 AM, Gregg Jaskiewicz wrote: > Thanks Merin. > > It does, and that's probably what I'll do. Your solution isn't great > either, because it requires extra function to be run on the postgresql > side. Me no likeey that ;) If you are sending a bytea as encoded text, you h

Re: [GENERAL] bytea insert difference between 8.3 and 9.x

2011-09-26 Thread Merlin Moncure
On Mon, Sep 26, 2011 at 5:51 AM, Gregg Jaskiewicz wrote: > So consider this code C++, using libpqxx: > > string = "INSERT INTO foo(x) VALUES( E'" + T.esc_raw(data) + "' )"; > > foo(x) is bytea , before you ask. > > On 8.3, it works fine. > On 9.x: > > ERROR:  invalid byte sequence for encoding "UT

Re: [GENERAL] bytea insert difference between 8.3 and 9.x

2011-09-26 Thread Gregg Jaskiewicz
On 26 September 2011 14:39, Merlin Moncure wrote: > urk -- I have to be honest -- that's a pretty lousy way to send bytea. > Personally, I'd encode the string as hex and send it like this: > > "INSERT INTO foo(x) VALUES( decode('" + hex_string + "'))"; > > libpqxx doesn't have the ability to para

[GENERAL] bytea insert difference between 8.3 and 9.x

2011-09-26 Thread Gregg Jaskiewicz
So consider this code C++, using libpqxx: string = "INSERT INTO foo(x) VALUES( E'" + T.esc_raw(data) + "' )"; foo(x) is bytea , before you ask. On 8.3, it works fine. On 9.x: ERROR: invalid byte sequence for encoding "UTF8": 0x00 (if \000 is in the string). Now, I can take out the E'' and it