Skip to content
Permalink
Browse files

postgresql provider: check connection state before running PQexec (fixes

  • Loading branch information
jef-n committed Jan 30, 2012
1 parent 93266ac commit 262392093356f7600089bf44d19984b56ec85bab
Showing with 17 additions and 0 deletions.
  1. +17 −0 src/providers/postgres/qgspostgresconn.cpp
@@ -699,6 +699,23 @@ QString QgsPostgresConn::quotedValue( QVariant value )

PGresult *QgsPostgresConn::PQexec( QString query, bool logError )
{
if ( PQstatus() != CONNECTION_OK )
{
if ( logError )
{
QgsMessageLog::logMessage( tr( "Connection error: %1 returned %2 [%3]" )
.arg( query ).arg( PQstatus() ).arg( PQerrorMessage() ),
tr( "PostGIS" ) );
}
else
{
QgsDebugMsg( QString( "Connection error: %1 returned %2 [%3]" )
.arg( query ).arg( PQstatus() ).arg( PQerrorMessage() ) );
}

return 0;
}

QgsDebugMsgLevel( QString( "Executing SQL: %1" ).arg( query ), 3 );
PGresult *res = ::PQexec( mConn, query.toUtf8() );

0 comments on commit 2623920

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