Re: bytea insert difference between 8.3 and 9.x

From: Gregg Jaskiewicz <gryzman(at)gmail(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: bytea insert difference between 8.3 and 9.x
Date: 2011-09-26 13:50:58
Message-ID: CAJY59_jNqb6jU59L3Q=PGB76FZJgmDj2=bOx1xYDe46S_5WE-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 26 September 2011 14:39, Merlin Moncure <mmoncure(at)gmail(dot)com> 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 parameterize queries?
>

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 ;)
When you say parameterized - it allows you to prepare queries - which
I do in 80% of select/insert/update cases, apart from some older code
that no one wants to touch.
But the time came for me to act on it, and try to put us forward using
9.1 instead of old rusty 8.3 (which is still better then 8.1 they used
before I started working here).

m_connection.prepare("INSERT INTO foo(x) VALUES($1)") ("bytea",
pqxx::prepare::treat_binary);

Gotta try that one with both boys ;)

Btw, I hope 9.1.1 is out soon, gotta package some version for tests.
We used floating point timestamps, and I gotta repackage centos rpms
with that config option - otherwise it's pg_dump and restore of gigs
of data....

--
GJ

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jov 2011-09-26 13:59:41 Pg and compress
Previous Message Merlin Moncure 2011-09-26 13:39:53 Re: bytea insert difference between 8.3 and 9.x