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 EB28952841 for ; Fri, 3 Jun 2005 16:01:01 -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 64184-07 for ; Fri, 3 Jun 2005 19:00:52 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) by svr1.postgresql.org (Postfix) with ESMTP id 8CCF652918 for ; Fri, 3 Jun 2005 16:00:49 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so949408wra for ; Fri, 03 Jun 2005 12:00:51 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=QX9zsv/1rOxZeb8WlZxAvQIxwQ3pcL7elvhLCHhxcnBLea2Vcp/lRM8Gfc6c+TprgRLO0iqW+UfTkP6SBvLNV65Pd/6H/WFUo8WwuYUuS0JL74Ba7kAJsbj30T40slZRAsYzeyNFSGESAegC76+3oWC+7Zjl6RC1VCOSkvvXz/g= Received: by 10.54.56.50 with SMTP id e50mr509031wra; Fri, 03 Jun 2005 12:00:51 -0700 (PDT) Received: by 10.54.53.40 with HTTP; Fri, 3 Jun 2005 12:00:51 -0700 (PDT) Message-ID: Date: Fri, 3 Jun 2005 14:00:51 -0500 From: David Hinkle Reply-To: David Hinkle To: pgsql-interfaces@postgresql.org Subject: Re: libpq, PQExecParams and the inserting of binary data In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <6424.1117820918@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/15 X-Sequence-Number: 5583 It would be great if someone could take the time to write this up and include it in the manual, I have to do about a million extraniouse text conversions, small string allocations and deallocations because I couldn't find any docs. David On 6/3/05, Robert Perry wrote: > While on the subject might I ask where I could find some document= ation > of the raw binary format for other types such a Date and Decimal(,)? >=20 > Thanks > Robert Perry >=20 >=20 > On Jun 3, 2005, at 1:48 PM, Tom Lane wrote: >=20 > > 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 > > >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose an index scan if you= r > joining column's datatypes do not match >