Skip to content

Commit 7f6663a

Browse files
committed
postgres: also accept PGRES_TUPLES_OK as positive result for UPDATE/DELETE/INSERT (fixes #9738)
1 parent bbb7518 commit 7f6663a

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/core/qgsapplication.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,6 @@ void QgsApplication::setMaxThreads( int maxThreads )
10451045

10461046
// set max thread count in QThreadPool
10471047
QThreadPool::globalInstance()->setMaxThreadCount( maxThreads );
1048-
QgsDebugMsg( QString( "set QThreadPool max thread count to %d" ).arg( QThreadPool::globalInstance()->maxThreadCount() ) );
1048+
QgsDebugMsg( QString( "set QThreadPool max thread count to %1" ).arg( QThreadPool::globalInstance()->maxThreadCount() ) );
10491049
}
10501050

src/providers/postgres/qgspostgresfeatureiterator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
302302
if ( mSource->mForce2d )
303303
{
304304
geom = QString( "%1(%2)" )
305-
.arg( mConn->majorVersion() < 2 ? "force2d" : "st_force2d" )
305+
.arg( mConn->majorVersion() < 2 ? "force_2d" : "st_force_2d" )
306306
.arg( geom );
307307
}
308308

src/providers/postgres/qgspostgresprovider.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -1825,7 +1825,7 @@ bool QgsPostgresProvider::deleteFeatures( const QgsFeatureIds & id )
18251825

18261826
//send DELETE statement and do error handling
18271827
QgsPostgresResult result = mConnectionRW->PQexec( sql );
1828-
if ( result.PQresultStatus() != PGRES_COMMAND_OK )
1828+
if ( result.PQresultStatus() != PGRES_COMMAND_OK && result.PQresultStatus() != PGRES_TUPLES_OK )
18291829
throw PGException( result );
18301830

18311831
mShared->removeFid( *it );
@@ -2036,7 +2036,7 @@ bool QgsPostgresProvider::changeAttributeValues( const QgsChangedAttributesMap &
20362036
sql += QString( " WHERE %1" ).arg( whereClause( fid ) );
20372037

20382038
QgsPostgresResult result = mConnectionRW->PQexec( sql );
2039-
if ( result.PQresultStatus() != PGRES_COMMAND_OK )
2039+
if ( result.PQresultStatus() != PGRES_COMMAND_OK && result.PQresultStatus() != PGRES_TUPLES_OK )
20402040
throw PGException( result );
20412041

20422042
// update feature id map if key was changed
@@ -2165,7 +2165,7 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
21652165
QgsDebugMsg( "updating: " + update );
21662166

21672167
result = mConnectionRW->PQprepare( "updatefeatures", update, 2, NULL );
2168-
if ( result.PQresultStatus() != PGRES_COMMAND_OK )
2168+
if ( result.PQresultStatus() != PGRES_COMMAND_OK && result.PQresultStatus() != PGRES_TUPLES_OK )
21692169
{
21702170
QgsDebugMsg( QString( "Exception thrown due to PQprepare of this query returning != PGRES_COMMAND_OK (%1 != expected %2): %3" )
21712171
.arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ).arg( update ) );
@@ -2203,13 +2203,8 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
22032203
appendPkParams( iter.key(), params );
22042204

22052205
result = mConnectionRW->PQexecPrepared( "updatefeatures", params );
2206-
int expected_status = ( mSpatialColType == sctTopoGeometry ) ? PGRES_TUPLES_OK : PGRES_COMMAND_OK;
2207-
if ( result.PQresultStatus() != expected_status )
2208-
{
2209-
QgsDebugMsg( QString( "Exception thrown due to PQexecPrepared of 'updatefeatures' returning %1 != expected %2" )
2210-
.arg( result.PQresultStatus() ).arg( expected_status ) );
2206+
if ( result.PQresultStatus() != PGRES_COMMAND_OK && result.PQresultStatus() != PGRES_TUPLES_OK )
22112207
throw PGException( result );
2212-
}
22132208

22142209
if ( mSpatialColType == sctTopoGeometry )
22152210
{
@@ -2695,6 +2690,7 @@ bool QgsPostgresProvider::getGeometryDetails()
26952690
}
26962691
layerProperty.geometryColName = mGeometryColumn;
26972692
layerProperty.geometryColType = sctNone;
2693+
layerProperty.force2d = false;
26982694

26992695
QString delim = "";
27002696

@@ -2762,7 +2758,8 @@ bool QgsPostgresProvider::getGeometryDetails()
27622758
// store whether the geometry includes measure value
27632759
if ( detectedType == "POINTM" || detectedType == "MULTIPOINTM" ||
27642760
detectedType == "LINESTRINGM" || detectedType == "MULTILINESTRINGM" ||
2765-
detectedType == "POLYGONM" || detectedType == "MULTIPOLYGONM" )
2761+
detectedType == "POLYGONM" || detectedType == "MULTIPOLYGONM" ||
2762+
mForce2d )
27662763
{
27672764
// explicitly disable adding new features and editing of geometries
27682765
// as this would lead to corruption of measures

0 commit comments

Comments
 (0)