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:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/sql/drivers/sqlite2/qsql_sqlite2.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**
     
    111111    sqlite_vm *currentMachine;
    112112
    113     uint skippedStatus: 1; // the status of the fetchNext() that's skipped
    114     uint skipRow: 1; // skip the next fetchNext()?
    115     uint utf8: 1;
     113    bool skippedStatus; // the status of the fetchNext() that's skipped
     114    bool skipRow; // skip the next fetchNext()?
     115    bool utf8;
    116116    QSqlRecord rInf;
    117     QSql::NumericalPrecisionPolicy precisionPolicy;
     117    QVector<QVariant> firstRow;
    118118};
    119119
     
    121121
    122122QSQLite2ResultPrivate::QSQLite2ResultPrivate(QSQLite2Result* res) : q(res), access(0), currentTail(0),
    123     currentMachine(0), skippedStatus(false), skipRow(false), utf8(false), precisionPolicy(QSql::HighPrecision)
     123    currentMachine(0), skippedStatus(false), skipRow(false), utf8(false)
    124124{
    125125}
     
    168168        const char* lastDot = strrchr(cnames[i], '.');
    169169        const char* fieldName = lastDot ? lastDot + 1 : cnames[i];
    170         rInf.append(QSqlField(QString::fromAscii(fieldName),
     170       
     171        //remove quotations around the field name if any
     172        QString fieldStr = QString::fromAscii(fieldName);
     173        QLatin1Char quote('\"');
     174        if ( fieldStr.length() > 2 && fieldStr.startsWith(quote) && fieldStr.endsWith(quote)) {
     175            fieldStr = fieldStr.mid(1);
     176            fieldStr.chop(1);
     177        }
     178        rInf.append(QSqlField(fieldStr,
    171179                              nameToType(QString::fromAscii(cnames[i+numCols]))));
    172180    }
     
    186194        Q_ASSERT(!initialFetch);
    187195        skipRow = false;
     196        for(int i=0;i<firstRow.count(); i++)
     197            values[i] = firstRow[i];
    188198        return skippedStatus;
    189199    }
     
    203213    }
    204214
     215    if(initialFetch) {
     216        firstRow.clear();
     217        firstRow.resize(colNum);
     218    }
     219   
    205220    switch(res) {
    206221    case SQLITE_ROW:
     
    253268        d->finalize();
    254269        break;
    255     case QSqlResult::SetNumericalPrecision:
    256         Q_ASSERT(data);
    257         d->precisionPolicy = *reinterpret_cast<QSql::NumericalPrecisionPolicy *>(data);
    258         break;
    259270    default:
    260         QSqlResult::virtual_hook(id, data);
     271        QSqlCachedResult::virtual_hook(id, data);
    261272    }
    262273}
     
    297308    // we have to fetch one row to find out about
    298309    // the structure of the result set
    299     d->skippedStatus = d->fetchNext(cache(), 0, true);
     310    d->skippedStatus = d->fetchNext(d->firstRow, 0, true);
    300311    if (lastError().isValid()) {
    301312        setSelect(false);
     
    386397    d->access = sqlite_open(QFile::encodeName(db), 0, &err);
    387398    if (err) {
    388         setLastError(QSqlError(tr("Error to open database"), QString::fromAscii(err),
     399        setLastError(QSqlError(tr("Error opening database"), QString::fromAscii(err),
    389400                     QSqlError::ConnectionError));
    390401        sqlite_freemem(err);
     
    461472        return true;
    462473
    463     setLastError(QSqlError(tr("Unable to rollback Transaction"),
     474    setLastError(QSqlError(tr("Unable to rollback transaction"),
    464475                           QString::fromAscii(err), QSqlError::TransactionError, res));
    465476    sqlite_freemem(err);
     
    504515    QSqlQuery q(createResult());
    505516    q.setForwardOnly(true);
     517    QString table = tblname;
     518    if (isIdentifierEscaped(table, QSqlDriver::TableName))
     519        table = stripDelimiters(table, QSqlDriver::TableName);
    506520    // finrst find a UNIQUE INDEX
    507     q.exec(QLatin1String("PRAGMA index_list('") + tblname + QLatin1String("');"));
     521    q.exec(QLatin1String("PRAGMA index_list('") + table + QLatin1String("');"));
    508522    QString indexname;
    509523    while(q.next()) {
     
    518532    q.exec(QLatin1String("PRAGMA index_info('") + indexname + QLatin1String("');"));
    519533
    520     QSqlIndex index(tblname, indexname);
     534    QSqlIndex index(table, indexname);
    521535    while(q.next()) {
    522536        QString name = q.value(2).toString();
     
    533547    if (!isOpen())
    534548        return QSqlRecord();
     549    QString table = tbl;
     550    if (isIdentifierEscaped(tbl, QSqlDriver::TableName))
     551        table = stripDelimiters(table, QSqlDriver::TableName);
    535552
    536553    QSqlQuery q(createResult());
     
    548565{
    549566    QString res = identifier;
    550     if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('"')) && identifier.right(1) != QString(QLatin1Char('"')) ) {
     567    if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) {
    551568        res.replace(QLatin1Char('"'), QLatin1String("\"\""));
    552569        res.prepend(QLatin1Char('"')).append(QLatin1Char('"'));
  • trunk/src/sql/drivers/sqlite2/qsql_sqlite2.h

    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**
Note: See TracChangeset for help on using the changeset viewer.