diff options
Diffstat (limited to 'src/sql/kernel')
-rw-r--r-- | src/sql/kernel/qsql.h | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlcachedresult.cpp | 17 | ||||
-rw-r--r-- | src/sql/kernel/qsqlcachedresult_p.h | 5 | ||||
-rw-r--r-- | src/sql/kernel/qsqldatabase.cpp | 60 | ||||
-rw-r--r-- | src/sql/kernel/qsqldatabase.h | 6 | ||||
-rw-r--r-- | src/sql/kernel/qsqldriver.cpp | 31 | ||||
-rw-r--r-- | src/sql/kernel/qsqldriver.h | 7 | ||||
-rw-r--r-- | src/sql/kernel/qsqldriverplugin.cpp | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqldriverplugin.h | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlerror.cpp | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlerror.h | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlfield.cpp | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlfield.h | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlindex.cpp | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlindex.h | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlnulldriver_p.h | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlquery.cpp | 27 | ||||
-rw-r--r-- | src/sql/kernel/qsqlquery.h | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlrecord.cpp | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlrecord.h | 4 | ||||
-rw-r--r-- | src/sql/kernel/qsqlresult.cpp | 23 | ||||
-rw-r--r-- | src/sql/kernel/qsqlresult.h | 5 |
22 files changed, 167 insertions, 66 deletions
diff --git a/src/sql/kernel/qsql.h b/src/sql/kernel/qsql.h index 0e3388a..971a152 100644 --- a/src/sql/kernel/qsql.h +++ b/src/sql/kernel/qsql.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp index e85229f..ca51dc0 100644 --- a/src/sql/kernel/qsqlcachedresult.cpp +++ b/src/sql/kernel/qsqlcachedresult.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -294,4 +294,17 @@ QSqlCachedResult::ValueCache &QSqlCachedResult::cache() return d->cache; } +void QSqlCachedResult::virtual_hook(int id, void *data) +{ + switch (id) { + case QSqlResult::DetachFromResultSet: + case QSqlResult::SetNumericalPrecision: + cleanup(); + break; + default: + QSqlResult::virtual_hook(id, data); + } +} + + QT_END_NAMESPACE diff --git a/src/sql/kernel/qsqlcachedresult_p.h b/src/sql/kernel/qsqlcachedresult_p.h index 8a4869c..a384b2e 100644 --- a/src/sql/kernel/qsqlcachedresult_p.h +++ b/src/sql/kernel/qsqlcachedresult_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -89,6 +89,7 @@ protected: int colCount() const; ValueCache &cache(); + void virtual_hook(int id, void *data); private: bool cacheNext(); QSqlCachedResultPrivate *d; diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index a270c0e..5aef39e 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -129,11 +129,16 @@ Q_GLOBAL_STATIC(QConnectionDict, dbDict) class QSqlDatabasePrivate { public: - QSqlDatabasePrivate(QSqlDriver *dr = 0): + QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0): + q(d), driver(dr), port(-1) { ref = 1; + if(driver) + precisionPolicy = driver->numericalPrecisionPolicy(); + else + precisionPolicy= QSql::LowPrecisionDouble; } QSqlDatabasePrivate(const QSqlDatabasePrivate &other); ~QSqlDatabasePrivate(); @@ -142,6 +147,7 @@ public: void disable(); QAtomicInt ref; + QSqlDatabase *q; QSqlDriver* driver; QString dbname; QString uname; @@ -151,6 +157,7 @@ public: int port; QString connOptions; QString connName; + QSql::NumericalPrecisionPolicy precisionPolicy; static QSqlDatabasePrivate *shared_null(); static QSqlDatabase database(const QString& name, bool open); @@ -164,6 +171,7 @@ public: QSqlDatabasePrivate::QSqlDatabasePrivate(const QSqlDatabasePrivate &other) { ref = 1; + q = other.q; dbname = other.dbname; uname = other.uname; pword = other.pword; @@ -172,6 +180,7 @@ QSqlDatabasePrivate::QSqlDatabasePrivate(const QSqlDatabasePrivate &other) port = other.port; connOptions = other.connOptions; driver = other.driver; + precisionPolicy = other.precisionPolicy; } QSqlDatabasePrivate::~QSqlDatabasePrivate() @@ -216,7 +225,7 @@ DriverDict &QSqlDatabasePrivate::driverDict() QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null() { static QSqlNullDriver dr; - static QSqlDatabasePrivate n(&dr); + static QSqlDatabasePrivate n(NULL, &dr); return &n; } @@ -281,6 +290,7 @@ QSqlDatabase QSqlDatabasePrivate::database(const QString& name, bool open) */ void QSqlDatabasePrivate::copy(const QSqlDatabasePrivate *other) { + q = other->q; dbname = other->dbname; uname = other->uname; pword = other->pword; @@ -288,6 +298,7 @@ void QSqlDatabasePrivate::copy(const QSqlDatabasePrivate *other) drvName = other->drvName; port = other->port; connOptions = other->connOptions; + precisionPolicy = other->precisionPolicy; } void QSqlDatabasePrivate::disable() @@ -658,7 +669,7 @@ QStringList QSqlDatabase::connectionNames() QSqlDatabase::QSqlDatabase(const QString &type) { - d = new QSqlDatabasePrivate(); + d = new QSqlDatabasePrivate(this); d->init(type); } @@ -670,7 +681,7 @@ QSqlDatabase::QSqlDatabase(const QString &type) QSqlDatabase::QSqlDatabase(QSqlDriver *driver) { - d = new QSqlDatabasePrivate(driver); + d = new QSqlDatabasePrivate(this, driver); } /*! @@ -949,7 +960,7 @@ bool QSqlDatabase::rollback() connection, set the database name, and call open() again. \note The \e{database name} is not the \e{connection name}. The connection name must be passed to addDatabase() at connection - object create time. + object create time. For the QOCI (Oracle) driver, the database name is the TNS Service Name. @@ -1469,6 +1480,41 @@ QString QSqlDatabase::connectionName() const return d->connName; } +/*! + Sets the default numerical precision policy used by queries created + on this database connection to \a precisionPolicy. + + Note: Drivers that don't support fetching numerical values with low + precision will ignore the precision policy. You can use + QSqlDriver::hasFeature() to find out whether a driver supports this + feature. + + Note: Setting the default precision policy to \a precisionPolicy + doesn't affect any currently active queries. + + \sa QSql::NumericalPrecisionPolicy, numericalPrecisionPolicy(), QSqlQuery::setNumericalPrecisionPolicy(), QSqlQuery::numericalPrecisionPolicy() +*/ +void QSqlDatabase::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy) +{ + if(driver()) + driver()->setNumericalPrecisionPolicy(precisionPolicy); + d->precisionPolicy = precisionPolicy; +} + +/*! + Returns the current default precision policy for the database connection. + + \sa QSql::NumericalPrecisionPolicy, setNumericalPrecisionPolicy(), QSqlQuery::numericalPrecisionPolicy(), QSqlQuery::setNumericalPrecisionPolicy() +*/ +QSql::NumericalPrecisionPolicy QSqlDatabase::numericalPrecisionPolicy() const +{ + if(driver()) + return driver()->numericalPrecisionPolicy(); + else + return d->precisionPolicy; +} + + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QSqlDatabase &d) { diff --git a/src/sql/kernel/qsqldatabase.h b/src/sql/kernel/qsqldatabase.h index ca6f0b0..d28c888 100644 --- a/src/sql/kernel/qsqldatabase.h +++ b/src/sql/kernel/qsqldatabase.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -120,6 +120,8 @@ public: int port() const; QString connectOptions() const; QString connectionName() const; + void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy); + QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const; QSqlDriver* driver() const; diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index 477d531..77e389f 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -72,10 +72,11 @@ public: uint isOpen : 1; uint isOpenError : 1; QSqlError error; + QSql::NumericalPrecisionPolicy precisionPolicy; }; inline QSqlDriverPrivate::QSqlDriverPrivate() - : QObjectPrivate(), isOpen(false), isOpenError(false) + : QObjectPrivate(), isOpen(false), isOpenError(false), precisionPolicy(QSql::LowPrecisionDouble) { } @@ -912,4 +913,28 @@ QString QSqlDriver::stripDelimitersImplementation(const QString &identifier, Ide return ret; } +/*! + Sets the default numerical precision policy used by queries created + by this driver to \a precisionPolicy. + + Note: Setting the default precision policy to \a precisionPolicy + doesn't affect any currently active queries. + + \sa QSql::NumericalPrecisionPolicy, numericalPrecisionPolicy(), QSqlQuery::setNumericalPrecisionPolicy(), QSqlQuery::numericalPrecisionPolicy() +*/ +void QSqlDriver::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy) +{ + d_func()->precisionPolicy = precisionPolicy; +} + +/*! + Returns the current default precision policy for the database connection. + + \sa QSql::NumericalPrecisionPolicy, setNumericalPrecisionPolicy(), QSqlQuery::numericalPrecisionPolicy(), QSqlQuery::setNumericalPrecisionPolicy() +*/ +QSql::NumericalPrecisionPolicy QSqlDriver::numericalPrecisionPolicy() const +{ + return d_func()->precisionPolicy; +} + QT_END_NAMESPACE diff --git a/src/sql/kernel/qsqldriver.h b/src/sql/kernel/qsqldriver.h index 8ac1471..3052be6 100644 --- a/src/sql/kernel/qsqldriver.h +++ b/src/sql/kernel/qsqldriver.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -130,6 +130,9 @@ public: bool isIdentifierEscaped(const QString &identifier, IdentifierType type) const; // ### Qt 5: make virtual QString stripDelimiters(const QString &identifier, IdentifierType type) const; // ### Qt 5: make virtual + void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy); + QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const; + Q_SIGNALS: void notification(const QString &name); diff --git a/src/sql/kernel/qsqldriverplugin.cpp b/src/sql/kernel/qsqldriverplugin.cpp index b3de2cd..149762f 100644 --- a/src/sql/kernel/qsqldriverplugin.cpp +++ b/src/sql/kernel/qsqldriverplugin.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqldriverplugin.h b/src/sql/kernel/qsqldriverplugin.h index 1150360..e101ba3 100644 --- a/src/sql/kernel/qsqldriverplugin.h +++ b/src/sql/kernel/qsqldriverplugin.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlerror.cpp b/src/sql/kernel/qsqlerror.cpp index b1fa6e2..bb2e7a1 100644 --- a/src/sql/kernel/qsqlerror.cpp +++ b/src/sql/kernel/qsqlerror.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlerror.h b/src/sql/kernel/qsqlerror.h index 9e09c27..884a824 100644 --- a/src/sql/kernel/qsqlerror.h +++ b/src/sql/kernel/qsqlerror.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlfield.cpp b/src/sql/kernel/qsqlfield.cpp index 80f193f..4bb56a3 100644 --- a/src/sql/kernel/qsqlfield.cpp +++ b/src/sql/kernel/qsqlfield.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlfield.h b/src/sql/kernel/qsqlfield.h index a5bd8c4..d70af15 100644 --- a/src/sql/kernel/qsqlfield.h +++ b/src/sql/kernel/qsqlfield.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlindex.cpp b/src/sql/kernel/qsqlindex.cpp index 02cdfb3..431d64e 100644 --- a/src/sql/kernel/qsqlindex.cpp +++ b/src/sql/kernel/qsqlindex.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlindex.h b/src/sql/kernel/qsqlindex.h index 82c0fb9..19f85c6 100644 --- a/src/sql/kernel/qsqlindex.h +++ b/src/sql/kernel/qsqlindex.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlnulldriver_p.h b/src/sql/kernel/qsqlnulldriver_p.h index e899a0b..3983c93 100644 --- a/src/sql/kernel/qsqlnulldriver_p.h +++ b/src/sql/kernel/qsqlnulldriver_p.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlquery.cpp b/src/sql/kernel/qsqlquery.cpp index 2a07e28..f55b86e 100644 --- a/src/sql/kernel/qsqlquery.cpp +++ b/src/sql/kernel/qsqlquery.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -61,7 +61,6 @@ public: ~QSqlQueryPrivate(); QAtomicInt ref; QSqlResult* sqlResult; - QSql::NumericalPrecisionPolicy precisionPolicy; static QSqlQueryPrivate* shared_null(); }; @@ -81,7 +80,7 @@ QSqlQueryPrivate* QSqlQueryPrivate::shared_null() \internal */ QSqlQueryPrivate::QSqlQueryPrivate(QSqlResult* result) - : ref(1), sqlResult(result), precisionPolicy(QSql::HighPrecision) + : ref(1), sqlResult(result) { if (!sqlResult) sqlResult = nullResult(); @@ -351,14 +350,14 @@ bool QSqlQuery::exec(const QString& query) if (d->ref != 1) { bool fo = isForwardOnly(); *this = QSqlQuery(driver()->createResult()); - d->sqlResult->setNumericalPrecisionPolicy(d->precisionPolicy); + d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy()); setForwardOnly(fo); } else { d->sqlResult->clear(); d->sqlResult->setActive(false); d->sqlResult->setLastError(QSqlError()); d->sqlResult->setAt(QSql::BeforeFirstRow); - d->sqlResult->setNumericalPrecisionPolicy(d->precisionPolicy); + d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy()); } d->sqlResult->setQuery(query.trimmed()); if (!driver()->isOpen() || driver()->isOpenError()) { @@ -891,12 +890,12 @@ bool QSqlQuery::prepare(const QString& query) bool fo = isForwardOnly(); *this = QSqlQuery(driver()->createResult()); setForwardOnly(fo); - d->sqlResult->setNumericalPrecisionPolicy(d->precisionPolicy); + d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy()); } else { d->sqlResult->setActive(false); d->sqlResult->setLastError(QSqlError()); d->sqlResult->setAt(QSql::BeforeFirstRow); - d->sqlResult->setNumericalPrecisionPolicy(d->precisionPolicy); + d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy()); } if (!driver()) { qWarning("QSqlQuery::prepare: no driver"); @@ -1126,10 +1125,10 @@ QVariant QSqlQuery::lastInsertId() const Instruct the database driver to return numerical values with a precision specified by \a precisionPolicy. - The Oracle driver, for example, retrieves numerical values as - strings by default to prevent the loss of precision. If the high - precision doesn't matter, use this method to increase execution - speed by bypassing string conversions. + The Oracle driver, for example, can retrieve numerical values as + strings to prevent the loss of precision. If high precision doesn't + matter, use this method to increase execution speed by bypassing + string conversions. Note: Drivers that don't support fetching numerical values with low precision will ignore the precision policy. You can use @@ -1144,7 +1143,7 @@ QVariant QSqlQuery::lastInsertId() const */ void QSqlQuery::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy) { - d->precisionPolicy = precisionPolicy; + d->sqlResult->setNumericalPrecisionPolicy(precisionPolicy); } /*! @@ -1154,7 +1153,7 @@ void QSqlQuery::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy preci */ QSql::NumericalPrecisionPolicy QSqlQuery::numericalPrecisionPolicy() const { - return d->precisionPolicy; + return d->sqlResult->numericalPrecisionPolicy(); } /*! diff --git a/src/sql/kernel/qsqlquery.h b/src/sql/kernel/qsqlquery.h index e042fbd..0bfe1bd 100644 --- a/src/sql/kernel/qsqlquery.h +++ b/src/sql/kernel/qsqlquery.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlrecord.cpp b/src/sql/kernel/qsqlrecord.cpp index 95f6020..64e52be 100644 --- a/src/sql/kernel/qsqlrecord.cpp +++ b/src/sql/kernel/qsqlrecord.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlrecord.h b/src/sql/kernel/qsqlrecord.h index 239ecdd..47b87bf 100644 --- a/src/sql/kernel/qsqlrecord.h +++ b/src/sql/kernel/qsqlrecord.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/sql/kernel/qsqlresult.cpp b/src/sql/kernel/qsqlresult.cpp index cffc570..2a1ba64 100644 --- a/src/sql/kernel/qsqlresult.cpp +++ b/src/sql/kernel/qsqlresult.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -48,6 +48,7 @@ #include "qsqlresult.h" #include "qvector.h" #include "qsqldriver.h" +#include <QDebug> QT_BEGIN_NAMESPACE @@ -66,7 +67,7 @@ class QSqlResultPrivate public: QSqlResultPrivate(QSqlResult* d) : q(d), sqldriver(0), idx(QSql::BeforeFirstRow), active(false), - isSel(false), forwardOnly(false), bindCount(0), binds(QSqlResult::PositionalBinding) + isSel(false), forwardOnly(false), precisionPolicy(QSql::LowPrecisionDouble), bindCount(0), binds(QSqlResult::PositionalBinding) {} void clearValues() @@ -106,6 +107,7 @@ public: bool isSel; QSqlError error; bool forwardOnly; + QSql::NumericalPrecisionPolicy precisionPolicy; int bindCount; QSqlResult::BindingSyntax binds; @@ -251,6 +253,9 @@ QSqlResult::QSqlResult(const QSqlDriver *db) { d = new QSqlResultPrivate(this); d->sqldriver = db; + if(db) { + setNumericalPrecisionPolicy(db->numericalPrecisionPolicy()); + } } /*! @@ -902,7 +907,6 @@ QVariant QSqlResult::lastInsertId() const */ void QSqlResult::virtual_hook(int, void *) { - Q_ASSERT(false); } /*! \internal @@ -967,8 +971,15 @@ void QSqlResult::detachFromResultSet() */ void QSqlResult::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy) { - if (driver()->hasFeature(QSqlDriver::LowPrecisionNumbers)) - virtual_hook(SetNumericalPrecision, &policy); + d->precisionPolicy = policy; + virtual_hook(SetNumericalPrecision, &policy); +} + +/*! \internal + */ +QSql::NumericalPrecisionPolicy QSqlResult::numericalPrecisionPolicy() const +{ + return d->precisionPolicy; } /*! \internal diff --git a/src/sql/kernel/qsqlresult.h b/src/sql/kernel/qsqlresult.h index 0a3d8b9..6d8f42e 100644 --- a/src/sql/kernel/qsqlresult.h +++ b/src/sql/kernel/qsqlresult.h @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the QtSql module of the Qt Toolkit. ** @@ -34,7 +34,7 @@ ** met: http://www.gnu.org/copyleft/gpl.html. ** ** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. +** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -135,6 +135,7 @@ protected: bool execBatch(bool arrayBind = false); void detachFromResultSet(); void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy policy); + QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const; bool nextResult(); private: |