From: Scot Loach <sloach@sandvine.com>
To: Dave Page <dpage@vale-housing.co.uk>
To: pgsql-odbc@postgresql.org
Subject: Re: row count with libpq driver
Date: Wed, 14 Sep 2005 23:02:15 -0400
Message-ID: <71837C040963F748B9B94E123A2896785A1086@mailserver.sandvine.com> (raw)
A patch for this is attached, please review.
scot.
-----Original Message-----
From: Dave Page [mailto:dpage@vale-housing.co.uk]
Sent: Fri 9/9/2005 8:02 AM
To: Scot Loach; pgsql-odbc@postgresql.org
Cc:
Subject: RE: [ODBC] row count with libpq driver
> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Scot Loach
> Sent: 09 September 2005 12:52
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] row count with libpq driver
>
> Previously you guys made some fixes to the odbc driver
> dealing with row counts.
> I have noticed that the old driver seems to return the
> correct row count for SELECT statements, at least in some cases.
> The new driver does not; it only works for INSERT and UPDATE
> statements.
> Is this behavior intentional, is it possible to fix this?
Technically that is as per spec
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/ht
m/odbcsqlrowcount.asp, however the spec does allow the row count from
selects to be returned if the driver wants. Feel free to submit a patch
(I'm swamped right now :-( ).
Regards, Dave
Attachments:rowcount.patch (application/octet-stream, 1.5K) download--- connection.c.old 2005-09-14 22:55:05.000000000 -0400+++ connection.c 2005-09-14 22:13:31.000000000 -0400@@ -3244,6 +3244,11 @@
PQclear(pgres);
return qres;
}
+ + if (PQresultStatus(pgres) == PGRES_TUPLES_OK)+ {+ qres->ntuples = PQntuples(pgres);+ }
qres=CC_mapping(self,pgres,qres);
QR_set_command(qres, query);
--- qresult.h.old 2005-09-14 22:57:12.000000000 -0400+++ qresult.h 2005-09-14 22:12:20.000000000 -0400@@ -69,6 +69,7 @@
#ifdef USE_LIBPQ
ExecStatusType status;
+ int ntuples;
#else
QueryResultCode status;
#endif /* USE_LIBPQ*/
--- qresult.c.old 2005-09-14 22:57:07.000000000 -0400+++ qresult.c 2005-09-14 22:13:01.000000000 -0400@@ -135,6 +135,9 @@
rv->dl_alloc = 0;
rv->dl_count = 0;
rv->deleted = NULL;
+#ifdef USE_LIBPQ+ rv->ntuples = 0;+#endif
}
mylog("exit QR_Constructor\n");
--- results.c.old 2005-09-14 22:57:16.000000000 -0400+++ results.c 2005-09-14 22:59:47.000000000 -0400@@ -74,6 +74,13 @@
}
if (res->recent_processed_row_count >= 0)
{
+#ifndef USE_LIBPQ+ if (res->recent_processed_row_count = 0 && res->ntuples > 0)+ {+ *pcrow = res->ntuples;+ return SQL_SUCCESS;+ }+#endif
*pcrow = res->recent_processed_row_count;
mylog("**** PGAPI_RowCount(): THE ROWS: *pcrow = %d\n", *pcrow);
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: sloach@sandvine.com, dpage@vale-housing.co.uk
Subject: Re: row count with libpq driver
In-Reply-To: <71837C040963F748B9B94E123A2896785A1086@mailserver.sandvine.com>
References: <71837C040963F748B9B94E123A2896785A1086@mailserver.sandvine.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox