From dev-return-15961-apmail-apr-dev-archive=apr.apache.org@apr.apache.org Mon Apr 10 02:52:50 2006 Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 1198 invoked from network); 10 Apr 2006 02:52:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 10 Apr 2006 02:52:50 -0000 Received: (qmail 89363 invoked by uid 500); 10 Apr 2006 02:52:49 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 89158 invoked by uid 500); 10 Apr 2006 02:52:48 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 89147 invoked by uid 99); 10 Apr 2006 02:52:48 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Apr 2006 19:52:48 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of bojan@rexursive.com designates 203.171.74.242 as permitted sender) Received: from [203.171.74.242] (HELO beauty.rexursive.com) (203.171.74.242) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Apr 2006 19:52:47 -0700 Received: by beauty.rexursive.com (Postfix, from userid 48) id BE16F25556E; Mon, 10 Apr 2006 12:52:25 +1000 (EST) Received: from cache0.syd.ops.aspac.uu.net (cache0.syd.ops.aspac.uu.net [203.166.96.234]) by www.rexursive.com (Horde MIME library) with HTTP; Mon, 10 Apr 2006 12:52:25 +1000 Message-ID: <20060410125225.lyzeqobja8c88soo@www.rexursive.com> Date: Mon, 10 Apr 2006 12:52:25 +1000 From: Bojan Smojver To: APR Development List Subject: [PATCH]: Use PQprepare MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_43x3mkgocakg" Content-Transfer-Encoding: 7bit User-Agent: Internet Messaging Program (IMP) H3 (4.1) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This message is in MIME format. --=_43x3mkgocakg Content-Type: text/plain; charset=ISO-8859-1; DelSp="Yes"; format="flowed" Content-Disposition: inline Content-Transfer-Encoding: 7bit This patch is just a request for comment, to see if I'm on the right track here. The thing does compile, but I didn't actually test it. You will note that I have hardcoded OIDs in several places, because if we want to pick them up from pg_type.h, the detection code in dbd.m4 will have to become far more complicated (in fact, unless certain options were used to install PGSQL, that file may not even be there - OUCH!). So, I just short circuited that for now, in order to get some feedback. -- Bojan --=_43x3mkgocakg Content-Type: text/x-patch; charset=ISO-8859-1; name="apr-util-PQprepare-use.patch" Content-Disposition: attachment; filename="apr-util-PQprepare-use.patch" Content-Transfer-Encoding: quoted-printable diff -rauN apr-util-with-test/dbd/apr_dbd_pgsql.c apr-util/dbd/apr_dbd_pgsql= .c --- apr-util-with-test/dbd/apr_dbd_pgsql.c=092006-04-10 08:55:44.000000000 += 1000 +++ apr-util/dbd/apr_dbd_pgsql.c=092006-04-10 12:45:08.000000000 +1000 @@ -28,6 +28,8 @@ =20 #include "apr_dbd_internal.h" =20 +#include "apu_config.h" + #define QUERY_MAX_ARGS 40 =20 struct apr_dbd_transaction_t { @@ -239,13 +241,17 @@ char *sqlptr; size_t length; size_t i =3D 0; - const char *args[QUERY_MAX_ARGS]; size_t alen; int nargs =3D 0; int ret; PGresult *res; char *pgquery; char *pgptr; +#if HAVE_PQPREPARE + Oid ptypes[QUERY_MAX_ARGS]; +#else + const char *args[QUERY_MAX_ARGS]; +#endif =20 if (!*statement) { *statement =3D apr_palloc(pool, sizeof(apr_dbd_prepared_t)); @@ -278,6 +284,18 @@ *pgptr++ =3D '0' + ((i+1)%10); } switch (*++sqlptr) { +#if HAVE_PQPREPARE + case 'd': + ptypes[i] =3D 23; /* INT4OID */ + break; + case 's': + ptypes[i] =3D 1023; /* VARCHAROID */ + break; + default: + ptypes[i] =3D 1023; /* VARCHAROID */ + break; + } +#else case 'd': args[i] =3D "integer"; break; @@ -289,6 +307,7 @@ break; } length +=3D 1 + strlen(args[i]); +#endif ++i; } else if ((sqlptr[0] =3D=3D '%') && (sqlptr[1] =3D=3D '%')) { @@ -309,6 +328,9 @@ } (*statement)->name =3D apr_pstrdup(pool, label); =20 +#if HAVE_PQPREPARE + res =3D PQprepare(sql->conn, (*statement)->name, pgquery, nargs, ptypes= ); +#else /* length of SQL query that prepares this statement */ length =3D 8 + strlen(label) + 2 + 4 + length + 1; sqlcmd =3D apr_palloc(pool, length); @@ -336,6 +358,7 @@ *sqlptr =3D 0; =20 res =3D PQexec(sql->conn, sqlcmd); +#endif if ( res ) { ret =3D PQresultStatus(res); if (dbd_pgsql_is_success(ret)) { --=_43x3mkgocakg--