Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/sql/kernel/qsqldatabase.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtSql module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    130130{
    131131public:
    132     QSqlDatabasePrivate(QSqlDriver *dr = 0):
     132    QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0):
     133        q(d),
    133134        driver(dr),
    134135        port(-1)
    135136    {
    136137        ref = 1;
     138        if(driver)
     139            precisionPolicy = driver->numericalPrecisionPolicy();
     140        else
     141            precisionPolicy= QSql::LowPrecisionDouble;
    137142    }
    138143    QSqlDatabasePrivate(const QSqlDatabasePrivate &other);
     
    143148
    144149    QAtomicInt ref;
     150    QSqlDatabase *q;
    145151    QSqlDriver* driver;
    146152    QString dbname;
     
    152158    QString connOptions;
    153159    QString connName;
     160    QSql::NumericalPrecisionPolicy precisionPolicy;
    154161
    155162    static QSqlDatabasePrivate *shared_null();
     
    165172{
    166173    ref = 1;
     174    q = other.q;
    167175    dbname = other.dbname;
    168176    uname = other.uname;
     
    173181    connOptions = other.connOptions;
    174182    driver = other.driver;
     183    precisionPolicy = other.precisionPolicy;
    175184}
    176185
     
    217226{
    218227    static QSqlNullDriver dr;
    219     static QSqlDatabasePrivate n(&dr);
     228    static QSqlDatabasePrivate n(NULL, &dr);
    220229    return &n;
    221230}
     
    282291void QSqlDatabasePrivate::copy(const QSqlDatabasePrivate *other)
    283292{
     293    q = other->q;
    284294    dbname = other->dbname;
    285295    uname = other->uname;
     
    289299    port = other->port;
    290300    connOptions = other->connOptions;
     301    precisionPolicy = other->precisionPolicy;
    291302}
    292303
     
    353364
    354365    \ingroup database
    355     \mainclass
     366
    356367    \inmodule QtSql
    357368
     
    379390    name argument, the default connection is assumed. The following
    380391    snippet shows how to create and open a default connection to a
    381     MySQL database:
     392    PostgreSQL database:
    382393
    383394    \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 0
     
    444455    The database connection is referred to by \a connectionName. The
    445456    newly added database connection is returned.
     457
     458    If \a type is not available or could not be loaded, isValid() returns false.
    446459
    447460    If \a connectionName is not specified, the new connection becomes
     
    659672QSqlDatabase::QSqlDatabase(const QString &type)
    660673{
    661     d = new QSqlDatabasePrivate();
     674    d = new QSqlDatabasePrivate(this);
    662675    d->init(type);
    663676}
     
    671684QSqlDatabase::QSqlDatabase(QSqlDriver *driver)
    672685{
    673     d = new QSqlDatabasePrivate(driver);
     686    d = new QSqlDatabasePrivate(this, driver);
    674687}
    675688
     
    950963    The \e{database name} is not the \e{connection name}. The
    951964    connection name must be passed to addDatabase() at connection
    952     object create time. 
     965    object create time.
    953966
    954967    For the QOCI (Oracle) driver, the database name is the TNS
     
    12181231    \i CLIENT_INTERACTIVE
    12191232    \i UNIX_SOCKET
     1233    \i MYSQL_OPT_RECONNECT
    12201234    \endlist
    12211235
     
    12531267    \list
    12541268    \i QSQLITE_BUSY_TIMEOUT
     1269    \i QSQLITE_OPEN_READONLY
    12551270    \endlist
    12561271
     
    14701485}
    14711486
     1487/*!
     1488    \since 4.6
     1489
     1490    Sets the default numerical precision policy used by queries created
     1491    on this database connection to \a precisionPolicy.
     1492
     1493    Note: Drivers that don't support fetching numerical values with low
     1494    precision will ignore the precision policy. You can use
     1495    QSqlDriver::hasFeature() to find out whether a driver supports this
     1496    feature.
     1497
     1498    Note: Setting the default precision policy to \a precisionPolicy
     1499    doesn't affect any currently active queries.
     1500
     1501    \sa QSql::NumericalPrecisionPolicy, numericalPrecisionPolicy(),
     1502    QSqlQuery::setNumericalPrecisionPolicy(), QSqlQuery::numericalPrecisionPolicy()
     1503*/
     1504void QSqlDatabase::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy)
     1505{
     1506    if(driver())
     1507        driver()->setNumericalPrecisionPolicy(precisionPolicy);
     1508    d->precisionPolicy = precisionPolicy;
     1509}
     1510
     1511/*!
     1512    \since 4.6
     1513
     1514    Returns the current default precision policy for the database connection.
     1515
     1516    \sa QSql::NumericalPrecisionPolicy, setNumericalPrecisionPolicy(),
     1517    QSqlQuery::numericalPrecisionPolicy(), QSqlQuery::setNumericalPrecisionPolicy()
     1518*/
     1519QSql::NumericalPrecisionPolicy QSqlDatabase::numericalPrecisionPolicy() const
     1520{
     1521    if(driver())
     1522        return driver()->numericalPrecisionPolicy();
     1523    else
     1524        return d->precisionPolicy;
     1525}
     1526
     1527
    14721528#ifndef QT_NO_DEBUG_STREAM
    14731529QDebug operator<<(QDebug dbg, const QSqlDatabase &d)
Note: See TracChangeset for help on using the changeset viewer.