Changeset 561 for trunk/src/sql/drivers/sqlite2
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/sql/drivers/sqlite2/qsql_sqlite2.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtSql module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 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 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 111 111 sqlite_vm *currentMachine; 112 112 113 uint skippedStatus: 1; // the status of the fetchNext() that's skipped114 uint skipRow: 1; // skip the next fetchNext()?115 uint utf8: 1;113 bool skippedStatus; // the status of the fetchNext() that's skipped 114 bool skipRow; // skip the next fetchNext()? 115 bool utf8; 116 116 QSqlRecord rInf; 117 Q Sql::NumericalPrecisionPolicy precisionPolicy;117 QVector<QVariant> firstRow; 118 118 }; 119 119 … … 121 121 122 122 QSQLite2ResultPrivate::QSQLite2ResultPrivate(QSQLite2Result* res) : q(res), access(0), currentTail(0), 123 currentMachine(0), skippedStatus(false), skipRow(false), utf8(false) , precisionPolicy(QSql::HighPrecision)123 currentMachine(0), skippedStatus(false), skipRow(false), utf8(false) 124 124 { 125 125 } … … 168 168 const char* lastDot = strrchr(cnames[i], '.'); 169 169 const char* fieldName = lastDot ? lastDot + 1 : cnames[i]; 170 rInf.append(QSqlField(QString::fromAscii(fieldName), 170 171 //remove quotations around the field name if any 172 QString fieldStr = QString::fromAscii(fieldName); 173 QLatin1Char quote('\"'); 174 if ( fieldStr.length() > 2 && fieldStr.startsWith(quote) && fieldStr.endsWith(quote)) { 175 fieldStr = fieldStr.mid(1); 176 fieldStr.chop(1); 177 } 178 rInf.append(QSqlField(fieldStr, 171 179 nameToType(QString::fromAscii(cnames[i+numCols])))); 172 180 } … … 186 194 Q_ASSERT(!initialFetch); 187 195 skipRow = false; 196 for(int i=0;i<firstRow.count(); i++) 197 values[i] = firstRow[i]; 188 198 return skippedStatus; 189 199 } … … 203 213 } 204 214 215 if(initialFetch) { 216 firstRow.clear(); 217 firstRow.resize(colNum); 218 } 219 205 220 switch(res) { 206 221 case SQLITE_ROW: … … 253 268 d->finalize(); 254 269 break; 255 case QSqlResult::SetNumericalPrecision:256 Q_ASSERT(data);257 d->precisionPolicy = *reinterpret_cast<QSql::NumericalPrecisionPolicy *>(data);258 break;259 270 default: 260 QSql Result::virtual_hook(id, data);271 QSqlCachedResult::virtual_hook(id, data); 261 272 } 262 273 } … … 297 308 // we have to fetch one row to find out about 298 309 // the structure of the result set 299 d->skippedStatus = d->fetchNext( cache(), 0, true);310 d->skippedStatus = d->fetchNext(d->firstRow, 0, true); 300 311 if (lastError().isValid()) { 301 312 setSelect(false); … … 386 397 d->access = sqlite_open(QFile::encodeName(db), 0, &err); 387 398 if (err) { 388 setLastError(QSqlError(tr("Error to opendatabase"), QString::fromAscii(err),399 setLastError(QSqlError(tr("Error opening database"), QString::fromAscii(err), 389 400 QSqlError::ConnectionError)); 390 401 sqlite_freemem(err); … … 461 472 return true; 462 473 463 setLastError(QSqlError(tr("Unable to rollback Transaction"),474 setLastError(QSqlError(tr("Unable to rollback transaction"), 464 475 QString::fromAscii(err), QSqlError::TransactionError, res)); 465 476 sqlite_freemem(err); … … 504 515 QSqlQuery q(createResult()); 505 516 q.setForwardOnly(true); 517 QString table = tblname; 518 if (isIdentifierEscaped(table, QSqlDriver::TableName)) 519 table = stripDelimiters(table, QSqlDriver::TableName); 506 520 // finrst find a UNIQUE INDEX 507 q.exec(QLatin1String("PRAGMA index_list('") + t blname + QLatin1String("');"));521 q.exec(QLatin1String("PRAGMA index_list('") + table + QLatin1String("');")); 508 522 QString indexname; 509 523 while(q.next()) { … … 518 532 q.exec(QLatin1String("PRAGMA index_info('") + indexname + QLatin1String("');")); 519 533 520 QSqlIndex index(t blname, indexname);534 QSqlIndex index(table, indexname); 521 535 while(q.next()) { 522 536 QString name = q.value(2).toString(); … … 533 547 if (!isOpen()) 534 548 return QSqlRecord(); 549 QString table = tbl; 550 if (isIdentifierEscaped(tbl, QSqlDriver::TableName)) 551 table = stripDelimiters(table, QSqlDriver::TableName); 535 552 536 553 QSqlQuery q(createResult()); … … 548 565 { 549 566 QString res = identifier; 550 if(!identifier.isEmpty() && identifier.left(1) != QString(QLatin1Char('"')) && identifier.right(1) != QString(QLatin1Char('"')) ) {567 if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) { 551 568 res.replace(QLatin1Char('"'), QLatin1String("\"\"")); 552 569 res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); -
trunk/src/sql/drivers/sqlite2/qsql_sqlite2.h
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtSql module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 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 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 **
Note:
See TracChangeset
for help on using the changeset viewer.