Web pgadmin.org
 Home 
 ·  ·  ·  ·  ·  ·  · 
pgSet MoveNext bug ?

pgSet MoveNext bug ?



Hi,

While reading the code, the PGSet->MoveNext() definition seems to have a small bug.

Since the PGSet->EOF() is defined as
bool Eof() const { return (!nRows || pos > nRows); }

I think it doesn't make sense to define PGSet->MoveNext() as
void MoveNext() { if (pos <= nRows) pos++; }

It should rather be
void MoveNext() { if (pos < nRows) pos++; }

The attached patch does the same.

Regards,
Robins Tharakan
Index: pgadmin/include/db/pgSet.h
===================================================================
--- pgadmin/include/db/pgSet.h	(revision 7108)
+++ pgadmin/include/db/pgSet.h	(working copy)
@@ -41,7 +41,7 @@
     long NumRows() const { return nRows; }
     long NumCols() const { return nCols; }
 
-    void MoveNext() { if (pos <= nRows) pos++; }
+    void MoveNext() { if (pos < nRows) pos++; }
     void MovePrevious() { if (pos > 0) pos--; }
     void MoveFirst() { if (nRows) pos=1; else pos=0; }
     void MoveLast() { pos=nRows; }


Home | Main Index | Thread Index

top