Allow SQLRowCount to work following SELECT queries [Scot Loach]
authorDave Page <dpage@pgadmin.org>
Thu, 15 Sep 2005 08:09:43 +0000 (08:09 +0000)
committerDave Page <dpage@pgadmin.org>
Thu, 15 Sep 2005 08:09:43 +0000 (08:09 +0000)
connection.c
qresult.c
qresult.h
results.c

index 6b8703d67f2434b989d5e13644f74834586f4547..71ac3adcdc38226c9397072ae3524158483b8708 100644 (file)
@@ -3244,6 +3244,11 @@ LIBPQ_execute_query(ConnectionClass *self,char *query)
            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);
index 9911c63d19861b0e0b5dd5c5ee07580b10794ca3..d1f922f2fcbcf13dde7d85f6ae40c5fb61f95d96 100644 (file)
--- a/qresult.c
+++ b/qresult.c
@@ -135,6 +135,9 @@ QR_Constructor()
        rv->dl_alloc = 0;
        rv->dl_count = 0;
        rv->deleted = NULL;
+#ifdef USE_LIBPQ
+                rv->ntuples = 0;
+#endif
    }
 
    mylog("exit QR_Constructor\n");
index effa58b613ba8f3cbbc9779ea9d5f246d2885902..6776d2a37d8cc83f0c782564736f8a3057e76fc9 100644 (file)
--- a/qresult.h
+++ b/qresult.h
@@ -69,6 +69,7 @@ struct QResultClass_
 
 #ifdef USE_LIBPQ
    ExecStatusType status;
+        int            ntuples;
 #else
    QueryResultCode status;
 #endif /* USE_LIBPQ*/
index f28deac3ea452eb80d1a5b68836a8605e1d2e41c..36963dc4418ce72c739fe4601c0ff4f160788080 100644 (file)
--- a/results.c
+++ b/results.c
@@ -54,7 +54,7 @@ PGAPI_RowCount(
        SC_log_error(func, "", NULL);
        return SQL_INVALID_HANDLE;
    }
-   ci = &(SC_get_conn(stmt)->connInfo);\r
+   ci = &(SC_get_conn(stmt)->connInfo);
 #ifndef USE_LIBPQ
    if (stmt->manual_result)
    {
@@ -74,6 +74,13 @@ PGAPI_RowCount(
        }
        if (res->recent_processed_row_count >= 0)
        {
+#ifdef 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);