Changeset 769 for trunk/src/sql/drivers
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/sql/drivers/drivers.pri
r2 r769 50 50 mac:!contains( LIBS, .*odbc.* ):LIBS *= -liodbc 51 51 unix:!contains( LIBS, .*odbc.* ):LIBS *= -lodbc 52 52 53 53 54 win32 { -
trunk/src/sql/drivers/mysql/qsql_mysql.cpp
r651 r769 321 321 } 322 322 323 324 325 326 327 328 329 330 331 332 323 333 void QMYSQLResultPrivate::bindBlobs() 324 334 { … … 369 379 hasBlobs = true; 370 380 } else { 381 382 383 384 385 386 387 371 388 fieldInfo->type = MYSQL_TYPE_STRING; 372 389 } -
trunk/src/sql/drivers/oci/qsql_oci.cpp
r651 r769 518 518 else if (ocitype == QLatin1String("LONG") || ocitype == QLatin1String("NCLOB") 519 519 || ocitype == QLatin1String("CLOB")) 520 type = QVariant:: String;520 type = QVariant::; 521 521 else if (ocitype == QLatin1String("RAW") || ocitype == QLatin1String("LONG RAW") 522 522 || ocitype == QLatin1String("ROWID") || ocitype == QLatin1String("BLOB") … … 544 544 case SQLT_RDD: 545 545 case SQLT_LNG: 546 case SQLT_CLOB:547 546 #ifdef SQLT_INTERVAL_YM 548 547 case SQLT_INTERVAL_YM: … … 582 581 case SQLT_LVB: 583 582 case SQLT_BLOB: 583 584 584 case SQLT_FILE: 585 585 case SQLT_NTY: -
trunk/src/sql/drivers/odbc/qsql_odbc.cpp
r651 r769 67 67 # undef UNICODE 68 68 # define SQLTCHAR SQLCHAR 69 # define SQL_C_ WCHAR SQL_C_CHAR69 # define SQL_C_CHAR SQL_C_CHAR 70 70 #endif 71 71 … … 79 79 #endif 80 80 81 82 81 static const int COLNAMESIZE = 256; 83 82 //Map Qt parameter types to ODBC types 84 83 static const SQLSMALLINT qParamType[4] = { SQL_PARAM_INPUT, SQL_PARAM_INPUT, SQL_PARAM_OUTPUT, SQL_PARAM_INPUT_OUTPUT }; 85 84 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 86 129 class QODBCDriverPrivate 87 130 { … … 89 132 enum DefaultCase{Lower, Mixed, Upper, Sensitive}; 90 133 QODBCDriverPrivate() 91 : hEnv(0), hDbc(0), u seSchema(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('"')) 94 137 { 95 unicode = false;96 138 } 97 139 … … 99 141 SQLHANDLE hDbc; 100 142 101 uint unicode :1;102 uint useSchema :1;143 ; 144 ; 103 145 int disconnectCount; 104 146 bool isMySqlServer; 105 147 bool isMSSqlServer; 148 106 149 bool hasSQLFetchScroll; 107 150 bool hasMultiResultSets; … … 130 173 : hStmt(0), useSchema(false), hasSQLFetchScroll(true), driverPrivate(dpp), userForwardOnly(false) 131 174 { 132 unicode = false; 175 unicode = dpp->unicode; 176 useSchema = dpp->useSchema; 177 disconnectCount = dpp->disconnectCount; 178 hasSQLFetchScroll = dpp->hasSQLFetchScroll; 133 179 } 134 180 … … 140 186 SQLHANDLE hStmt; 141 187 142 uint unicode :1;143 uint useSchema :1;188 ; 189 ; 144 190 145 191 QSqlRecord rInf; … … 178 224 179 225 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);191 226 do { 227 228 229 230 231 232 233 234 235 236 192 237 r = SQLGetDiagRec(handleType, 193 238 handle, … … 203 248 QString tmpstore; 204 249 #ifdef UNICODE 205 tmpstore = QString((const QChar*)description_.data(), msgLen);250 tmpstore = , msgLen); 206 251 #else 207 tmpstore = QString::from Local8Bit((const char*)description_.data(), msgLen);252 tmpstore = QString::fromata(), msgLen); 208 253 #endif 209 254 if(result != tmpstore) { … … 224 269 return (qWarnODBCHandle(SQL_HANDLE_ENV, odbc->dpEnv()) + QLatin1Char(' ') 225 270 + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->dpDbc()) + QLatin1Char(' ') 226 + qWarnODBCHandle(SQL_HANDLE_STMT, odbc->hStmt, nativeCode)) ;271 + qWarnODBCHandle(SQL_HANDLE_STMT, odbc->hStmt, nativeCode)); 227 272 } 228 273 … … 230 275 { 231 276 return (qWarnODBCHandle(SQL_HANDLE_ENV, odbc->hEnv) + QLatin1Char(' ') 232 + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->hDbc, nativeCode)) ;277 + qWarnODBCHandle(SQL_HANDLE_DBC, odbc->hDbc, nativeCode)); 233 278 } 234 279 … … 308 353 case SQL_CHAR: 309 354 case SQL_VARCHAR: 355 310 356 case SQL_GUID: 357 311 358 case SQL_LONGVARCHAR: 312 359 type = QVariant::String; … … 332 379 } else { 333 380 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) { 340 383 r = SQLGetData(hStmt, 341 384 column+1, 342 unicode ? SQL_C_WCHAR : SQL_C_CHAR,343 (SQLPOINTER)buf.data(),344 colSize,385 CHAR, 386 , 387 , 345 388 &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) << ')'; 348 420 fieldVal.clear(); 349 421 break; 350 422 } 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; 359 459 } 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(); 365 462 break; 366 463 } 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;373 464 } 374 465 } … … 387 478 SQLRETURN r = SQL_ERROR; 388 479 389 SQLTCHAR colName[COLNAMESIZE]; 480 QVarLengthArray<SQLTCHAR> colName(COLNAMESIZE); 481 390 482 r = SQLDescribeCol(hStmt, 391 483 column + 1, 392 colName ,484 colName, 393 485 COLNAMESIZE, 394 486 &colNameLen, … … 523 615 SQLSMALLINT nullable; 524 616 SQLRETURN r = SQL_ERROR; 525 SQLTCHAR colName[COLNAMESIZE];617 ; 526 618 r = SQLDescribeCol(p->hStmt, 527 619 i+1, 528 colName ,620 colName, 529 621 (SQLSMALLINT)COLNAMESIZE, 530 622 &colNameLen, … … 552 644 553 645 #ifdef UNICODE 554 QString qColName( (const QChar*)colName, colNameLen);646 QString qColName(); 555 647 #else 556 QString qColName = QString::from Local8Bit((const char*)colName);648 QString qColName = QString::from); 557 649 #endif 558 650 // nullable can be SQL_NO_NULLS, SQL_NULLABLE or SQL_NULLABLE_UNKNOWN … … 582 674 return SQL_OV_ODBC3; 583 675 #endif 676 677 678 679 680 584 681 return SQL_OV_ODBC2; 682 585 683 } 586 684 … … 588 686 { 589 687 if (!isQuoteInitialized) { 590 chardriverResponse[4];688 driverResponse[4]; 591 689 SQLSMALLINT length; 592 690 int r = SQLGetInfo(hDbc, … … 595 693 sizeof(driverResponse), 596 694 &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 598 699 quote = QLatin1Char(driverResponse[0]); 599 } else { 700 #endif 701 else 600 702 quote = QLatin1Char('"'); 601 }602 703 isQuoteInitialized = true; 603 704 } … … 643 744 r = SQLSetConnectAttr(hDbc, SQL_ATTR_CURRENT_CATALOG, 644 745 #ifdef UNICODE 645 (SQLWCHAR*) val.unicode(),746 (), 646 747 #else 647 (SQLCHAR*) val.to Latin1().constData(),648 #endif 649 SQL_NTS);748 (SQLCHAR*) val.toata(), 749 #endif 750 ); 650 751 } else if (opt.toUpper() == QLatin1String("SQL_ATTR_METADATA_ID")) { 651 752 if (val.toUpper() == QLatin1String("SQL_TRUE")) { … … 665 766 r = SQLSetConnectAttr(hDbc, SQL_ATTR_TRACEFILE, 666 767 #ifdef UNICODE 667 (SQLWCHAR*) val.unicode(),768 (), 668 769 #else 669 (SQLCHAR*) val.to Latin1().constData(),670 #endif 671 SQL_NTS);770 (SQLCHAR*) val.toata(), 771 #endif 772 ); 672 773 } else if (opt.toUpper() == QLatin1String("SQL_ATTR_TRACE")) { 673 774 if (val.toUpper() == QLatin1String("SQL_OPT_TRACE_OFF")) { … … 815 916 { 816 917 d = new QODBCPrivate(p); 817 d->unicode = p->unicode;818 d->useSchema = p->useSchema;819 d->disconnectCount = p->disconnectCount;820 d->hasSQLFetchScroll = p->hasSQLFetchScroll;821 918 } 822 919 … … 881 978 #ifdef UNICODE 882 979 r = SQLExecDirect(d->hStmt, 883 (SQLWCHAR*) query.unicode(),980 (), 884 981 (SQLINTEGER) query.length()); 885 982 #else 886 QByteArray query8 = query.to Local8Bit();983 QByteArray query8 = query.to(); 887 984 r = SQLExecDirect(d->hStmt, 888 (SQLCHAR*) query8. constData(),985 (SQLCHAR*) query8.ata(), 889 986 (SQLINTEGER) query8.length()); 890 987 #endif … … 1232 1329 #ifdef UNICODE 1233 1330 r = SQLPrepare(d->hStmt, 1234 (SQLWCHAR*) query.unicode(),1331 (), 1235 1332 (SQLINTEGER) query.length()); 1236 1333 #else 1237 QByteArray query8 = query.to Local8Bit();1334 QByteArray query8 = query.to(); 1238 1335 r = SQLPrepare(d->hStmt, 1239 (SQLCHAR*) query8. constData(),1336 (SQLCHAR*) query8.ata(), 1240 1337 (SQLINTEGER) query8.length()); 1241 1338 #endif … … 1436 1533 if (d->unicode) { 1437 1534 QString str = val.toString(); 1438 str.utf16();1439 1535 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(); 1442 1538 1443 1539 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()); 1445 1542 r = SQLBindParameter(d->hStmt, 1446 1543 i + 1, 1447 1544 qParamType[(QFlag)(bindValueType(i)) & QSql::InOut], 1448 SQL_C_ WCHAR,1545 SQL_C_CHAR, 1449 1546 strSize > 254 ? SQL_WLONGVARCHAR : SQL_WVARCHAR, 1450 1547 0, // god knows... don't change this! … … 1453 1550 ba.size(), 1454 1551 ind); 1455 tmpStorage.append( ba);1552 tmpStorage.append(); 1456 1553 break; 1457 1554 } 1458 1555 QByteArray strba((const char *)toSQLTCHAR(str).constData(), str.size()*sizeof(SQLTCHAR)); 1459 1556 r = SQLBindParameter(d->hStmt, 1460 1557 i + 1, 1461 1558 qParamType[(QFlag)(bindValueType(i)) & QSql::InOut], 1462 SQL_C_ WCHAR,1559 SQL_C_CHAR, 1463 1560 strSize > 254 ? SQL_WLONGVARCHAR : SQL_WVARCHAR, 1464 1561 strSize, 1465 1562 0, 1466 ( void *)str.constData(),1467 str Size,1563 (.constData(), 1564 str, 1468 1565 ind); 1566 1469 1567 break; 1470 1568 } … … 1472 1570 #endif 1473 1571 { 1474 QByteArray str = val.toString().to Ascii();1572 QByteArray str = val.toString().to(); 1475 1573 if (*ind != SQL_NULL_DATA) 1476 1574 *ind = str.length(); … … 1573 1671 case QVariant::String: 1574 1672 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 } 1577 1679 break; 1578 1680 } 1579 1681 // fall through 1580 1682 default: { 1581 QByteArray ba = tmpStorage.takeFirst();1582 1683 if (bindValueType(i) & QSql::Out) 1583 values[i] = QString::fromAscii(ba.constData());1684 values[i] = ); 1584 1685 break; } 1585 1686 } … … 1790 1891 1791 1892 SQLSMALLINT cb; 1792 SQLTCHAR connOut[1024]; 1893 QVarLengthArray<SQLTCHAR> connOut(1024); 1894 memset(connOut.data(), 0, connOut.size() * sizeof(SQLTCHAR)); 1793 1895 r = SQLDriverConnect(d->hDbc, 1794 1896 NULL, 1795 1897 #ifdef UNICODE 1796 (SQLWCHAR*)connQStr.unicode(),1898 (), 1797 1899 #else 1798 (SQLCHAR*)connQStr.to Latin1().constData(),1900 (SQLCHAR*)connQStr.toata(), 1799 1901 #endif 1800 1902 (SQLSMALLINT)connQStr.length(), 1801 connOut ,1903 connOut, 1802 1904 1024, 1803 1905 &cb, 1804 SQL_DRIVER_NOPROMPT); 1906 /*SQL_DRIVER_NOPROMPT*/0); 1907 1805 1908 if (r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO) { 1806 1909 setLastError(qMakeError(tr("Unable to connect"), QSqlError::ConnectionError, d)); … … 1887 1990 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WCHAR)) { 1888 1991 unicode = true; 1992 1889 1993 } 1890 1994 … … 1896 2000 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WVARCHAR)) { 1897 2001 unicode = true; 2002 1898 2003 } 1899 2004 … … 1905 2010 if ((r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) && (fFunc & SQL_CVT_WLONGVARCHAR)) { 1906 2011 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); 1908 2031 } 1909 2032 … … 1978 2101 { 1979 2102 SQLRETURN r; 1980 char serverString[200];2103 ; 1981 2104 SQLSMALLINT t; 2105 1982 2106 1983 2107 r = SQLGetInfo(hDbc, 1984 2108 SQL_DBMS_NAME, 1985 serverString ,1986 s izeof(serverString),2109 serverString, 2110 s), 1987 2111 &t); 1988 2112 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) { 1989 2113 QString serverType; 1990 2114 #ifdef UNICODE 1991 serverType = QString(reinterpret_cast<const QChar*>(serverString), t/sizeof(QChar));2115 serverType = )); 1992 2116 #else 1993 serverType = QString::from Local8Bit(serverString, t);2117 serverType = QString::from, t); 1994 2118 #endif 1995 2119 isMySqlServer = serverType.contains(QLatin1String("mysql"), Qt::CaseInsensitive); 1996 2120 isMSSqlServer = serverType.contains(QLatin1String("Microsoft SQL Server"), Qt::CaseInsensitive); 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 1997 2136 } 1998 2137 } … … 2010 2149 void QODBCDriverPrivate::checkHasMultiResults() 2011 2150 { 2012 char driverResponse[4];2151 ; 2013 2152 SQLSMALLINT length; 2014 2153 SQLRETURN r = SQLGetInfo(hDbc, 2015 2154 SQL_MULT_RESULT_SETS, 2016 driverResponse ,2017 sizeof(driverResponse),2155 driverResponse, 2156 ), 2018 2157 &length); 2019 2158 if (r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO) 2020 2159 #ifdef UNICODE 2021 hasMultiResultSets = QString(reinterpret_cast<const QChar*>(driverResponse), length/sizeof(QChar)).startsWith(QLatin1Char('Y'));2160 hasMultiResultSets = )).startsWith(QLatin1Char('Y')); 2022 2161 #else 2023 hasMultiResultSets = QString::from Local8Bit(driverResponse, length).startsWith(QLatin1Char('Y'));2162 hasMultiResultSets = QString::from, length).startsWith(QLatin1Char('Y')); 2024 2163 #endif 2025 2164 } … … 2135 2274 0, 2136 2275 #ifdef UNICODE 2137 (SQLWCHAR*)joinedTableTypeString.unicode(),2276 (), 2138 2277 #else 2139 (SQLCHAR*)joinedTableTypeString.to Latin1().constData(),2278 (SQLCHAR*)joinedTableTypeString.toata(), 2140 2279 #endif 2141 2280 joinedTableTypeString.length() /* characters, not bytes */); … … 2150 2289 else 2151 2290 r = SQLFetch(hStmt); 2291 2292 2293 2294 2295 2152 2296 2153 2297 while (r == SQL_SUCCESS) { … … 2209 2353 r = SQLPrimaryKeys(hStmt, 2210 2354 #ifdef UNICODE 2211 catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(),2355 catalog.length() == 0 ? NULL : (), 2212 2356 #else 2213 catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.to Latin1().constData(),2357 catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toata(), 2214 2358 #endif 2215 2359 catalog.length(), 2216 2360 #ifdef UNICODE 2217 schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(),2361 schema.length() == 0 ? NULL : (), 2218 2362 #else 2219 schema.length() == 0 ? NULL : (SQLCHAR*)schema.to Latin1().constData(),2363 schema.length() == 0 ? NULL : (SQLCHAR*)schema.toata(), 2220 2364 #endif 2221 2365 schema.length(), 2222 2366 #ifdef UNICODE 2223 (SQLWCHAR*)table.unicode(),2367 (), 2224 2368 #else 2225 (SQLCHAR*)table.to Latin1().constData(),2369 (SQLCHAR*)table.toata(), 2226 2370 #endif 2227 2371 table.length() /* in characters, not in bytes */); … … 2234 2378 SQL_BEST_ROWID, 2235 2379 #ifdef UNICODE 2236 catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(),2380 catalog.length() == 0 ? NULL : (), 2237 2381 #else 2238 catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.to Latin1().constData(),2382 catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toata(), 2239 2383 #endif 2240 2384 catalog.length(), 2241 2385 #ifdef UNICODE 2242 schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(),2386 schema.length() == 0 ? NULL : (), 2243 2387 #else 2244 schema.length() == 0 ? NULL : (SQLCHAR*)schema.to Latin1().constData(),2388 schema.length() == 0 ? NULL : (SQLCHAR*)schema.toata(), 2245 2389 #endif 2246 2390 schema.length(), 2247 2391 #ifdef UNICODE 2248 (SQLWCHAR*)table.unicode(),2392 (), 2249 2393 #else 2250 (SQLCHAR*)table.to Latin1().constData(),2394 (SQLCHAR*)table.toata(), 2251 2395 #endif 2252 2396 table.length(), … … 2334 2478 r = SQLColumns(hStmt, 2335 2479 #ifdef UNICODE 2336 catalog.length() == 0 ? NULL : (SQLWCHAR*)catalog.unicode(),2480 catalog.length() == 0 ? NULL : (), 2337 2481 #else 2338 catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.to Latin1().constData(),2482 catalog.length() == 0 ? NULL : (SQLCHAR*)catalog.toata(), 2339 2483 #endif 2340 2484 catalog.length(), 2341 2485 #ifdef UNICODE 2342 schema.length() == 0 ? NULL : (SQLWCHAR*)schema.unicode(),2486 schema.length() == 0 ? NULL : (), 2343 2487 #else 2344 schema.length() == 0 ? NULL : (SQLCHAR*)schema.to Latin1().constData(),2488 schema.length() == 0 ? NULL : (SQLCHAR*)schema.toata(), 2345 2489 #endif 2346 2490 schema.length(), 2347 2491 #ifdef UNICODE 2348 (SQLWCHAR*)table.unicode(),2492 (), 2349 2493 #else 2350 (SQLCHAR*)table.to Latin1().constData(),2494 (SQLCHAR*)table.toata(), 2351 2495 #endif 2352 2496 table.length(), -
trunk/src/sql/drivers/odbc/qsql_odbc.h
r651 r769 74 74 #if defined(Q_CC_BOR) 75 75 # undef _MSC_VER 76 #endif77 78 #ifndef Q_ODBC_VERSION_279 #include <sqlucode.h>80 76 #endif 81 77 -
trunk/src/sql/drivers/sqlite/qsql_sqlite.cpp
r651 r769 246 246 break; 247 247 default: 248 values[i + idx] = QString ::fromUtf16(static_cast<const ushort*>(248 values[i + idx] = QString *>( 249 249 sqlite3_column_text16(stmt, i)), 250 sqlite3_column_bytes16(stmt, i) / sizeof( ushort));250 sqlite3_column_bytes16(stmt, i) / sizeof()); 251 251 break; 252 252 } … … 260 260 sqlite3_reset(stmt); 261 261 return false; 262 262 263 case SQLITE_ERROR: 263 264 // SQLITE_ERROR is a generic error code and we must call sqlite3_reset() … … 501 502 } 502 503 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 529 504 /* 530 505 SQLite dbs have no user name, passwords, hosts or ports. … … 538 513 if (db.isEmpty()) 539 514 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); 543 535 setOpen(true); 544 536 setOpenError(false);
Note:
See TracChangeset
for help on using the changeset viewer.