Skip site navigation (1) Skip section navigation (2)

Re: libpq, PQExecParams and the inserting of binary data

From: David Hinkle <drachs(at)gmail(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: libpq, PQExecParams and the inserting of binary data
Date: 2005-06-03 18:04:11
Message-ID: ae830e6c0506031104140a2b35@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
I read all the examples and documentation thouroughly.  I would not
bother you guys otherwise.  That example doesn't show you how to use
any binary parameters... All the parameters are text, it only shows
you how get binary results.  I think it's a huge oversight myself.

I could probably figure out how to use the parameters as binary, but I
have no idea what to do with the OID field.

David

On 6/3/05, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> David Hinkle <drachs(at)gmail(dot)com> writes:
> > As you can see, I assumed I could use PQexapeBytea to escape the
> > binary data and then just use the returned value as a text parameter.
> 
> No, because PQescapeBytea is designed to do the escaping that would be
> needed to put the bytea value into a string literal in a SQL command.
> There's an extra level of backslashing involved to do that (because
> backslashes are special to both the string-literal syntax and the
> text input syntax for bytea).
> 
> But this is really the hard way to do it considering that you are using
> PQexecParams.  Just tell PQexecParams that you want this parameter to be
> binary format, and pass the *raw* binary string as the parameter.
> 
> > I couldn't find any documentation on using PQExecParams
> > with binary parameters,
> 
> src/test/examples/testlibpq3.c ... that example is reproduced in
> the libpq manual, as well.
> 
>                         regards, tom lane
>

In response to

Responses

pgsql-interfaces by date

Next:From: David HinkleDate: 2005-06-03 18:05:35
Subject: Re: libpq, PQExecParams and the inserting of binary data
Previous:From: Daniel VeriteDate: 2005-06-03 17:54:52
Subject: Re: libpq, PQExecParams and the inserting of binary data

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group