Changeset 846 for trunk/src/sql


Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
54 edited
9 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/sql/drivers/db2/qsql_db2.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    110110static QString qFromTChar(SQLTCHAR* str)
    111111{
    112     return QString::fromUtf16(str);
     112    return QString((const QChar *)str);
    113113}
    114114
     
    834834            case QVariant::String:
    835835                if (bindValueType(i) & QSql::Out)
    836                     values[i] = QString::fromUtf16((ushort*)tmpStorage.takeFirst().constData());
     836                    values[i] = QString((const QChar *)tmpStorage.takeFirst().constData());
    837837                break;
    838838            default: {
  • trunk/src/sql/drivers/db2/qsql_db2.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/drivers.pri

    r769 r846  
    1 contains(sql-drivers, all ) {
    2     sql-driver +=   psql mysql odbc oci tds db2 sqlite ibase
    3 }
     1contains(sql-drivers, all):sql-driver += psql mysql odbc oci tds db2 sqlite ibase
    42
    5 contains(sql-drivers, psql) {
    6     HEADERS +=      drivers/psql/qsql_psql.h
    7     SOURCES +=      drivers/psql/qsql_psql.cpp
    8 
    9     unix {
    10         !isEmpty(QT_LFLAGS_PSQL) {
    11             LIBS *= $$QT_LFLAGS_PSQL
    12             QMAKE_CXXFLAGS *= $$QT_CFLAGS_PSQL
    13         }
    14         !contains(LIBS, .*pq.*):LIBS *= -lpq
    15     }
    16 
    17     win32 {
    18         !win32-g++:!contains( LIBS, .*pq.* ):LIBS *= -llibpq
    19         win32-g++:!contains( LIBS, .*pq.* ):LIBS *= -lpq
    20         LIBS *= -lws2_32 -ladvapi32
    21     }
    22 }
    23 
    24 contains(sql-drivers, mysql) {
    25     HEADERS +=      drivers/mysql/qsql_mysql.h
    26     SOURCES +=      drivers/mysql/qsql_mysql.cpp
    27 
    28     unix {
    29         isEmpty(QT_LFLAGS_MYSQL) {
    30             !contains(LIBS, .*mysqlclient.*):!contains(LIBS, .*mysqld.*) {
    31                 use_libmysqlclient_r:LIBS *= -lmysqlclient_r
    32                 else:LIBS *= -lmysqlclient
    33             }
    34         } else {
    35             LIBS *= $$QT_LFLAGS_MYSQL
    36             QMAKE_CXXFLAGS *= $$QT_CFLAGS_MYSQL
    37         }
    38     }
    39 
    40     win32:!contains(LIBS, .*mysql.*):!contains(LIBS, .*mysqld.*) {
    41         !win32-g++:LIBS     *= -llibmysql   
    42         win32-g++:LIBS      *= -lmysql
    43     }   
    44 }
    45 
    46 contains(sql-drivers, odbc) {
    47      HEADERS += drivers/odbc/qsql_odbc.h
    48      SOURCES += drivers/odbc/qsql_odbc.cpp
    49 
    50      mac:!contains( LIBS, .*odbc.* ):LIBS        *= -liodbc
    51      unix:!contains( LIBS, .*odbc.* ):LIBS       *= -lodbc
    52      unix:DEFINES += UNICODE
    53 
    54      win32 {
    55          !win32-borland:LIBS     *= -lodbc32
    56          win32-borland:LIBS      *= $(BCB)/lib/PSDK/odbc32.lib
    57      }
    58 }
    59 
    60 contains(sql-drivers, oci) {
    61     HEADERS += drivers/oci/qsql_oci.h
    62     SOURCES += drivers/oci/qsql_oci.cpp
    63 
    64     unix:!contains( LIBS, .*clnts.* ):LIBS += -lclntsh
    65 
    66     win32:LIBS += -loci
    67 }
    68 
    69 contains(sql-drivers, tds) {
    70     HEADERS += drivers/tds/qsql_tds.h
    71     SOURCES += drivers/tds/qsql_tds.cpp
    72 
    73     unix:LIBS += -L$SYBASE/lib -lsybdb
    74 
    75     win32 {
    76         !win32-borland:LIBS += -lNTWDBLIB
    77         win32-borland:LIBS += $(BCB)/lib/PSDK/NTWDBLIB.LIB
    78     }
    79 }
    80 
    81 contains(sql-drivers, db2) {
    82     HEADERS += drivers/db2/qsql_db2.h
    83     SOURCES += drivers/db2/qsql_db2.cpp
    84    
    85     unix:LIBS += -ldb2
    86    
    87     win32 {
    88         !win32-borland:LIBS += -ldb2cli
    89 #        win32-borland:LIBS  += $(BCB)/lib/PSDK/db2cli.lib
    90     }
    91 }
    92 
    93 contains(sql-drivers, ibase) {
    94     HEADERS += drivers/ibase/qsql_ibase.h
    95     SOURCES += drivers/ibase/qsql_ibase.cpp
    96    
    97     unix:LIBS *= -lgds 
    98    
    99     win32 {
    100         !win32-borland:LIBS *= -lgds32_ms
    101         win32-borland:LIBS  += gds32.lib
    102     }
    103 }
    104 
    105 contains(sql-drivers, sqlite2) {
    106     HEADERS += drivers/sqlite2/qsql_sqlite2.h
    107     SOURCES += drivers/sqlite2/qsql_sqlite2.cpp
    108     !contains(LIBS, .*sqlite.*):LIBS *= -lsqlite
    109 }
    110 
    111 contains(sql-drivers, sqlite) {
    112     !system-sqlite:!contains( LIBS, .*sqlite3.* ) {
    113         CONFIG(release, debug|release):DEFINES *= NDEBUG
    114         DEFINES += SQLITE_OMIT_LOAD_EXTENSION SQLITE_OMIT_COMPLETE
    115         INCLUDEPATH +=  ../3rdparty/sqlite
    116         SOURCES +=      ../3rdparty/sqlite/sqlite3.c
    117     } else {
    118         LIBS *= $$QT_LFLAGS_SQLITE
    119         QMAKE_CXXFLAGS *= $$QT_CFLAGS_SQLITE
    120     }
    121 
    122     HEADERS +=      drivers/sqlite/qsql_sqlite.h
    123     SOURCES +=      drivers/sqlite/qsql_sqlite.cpp
    124 }
     3contains(sql-drivers, psql):include($$PWD/psql/qsql_psql.pri)
     4contains(sql-drivers, mysql):include($$PWD/mysql/qsql_mysql.pri)
     5contains(sql-drivers, odbc):include($$PWD/odbc/qsql_odbc.pri)
     6contains(sql-drivers, oci):include($$PWD/oci/qsql_oci.pri)
     7contains(sql-drivers, tds):include($$PWD/tds/qsql_tds.pri)
     8contains(sql-drivers, db2):include($$PWD/db2/qsql_db2.pri)
     9contains(sql-drivers, ibase):include($$PWD/ibase/qsql_ibase.pri)
     10contains(sql-drivers, sqlite2):include($$PWD/sqlite2/qsql_sqlite2.pri)
     11contains(sql-drivers, sqlite):include($$PWD/sqlite/qsql_sqlite.pri)
  • trunk/src/sql/drivers/ibase/qsql_ibase.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/ibase/qsql_ibase.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/mysql/qsql_mysql.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/mysql/qsql_mysql.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/oci/qsql_oci.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5757#include <qdebug.h>
    5858
     59// This is needed for oracle oci when compiling with mingw-w64 headers
     60#if defined(__MINGW64_VERSION_MAJOR) && defined(_WIN64)
     61#define _int64 __int64
     62#endif
     63
     64
    5965#include <oci.h>
    6066#ifdef max
     
    8894#endif
    8995
    90 static const ub1 CSID_NCHAR = SQLCS_NCHAR;
     96#ifdef OCI_ATTR_CHARSET_FORM
     97// Always set the OCI_ATTR_CHARSET_FORM to SQLCS_NCHAR is safe
     98// because Oracle server will deal with the implicit Conversion
     99// Between CHAR and NCHAR.
     100// see: http://download.oracle.com/docs/cd/A91202_01/901_doc/appdev.901/a89857/oci05bnd.htm#422705
     101static const ub1 qOraCharsetForm = SQLCS_NCHAR;
     102#endif
     103
     104#if defined (OCI_UTF16ID)
     105static const ub2 qOraCharset = OCI_UTF16ID;
     106#else
    91107static const ub2 qOraCharset = OCI_UCS2ID;
     108#endif
    92109
    93110typedef QVarLengthArray<sb2, 32> IndicatorArray;
     
    96113static QByteArray qMakeOraDate(const QDateTime& dt);
    97114static QDateTime qMakeDate(const char* oraDate);
     115
     116static QByteArray qMakeOCINumber(const qlonglong &ll, OCIError *err);
     117static QByteArray qMakeOCINumber(const qulonglong& ull, OCIError* err);
     118
     119static qlonglong qMakeLongLong(const char* ociNumber, OCIError* err);
     120static qulonglong qMakeULongLong(const char* ociNumber, OCIError* err);
     121
    98122static QString qOraWarn(OCIError *err, int *errorCode = 0);
     123
    99124#ifndef Q_CC_SUN
    100125static // for some reason, Sun CC can't use qOraWarning when it's declared static
     
    102127void qOraWarning(const char* msg, OCIError *err);
    103128static QSqlError qMakeError(const QString& errString, QSqlError::ErrorType type, OCIError *err);
     129
     130
    104131
    105132class QOCIRowId: public QSharedData
     
    150177    int prefetchRows, prefetchMem;
    151178
    152     void setCharset(OCIBind* hbnd);
    153179    void setStatementAttributes();
    154180    int bindValue(OCIStmt *sql, OCIBind **hbnd, OCIError *err, int pos,
     
    162188    inline bool isBinaryValue(int i) const
    163189    { return q->bindValueType(i) & QSql::Binary; }
     190
     191    void setCharset(dvoid* handle, ub4 type) const
     192    {
     193        int r = 0;
     194        Q_ASSERT(handle);
     195
     196#ifdef OCI_ATTR_CHARSET_FORM
     197        r = OCIAttrSet(handle,
     198                       type,
     199                       // this const cast is safe since OCI doesn't touch
     200                       // the charset.
     201                       const_cast<void *>(static_cast<const void *>(&qOraCharsetForm)),
     202                       0,
     203                       OCI_ATTR_CHARSET_FORM,
     204                       //Strange Oracle bug: some Oracle servers crash the server process with non-zero error handle (mostly for 10g).
     205                       //So ignore the error message here.
     206                       0);
     207        #ifdef QOCI_DEBUG
     208        if (r != 0)
     209            qWarning("QOCIResultPrivate::setCharset: Couldn't set OCI_ATTR_CHARSET_FORM.");
     210        #endif
     211#endif
     212
     213        r = OCIAttrSet(handle,
     214                       type,
     215                       // this const cast is safe since OCI doesn't touch
     216                       // the charset.
     217                       const_cast<void *>(static_cast<const void *>(&qOraCharset)),
     218                       0,
     219                       OCI_ATTR_CHARSET_ID,
     220                       err);
     221        if (r != 0)
     222            qOraWarning("QOCIResultPrivate::setCharsetI Couldn't set OCI_ATTR_CHARSET_ID: ", err);
     223
     224    }
    164225};
    165226
     
    192253                        " Couldn't set OCI_ATTR_PREFETCH_MEMORY: ", err);
    193254    }
    194 }
    195 
    196 void QOCIResultPrivate::setCharset(OCIBind* hbnd)
    197 {
    198     int r = 0;
    199 
    200     Q_ASSERT(hbnd);
    201 
    202     r = OCIAttrSet(hbnd,
    203                    OCI_HTYPE_BIND,
    204                    // this const cast is safe since OCI doesn't touch
    205                    // the charset.
    206                    const_cast<void *>(static_cast<const void *>(&qOraCharset)),
    207                    0,
    208                    OCI_ATTR_CHARSET_ID,
    209                    err);
    210     if (r != 0)
    211         qOraWarning("QOCIResultPrivate::setCharset: Couldn't set OCI_ATTR_CHARSET_ID: ", err);
    212255}
    213256
     
    257300                         SQLT_UIN, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
    258301        break;
     302    case QVariant::LongLong:
     303    {
     304        QByteArray ba = qMakeOCINumber(val.toLongLong(), err);
     305        r = OCIBindByPos(sql, hbnd, err,
     306                           pos + 1,
     307                           ba.data(),
     308                           ba.size(),
     309                           SQLT_VNU, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
     310        tmpStorage.append(ba);
     311        break;
     312    }
     313    case QVariant::ULongLong:
     314    {
     315        QByteArray ba = qMakeOCINumber(val.toULongLong(), err);
     316        r = OCIBindByPos(sql, hbnd, err,
     317                           pos + 1,
     318                           ba.data(),
     319                           ba.size(),
     320                           SQLT_VNU, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
     321        tmpStorage.append(ba);
     322        break;
     323    }
    259324    case QVariant::Double:
    260325        r = OCIBindByPos(sql, hbnd, err,
     
    299364                             SQLT_STR, indPtr, 0, 0, 0, 0, OCI_DEFAULT);
    300365            if (r == OCI_SUCCESS)
    301                 setCharset(*hbnd);
     366                setCharset(*hbnd, OCI_HTYPE_BIND);
    302367            break;
    303368        }
     
    323388        }
    324389        if (r == OCI_SUCCESS)
    325             setCharset(*hbnd);
     390            setCharset(*hbnd, OCI_HTYPE_BIND);
    326391        tmpStorage.append(ba);
    327392        break;
     
    352417
    353418// will assign out value and remove its temp storage.
    354 static void qOraOutValue(QVariant &value, QList<QByteArray> &storage)
     419static void qOraOutValue(QVariant &value, QList<QByteArray> &storage, OCIError* err)
    355420{
    356421    switch (value.type()) {
     
    364429        value = qMakeDate(storage.takeFirst());
    365430        break;
     431    case QVariant::LongLong:
     432        value = qMakeLongLong(storage.takeFirst(), err);
     433        break;
     434    case QVariant::ULongLong:
     435        value = qMakeULongLong(storage.takeFirst(), err);
     436        break;
    366437    case QVariant::String:
    367         value = QString::fromUtf16(
    368                 reinterpret_cast<const ushort *>(storage.takeFirst().constData()));
     438        value = QString(
     439                reinterpret_cast<const QChar *>(storage.takeFirst().constData()));
    369440        break;
    370441    default:
     
    381452            continue;
    382453
    383         qOraOutValue(values[i], tmpStorage);
     454        qOraOutValue(values[i], tmpStorage, err);
    384455
    385456        QVariant::Type typ = values.at(i).type();
     
    455526    if (errorCode)
    456527        *errorCode = errcode;
    457     return QString::fromUtf16(reinterpret_cast<const ushort *>(errbuf));
     528    return QString(reinterpret_cast<const QChar *>(errbuf));
    458529}
    459530
     
    641712}
    642713
     714/*!
     715  \internal
     716
     717   Convert qlonglong to the internal Oracle OCINumber format.
     718  */
     719QByteArray qMakeOCINumber(const qlonglong& ll, OCIError* err)
     720{
     721    QByteArray ba(sizeof(OCINumber), 0);
     722
     723    OCINumberFromInt(err,
     724                     &ll,
     725                     sizeof(qlonglong),
     726                     OCI_NUMBER_SIGNED,
     727                     reinterpret_cast<OCINumber*>(ba.data()));
     728    return ba;
     729}
     730
     731/*!
     732  \internal
     733
     734   Convert qulonglong to the internal Oracle OCINumber format.
     735  */
     736QByteArray qMakeOCINumber(const qulonglong& ull, OCIError* err)
     737{
     738    QByteArray ba(sizeof(OCINumber), 0);
     739
     740    OCINumberFromInt(err,
     741                     &ull,
     742                     sizeof(qlonglong),
     743                     OCI_NUMBER_UNSIGNED,
     744                     reinterpret_cast<OCINumber*>(ba.data()));
     745    return ba;
     746}
     747
     748qlonglong qMakeLongLong(const char* ociNumber, OCIError* err)
     749{
     750    qlonglong qll = 0;
     751    OCINumberToInt(err, reinterpret_cast<const OCINumber *>(ociNumber), sizeof(qlonglong),
     752                   OCI_NUMBER_SIGNED, &qll);
     753    return qll;
     754}
     755
     756qulonglong qMakeULongLong(const char* ociNumber, OCIError* err)
     757{
     758    qulonglong qull = 0;
     759    OCINumberToInt(err, reinterpret_cast<const OCINumber *>(ociNumber), sizeof(qulonglong),
     760                   OCI_NUMBER_UNSIGNED, &qull);
     761    return qull;
     762}
     763
    643764QDateTime qMakeDate(const char* oraDate)
    644765{
    645     int century = oraDate[0];
     766    int century = uchar(oraDate[0]);
    646767    if(century >= 100){
    647768        int year    = uchar(oraDate[1]);
     
    662783    QOCICols(int size, QOCIResultPrivate* dp);
    663784    ~QOCICols();
    664     void setCharset(OCIDefine* dfn);
    665785    int readPiecewise(QVector<QVariant> &values, int index = 0);
    666786    int readLOBs(QVector<QVariant> &values, int index = 0);
     
    864984                        0, 0, OCI_DEFAULT);
    865985                if (r == 0)
    866                     setCharset(dfn);
     986                    d->setCharset(dfn, OCI_HTYPE_DEFINE);
    867987            }
    868988           break;
     
    9221042    }
    9231043    return &lob;
    924 }
    925 
    926 void QOCICols::setCharset(OCIDefine* dfn)
    927 {
    928     int r = 0;
    929 
    930     Q_ASSERT(dfn);
    931 
    932     r = OCIAttrSet(dfn,
    933                    OCI_HTYPE_DEFINE,
    934                    // this const cast is safe since OCI doesn't touch
    935                    // the charset.
    936                    const_cast<void *>(static_cast<const void *>(&qOraCharset)),
    937                    0,
    938                    OCI_ATTR_CHARSET_ID,
    939                    d->err);
    940         if (r != 0)
    941             qOraWarning("QOCICols::setCharset: Couldn't set OCI_ATTR_CHARSET_ID: ", d->err);
    9421044}
    9431045
     
    9901092            if (isStringField) {
    9911093                QString str = values.at(fieldNum + index).toString();
    992                 str += QString::fromUtf16(reinterpret_cast<const ushort *>(col),
    993                                           chunkSize / 2);
     1094                str += QString(reinterpret_cast<const QChar *>(col), chunkSize / 2);
    9941095                values[fieldNum + index] = str;
    9951096                fieldInf[fieldNum].ind = 0;
     
    12451346                break;
    12461347
     1348            case QVariant::LongLong:
     1349                col.bindAs = SQLT_VNU;
     1350                col.maxLen = sizeof(OCINumber);
     1351                break;
     1352
     1353            case QVariant::ULongLong:
     1354                col.bindAs = SQLT_VNU;
     1355                col.maxLen = sizeof(OCINumber);
     1356                break;
     1357
    12471358            case QVariant::Double:
    12481359                col.bindAs = SQLT_FLT;
     
    13161427                        break;
    13171428
     1429                    case QVariant::LongLong:
     1430                    {
     1431                        columns[i].lengths[row] = columns[i].maxLen;
     1432                        const QByteArray ba = qMakeOCINumber(val.toLongLong(), d->err);
     1433                        Q_ASSERT(ba.size() == int(columns[i].maxLen));
     1434                        memcpy(dataPtr, ba.constData(), columns[i].maxLen);
     1435                        break;
     1436                    }
     1437                    case QVariant::ULongLong:
     1438                    {
     1439                        columns[i].lengths[row] = columns[i].maxLen;
     1440                        const QByteArray ba = qMakeOCINumber(val.toULongLong(), d->err);
     1441                        Q_ASSERT(ba.size() == int(columns[i].maxLen));
     1442                        memcpy(dataPtr, ba.constData(), columns[i].maxLen);
     1443                        break;
     1444                    }
    13181445                    case QVariant::Double:
    13191446                         columns[i].lengths[row] = columns[i].maxLen;
     
    14231550        QVariant::Type tp = boundValues.at(i).type();
    14241551        if (tp != QVariant::List) {
    1425             qOraOutValue(boundValues[i], tmpStorage);
     1552            qOraOutValue(boundValues[i], tmpStorage, d->err);
    14261553            if (*columns[i].indicators == -1)
    14271554                boundValues[i] = QVariant(tp);
     
    14531580                    break;
    14541581
     1582                case SQLT_VNU:
     1583                {
     1584                    switch (boundValues.at(i).type()) {
     1585                    case QVariant::LongLong:
     1586                        (*list)[r] =  qMakeLongLong(data + r * columns[i].maxLen, d->err);
     1587                        break;
     1588                    case QVariant::ULongLong:
     1589                        (*list)[r] =  qMakeULongLong(data + r * columns[i].maxLen, d->err);
     1590                        break;
     1591                    default:
     1592                        break;
     1593                    }
     1594                    break;
     1595                }
     1596
    14551597                case SQLT_FLT:
    14561598                    (*list)[r] =  *reinterpret_cast<double*>(data + r * columns[i].maxLen);
     
    14581600
    14591601                case SQLT_STR:
    1460                     (*list)[r] =  QString::fromUtf16(reinterpret_cast<ushort *>(data
     1602                    (*list)[r] =  QString(reinterpret_cast<const QChar *>(data
    14611603                                                                + r * columns[i].maxLen));
    14621604                    break;
     
    16091751            // else fall through
    16101752        case QVariant::String:
    1611             v[index + i] = QString::fromUtf16(reinterpret_cast<const ushort *>(fld.data));
     1753            v[index + i] = QString(reinterpret_cast<const QChar *>(fld.data));
    16121754            break;
    16131755        case QVariant::ByteArray:
     
    21032245    } else {
    21042246        QString versionStr;
    2105         versionStr = QString::fromUtf16(reinterpret_cast<ushort *>(vertxt));
     2247        versionStr = QString(reinterpret_cast<const QChar *>(vertxt));
    21062248        QRegExp vers(QLatin1String("([0-9]+)\\.[0-9\\.]+[0-9]"));
    21072249        if (vers.indexIn(versionStr) >= 0)
  • trunk/src/sql/drivers/oci/qsql_oci.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5555QT_BEGIN_HEADER
    5656
     57typedef struct OCIEnv OCIEnv;
     58typedef struct OCISvcCtx OCISvcCtx;
     59
    5760QT_BEGIN_NAMESPACE
    5861
     
    6164struct QOCIDriverPrivate;
    6265struct QOCIResultPrivate;
    63 
    64 typedef struct OCIEnv OCIEnv;
    65 typedef struct OCISvcCtx OCISvcCtx;
    6666
    6767class Q_EXPORT_SQLDRIVER_OCI QOCIResult : public QSqlCachedResult
  • trunk/src/sql/drivers/odbc/qsql_odbc.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6363#define ODBC_CHECK_DRIVER
    6464
    65 #if defined(Q_ODBC_VERSION_2)
    66 //crude hack to get non-unicode capable driver managers to work
    67 # undef UNICODE
    68 # define SQLTCHAR SQLCHAR
    69 # define SQL_C_TCHAR SQL_C_CHAR
    70 #endif
    71 
    7265// newer platform SDKs use SQLLEN instead of SQLINTEGER
    73 #if defined(WIN32) && (_MSC_VER < 1300)
     66#if defined(WIN32) && (_MSC_VER < 1300) && !defined(__MINGW64_VERSION_MAJOR)
    7467# define QSQLLEN SQLINTEGER
    7568# define QSQLULEN SQLUINTEGER
     
    267260static QString qODBCWarn(const QODBCPrivate* odbc, int *nativeCode = 0)
    268261{
    269     return (qWarnODBCHandle(SQL_HANDLE_ENV, odbc->dpEnv()) + QLatin1Char(' ')
     262    return QString(qWarnODBCHandle(SQL_HANDLE_ENV, odbc->dpEnv()) + QLatin1Char(' ')
    270263             + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->dpDbc()) + QLatin1Char(' ')
    271264             + qWarnODBCHandle(SQL_HANDLE_STMT, odbc->hStmt, nativeCode)).simplified();
     
    274267static QString qODBCWarn(const QODBCDriverPrivate* odbc, int *nativeCode = 0)
    275268{
    276     return (qWarnODBCHandle(SQL_HANDLE_ENV, odbc->hEnv) + QLatin1Char(' ')
     269    return QString(qWarnODBCHandle(SQL_HANDLE_ENV, odbc->hEnv) + QLatin1Char(' ')
    277270             + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->hDbc, nativeCode)).simplified();
    278271}
     
    344337        type = QVariant::DateTime;
    345338        break;
    346 #ifndef Q_ODBC_VERSION_2
    347339    case SQL_WCHAR:
    348340    case SQL_WVARCHAR:
     
    350342        type = QVariant::String;
    351343        break;
    352 #endif
    353344    case SQL_CHAR:
    354345    case SQL_VARCHAR:
     
    670661static int qGetODBCVersion(const QString &connOpts)
    671662{
    672 #ifndef Q_ODBC_VERSION_2
    673663    if (connOpts.contains(QLatin1String("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC3"), Qt::CaseInsensitive))
    674664        return SQL_OV_ODBC3;
    675 #endif
    676     if (connOpts.contains(QLatin1String("SQL_ATTR_ODBC_VERSION=SQL_OV_ODBC2"), Qt::CaseInsensitive))
    677         return SQL_OV_ODBC2;
    678 #ifdef _IODBCUNIX_H
    679     return SQL_OV_ODBC3;
    680 #else
    681665    return SQL_OV_ODBC2;
    682 #endif
    683666}
    684667
     
    781764            }
    782765            r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACE, (SQLPOINTER) v, 0);
    783 #ifndef Q_ODBC_VERSION_2
    784766        } else if (opt.toUpper() == QLatin1String("SQL_ATTR_CONNECTION_POOLING")) {
    785767            if (val == QLatin1String("SQL_CP_OFF"))
     
    808790            }
    809791            r = SQLSetConnectAttr(hDbc, SQL_ATTR_CP_MATCH, (SQLPOINTER)v, 0);
    810 #endif
    811792        } else if (opt.toUpper() == QLatin1String("SQL_ATTR_ODBC_VERSION")) {
    812793            // Already handled in QODBCDriver::open()
     
    15301511                break;
    15311512            case QVariant::String:
    1532 #ifndef Q_ODBC_VERSION_2
    15331513                if (d->unicode) {
    15341514                    QString str = val.toString();
     
    15681548                }
    15691549                else
    1570 #endif
    15711550                {
    15721551                    QByteArray str = val.toString().toUtf8();
     
    19741953void QODBCDriverPrivate::checkUnicode()
    19751954{
    1976 #if defined(Q_ODBC_VERSION_2)
    1977     unicode = false;
    1978     return;
    1979 #endif
    1980 
    19811955    SQLRETURN   r;
    19821956    SQLUINTEGER fFunc;
     
    21332107#endif
    21342108        isFreeTDSDriver = serverType.contains(QLatin1String("tdsodbc"), Qt::CaseInsensitive);
    2135         unicode = isFreeTDSDriver == false;
     2109        unicode = unicode && !isFreeTDSDriver;
    21362110    }
    21372111}
  • trunk/src/sql/drivers/odbc/qsql_odbc.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4848#if defined (Q_OS_WIN32)
    4949#include <QtCore/qt_windows.h>
    50 #endif
    51 
    52 #if defined (Q_OS_MAC) && (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_3)
    53 // assume we use iodbc on MACX
    54 // comment next line out if you use a
    55 // unicode compatible manager
    56 # define Q_ODBC_VERSION_2
    5750#endif
    5851
  • trunk/src/sql/drivers/psql/qsql_psql.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    5555#include <qmutex.h>
    5656
    57 
    5857#include <libpq-fe.h>
    5958#include <pg_config.h>
     
    620619}
    621620
     621static QPSQLDriver::Protocol qMakePSQLVersion(int vMaj, int vMin)
     622{
     623    switch (vMaj) {
     624    case 6:
     625        return QPSQLDriver::Version6;
     626    case 7:
     627    {
     628        switch (vMin) {
     629        case 1:
     630            return QPSQLDriver::Version71;
     631        case 3:
     632            return QPSQLDriver::Version73;
     633        case 4:
     634            return QPSQLDriver::Version74;
     635        default:
     636            return QPSQLDriver::Version7;
     637        }
     638        break;
     639    }
     640    case 8:
     641    {
     642        switch (vMin) {
     643        case 1:
     644            return QPSQLDriver::Version81;
     645        case 2:
     646            return QPSQLDriver::Version82;
     647        case 3:
     648            return QPSQLDriver::Version83;
     649        case 4:
     650            return QPSQLDriver::Version84;
     651        default:
     652            return QPSQLDriver::Version8;
     653        }
     654        break;
     655    }
     656    case 9:
     657        return QPSQLDriver::Version9;
     658        break;
     659    default:
     660        break;
     661    }
     662    return QPSQLDriver::VersionUnknown;
     663}
     664
    622665static QPSQLDriver::Protocol getPSQLVersion(PGconn* connection)
    623666{
     
    627670    if (status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK) {
    628671        QString val = QString::fromAscii(PQgetvalue(result, 0, 0));
     672
    629673        QRegExp rx(QLatin1String("(\\d+)\\.(\\d+)"));
    630674        rx.setMinimal(true); // enforce non-greedy RegExp
     675
    631676        if (rx.indexIn(val) != -1) {
    632677            int vMaj = rx.cap(1).toInt();
    633678            int vMin = rx.cap(2).toInt();
    634 
    635             switch (vMaj) {
    636             case 7:
    637                 switch (vMin) {
    638                 case 0:
    639                     serverVersion = QPSQLDriver::Version7;
    640                     break;
    641                 case 1:
    642                 case 2:
    643                     serverVersion = QPSQLDriver::Version71;
    644                     break;
    645                 default:
    646                     serverVersion = QPSQLDriver::Version73;
    647                     break;
    648                 }
    649                 break;
    650             case 8:
    651                 switch (vMin) {
    652                 case 0:
    653                     serverVersion = QPSQLDriver::Version8;
    654                     break;
    655                 case 1:
    656                     serverVersion = QPSQLDriver::Version81;
    657                     break;
    658                 case 2:
    659                 default:
    660                     serverVersion = QPSQLDriver::Version82;
    661                     break;
    662                 }
    663                 break;
    664             default:
    665                 break;
     679            serverVersion = qMakePSQLVersion(vMaj, vMin);
     680#ifdef PG_MAJORVERSION
     681            if (rx.indexIn(QLatin1String(PG_MAJORVERSION)) != -1) {
     682                vMaj = rx.cap(1).toInt();
     683                vMin = rx.cap(2).toInt();
    666684            }
     685            QPSQLDriver::Protocol clientVersion = qMakePSQLVersion(vMaj, vMin);
     686
     687            if (serverVersion >= QPSQLDriver::Version9 && clientVersion < QPSQLDriver::Version9) {
     688                //Client version before QPSQLDriver::Version9 only supports escape mode for bytea type,
     689                //but bytea format is set to hex by default in PSQL 9 and above. So need to force the
     690                //server use the old escape mode when connects to the new server with old client library.
     691                result = PQexec(connection, "SET bytea_output=escape; ");
     692                status = PQresultStatus(result);
     693            } else if (serverVersion == QPSQLDriver::VersionUnknown) {
     694                serverVersion = clientVersion;
     695                if (serverVersion != QPSQLDriver::VersionUnknown)
     696                   qWarning("The server version of this PostgreSQL is unknown, falling back to the client version.");
     697            }
     698#endif
    667699        }
    668700    }
    669701    PQclear(result);
    670702
    671     if (serverVersion < QPSQLDriver::Version71)
     703    //keep the old behavior unchanged
     704    if (serverVersion == QPSQLDriver::VersionUnknown)
     705        serverVersion = QPSQLDriver::Version6;
     706
     707    if (serverVersion < QPSQLDriver::Version71) {
    672708        qWarning("This version of PostgreSQL is not supported and may not work.");
     709    }
    673710
    674711    return serverVersion;
     
    853890    if (d->pro == QPSQLDriver::Version8 ||
    854891        d->pro == QPSQLDriver::Version81 ||
    855         d->pro == QPSQLDriver::Version82) {
     892        d->pro == QPSQLDriver::Version82 ||
     893        d->pro == QPSQLDriver::Version83 ||
     894        d->pro == QPSQLDriver::Version84 ||
     895        d->pro == QPSQLDriver::Version9) {
    856896        transaction_failed = qstrcmp(PQcmdStatus(res), "ROLLBACK") == 0;
    857897    }
     
    9641004    case QPSQLDriver::Version81:
    9651005    case QPSQLDriver::Version82:
     1006    case QPSQLDriver::Version83:
     1007    case QPSQLDriver::Version84:
     1008    case QPSQLDriver::Version9:
    9661009        stmt = QLatin1String("SELECT pg_attribute.attname, pg_attribute.atttypid::int, "
    9671010                "pg_class.relname "
     
    10471090    case QPSQLDriver::Version81:
    10481091    case QPSQLDriver::Version82:
     1092    case QPSQLDriver::Version83:
     1093    case QPSQLDriver::Version84:
     1094    case QPSQLDriver::Version9:
    10491095        stmt = QLatin1String("select pg_attribute.attname, pg_attribute.atttypid::int, "
    10501096                "pg_attribute.attnotnull, pg_attribute.attlen, pg_attribute.atttypmod, "
  • trunk/src/sql/drivers/psql/qsql_psql.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9898public:
    9999    enum Protocol {
     100        VersionUnknown = -1,
    100101        Version6 = 6,
    101102        Version7 = 7,
     
    105106        Version8 = 11,
    106107        Version81 = 12,
    107         Version82 = 13
     108        Version82 = 13,
     109        Version83 = 14,
     110        Version84 = 15,
     111        Version9 = 16,
    108112    };
    109113
  • trunk/src/sql/drivers/sqlite/qsql_sqlite.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    9696{
    9797    return QSqlError(descr,
    98                      QString::fromUtf16(static_cast<const ushort *>(sqlite3_errmsg16(access))),
     98                     QString(reinterpret_cast<const QChar *>(sqlite3_errmsg16(access))),
    9999                     type, errorCode);
    100100}
     
    163163
    164164    for (int i = 0; i < nCols; ++i) {
    165         QString colName = QString::fromUtf16(
    166                     static_cast<const ushort *>(sqlite3_column_name16(stmt, i))
     165        QString colName = QString(reinterpret_cast<const QChar *>(
     166                    sqlite3_column_name16(stmt, i))
    167167                    ).remove(QLatin1Char('"'));
    168168
    169169        // must use typeName for resolving the type to match QSqliteDriver::record
    170         QString typeName = QString::fromUtf16(
    171                     static_cast<const ushort *>(sqlite3_column_decltype16(stmt, i)));
     170        QString typeName = QString(reinterpret_cast<const QChar *>(
     171                    sqlite3_column_decltype16(stmt, i)));
    172172
    173173        int dotIdx = colName.lastIndexOf(QLatin1Char('.'));
  • trunk/src/sql/drivers/sqlite/qsql_sqlite.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/sqlite2/qsql_sqlite2.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/sqlite2/qsql_sqlite2.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/tds/qsql_tds.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/drivers/tds/qsql_tds.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4949#ifdef Q_OS_WIN32
    5050#define WIN32_LEAN_AND_MEAN
     51#ifndef Q_USE_SYBASE
    5152#define DBNTWIN32 // indicates 32bit windows dblib
     53#endif
     54#include <winsock2.h>
    5255#include <QtCore/qt_windows.h>
    5356#include <sqlfront.h>
  • trunk/src/sql/kernel/qsql.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsql.qdoc

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    77** This file is part of the documentation of the Qt Toolkit.
    88**
    9 ** $QT_BEGIN_LICENSE:LGPL$
     9** $QT_BEGIN_LICENSE:FDL$
    1010** Commercial Usage
    1111** Licensees holding valid Qt Commercial licenses may use this file in
    1212** accordance with the Qt Commercial License Agreement provided with the
    13 ** Software or, alternatively, in accordance with the terms contained in
    14 ** a written agreement between you and Nokia.
     13** Software or, alternatively, in accordance with the terms contained in a
     14** written agreement between you and Nokia.
    1515**
    16 ** GNU Lesser General Public License Usage
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
    18 ** General Public License version 2.1 as published by the Free Software
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
    20 ** packaging of this file.  Please review the following information to
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    23 **
    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.
    27 **
    28 ** GNU General Public License Usage
    29 ** Alternatively, this file may be used under the terms of the GNU
    30 ** General Public License version 3.0 as published by the Free Software
    31 ** Foundation and appearing in the file LICENSE.GPL included in the
    32 ** packaging of this file.  Please review the following information to
    33 ** ensure the GNU General Public License version 3.0 requirements will be
    34 ** met: http://www.gnu.org/copyleft/gpl.html.
     16** GNU Free Documentation License
     17** Alternatively, this file may be used under the terms of the GNU Free
     18** Documentation License version 1.3 as published by the Free Software
     19** Foundation and appearing in the file included in the packaging of this
     20** file.
    3521**
    3622** If you have questions regarding the use of this file, please contact
  • trunk/src/sql/kernel/qsqlcachedresult.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlcachedresult_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqldatabase.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6161#endif
    6262#ifdef QT_SQL_TDS
     63// conflicting RETCODE typedef between odbc and freetds
     64#define RETCODE DBRETCODE
    6365#include "../drivers/tds/qsql_tds.h"
     66#undef RETCODE
    6467#endif
    6568#ifdef QT_SQL_DB2
     
    99102QT_BEGIN_NAMESPACE
    100103
    101 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
     104#ifndef QT_NO_LIBRARY
    102105Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
    103106                          (QSqlDriverFactoryInterface_iid,
     
    577580#endif
    578581
    579 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
     582#ifndef QT_NO_LIBRARY
    580583    if (QFactoryLoader *fl = loader()) {
    581584        QStringList keys = fl->keys();
     
    775778    }
    776779
    777 #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
     780#ifndef QT_NO_LIBRARY
    778781    if (!driver && loader()) {
    779782        if (QSqlDriverFactoryInterface *factory = qobject_cast<QSqlDriverFactoryInterface*>(loader()->instance(type)))
  • trunk/src/sql/kernel/qsqldatabase.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqldriver.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    397397    on \a type.
    398398
    399     \warning Because of binary compatability constraints, this function is not virtual.
     399    \warning Because of binary compatibility constraints, this function is not virtual.
    400400    If you want to provide your own implementation in your QSqlDriver subclass,
    401401    reimplement the isIdentifierEscapedImplementation() slot in your subclass instead.
     
    422422    modification.
    423423
    424     \warning Because of binary compatability constraints, this function is not virtual,
     424    \warning Because of binary compatibility constraints, this function is not virtual,
    425425    If you want to provide your own implementation in your QSqlDriver subclass,
    426426    reimplement the stripDelimitersImplementation() slot in your subclass instead.
     
    872872    on \a type.
    873873
    874     Because of binary compatability constraints, isIdentifierEscaped() function
     874    Because of binary compatibility constraints, isIdentifierEscaped() function
    875875    (introduced in Qt 4.5) is not virtual.  Instead, isIdentifierEscaped() will
    876876    dynamically detect and call \e this slot.  The default implementation
     
    897897    identifier is returned without modification.
    898898
    899     Because of binary compatability constraints, the stripDelimiters() function
     899    Because of binary compatibility constraints, the stripDelimiters() function
    900900    (introduced in Qt 4.5) is not virtual.  Instead, stripDelimiters() will
    901901    dynamically detect and call \e this slot.  It generally unnecessary
  • trunk/src/sql/kernel/qsqldriver.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqldriverplugin.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqldriverplugin.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlerror.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlerror.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlfield.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlfield.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlindex.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlindex.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlnulldriver_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlquery.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    273273/*!
    274274    Constructs a QSqlQuery object using the SQL \a query and the
    275     database \a db. If \a db is not specified, the application's
     275    database \a db. If \a db is not specified, or is invalid, the application's
    276276    default database is used. If \a query is not an empty string, it
    277277    will be executed.
     
    287287/*!
    288288    Constructs a QSqlQuery object using the database \a db.
     289    If \a db is invalid, the application's default database will be used.
    289290
    290291    \sa QSqlDatabase
  • trunk/src/sql/kernel/qsqlquery.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlrecord.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlrecord.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlresult.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/kernel/qsqlresult.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/models/qsqlquerymodel.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    280280        if (val.isValid())
    281281            return val;
    282         if (role == Qt::DisplayRole && d->rec.count() > section)
     282
     283        // See if it's an inserted column (iiq.column() != -1)
     284        QModelIndex dItem = indexInQuery(createIndex(0, section));
     285
     286        if (role == Qt::DisplayRole && d->rec.count() > section && dItem.column() != -1)
    283287            return d->rec.fieldName(section);
    284288    }
     
    306310    lastError() can be used to retrieve verbose information if there
    307311    was an error setting the query.
     312
     313    \note Calling setQuery() will remove any inserted columns.
    308314
    309315    \sa query(), QSqlQuery::isActive(), QSqlQuery::setForwardOnly(), lastError()
     
    371377
    372378    Executes the query \a query for the given database connection \a
    373     db. If no database is specified, the default connection is used.
     379    db. If no database (or an invalid database) is specified, the
     380    default connection is used.
    374381
    375382    lastError() can be used to retrieve verbose information if there
  • trunk/src/sql/models/qsqlquerymodel.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/models/qsqlquerymodel_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/models/qsqlrelationaldelegate.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/models/qsqlrelationaldelegate.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    6060public:
    6161
    62 explicit QSqlRelationalDelegate(QObject *parent = 0)
    63     : QItemDelegate(parent)
     62explicit QSqlRelationalDelegate(QObject *aParent = 0)
     63    : QItemDelegate(aParent)
    6464{}
    6565
     
    6767{}
    6868
    69 QWidget *createEditor(QWidget *parent,
     69QWidget *createEditor(QWidget *aParent,
    7070                      const QStyleOptionViewItem &option,
    7171                      const QModelIndex &index) const
     
    7474    QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0;
    7575    if (!childModel)
    76         return QItemDelegate::createEditor(parent, option, index);
     76        return QItemDelegate::createEditor(aParent, option, index);
    7777
    78     QComboBox *combo = new QComboBox(parent);
     78    QComboBox *combo = new QComboBox(aParent);
    7979    combo->setModel(childModel);
    8080    combo->setModelColumn(childModel->fieldIndex(sqlModel->relation(index.column()).displayColumn()));
  • trunk/src/sql/models/qsqlrelationaltablemodel.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/models/qsqlrelationaltablemodel.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/models/qsqltablemodel.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    266266    programmatically, without binding it to a view:
    267267
    268     \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 25
     268    \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 21
    269269
    270270    The code snippet above extracts the \c salary field from record 4 in
     
    394394    returns false.
    395395
     396    \note Calling select() will revert any unsubmitted changes and remove any inserted columns.
     397
    396398    \sa setTable(), setFilter(), selectStatement()
    397399*/
     
    424426        return QVariant();
    425427
     428    // Problem.. we need to use QSQM::indexInQuery to handle inserted columns
     429    // but inserted rows we need to handle
     430    // and indexInQuery is not virtual (grrr) so any values we pass to QSQM need
     431    // to handle the insertedRows
    426432    QModelIndex item = indexInQuery(index);
    427433
     
    451457        break; }
    452458    }
    453     return QSqlQueryModel::data(item, role);
     459
     460    // We need to handle row mapping here, but not column mapping
     461    return QSqlQueryModel::data(index.sibling(item.row(), index.column()), role);
    454462}
    455463
     
    10961104            if (idx >= rowCount())
    10971105                return false;
    1098             if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert)
     1106            if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) {
    10991107                revertRow(idx);
    1100             else {
     1108                // Reverting a row means all the other cache entries have been adjusted downwards
     1109                // so fake this by adjusting row
     1110                --row;
     1111            } else {
    11011112                d->cache[idx].op = QSqlTableModelPrivate::Delete;
    11021113                d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row());
     
    12261237{
    12271238    Q_D(const QSqlTableModel);
    1228     const QModelIndex it = QSqlQueryModel::indexInQuery(item);
     1239    const QModelIndex it = QSqlQueryModel::indexInQuery(item); // this adjusts columns only
    12291240    if (d->strategy == OnManualSubmit) {
    12301241        int rowOffset = 0;
     
    13331344                mrow.rec.setValue(idx, record.value(i));
    13341345        }
     1346
     1347        if (isOk)
     1348            emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
    13351349        return isOk; }
    13361350    }
  • trunk/src/sql/models/qsqltablemodel.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/models/qsqltablemodel_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
  • trunk/src/sql/sql.pro

    r561 r846  
    2121    TARGET.UID3=0x2001E61D
    2222
    23     # Workaroud for problems with paging this dll
    24     MMP_RULES -= PAGED
    25     MMP_RULES *= UNPAGED
     23    # Problems using data exports from this DLL mean that we can't page it on releases that don't support
     24    # data exports (currently that's any release before Symbian^3)
     25    pagingBlock = "$${LITERAL_HASH}ifndef SYMBIAN_DLL_DATA_EXPORTS_SUPPORTED" \
     26                  "UNPAGED" \
     27                  "$${LITERAL_HASH}endif"
     28    MMP_RULES += pagingBlock
    2629}
Note: See TracChangeset for help on using the changeset viewer.