summaryrefslogtreecommitdiffstats
path: root/src/sql/drivers
diff options
context:
space:
mode:
authorAaron McCarthy <amccarthy@sigtec.com>2012-11-08 05:13:10 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-23 09:20:20 (GMT)
commit5c5358930afe743cc293911ec284549f3feeb687 (patch)
treef93a75ba022151206db68396f28f396dc5107b8f /src/sql/drivers
parent58384f346b13b27c58a2efb3ba8b6be98ab54fbf (diff)
downloadQt-5c5358930afe743cc293911ec284549f3feeb687.zip
Qt-5c5358930afe743cc293911ec284549f3feeb687.tar.gz
Qt-5c5358930afe743cc293911ec284549f3feeb687.tar.bz2
Fix error reporting in TDS SQL driver.
The error and message handlers used by the freetds library were getting reset to back to the default every time a database was opened. The Qt TDS SQL driver was calling dbinit() from QTDSDriver::open(). This had two problems: 1. dbinit() would reset the error handler previously set by a call to dberrhandle(). A db error would then cause the application to abort. 2. freetds expects dbinit() and dbexit() to be called symmetrically. Opening multiple database connections would result in freetds not cleaning up on application close. Solved by moving the dbinit() call into the QTDSDriver constructor. Backported from Qt5/qtbase change 7456562e7f647e7cb2c854c4272c5599b26dbd37 Change-Id: I43087a44d74de38918c7285a228e2f3d25d070fd Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Diffstat (limited to 'src/sql/drivers')
-rw-r--r--src/sql/drivers/tds/qsql_tds.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/sql/drivers/tds/qsql_tds.cpp b/src/sql/drivers/tds/qsql_tds.cpp
index df0c4c5..abfa3be 100644
--- a/src/sql/drivers/tds/qsql_tds.cpp
+++ b/src/sql/drivers/tds/qsql_tds.cpp
@@ -135,10 +135,11 @@ QSqlError qMakeError(const QString& err, QSqlError::ErrorType type, int errNo =
class QTDSDriverPrivate
{
public:
- QTDSDriverPrivate(): login(0) {}
+ QTDSDriverPrivate(): login(0), initialized(false) {}
LOGINREC* login; // login information
QString hostName;
QString db;
+ bool initialized;
};
@@ -534,6 +535,7 @@ QVariant QTDSDriver::handle() const
void QTDSDriver::init()
{
d = new QTDSDriverPrivate();
+ d->initialized = (dbinit() == SUCCEED);
// the following two code-lines will fail compilation on some FreeTDS versions
// just comment them out if you have FreeTDS (you won't get any errors and warnings then)
dberrhandle((QERRHANDLE)qTdsErrHandler);
@@ -575,7 +577,7 @@ bool QTDSDriver::open(const QString & db,
{
if (isOpen())
close();
- if (!dbinit()) {
+ if (!d->initialized) {
setOpenError(true);
return false;
}