@@ -443,7 +443,8 @@ QgsFeature *QgsPostgresProvider::getNextFeature(bool fetchAttributes)
443
443
// std::cerr << "Error: " << PQerrorMessage(connection) << std::endl;
444
444
// std::cerr << "Fetched " << PQntuples(queryResult) << "rows" << std::endl;
445
445
if (PQntuples (queryResult) == 0 ){
446
- PQexec (connection, " end work" );
446
+ if (ready)
447
+ PQexec (connection, " end work" );
447
448
ready = false ;
448
449
return 0 ;
449
450
}
@@ -525,7 +526,8 @@ QgsFeature* QgsPostgresProvider::getNextFeature(std::list<int> const & attlist,
525
526
if (rows == 0 )
526
527
{
527
528
QgsDebugMsg (" End of features." );
528
- PQexec (connection, " end work" );
529
+ if (ready)
530
+ PQexec (connection, " end work" );
529
531
ready = false ;
530
532
return 0 ;
531
533
}
@@ -644,6 +646,7 @@ void QgsPostgresProvider::select(QgsRect * rect, bool useIntersect)
644
646
PQexec (connection, " end work" );
645
647
}
646
648
PQexec (connection," begin work" );
649
+ ready = true ;
647
650
PQexec (connection, (const char *)(declare.utf8 ()));
648
651
649
652
// TODO - see if this deallocates member features
@@ -791,7 +794,10 @@ void QgsPostgresProvider::getFeatureGeometry(int key, QgsFeature *f)
791
794
792
795
QgsDebugMsg (" QgsPostgresProvider::getFeatureGeometry using: " + cursor);
793
796
797
+ if (ready)
798
+ PQexec (connection, " end work" );
794
799
PQexec (connection, " begin work" );
800
+ ready = true ;
795
801
PQexec (connection, (const char *)(cursor.utf8 ()));
796
802
797
803
QString fetch = " fetch forward 1 from qgisf" ;
@@ -801,6 +807,7 @@ void QgsPostgresProvider::getFeatureGeometry(int key, QgsFeature *f)
801
807
{
802
808
// Nothing found - therefore nothing to change
803
809
PQexec (connection," end work" );
810
+ ready = false ;
804
811
PQclear (geomResult);
805
812
return ;
806
813
}
@@ -822,8 +829,9 @@ void QgsPostgresProvider::getFeatureGeometry(int key, QgsFeature *f)
822
829
823
830
PQclear (geomResult);
824
831
825
- PQexec (connection," end work" );
826
-
832
+ if (ready)
833
+ PQexec (connection," end work" );
834
+ ready = false ;
827
835
}
828
836
829
837
@@ -848,16 +856,17 @@ void QgsPostgresProvider::reset()
848
856
QgsDebugMsg (" Setting up binary cursor: " + declare);
849
857
850
858
// set up the cursor
851
- PQexec (connection," end work" );
859
+ if (ready)
860
+ PQexec (connection," end work" );
852
861
853
862
PQexec (connection," begin work" );
863
+ ready = true ;
854
864
PQexec (connection, (const char *)(declare.utf8 ()));
855
865
// QgsDebugMsg("Error: " + PQerrorMessage(connection));
856
866
857
867
// TODO - see if this deallocates member features
858
868
mFeatureQueue .empty ();
859
869
860
- ready = true ;
861
870
}
862
871
/* QString QgsPostgresProvider::getFieldTypeName(PGconn * pd, int oid)
863
872
{
0 commit comments