X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0BF745283A for ; Fri, 3 Jun 2005 15:28:25 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 42334-09 for ; Fri, 3 Jun 2005 18:28:16 +0000 (GMT) Received: from www.lodestonetechnologies.com (lodestonetechnologies.com [69.64.33.50]) by svr1.postgresql.org (Postfix) with ESMTP id 9AD7952906 for ; Fri, 3 Jun 2005 15:28:15 -0300 (ADT) Received: (qmail 7024 invoked from network); 3 Jun 2005 19:31:59 -0000 Received: from 69-170-154-159.ironoh.adelphia.net (HELO ?192.168.253.4?) (69.170.154.159) by lodestonetechnologies.com with SMTP; 3 Jun 2005 19:31:58 -0000 Mime-Version: 1.0 (Apple Message framework v622) In-Reply-To: <6424.1117820918@sss.pgh.pa.us> References: <6424.1117820918@sss.pgh.pa.us> Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Robert Perry Subject: Re: libpq, PQExecParams and the inserting of binary data Date: Fri, 3 Jun 2005 14:28:14 -0400 To: pgsql-interfaces@postgresql.org X-Mailer: Apple Mail (2.622) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/14 X-Sequence-Number: 5582 While on the subject might I ask where I could find some documentation of the raw binary format for other types such a Date and Decimal(,)? Thanks Robert Perry On Jun 3, 2005, at 1:48 PM, Tom Lane wrote: > David Hinkle 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 > > ---------------------------(end of > broadcast)--------------------------- > TIP 8: explain analyze is your friend >