src/sql/drivers/oci/qsql_oci.cpp
changeset 30 5dc02b23752f
parent 19 fcece45ef507
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
    53 #include <qsqlquery.h>
    53 #include <qsqlquery.h>
    54 #include <qstringlist.h>
    54 #include <qstringlist.h>
    55 #include <qvarlengtharray.h>
    55 #include <qvarlengtharray.h>
    56 #include <qvector.h>
    56 #include <qvector.h>
    57 #include <qdebug.h>
    57 #include <qdebug.h>
       
    58 
       
    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 
    58 
    64 
    59 #include <oci.h>
    65 #include <oci.h>
    60 #ifdef max
    66 #ifdef max
    61 #undef max
    67 #undef max
    62 #endif
    68 #endif
   362         break;
   368         break;
   363     case QVariant::DateTime:
   369     case QVariant::DateTime:
   364         value = qMakeDate(storage.takeFirst());
   370         value = qMakeDate(storage.takeFirst());
   365         break;
   371         break;
   366     case QVariant::String:
   372     case QVariant::String:
   367         value = QString::fromUtf16(
   373         value = QString(
   368                 reinterpret_cast<const ushort *>(storage.takeFirst().constData()));
   374                 reinterpret_cast<const QChar *>(storage.takeFirst().constData()));
   369         break;
   375         break;
   370     default:
   376     default:
   371         break; //nothing
   377         break; //nothing
   372     }
   378     }
   373 }
   379 }
   452                 errbuf,
   458                 errbuf,
   453                 sizeof(errbuf),
   459                 sizeof(errbuf),
   454                 OCI_HTYPE_ERROR);
   460                 OCI_HTYPE_ERROR);
   455     if (errorCode)
   461     if (errorCode)
   456         *errorCode = errcode;
   462         *errorCode = errcode;
   457     return QString::fromUtf16(reinterpret_cast<const ushort *>(errbuf));
   463     return QString(reinterpret_cast<const QChar *>(errbuf));
   458 }
   464 }
   459 
   465 
   460 void qOraWarning(const char* msg, OCIError *err)
   466 void qOraWarning(const char* msg, OCIError *err)
   461 {
   467 {
   462 #ifdef QOCI_DEBUG
   468 #ifdef QOCI_DEBUG
   987         if (nullField || !chunkSize) {
   993         if (nullField || !chunkSize) {
   988             fieldInf[fieldNum].ind = -1;
   994             fieldInf[fieldNum].ind = -1;
   989         } else {
   995         } else {
   990             if (isStringField) {
   996             if (isStringField) {
   991                 QString str = values.at(fieldNum + index).toString();
   997                 QString str = values.at(fieldNum + index).toString();
   992                 str += QString::fromUtf16(reinterpret_cast<const ushort *>(col),
   998                 str += QString(reinterpret_cast<const QChar *>(col), chunkSize / 2);
   993                                           chunkSize / 2);
       
   994                 values[fieldNum + index] = str;
   999                 values[fieldNum + index] = str;
   995                 fieldInf[fieldNum].ind = 0;
  1000                 fieldInf[fieldNum].ind = 0;
   996             } else {
  1001             } else {
   997                 QByteArray ba = values.at(fieldNum + index).toByteArray();
  1002                 QByteArray ba = values.at(fieldNum + index).toByteArray();
   998                 int sz = ba.size();
  1003                 int sz = ba.size();
  1455                 case SQLT_FLT:
  1460                 case SQLT_FLT:
  1456                     (*list)[r] =  *reinterpret_cast<double*>(data + r * columns[i].maxLen);
  1461                     (*list)[r] =  *reinterpret_cast<double*>(data + r * columns[i].maxLen);
  1457                     break;
  1462                     break;
  1458 
  1463 
  1459                 case SQLT_STR:
  1464                 case SQLT_STR:
  1460                     (*list)[r] =  QString::fromUtf16(reinterpret_cast<ushort *>(data
  1465                     (*list)[r] =  QString(reinterpret_cast<const QChar *>(data
  1461                                                                 + r * columns[i].maxLen));
  1466                                                                 + r * columns[i].maxLen));
  1462                     break;
  1467                     break;
  1463 
  1468 
  1464                 default:
  1469                 default:
  1465                     (*list)[r] =  QByteArray(data + r * columns[i].maxLen, columns[i].maxLen);
  1470                     (*list)[r] =  QByteArray(data + r * columns[i].maxLen, columns[i].maxLen);
  1606                     break;
  1611                     break;
  1607                 }
  1612                 }
  1608             }
  1613             }
  1609             // else fall through
  1614             // else fall through
  1610         case QVariant::String:
  1615         case QVariant::String:
  1611             v[index + i] = QString::fromUtf16(reinterpret_cast<const ushort *>(fld.data));
  1616             v[index + i] = QString(reinterpret_cast<const QChar *>(fld.data));
  1612             break;
  1617             break;
  1613         case QVariant::ByteArray:
  1618         case QVariant::ByteArray:
  1614             if (fld.len > 0)
  1619             if (fld.len > 0)
  1615                 v[index + i] = QByteArray(fld.data, fld.len);
  1620                 v[index + i] = QByteArray(fld.data, fld.len);
  1616             else
  1621             else
  2100                           OCI_HTYPE_SVCCTX);
  2105                           OCI_HTYPE_SVCCTX);
  2101     if (r != 0) {
  2106     if (r != 0) {
  2102         qWarning("QOCIDriver::open: could not get Oracle server version.");
  2107         qWarning("QOCIDriver::open: could not get Oracle server version.");
  2103     } else {
  2108     } else {
  2104         QString versionStr;
  2109         QString versionStr;
  2105         versionStr = QString::fromUtf16(reinterpret_cast<ushort *>(vertxt));
  2110         versionStr = QString(reinterpret_cast<const QChar *>(vertxt));
  2106         QRegExp vers(QLatin1String("([0-9]+)\\.[0-9\\.]+[0-9]"));
  2111         QRegExp vers(QLatin1String("([0-9]+)\\.[0-9\\.]+[0-9]"));
  2107         if (vers.indexIn(versionStr) >= 0)
  2112         if (vers.indexIn(versionStr) >= 0)
  2108             d->serverVersion = vers.cap(1).toInt();
  2113             d->serverVersion = vers.cap(1).toInt();
  2109         if (d->serverVersion == 0)
  2114         if (d->serverVersion == 0)
  2110             d->serverVersion = -1;
  2115             d->serverVersion = -1;