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 B99755288E for ; Fri, 3 Jun 2005 14:48:48 -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 31631-10 for ; Fri, 3 Jun 2005 17:48:40 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id C096252875 for ; Fri, 3 Jun 2005 14:48:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j53HmcEh006425; Fri, 3 Jun 2005 13:48:38 -0400 (EDT) To: David Hinkle Cc: pgsql-interfaces@postgresql.org Subject: Re: libpq, PQExecParams and the inserting of binary data In-reply-to: References: Comments: In-reply-to David Hinkle message dated "Fri, 03 Jun 2005 11:18:25 -0500" Date: Fri, 03 Jun 2005 13:48:38 -0400 Message-ID: <6424.1117820918@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/9 X-Sequence-Number: 5577 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