Changeset 769 for trunk/src/sql/drivers


Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

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

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/sql/drivers/drivers.pri

    r2 r769  
    5050     mac:!contains( LIBS, .*odbc.* ):LIBS        *= -liodbc
    5151     unix:!contains( LIBS, .*odbc.* ):LIBS       *= -lodbc
     52
    5253
    5354     win32 {
  • trunk/src/sql/drivers/mysql/qsql_mysql.cpp

    r651 r769  
    321321}
    322322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
    323333void QMYSQLResultPrivate::bindBlobs()
    324334{
     
    369379            hasBlobs = true;
    370380        } else {
     381
     382
     383
     384
     385
     386
     387
    371388            fieldInfo->type = MYSQL_TYPE_STRING;
    372389        }
  • trunk/src/sql/drivers/oci/qsql_oci.cpp

    r651 r769  
    518518    else if (ocitype == QLatin1String("LONG") || ocitype == QLatin1String("NCLOB")
    519519             || ocitype == QLatin1String("CLOB"))
    520         type = QVariant::String;
     520        type = QVariant::;
    521521    else if (ocitype == QLatin1String("RAW") || ocitype == QLatin1String("LONG RAW")
    522522             || ocitype == QLatin1String("ROWID") || ocitype == QLatin1String("BLOB")
     
    544544    case SQLT_RDD:
    545545    case SQLT_LNG:
    546     case SQLT_CLOB:
    547546#ifdef SQLT_INTERVAL_YM
    548547    case SQLT_INTERVAL_YM:
     
    582581    case SQLT_LVB:
    583582    case SQLT_BLOB:
     583
    584584    case SQLT_FILE:
    585585    case SQLT_NTY:
  • trunk/src/sql/drivers/odbc/qsql_odbc.cpp

    r651 r769  
    6767# undef UNICODE
    6868# define SQLTCHAR SQLCHAR
    69 # define SQL_C_WCHAR SQL_C_CHAR
     69# define SQL_C_CHAR SQL_C_CHAR
    7070#endif
    7171
     
    7979#endif
    8080
    81 
    8281static const int COLNAMESIZE = 256;
    8382//Map Qt parameter types to ODBC types
    8483static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT };
    8584
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
    86129class QODBCDriverPrivate
    87130{
     
    89132    enum DefaultCase{Lower, Mixed, Upper, Sensitive};
    90133    QODBCDriverPrivate()
    91     : hEnv(0), hDbc(0), useSchema(false), disconnectCount(0), isMySqlServer(false),
    92            isMSSqlServer(false), hasSQLFetchScroll(true), hasMultiResultSets(false),
    93            isQuoteInitialized(false), quote(QLatin1Char('"'))
     134    : hEnv(0), hDbc(0), useSchema(false), disconnectCount(0), isMySqlServer(false),
     135           isMSSqlServer(false), e),
     136           isQuoteInitialized(false), quote(QLatin1Char('"'))
    94137    {
    95         unicode = false;
    96138    }
    97139
     
    99141    SQLHANDLE hDbc;
    100142
    101     uint unicode :1;
    102     uint useSchema :1;
     143    ;
     144    ;
    103145    int disconnectCount;
    104146    bool isMySqlServer;
    105147    bool isMSSqlServer;
     148
    106149    bool hasSQLFetchScroll;
    107150    bool hasMultiResultSets;
     
    130173    : hStmt(0), useSchema(false), hasSQLFetchScroll(true), driverPrivate(dpp), userForwardOnly(false)
    131174    {
    132         unicode = false;
     175        unicode = dpp->unicode;
     176        useSchema = dpp->useSchema;
     177        disconnectCount = dpp->disconnectCount;
     178        hasSQLFetchScroll = dpp->hasSQLFetchScroll;
    133179    }
    134180
     
    140186    SQLHANDLE hStmt;
    141187
    142     uint unicode :1;
    143     uint useSchema :1;
     188    ;
     189    ;
    144190
    145191    QSqlRecord rInf;
     
    178224
    179225    description_[0] = 0;
    180     r = SQLGetDiagRec(handleType,
    181                       handle,
    182                       i,
    183                       state_,
    184                       &nativeCode_,
    185                       0,
    186                       NULL,
    187                       &msgLen);
    188     if(r == SQL_NO_DATA)
    189         return QString();
    190     description_.resize(msgLen+1);
    191226    do {
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
    192237        r = SQLGetDiagRec(handleType,
    193238                            handle,
     
    203248            QString tmpstore;
    204249#ifdef UNICODE
    205             tmpstore = QString((const QChar*)description_.data(), msgLen);
     250            tmpstore = , msgLen);
    206251#else
    207             tmpstore = QString::fromLocal8Bit((const char*)description_.data(), msgLen);
     252            tmpstore = QString::fromata(), msgLen);
    208253#endif
    209254            if(result != tmpstore) {
     
    224269    return (qWarnODBCHandle(SQL_HANDLE_ENV, odbc->dpEnv()) + QLatin1Char(' ')
    225270             + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->dpDbc()) + QLatin1Char(' ')
    226              + qWarnODBCHandle(SQL_HANDLE_STMT, odbc->hStmt, nativeCode));
     271             + qWarnODBCHandle(SQL_HANDLE_STMT, odbc->hStmt, nativeCode));
    227272}
    228273
     
    230275{
    231276    return (qWarnODBCHandle(SQL_HANDLE_ENV, odbc->hEnv) + QLatin1Char(' ')
    232              + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->hDbc, nativeCode));
     277             + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->hDbc, nativeCode));
    233278}
    234279
     
    308353    case SQL_CHAR:
    309354    case SQL_VARCHAR:
     355
    310356    case SQL_GUID:
     357
    311358    case SQL_LONGVARCHAR:
    312359        type = QVariant::String;
     
    332379    } else {
    333380        colSize++; // make sure there is room for more than the 0 termination
    334         if (unicode) {
    335             colSize *= 2; // a tiny bit faster, since it saves a SQLGetData() call
    336         }
    337     }
    338     QVarLengthArray<char> buf(colSize);
    339     while (true) {
     381    }
     382    if(unicode) {
    340383        r = SQLGetData(hStmt,
    341384                        column+1,
    342                         unicode ? SQL_C_WCHAR : SQL_C_CHAR,
    343                         (SQLPOINTER)buf.data(),
    344                         colSize,
     385                        CHAR,
     386                        ,
     387                        ,
    345388                        &lengthIndicator);
    346         if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
    347             if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
     389        if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0)
     390            colSize = lengthIndicator/sizeof(SQLTCHAR) + 1;
     391        QVarLengthArray<SQLTCHAR> buf(colSize);
     392        memset(buf.data(), 0, colSize*sizeof(SQLTCHAR));
     393        while (true) {
     394            r = SQLGetData(hStmt,
     395                            column+1,
     396                            SQL_C_TCHAR,
     397                            (SQLPOINTER)buf.data(),
     398                            colSize*sizeof(SQLTCHAR),
     399                            &lengthIndicator);
     400            if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
     401                if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
     402                    fieldVal.clear();
     403                    break;
     404                }
     405                // if SQL_SUCCESS_WITH_INFO is returned, indicating that
     406                // more data can be fetched, the length indicator does NOT
     407                // contain the number of bytes returned - it contains the
     408                // total number of bytes that CAN be fetched
     409                // colSize-1: remove 0 termination when there is more data to fetch
     410                int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator/sizeof(SQLTCHAR);
     411                    fieldVal += fromSQLTCHAR(buf, rSize);
     412                if (lengthIndicator < (unsigned int)colSize*sizeof(SQLTCHAR)) {
     413                    // workaround for Drivermanagers that don't return SQL_NO_DATA
     414                    break;
     415                }
     416            } else if (r == SQL_NO_DATA) {
     417                break;
     418            } else {
     419                qWarning() << "qGetStringData: Error while fetching data (" << qWarnODBCHandle(SQL_HANDLE_STMT, hStmt) << ')';
    348420                fieldVal.clear();
    349421                break;
    350422            }
    351             // if SQL_SUCCESS_WITH_INFO is returned, indicating that
    352             // more data can be fetched, the length indicator does NOT
    353             // contain the number of bytes returned - it contains the
    354             // total number of bytes that CAN be fetched
    355             // colSize-1: remove 0 termination when there is more data to fetch
    356             int rSize = (r == SQL_SUCCESS_WITH_INFO) ? (unicode ? colSize-2 : colSize-1) : lengthIndicator;
    357             if (unicode) {
    358                 fieldVal += QString((const QChar*) buf.constData(), rSize / 2);
     423        }
     424    } else {
     425        r = SQLGetData(hStmt,
     426                        column+1,
     427                        SQL_C_CHAR,
     428                        NULL,
     429                        0,
     430                        &lengthIndicator);
     431        if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && lengthIndicator > 0)
     432            colSize = lengthIndicator + 1;
     433        QVarLengthArray<SQLCHAR> buf(colSize);
     434        while (true) {
     435            r = SQLGetData(hStmt,
     436                            column+1,
     437                            SQL_C_CHAR,
     438                            (SQLPOINTER)buf.data(),
     439                            colSize,
     440                            &lengthIndicator);
     441            if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
     442                if (lengthIndicator == SQL_NULL_DATA || lengthIndicator == SQL_NO_TOTAL) {
     443                    fieldVal.clear();
     444                    break;
     445                }
     446                // if SQL_SUCCESS_WITH_INFO is returned, indicating that
     447                // more data can be fetched, the length indicator does NOT
     448                // contain the number of bytes returned - it contains the
     449                // total number of bytes that CAN be fetched
     450                // colSize-1: remove 0 termination when there is more data to fetch
     451                int rSize = (r == SQL_SUCCESS_WITH_INFO) ? colSize : lengthIndicator;
     452                    fieldVal += QString::fromUtf8((const char *)buf.constData(), rSize);
     453                if (lengthIndicator < (unsigned int)colSize) {
     454                    // workaround for Drivermanagers that don't return SQL_NO_DATA
     455                    break;
     456                }
     457            } else if (r == SQL_NO_DATA) {
     458                break;
    359459            } else {
    360                 fieldVal += QString::fromAscii(buf.constData(), rSize);
    361             }
    362             memset(buf.data(), 0, colSize);
    363             if (lengthIndicator < colSize) {
    364                 // workaround for Drivermanagers that don't return SQL_NO_DATA
     460                qWarning() << "qGetStringData: Error while fetching data (" << qWarnODBCHandle(SQL_HANDLE_STMT, hStmt) << ')';
     461                fieldVal.clear();
    365462                break;
    366463            }
    367         } else if (r == SQL_NO_DATA) {
    368             break;
    369         } else {
    370             qWarning() << "qGetStringData: Error while fetching data (" << qWarnODBCHandle(SQL_HANDLE_STMT, hStmt) << ')';
    371             fieldVal.clear();
    372             break;
    373464        }
    374465    }
     
    387478    SQLRETURN r = SQL_ERROR;
    388479
    389     SQLTCHAR colName[COLNAMESIZE];
     480    QVarLengthArray<SQLTCHAR> colName(COLNAMESIZE);
     481
    390482    r = SQLDescribeCol(hStmt,
    391483                       column + 1,
    392                        colName,
     484                       colName,
    393485                       COLNAMESIZE,
    394486                       &colNameLen,
     
    523615    SQLSMALLINT nullable;
    524616    SQLRETURN r = SQL_ERROR;
    525     SQLTCHAR colName[COLNAMESIZE];
     617    ;
    526618    r = SQLDescribeCol(p->hStmt,
    527619                        i+1,
    528                         colName,
     620                        colName,
    529621                        (SQLSMALLINT)COLNAMESIZE,
    530622                        &colNameLen,
     
    552644
    553645#ifdef UNICODE
    554     QString qColName((const QChar*)colName, colNameLen);
     646    QString qColName();
    555647#else
    556     QString qColName = QString::fromLocal8Bit((const char*)colName);
     648    QString qColName = QString::from);
    557649#endif
    558650    // nullable can be SQL_NO_NULLS, SQL_NULLABLE or SQL_NULLABLE_UNKNOWN
     
    582674        return SQL_OV_ODBC3;
    583675#endif
     676
     677
     678
     679
     680
    584681    return SQL_OV_ODBC2;
     682
    585683}
    586684
     
    588686{
    589687    if (!isQuoteInitialized) {
    590         char driverResponse[4];
     688        driverResponse[4];
    591689        SQLSMALLINT length;
    592690        int r = SQLGetInfo(hDbc,
     
    595693                sizeof(driverResponse),
    596694                &length);
    597         if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
     695        if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
     696#ifdef UNICODE
     697            quote = QChar(driverResponse[0]);
     698#else
    598699            quote = QLatin1Char(driverResponse[0]);
    599         } else {
     700#endif
     701        else
    600702            quote = QLatin1Char('"');
    601         }
    602703        isQuoteInitialized = true;
    603704    }
     
    643744            r = SQLSetConnectAttr(hDbc, SQL_ATTR_CURRENT_CATALOG,
    644745#ifdef UNICODE
    645                                     (SQLWCHAR*) val.unicode(),
     746                                    (),
    646747#else
    647                                     (SQLCHAR*) val.toLatin1().constData(),
    648 #endif
    649                                     SQL_NTS);
     748                                    (SQLCHAR*) val.toata(),
     749#endif
     750                                    );
    650751        } else if (opt.toUpper() == QLatin1String("SQL_ATTR_METADATA_ID")) {
    651752            if (val.toUpper() == QLatin1String("SQL_TRUE")) {
     
    665766            r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACEFILE,
    666767#ifdef UNICODE
    667                                     (SQLWCHAR*) val.unicode(),
     768                                    (),
    668769#else
    669                                     (SQLCHAR*) val.toLatin1().constData(),
    670 #endif
    671                                     SQL_NTS);
     770                                    (SQLCHAR*) val.toata(),
     771#endif
     772                                    );
    672773        } else if (opt.toUpper() == QLatin1String("SQL_ATTR_TRACE")) {
    673774            if (val.toUpper() == QLatin1String("SQL_OPT_TRACE_OFF")) {
     
    815916{
    816917    d = new QODBCPrivate(p);
    817     d->unicode = p->unicode;
    818     d->useSchema = p->useSchema;
    819     d->disconnectCount = p->disconnectCount;
    820     d->hasSQLFetchScroll = p->hasSQLFetchScroll;
    821918}
    822919
     
    881978#ifdef UNICODE
    882979    r = SQLExecDirect(d->hStmt,
    883                        (SQLWCHAR*) query.unicode(),
     980                       (),
    884981                       (SQLINTEGER) query.length());
    885982#else
    886     QByteArray query8 = query.toLocal8Bit();
     983    QByteArray query8 = query.to();
    887984    r = SQLExecDirect(d->hStmt,
    888                        (SQLCHAR*) query8.constData(),
     985                       (SQLCHAR*) query8.ata(),
    889986                       (SQLINTEGER) query8.length());
    890987#endif
     
    12321329#ifdef UNICODE
    12331330    r = SQLPrepare(d->hStmt,
    1234                     (SQLWCHAR*) query.unicode(),
     1331                    (),
    12351332                    (SQLINTEGER) query.length());
    12361333#else
    1237     QByteArray query8 = query.toLocal8Bit();
     1334    QByteArray query8 = query.to();
    12381335    r = SQLPrepare(d->hStmt,
    1239                     (SQLCHAR*) query8.constData(),
     1336                    (SQLCHAR*) query8.ata(),
    12401337                    (SQLINTEGER) query8.length());
    12411338#endif
     
    14361533                if (d->unicode) {
    14371534                    QString str = val.toString();
    1438                     str.utf16();
    14391535                    if (*ind != SQL_NULL_DATA)
    1440                         *ind = str.length() * sizeof(QChar);
    1441                     int strSize = str.length() * sizeof(QChar);
     1536                        *ind = str.length() * sizeof();
     1537                    int strSize = str.length() * sizeof();
    14421538
    14431539                    if (bindValueType(i) & QSql::Out) {
    1444                         QByteArray ba((char*)str.constData(), str.capacity() * sizeof(QChar));
     1540                        QVarLengthArray<SQLTCHAR> ba(toSQLTCHAR(str));
     1541                        ba.reserve(str.capacity());
    14451542                        r = SQLBindParameter(d->hStmt,
    14461543                                            i + 1,
    14471544                                            qParamType[(QFlag)(bindValueType(i)) & QSql::InOut],
    1448                                             SQL_C_WCHAR,
     1545                                            SQL_C_CHAR,
    14491546                                            strSize > 254 ? SQL_WLONGVARCHAR : SQL_WVARCHAR,
    14501547                                            0, // god knows... don't change this!
     
    14531550                                            ba.size(),
    14541551                                            ind);
    1455                         tmpStorage.append(ba);
     1552                        tmpStorage.append();
    14561553                        break;
    14571554                    }
    1458 
     1555                    QByteArray strba((const char *)toSQLTCHAR(str).constData(), str.size()*sizeof(SQLTCHAR));
    14591556                    r = SQLBindParameter(d->hStmt,
    14601557                                          i + 1,
    14611558                                          qParamType[(QFlag)(bindValueType(i)) & QSql::InOut],
    1462                                           SQL_C_WCHAR,
     1559                                          SQL_C_CHAR,
    14631560                                          strSize > 254 ? SQL_WLONGVARCHAR : SQL_WVARCHAR,
    14641561                                          strSize,
    14651562                                          0,
    1466                                           (void *)str.constData(),
    1467                                           strSize,
     1563                                          (.constData(),
     1564                                          str,
    14681565                                          ind);
     1566
    14691567                    break;
    14701568                }
     
    14721570#endif
    14731571                {
    1474                     QByteArray str = val.toString().toAscii();
     1572                    QByteArray str = val.toString().to();
    14751573                    if (*ind != SQL_NULL_DATA)
    14761574                        *ind = str.length();
     
    15731671            case QVariant::String:
    15741672                if (d->unicode) {
    1575                     if (bindValueType(i) & QSql::Out)
    1576                         values[i] = QString::fromUtf16((ushort*)tmpStorage.takeFirst().constData());
     1673                    if (bindValueType(i) & QSql::Out) {
     1674                        QByteArray first = tmpStorage.takeFirst();
     1675                        QVarLengthArray<SQLTCHAR> array;
     1676                        array.append((SQLTCHAR *)first.constData(), first.size());
     1677                        values[i] = fromSQLTCHAR(array, first.size()/sizeof(SQLTCHAR*));
     1678                    }
    15771679                    break;
    15781680                }
    15791681                // fall through
    15801682            default: {
    1581                 QByteArray ba = tmpStorage.takeFirst();
    15821683                if (bindValueType(i) & QSql::Out)
    1583                     values[i] = QString::fromAscii(ba.constData());
     1684                    values[i] = );
    15841685                break; }
    15851686        }
     
    17901891
    17911892    SQLSMALLINT cb;
    1792     SQLTCHAR connOut[1024];
     1893    QVarLengthArray<SQLTCHAR> connOut(1024);
     1894    memset(connOut.data(), 0, connOut.size() * sizeof(SQLTCHAR));
    17931895    r = SQLDriverConnect(d->hDbc,
    17941896                          NULL,
    17951897#ifdef UNICODE
    1796                           (SQLWCHAR*)connQStr.unicode(),
     1898                          (),
    17971899#else
    1798                           (SQLCHAR*)connQStr.toLatin1().constData(),
     1900                          (SQLCHAR*)connQStr.toata(),
    17991901#endif
    18001902                          (SQLSMALLINT)connQStr.length(),
    1801                           connOut,
     1903                          connOut,
    18021904                          1024,
    18031905                          &cb,
    1804                           SQL_DRIVER_NOPROMPT);
     1906                          /*SQL_DRIVER_NOPROMPT*/0);
     1907
    18051908    if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) {
    18061909        setLastError(qMakeError(tr("Unable to connect"), QSqlError::ConnectionError, d));
     
    18871990    if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WCHAR)) {
    18881991        unicode = true;
     1992
    18891993    }
    18901994
     
    18962000    if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WVARCHAR)) {
    18972001        unicode = true;
     2002
    18982003    }
    18992004
     
    19052010    if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WLONGVARCHAR)) {
    19062011        unicode = true;
    1907     }
     2012        return;
     2013    }
     2014    SQLHANDLE hStmt;
     2015    r = SQLAllocHandle(SQL_HANDLE_STMT,
     2016                                  hDbc,
     2017                                  &hStmt);
     2018
     2019    r = SQLExecDirect(hStmt, toSQLTCHAR(QLatin1String("select 'test'")).data(), SQL_NTS);
     2020    if(r == SQL_SUCCESS) {
     2021        r = SQLFetch(hStmt);
     2022        if(r == SQL_SUCCESS) {
     2023            QVarLengthArray<SQLWCHAR> buffer(10);
     2024            r = SQLGetData(hStmt, 1, SQL_C_WCHAR, buffer.data(), buffer.size() * sizeof(SQLWCHAR), NULL);
     2025            if(r == SQL_SUCCESS && fromSQLTCHAR(buffer) == QLatin1String("test")) {
     2026                unicode = true;
     2027            }
     2028        }
     2029    }
     2030    r = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
    19082031}
    19092032
     
    19782101{
    19792102    SQLRETURN   r;
    1980     char serverString[200];
     2103    ;
    19812104    SQLSMALLINT t;
     2105
    19822106
    19832107    r = SQLGetInfo(hDbc,
    19842108                   SQL_DBMS_NAME,
    1985                    serverString,
    1986                    sizeof(serverString),
     2109                   serverString,
     2110                   s),
    19872111                   &t);
    19882112    if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) {
    19892113        QString serverType;
    19902114#ifdef UNICODE
    1991         serverType = QString(reinterpret_cast<const QChar*>(serverString), t/sizeof(QChar));
     2115        serverType = ));
    19922116#else
    1993         serverType = QString::fromLocal8Bit(serverString, t);
     2117        serverType = QString::from, t);
    19942118#endif
    19952119        isMySqlServer = serverType.contains(QLatin1String("mysql"), Qt::CaseInsensitive);
    19962120        isMSSqlServer = serverType.contains(QLatin1String("Microsoft SQL Server"), Qt::CaseInsensitive);
     2121
     2122
     2123
     2124
     2125
     2126
     2127
     2128
     2129
     2130
     2131
     2132
     2133
     2134
     2135
    19972136    }
    19982137}
     
    20102149void QODBCDriverPrivate::checkHasMultiResults()
    20112150{
    2012     char driverResponse[4];
     2151    ;
    20132152    SQLSMALLINT length;
    20142153    SQLRETURN r = SQLGetInfo(hDbc,
    20152154                             SQL_MULT_RESULT_SETS,
    2016                              driverResponse,
    2017                              sizeof(driverResponse),
     2155                             driverResponse,
     2156                             ),
    20182157                             &length);
    20192158    if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO)
    20202159#ifdef UNICODE
    2021         hasMultiResultSets = QString(reinterpret_cast<const QChar*>(driverResponse), length/sizeof(QChar)).startsWith(QLatin1Char('Y'));
     2160        hasMultiResultSets = )).startsWith(QLatin1Char('Y'));
    20222161#else
    2023         hasMultiResultSets = QString::fromLocal8Bit(driverResponse, length).startsWith(QLatin1Char('Y'));
     2162        hasMultiResultSets = QString::from, length).startsWith(QLatin1Char('Y'));
    20242163#endif
    20252164}
     
    21352274                   0,
    21362275#ifdef UNICODE
    2137                    (SQLWCHAR*)joinedTableTypeString.unicode(),
     2276                   (),
    21382277#else
    2139                    (SQLCHAR*)joinedTableTypeString.toLatin1().constData(),
     2278                   (SQLCHAR*)joinedTableTypeString.toata(),
    21402279#endif
    21412280                   joinedTableTypeString.length() /* characters, not bytes */);
     
    21502289    else
    21512290        r = SQLFetch(hStmt);
     2291
     2292
     2293
     2294
     2295
    21522296
    21532297    while (r == SQL_SUCCESS) {
     
    22092353    r = SQLPrimaryKeys(hStmt,
    22102354#ifdef UNICODE
    2211                         catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(),
     2355                        catalog.length() == 0 ? NULL : (),
    22122356#else
    2213                         catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toLatin1().constData(),
     2357                        catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toata(),
    22142358#endif
    22152359                        catalog.length(),
    22162360#ifdef UNICODE
    2217                         schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(),
     2361                        schema.length() == 0 ? NULL : (),
    22182362#else
    2219                         schema.length() == 0 ? NULL : (SQLCHAR*)schema.toLatin1().constData(),
     2363                        schema.length() == 0 ? NULL : (SQLCHAR*)schema.toata(),
    22202364#endif
    22212365                        schema.length(),
    22222366#ifdef UNICODE
    2223                         (SQLWCHAR*)table.unicode(),
     2367                        (),
    22242368#else
    2225                         (SQLCHAR*)table.toLatin1().constData(),
     2369                        (SQLCHAR*)table.toata(),
    22262370#endif
    22272371                        table.length() /* in characters, not in bytes */);
     
    22342378                        SQL_BEST_ROWID,
    22352379#ifdef UNICODE
    2236                         catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(),
     2380                        catalog.length() == 0 ? NULL : (),
    22372381#else
    2238                         catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toLatin1().constData(),
     2382                        catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toata(),
    22392383#endif
    22402384                        catalog.length(),
    22412385#ifdef UNICODE
    2242                         schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(),
     2386                        schema.length() == 0 ? NULL : (),
    22432387#else
    2244                         schema.length() == 0 ? NULL : (SQLCHAR*)schema.toLatin1().constData(),
     2388                        schema.length() == 0 ? NULL : (SQLCHAR*)schema.toata(),
    22452389#endif
    22462390                        schema.length(),
    22472391#ifdef UNICODE
    2248                         (SQLWCHAR*)table.unicode(),
     2392                        (),
    22492393#else
    2250                         (SQLCHAR*)table.toLatin1().constData(),
     2394                        (SQLCHAR*)table.toata(),
    22512395#endif
    22522396                        table.length(),
     
    23342478    r =  SQLColumns(hStmt,
    23352479#ifdef UNICODE
    2336                      catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(),
     2480                     catalog.length() == 0 ? NULL : (),
    23372481#else
    2338                      catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toLatin1().constData(),
     2482                     catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toata(),
    23392483#endif
    23402484                     catalog.length(),
    23412485#ifdef UNICODE
    2342                      schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(),
     2486                     schema.length() == 0 ? NULL : (),
    23432487#else
    2344                      schema.length() == 0 ? NULL : (SQLCHAR*)schema.toLatin1().constData(),
     2488                     schema.length() == 0 ? NULL : (SQLCHAR*)schema.toata(),
    23452489#endif
    23462490                     schema.length(),
    23472491#ifdef UNICODE
    2348                      (SQLWCHAR*)table.unicode(),
     2492                     (),
    23492493#else
    2350                      (SQLCHAR*)table.toLatin1().constData(),
     2494                     (SQLCHAR*)table.toata(),
    23512495#endif
    23522496                     table.length(),
  • trunk/src/sql/drivers/odbc/qsql_odbc.h

    r651 r769  
    7474#if defined(Q_CC_BOR)
    7575#  undef _MSC_VER
    76 #endif
    77 
    78 #ifndef Q_ODBC_VERSION_2
    79 #include <sqlucode.h>
    8076#endif
    8177
  • trunk/src/sql/drivers/sqlite/qsql_sqlite.cpp

    r651 r769  
    246246                break;
    247247            default:
    248                 values[i + idx] = QString::fromUtf16(static_cast<const ushort *>(
     248                values[i + idx] = QString *>(
    249249                            sqlite3_column_text16(stmt, i)),
    250                             sqlite3_column_bytes16(stmt, i) / sizeof(ushort));
     250                            sqlite3_column_bytes16(stmt, i) / sizeof());
    251251                break;
    252252            }
     
    260260        sqlite3_reset(stmt);
    261261        return false;
     262
    262263    case SQLITE_ERROR:
    263264        // SQLITE_ERROR is a generic error code and we must call sqlite3_reset()
     
    501502}
    502503
    503 static int qGetSqliteTimeout(QString opts)
    504 {
    505     enum { DefaultTimeout = 5000 };
    506 
    507     opts.remove(QLatin1Char(' '));
    508     foreach(QString option, opts.split(QLatin1Char(';'))) {
    509         if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) {
    510             bool ok;
    511             int nt = option.mid(21).toInt(&ok);
    512             if (ok)
    513                 return nt;
    514         }
    515     }
    516     return DefaultTimeout;
    517 }
    518 
    519 static int qGetSqliteOpenMode(QString opts)
    520 {
    521     opts.remove(QLatin1Char(' '));
    522     foreach(QString option, opts.split(QLatin1Char(';'))) {
    523         if (option == QLatin1String("QSQLITE_OPEN_READONLY"))
    524                 return SQLITE_OPEN_READONLY;
    525     }
    526     return SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
    527 }
    528 
    529504/*
    530505   SQLite dbs have no user name, passwords, hosts or ports.
     
    538513    if (db.isEmpty())
    539514        return false;
    540 
    541     if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, qGetSqliteOpenMode(conOpts), NULL) == SQLITE_OK) {
    542         sqlite3_busy_timeout(d->access, qGetSqliteTimeout(conOpts));
     515    bool sharedCache = false;
     516    int openMode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, timeOut=5000;
     517    QStringList opts=QString(conOpts).remove(QLatin1Char(' ')).split(QLatin1Char(';'));
     518    foreach(const QString &option, opts) {
     519        if (option.startsWith(QLatin1String("QSQLITE_BUSY_TIMEOUT="))) {
     520            bool ok;
     521            int nt = option.mid(21).toInt(&ok);
     522            if (ok)
     523                timeOut = nt;
     524        }
     525        if (option == QLatin1String("QSQLITE_OPEN_READONLY"))
     526            openMode = SQLITE_OPEN_READONLY;
     527        if (option == QLatin1String("QSQLITE_ENABLE_SHARED_CACHE"))
     528            sharedCache = true;
     529    }
     530
     531    sqlite3_enable_shared_cache(sharedCache);
     532
     533    if (sqlite3_open_v2(db.toUtf8().constData(), &d->access, openMode, NULL) == SQLITE_OK) {
     534        sqlite3_busy_timeout(d->access, timeOut);
    543535        setOpen(true);
    544536        setOpenError(false);
Note: See TracChangeset for help on using the changeset viewer.