summaryrefslogtreecommitdiffstats
path: root/src/sql
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-09-03 18:37:52 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2014-09-03 18:37:52 -0500
commitd8352f9db21a44c56049d6a5b2223ff888676286 (patch)
treed42d56c1dcbab9701a7ad8fac3e46f4031391aa4 /src/sql
parented5df1398ec8899bfea12d75f12a0f1474ef2258 (diff)
downloadtqt3-d8352f9db21a44c56049d6a5b2223ff888676286.tar.gz
tqt3-d8352f9db21a44c56049d6a5b2223ff888676286.zip
Automated update from Qt3
Diffstat (limited to 'src/sql')
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.cpp11
-rw-r--r--src/sql/drivers/ibase/qsql_ibase.h1
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.cpp17
-rw-r--r--src/sql/drivers/mysql/qsql_mysql.h1
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.cpp7
-rw-r--r--src/sql/drivers/odbc/qsql_odbc.h1
-rw-r--r--src/sql/drivers/psql/qsql_psql.cpp23
-rw-r--r--src/sql/drivers/psql/qsql_psql.h1
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.cpp11
-rw-r--r--src/sql/drivers/sqlite/qsql_sqlite.h1
-rw-r--r--src/sql/drivers/sqlite3/qsql_sqlite3.cpp11
-rw-r--r--src/sql/drivers/sqlite3/qsql_sqlite3.h1
-rw-r--r--src/sql/ntqsqldatabase.h1
-rw-r--r--src/sql/ntqsqldriver.h1
-rw-r--r--src/sql/qsqldatabase.cpp10
15 files changed, 98 insertions, 0 deletions
diff --git a/src/sql/drivers/ibase/qsql_ibase.cpp b/src/sql/drivers/ibase/qsql_ibase.cpp
index 6a1d0abfd..ee2976d68 100644
--- a/src/sql/drivers/ibase/qsql_ibase.cpp
+++ b/src/sql/drivers/ibase/qsql_ibase.cpp
@@ -848,6 +848,17 @@ void TQIBaseDriver::close()
}
}
+bool TQIBaseDriver::ping()
+{
+ if ( !isOpen() ) {
+ return FALSE;
+ }
+
+ // FIXME
+ // Implement ping if available
+ return TRUE;
+}
+
TQSqlQuery TQIBaseDriver::createQuery() const
{
return TQSqlQuery(new TQIBaseResult(this));
diff --git a/src/sql/drivers/ibase/qsql_ibase.h b/src/sql/drivers/ibase/qsql_ibase.h
index 45cb4b86b..023a6b028 100644
--- a/src/sql/drivers/ibase/qsql_ibase.h
+++ b/src/sql/drivers/ibase/qsql_ibase.h
@@ -94,6 +94,7 @@ public:
const TQString & host,
int port ) { return open (db, user, password, host, port, TQString()); }
void close();
+ bool ping();
TQSqlQuery createQuery() const;
bool beginTransaction();
bool commitTransaction();
diff --git a/src/sql/drivers/mysql/qsql_mysql.cpp b/src/sql/drivers/mysql/qsql_mysql.cpp
index aca83545f..aad846243 100644
--- a/src/sql/drivers/mysql/qsql_mysql.cpp
+++ b/src/sql/drivers/mysql/qsql_mysql.cpp
@@ -504,6 +504,8 @@ bool TQMYSQLDriver::open( const TQString& db,
optionFlags |= CLIENT_ODBC;
else if ( opt == "CLIENT_SSL" )
optionFlags |= CLIENT_SSL;
+ else if ( opt == "MYSQL_OPT_RECONNECT" )
+ optionFlags |= MYSQL_OPT_RECONNECT;
else
tqWarning( "TQMYSQLDriver::open: Unknown connect option '%s'", (*it).latin1() );
}
@@ -544,6 +546,21 @@ void TQMYSQLDriver::close()
}
}
+bool TQMYSQLDriver::ping()
+{
+ if ( !isOpen() ) {
+ return FALSE;
+ }
+
+ if (mysql_ping( d->mysql )) {
+ return TRUE;
+ }
+ else {
+ setLastError( qMakeError("Unable to execute ping", TQSqlError::Statement, d ) );
+ return FALSE;
+ }
+}
+
TQSqlQuery TQMYSQLDriver::createQuery() const
{
return TQSqlQuery( new TQMYSQLResult( this ) );
diff --git a/src/sql/drivers/mysql/qsql_mysql.h b/src/sql/drivers/mysql/qsql_mysql.h
index 6b1daef3a..e4646256d 100644
--- a/src/sql/drivers/mysql/qsql_mysql.h
+++ b/src/sql/drivers/mysql/qsql_mysql.h
@@ -100,6 +100,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;
diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp
index 40739b36c..3bedbb8cc 100644
--- a/src/sql/drivers/odbc/qsql_odbc.cpp
+++ b/src/sql/drivers/odbc/qsql_odbc.cpp
@@ -1490,6 +1490,13 @@ void TQODBCDriver::close()
setOpenError( FALSE );
}
+bool TQODBCDriver::ping()
+{
+ // FIXME
+ // Implement ping if supported
+ return TRUE;
+}
+
void TQODBCDriver::cleanup()
{
SQLRETURN r;
diff --git a/src/sql/drivers/odbc/qsql_odbc.h b/src/sql/drivers/odbc/qsql_odbc.h
index 0ce01703a..619212d4a 100644
--- a/src/sql/drivers/odbc/qsql_odbc.h
+++ b/src/sql/drivers/odbc/qsql_odbc.h
@@ -128,6 +128,7 @@ public:
const TQString & host = TQString::null,
int port = -1 );
void close();
+ bool ping();
TQSqlQuery createQuery() const;
TQStringList tables( const TQString& user ) const;
TQSqlRecord record( const TQString& tablename ) const;
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;
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.cpp b/src/sql/drivers/sqlite/qsql_sqlite.cpp
index ece3b9ee3..92a66c72e 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.cpp
+++ b/src/sql/drivers/sqlite/qsql_sqlite.cpp
@@ -352,6 +352,17 @@ void TQSQLiteDriver::close()
}
}
+bool TQSQLiteDriver::ping()
+{
+ if ( !isOpen() ) {
+ return FALSE;
+ }
+
+ // FIXME
+ // Implement ping if available
+ return TRUE;
+}
+
TQSqlQuery TQSQLiteDriver::createQuery() const
{
return TQSqlQuery(new TQSQLiteResult(this));
diff --git a/src/sql/drivers/sqlite/qsql_sqlite.h b/src/sql/drivers/sqlite/qsql_sqlite.h
index ff05ede60..b90662c01 100644
--- a/src/sql/drivers/sqlite/qsql_sqlite.h
+++ b/src/sql/drivers/sqlite/qsql_sqlite.h
@@ -72,6 +72,7 @@ public:
const TQString & host,
int port ) { return open (db, user, password, host, port, TQString()); }
void close();
+ bool ping();
TQSqlQuery createQuery() const;
bool beginTransaction();
bool commitTransaction();
diff --git a/src/sql/drivers/sqlite3/qsql_sqlite3.cpp b/src/sql/drivers/sqlite3/qsql_sqlite3.cpp
index a756c7da7..4d79cb4ea 100644
--- a/src/sql/drivers/sqlite3/qsql_sqlite3.cpp
+++ b/src/sql/drivers/sqlite3/qsql_sqlite3.cpp
@@ -336,6 +336,17 @@ void TQSQLite3Driver::close()
}
}
+bool TQSQLite3Driver::ping()
+{
+ if ( !isOpen() ) {
+ return FALSE;
+ }
+
+ // FIXME
+ // Implement ping if available
+ return TRUE;
+}
+
TQSqlQuery TQSQLite3Driver::createQuery() const
{
return TQSqlQuery(new TQSQLite3Result(this));
diff --git a/src/sql/drivers/sqlite3/qsql_sqlite3.h b/src/sql/drivers/sqlite3/qsql_sqlite3.h
index 4d79176a7..facd85a1d 100644
--- a/src/sql/drivers/sqlite3/qsql_sqlite3.h
+++ b/src/sql/drivers/sqlite3/qsql_sqlite3.h
@@ -72,6 +72,7 @@ public:
const TQString & host,
int port ) { return open (db, user, password, host, port, TQString()); }
void close();
+ bool ping();
TQSqlQuery createQuery() const;
bool beginTransaction();
bool commitTransaction();
diff --git a/src/sql/ntqsqldatabase.h b/src/sql/ntqsqldatabase.h
index 2423fd2ce..b44735e61 100644
--- a/src/sql/ntqsqldatabase.h
+++ b/src/sql/ntqsqldatabase.h
@@ -95,6 +95,7 @@ public:
bool open();
bool open( const TQString& user, const TQString& password );
void close();
+ bool ping();
bool isOpen() const;
bool isOpenError() const;
TQStringList tables() const;
diff --git a/src/sql/ntqsqldriver.h b/src/sql/ntqsqldriver.h
index 5da90309d..09c74b249 100644
--- a/src/sql/ntqsqldriver.h
+++ b/src/sql/ntqsqldriver.h
@@ -98,6 +98,7 @@ public:
const TQString & host = TQString::null,
int port = -1 ) = 0;
virtual void close() = 0;
+ virtual bool ping() = 0;
virtual TQSqlQuery createQuery() const = 0;
// ### remove for 4.0
diff --git a/src/sql/qsqldatabase.cpp b/src/sql/qsqldatabase.cpp
index 606adb9f1..cc38f86fc 100644
--- a/src/sql/qsqldatabase.cpp
+++ b/src/sql/qsqldatabase.cpp
@@ -144,6 +144,7 @@ public:
return FALSE;
}
void close() {}
+ bool ping() { return TRUE; }
TQSqlQuery createQuery() const { return TQSqlQuery( new TQNullResult(this) ); }
};
@@ -796,6 +797,15 @@ void TQSqlDatabase::close()
}
/*!
+ Sends a ping to the database server.
+*/
+
+bool TQSqlDatabase::ping()
+{
+ return d->driver->ping();
+}
+
+/*!
Returns TRUE if the database connection is currently open;
otherwise returns FALSE.
*/