Thread: row count with libpq driver

row count with libpq driver

From
"Scot Loach"
Date:
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?


Re: row count with libpq driver

From
"Dave Page"
Date:

> -----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

Re: row count with libpq driver

From
"Scot Loach"
Date:
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




Attachment

Re: row count with libpq driver

From
"Dave Page"
Date:

> -----Original Message-----
> From: Scot Loach [mailto:sloach@sandvine.com]
> Sent: 15 September 2005 04:02
> To: Dave Page; pgsql-odbc@postgresql.org
> Subject: RE: [ODBC] row count with libpq driver
>
> A patch for this is attached, please review.

Thanks Scot - patch applied with a couple of minor fixes - specifically

+#ifndef USE_LIBPQ
+                        if (res->recent_processed_row_count = 0 &&
res->ntuples > 0)
+                        {
+                            *pcrow = res->ntuples;
+                            return SQL_SUCCESS;
+                        }
+#endif

Was changed to

+#ifdef USE_LIBPQ
+                        if (res->recent_processed_row_count == 0 &&
res->ntuples > 0)
+                        {
+                            *pcrow = res->ntuples;
+                            return SQL_SUCCESS;
+                        }
+#endif

Note the '#ifdef', and '== 0'

Regards, Dave

Re: row count with libpq driver

From
"Dave Page"
Date:
Hi Scot,

Unfortunately I've been seeing some unexplained errors with some
Microsoft ADO based apps since applying this patch, so I've backed it
out for now. Unfortunately, ADO doesn't give any useful error messages.

I'm not entirely sure what's wrong - can you look at it please? I'm
still swamped at the moment :-(

Regards, Dave

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Dave Page
> Sent: 15 September 2005 09:12
> To: Scot Loach; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] row count with libpq driver
>
>
>
> > -----Original Message-----
> > From: Scot Loach [mailto:sloach@sandvine.com]
> > Sent: 15 September 2005 04:02
> > To: Dave Page; pgsql-odbc@postgresql.org
> > Subject: RE: [ODBC] row count with libpq driver
> >
> > A patch for this is attached, please review.
>
> Thanks Scot - patch applied with a couple of minor fixes -
> specifically
>
> +#ifndef USE_LIBPQ
> +                        if (res->recent_processed_row_count = 0 &&
> res->ntuples > 0)
> +                        {
> +                            *pcrow = res->ntuples;
> +                            return SQL_SUCCESS;
> +                        }
> +#endif
>
> Was changed to
>
> +#ifdef USE_LIBPQ
> +                        if (res->recent_processed_row_count == 0 &&
> res->ntuples > 0)
> +                        {
> +                            *pcrow = res->ntuples;
> +                            return SQL_SUCCESS;
> +                        }
> +#endif
>
> Note the '#ifdef', and '== 0'
>
> Regards, Dave
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

Re: row count with libpq driver

From
"Scot Loach"
Date:
I'm not sure how I'd investigate such an issue.
And I'm also swamped :)
I don't even know what ADO is so I doubt if I'd be much help.

scot.


-----Original Message-----
From: Dave Page [mailto:dpage@vale-housing.co.uk]
Sent: Friday, September 16, 2005 12:06 PM
To: Scot Loach; pgsql-odbc@postgresql.org
Subject: RE: [ODBC] row count with libpq driver


Hi Scot,

Unfortunately I've been seeing some unexplained errors with some
Microsoft ADO based apps since applying this patch, so I've backed it
out for now. Unfortunately, ADO doesn't give any useful error messages.

