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 51F515288E for ; Fri, 3 Jun 2005 14:36:42 -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 25856-10 for ; Fri, 3 Jun 2005 17:36:39 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.205]) by svr1.postgresql.org (Postfix) with ESMTP id 995B15287E for ; Fri, 3 Jun 2005 14:36:37 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so919612wra for ; Fri, 03 Jun 2005 10:36:38 -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=dTPUj5FFDKiorKvQ1lK/pOE0H7nxphSg2qY1qgXLDDcrHPWgL87Mw3mksLLVXWkQFNu4p7mJjchYKJ605nSREx3oYwtqeaieVZoTL1xLLholigHmSlVpoMoQrOk9/2Wng+mHRtxGbKt9LJ8aaZhzk7YSiv2/PRcNphcVGAPnwZs= Received: by 10.54.39.69 with SMTP id m69mr1343620wrm; Fri, 03 Jun 2005 10:36:38 -0700 (PDT) Received: by 10.54.53.40 with HTTP; Fri, 3 Jun 2005 10:36:38 -0700 (PDT) Message-ID: Date: Fri, 3 Jun 2005 12:36:38 -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: <7104a7370506030943662e4be@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <7104a7370506030943662e4be@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/8 X-Sequence-Number: 5576 Yea, I know, but that doesn't help me. I need to know how to insert binary data. I can't do it as text without escaping because it's not null terminated and may contain nulls. I can't do it as binary because I don't have any documentation on how to use it that way.=20 What I'm asking for is an expample or a document showing me how to do it. I already know my way doesn't work. If you could show me the proper way to do it that would be great. David On 6/3/05, Volkan YAZICI wrote: > Hi, >=20 > On 6/3/05, David Hinkle wrote: > > 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. >=20 > You don't need to (also you shouldn't) escape any data while using > parameters. Because, you'll miss one big advantage of parameter usage. > From PQexecParams() documentation: >=20 > =ABThe primary advantage of PQexecParams over PQexec is that parameter > values may be separated from the command string, thus avoiding the > need for tedious and error-prone quoting and escaping. Unlike PQexec, > PQexecParams allows at most one SQL command in the given string. > (There can be semicolons in it, but not more than one nonempty > command.) This is a limitation of the underlying protocol, but has > some usefulness as an extra defense against SQL-injection attacks.=BB >=20 > Regards. >