diff options
Diffstat (limited to 'src/sql/drivers/psql/qsql_psql.cpp')
-rw-r--r-- | src/sql/drivers/psql/qsql_psql.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/sql/drivers/psql/qsql_psql.cpp b/src/sql/drivers/psql/qsql_psql.cpp index 033c69f35..8e2c02ad3 100644 --- a/src/sql/drivers/psql/qsql_psql.cpp +++ b/src/sql/drivers/psql/qsql_psql.cpp @@ -679,6 +679,29 @@ void TQPSQLDriver::close() } } +bool TQPSQLDriver::ping() +{ + if ( !isOpen() ) { + return FALSE; + } + + PGresult *res = NULL; + + // Send ping + res = PQexec( d->connection, "" ); + PQclear(res); + + // Check connection status + if ( PQstatus( d->connection ) != CONNECTION_OK ) { + PQreset( d->connection ); + if ( PQstatus( d->connection ) != CONNECTION_OK ) { + setLastError( qMakeError("Unable to execute ping", TQSqlError::Statement, d ) ); + return FALSE; + } + } + return TRUE; +} + TQSqlQuery TQPSQLDriver::createQuery() const { return TQSqlQuery( new TQPSQLResult( this, d ) ); |