I'm not entirely sure what's wrong - can you look at it please? I'm
still swamped at the moment :-(

Regards, Dave

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Dave Page
> Sent: 15 September 2005 09:12
> To: Scot Loach; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] row count with libpq driver
>
>
>
> > -----Original Message-----
> > From: Scot Loach [mailto:sloach@sandvine.com]
> > Sent: 15 September 2005 04:02
> > To: Dave Page; pgsql-odbc@postgresql.org
> > Subject: RE: [ODBC] row count with libpq driver
> >
> > A patch for this is attached, please review.
>
> Thanks Scot - patch applied with a couple of minor fixes -
> specifically
>
> +#ifndef USE_LIBPQ
> +                        if (res->recent_processed_row_count = 0 &&
> res->ntuples > 0)
> +                        {
> +                            *pcrow = res->ntuples;
> +                            return SQL_SUCCESS;
> +                        }
> +#endif
>
> Was changed to
>
> +#ifdef USE_LIBPQ
> +                        if (res->recent_processed_row_count == 0 &&
> res->ntuples > 0)
> +                        {
> +                            *pcrow = res->ntuples;
> +                            return SQL_SUCCESS;
> +                        }
> +#endif
>
> Note the '#ifdef', and '== 0'
>
> Regards, Dave
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

Re: row count with libpq driver

From
"Dave Page"
Date:
-----Original Message-----
From: "Scot Loach"<sloach@sandvine.com>
Sent: 16/09/05 18:11:51
To: "Dave Page"<dpage@vale-housing.co.uk>, "pgsql-odbc@postgresql.org"<pgsql-odbc@postgresql.org>
Subject: RE: [ODBC] row count with libpq driver

> I'm not sure how I'd investigate such an issue.

No, nor I. Perhaps something else needs to be done before returning from pgapi_rowcount?

> And I'm also swamped :)

:-(. I believe Anoop is as well, so if anyone else wants to try a mini project...

> I don't even know what ADO is so I doubt if I'd be much help.

Microsoft's ActiveX Data Objects - their most popular and recommended non-dotNET data access libraries. If they break,
wewill certainly get lots of bug reports :-(. My app is pretty basic as well, so it's unlikely to be an edge case. Oh,
andfwiw, it's worked with psqlODBC back to v6.something, so it's not simply that it gets confused now it sees a
rowcountfrom a select 'cos it always used to :-) 

/D

-----Unmodified Original Message-----
I'm not sure how I'd investigate such an issue.
And I'm also swamped :)
I don't even know what ADO is so I doubt if I'd be much help.

scot.


-----Original Message-----
From: Dave Page [mailto:dpage@vale-housing.co.uk]
Sent: Friday, September 16, 2005 12:06 PM
To: Scot Loach; pgsql-odbc@postgresql.org
Subject: RE: [ODBC] row count with libpq driver


Hi Scot,

Unfortunately I've been seeing some unexplained errors with some
Microsoft ADO based apps since applying this patch, so I've backed it
out for now. Unfortunately, ADO doesn't give any useful error messages.

I'm not entirely sure what's wrong - can you look at it please? I'm
still swamped at the moment :-(

Regards, Dave

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Dave Page
> Sent: 15 September 2005 09:12
> To: Scot Loach; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] row count with libpq driver
>
>
>
> > -----Original Message-----
> > From: Scot Loach [mailto:sloach@sandvine.com]
> > Sent: 15 September 2005 04:02
> > To: Dave Page; pgsql-odbc@postgresql.org
> > Subject: RE: [ODBC] row count with libpq driver
> >
> > A patch for this is attached, please review.
>
> Thanks Scot - patch applied with a couple of minor fixes -
> specifically
>
> +#ifndef USE_LIBPQ
> +                        if (res->recent_processed_row_count = 0 &&
> res->ntuples > 0)
> +                        {
> +                            *pcrow = res->ntuples;
> +                            return SQL_SUCCESS;
> +                        }
> +#endif
>
> Was changed to
>
> +#ifdef USE_LIBPQ
> +                        if (res->recent_processed_row_count == 0 &&
> res->ntuples > 0)
> +                        {
> +                            *pcrow = res->ntuples;
> +                            return SQL_SUCCESS;
> +                        }
> +#endif
>
> Note the '#ifdef', and '== 0'
>
> Regards, Dave
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: explain analyze is your friend
>