@@ -2084,15 +2084,18 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
20842084
20852085 insert += values + ' )' ;
20862086
2087- if ( mPrimaryKeyType == PktFidMap || mPrimaryKeyType == PktInt || mPrimaryKeyType == PktUint64 )
2087+ if ( !( flags & QgsFeatureSink::FastInsert ) )
20882088 {
2089- insert += QLatin1String ( " RETURNING " );
2090-
2091- QString delim;
2092- Q_FOREACH ( int idx, mPrimaryKeyAttrs )
2089+ if ( mPrimaryKeyType == PktFidMap || mPrimaryKeyType == PktInt || mPrimaryKeyType == PktUint64 )
20932090 {
2094- insert += delim + quotedIdentifier ( mAttributeFields .at ( idx ).name () );
2095- delim = ' ,' ;
2091+ insert += QLatin1String ( " RETURNING " );
2092+
2093+ QString delim;
2094+ Q_FOREACH ( int idx, mPrimaryKeyAttrs )
2095+ {
2096+ insert += delim + quotedIdentifier ( mAttributeFields .at ( idx ).name () );
2097+ delim = ' ,' ;
2098+ }
20962099 }
20972100 }
20982101
@@ -2141,7 +2144,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
21412144
21422145 QgsPostgresResult result ( conn->PQexecPrepared ( QStringLiteral ( " addfeatures" ), params ) );
21432146
2144- if ( result.PQresultStatus () == PGRES_TUPLES_OK )
2147+ if ( !( flags & QgsFeatureSink::FastInsert ) && result.PQresultStatus () == PGRES_TUPLES_OK )
21452148 {
21462149 for ( int i = 0 ; i < mPrimaryKeyAttrs .size (); ++i )
21472150 {
@@ -2153,7 +2156,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist, Flags flags )
21532156 else if ( result.PQresultStatus () != PGRES_COMMAND_OK )
21542157 throw PGException ( result );
21552158
2156- if ( mPrimaryKeyType == PktOid )
2159+ if ( !( flags & QgsFeatureSink::FastInsert ) && mPrimaryKeyType == PktOid )
21572160 {
21582161 features->setId ( result.PQoidValue () );
21592162 QgsDebugMsgLevel ( QString ( " new fid=%1" ).arg ( features->id () ), 4 );
0 commit comments