Skip to content
Permalink
Browse files

Fix for ticket #406 (problems with copying selected attributes from a…

… 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
g_j_m committed Dec 2, 2006
1 parent f6053ce commit 3486d4bb0b003d545f79645835f832d1c967860b
Showing with 15 additions and 6 deletions.
  1. +15 −6 src/providers/postgres/qgspostgresprovider.cpp
@@ -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;
}
@@ -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;
}
@@ -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
@@ -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";
@@ -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;
}
@@ -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;
}


@@ -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)
{

0 comments on commit 3486d4b

Please sign in to comment.
You can’t perform that action at this time.