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

Legend:

Unmodified
Added
Removed
  • trunk

  • 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) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    5757#include <qdebug.h>
    5858
     59
     60
     61
     62
     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
    92109
    93110typedef QVarLengthArray<sb2, 32> IndicatorArray;
     
    96113static QByteArray qMakeOraDate(const QDateTime& dt);
    97114static QDateTime qMakeDate(const char* oraDate);
     115
     116
     117
     118
     119
     120
     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
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     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
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     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);
    302367            break;
    303368        }
     
    323388        }
    324389        if (r == OCI_SUCCESS)
    325             setCharset(*hbnd);
     390            setCharset(*hbnd);
    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)
    355420{
    356421    switch (value.type()) {
     
    364429        value = qMakeDate(storage.takeFirst());
    365430        break;
     431
     432
     433
     434
     435
     436
    366437    case QVariant::String:
    367         value = QString::fromUtf16(
    368                 reinterpret_cast<const ushort *>(storage.takeFirst().constData()));
     438        value = QString(
     439                reinterpret_cast<const *>(storage.takeFirst().constData()));
    369440        break;
    370441    default:
     
    381452            continue;
    382453
    383         qOraOutValue(values[i], tmpStorage);
     454        qOraOutValue(values[i], tmpStorage);
    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 *>(errbuf));
    458529}
    459530
     
    641712}
    642713
     714
     715
     716
     717
     718
     719
     720
     721
     722
     723
     724
     725
     726
     727
     728
     729
     730
     731
     732
     733
     734
     735
     736
     737
     738
     739
     740
     741
     742
     743
     744
     745
     746
     747
     748
     749
     750
     751
     752
     753
     754
     755
     756
     757
     758
     759
     760
     761
     762
     763
    643764QDateTime qMakeDate(const char* oraDate)
    644765{
    645     int century = oraDate[0];
     766    int century = ;
    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                    );
    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
     1349
     1350
     1351
     1352
     1353
     1354
     1355
     1356
     1357
    12471358            case QVariant::Double:
    12481359                col.bindAs = SQLT_FLT;
     
    13161427                        break;
    13171428
     1429
     1430
     1431
     1432
     1433
     1434
     1435
     1436
     1437
     1438
     1439
     1440
     1441
     1442
     1443
     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);
    14261553            if (*columns[i].indicators == -1)
    14271554                boundValues[i] = QVariant(tp);
     
    14531580                    break;
    14541581
     1582
     1583
     1584
     1585
     1586
     1587
     1588
     1589
     1590
     1591
     1592
     1593
     1594
     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 *>(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 *>(fld.data));
    16121754            break;
    16131755        case QVariant::ByteArray:
     
    21032245    } else {
    21042246        QString versionStr;
    2105         versionStr = QString::fromUtf16(reinterpret_cast<ushort *>(vertxt));
     2247        versionStr = QString *>(vertxt));
    21062248        QRegExp vers(QLatin1String("([0-9]+)\\.[0-9\\.]+[0-9]"));
    21072249        if (vers.indexIn(versionStr) >= 0)
Note: See TracChangeset for help on using the changeset viewer.