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 3EC2B5287E for ; Fri, 3 Jun 2005 13:43:40 -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 13877-04 for ; Fri, 3 Jun 2005 16:43:35 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) by svr1.postgresql.org (Postfix) with ESMTP id 30D2352802 for ; Fri, 3 Jun 2005 13:43:34 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 71so378637wra for ; Fri, 03 Jun 2005 09:43:34 -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:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=P8B5DBjTiWHcWA7uuvGKTBTt9zfsoofL/fZrXa5QSimfF2J39if+7GxNnJ+mmA2K1I62AqDA6sTNf1OynYzC+z/qoeJcTR1NvZCUX6B4atbxSIwsJ0NsROKajR3CvyjDchV3pe6fAmNni+sbFShZ9M5/3QA0RhVMV1DEwj0Gjhs= Received: by 10.54.26.62 with SMTP id 62mr1212732wrz; Fri, 03 Jun 2005 09:43:34 -0700 (PDT) Received: by 10.54.30.45 with HTTP; Fri, 3 Jun 2005 09:43:34 -0700 (PDT) Message-ID: <7104a7370506030943662e4be@mail.gmail.com> Date: Fri, 3 Jun 2005 19:43:34 +0300 From: Volkan YAZICI Reply-To: Volkan YAZICI To: David Hinkle Subject: Re: libpq, PQExecParams and the inserting of binary data Cc: pgsql-interfaces@postgresql.org In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.172 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200506/7 X-Sequence-Number: 5575 Hi, 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. 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: =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 Regards.