diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-09-03 18:37:52 -0500 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2014-09-03 18:37:52 -0500 |
commit | d8352f9db21a44c56049d6a5b2223ff888676286 (patch) | |
tree | d42d56c1dcbab9701a7ad8fac3e46f4031391aa4 /src/sql/drivers/psql | |
parent | ed5df1398ec8899bfea12d75f12a0f1474ef2258 (diff) | |
download | tqt3-d8352f9db21a44c56049d6a5b2223ff888676286.tar.gz tqt3-d8352f9db21a44c56049d6a5b2223ff888676286.zip |
Automated update from Qt3
Diffstat (limited to 'src/sql/drivers/psql')
-rw-r--r-- | src/sql/drivers/psql/qsql_psql.cpp | 23 | ||||
-rw-r--r-- | src/sql/drivers/psql/qsql_psql.h | 1 |
2 files changed, 24 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 ) ); diff --git a/src/sql/drivers/psql/qsql_psql.h b/src/sql/drivers/psql/qsql_psql.h index dd1ddc71c..6f9c4f5f1 100644 --- a/src/sql/drivers/psql/qsql_psql.h +++ b/src/sql/drivers/psql/qsql_psql.h @@ -98,6 +98,7 @@ public: const TQString & host = TQString::null, int port = -1 ); void close(); + bool ping(); TQSqlQuery createQuery() const; TQStringList tables( const TQString& user ) const; TQSqlIndex primaryIndex( const TQString& tablename ) const; |