Skip to content

Commit

Permalink
Fix for ticket #406 (problems with copying selected attributes from a…
Browse files Browse the repository at this point in the history
… postgres

layer). Has the side-effect of eliminating the postgresql server 'no
transaction in progress warnings'.


git-svn-id: http://svn.osgeo.org/qgis/trunk@6171 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Dec 2, 2006
1 parent f6053ce commit 3486d4b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ QgsFeature *QgsPostgresProvider::getNextFeature(bool fetchAttributes)
// std::cerr << "Error: " << PQerrorMessage(connection) << std::endl;
// std::cerr << "Fetched " << PQntuples(queryResult) << "rows" << std::endl;
if(PQntuples(queryResult) == 0){
PQexec(connection, "end work");
if (ready)
PQexec(connection, "end work");
ready = false;
return 0;
}
Expand Down Expand Up @@ -525,7 +526,8 @@ QgsFeature* QgsPostgresProvider::getNextFeature(std::list<int> const & attlist,
if (rows == 0)
{
QgsDebugMsg("End of features.");
PQexec(connection, "end work");
if (ready)
PQexec(connection, "end work");
ready = false;
return 0;
}
Expand Down Expand Up @@ -644,6 +646,7 @@ void QgsPostgresProvider::select(QgsRect * rect, bool useIntersect)
PQexec(connection, "end work");
}
PQexec(connection,"begin work");
ready = true;
PQexec(connection, (const char *)(declare.utf8()));

// TODO - see if this deallocates member features
Expand Down Expand Up @@ -791,7 +794,10 @@ void QgsPostgresProvider::getFeatureGeometry(int key, QgsFeature *f)

QgsDebugMsg("QgsPostgresProvider::getFeatureGeometry using: " + cursor);

if (ready)
PQexec(connection, "end work");
PQexec(connection, "begin work");
ready = true;
PQexec(connection, (const char *)(cursor.utf8()));

QString fetch = "fetch forward 1 from qgisf";
Expand All @@ -801,6 +807,7 @@ void QgsPostgresProvider::getFeatureGeometry(int key, QgsFeature *f)
{
// Nothing found - therefore nothing to change
PQexec(connection,"end work");
ready = false;
PQclear(geomResult);
return;
}
Expand All @@ -822,8 +829,9 @@ void QgsPostgresProvider::getFeatureGeometry(int key, QgsFeature *f)

PQclear(geomResult);

PQexec(connection,"end work");

if (ready)
PQexec(connection,"end work");
ready = false;
}


Expand All @@ -848,16 +856,17 @@ void QgsPostgresProvider::reset()
QgsDebugMsg("Setting up binary cursor: " + declare);

// set up the cursor
PQexec(connection,"end work");
if (ready)
PQexec(connection,"end work");

PQexec(connection,"begin work");
ready = true;
PQexec(connection, (const char *)(declare.utf8()));
//QgsDebugMsg("Error: " + PQerrorMessage(connection));

// TODO - see if this deallocates member features
mFeatureQueue.empty();

ready = true;
}
/* QString QgsPostgresProvider::getFieldTypeName(PGconn * pd, int oid)
{
Expand Down

0 comments on commit 3486d4b

Please sign in to comment.