Skip to content

Commit 684398e

Browse files
committed
Try to reopen broken postgres connection
1 parent 9db4f98 commit 684398e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/providers/postgres/qgspostgresprovider.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,14 @@ bool QgsPostgresProvider::declareCursor(
439439

440440
if ( !connectionRO->openCursor( cursorName, query ) )
441441
{
442-
// reloading the fields might help next time around
443-
rewind();
444-
return false;
442+
//try to re-etablish broken connection
443+
::PQreset( connectionRO->pgConnection() );
444+
if ( !connectionRO->openCursor( cursorName, query ) )
445+
{
446+
// reloading the fields might help next time around
447+
rewind();
448+
return false;
449+
}
445450
}
446451
}
447452
catch ( PGFieldNotFound )

0 commit comments

Comments
 (0)