Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | static QFactoryLoader *loader() { static QGlobalStatic<QFactoryLoader > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QFactoryLoader *x = new QFactoryLoader ("org.qt-project.Qt.QSqlDriverFactoryInterface", QLatin1String("/sqldrivers")); if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QFactoryLoader > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:97 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:9 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:9 | yes Evaluation Count:88 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-97 |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | const char *QSqlDatabase::defaultConnection = "qt_sql_default_connection"; | - |
12 | | - |
13 | typedef QHash<QString, QSqlDriverCreatorBase*> DriverDict; | - |
14 | | - |
15 | class QConnectionDict: public QHash<QString, QSqlDatabase> | - |
16 | { | - |
17 | public: | - |
18 | inline bool contains_ts(const QString &key) | - |
19 | { | - |
20 | QReadLocker locker(&lock); | - |
21 | return contains(key); executed: return contains(key); Execution Count:2 | 2 |
22 | } | - |
23 | inline QStringList keys_ts() const | - |
24 | { | - |
25 | QReadLocker locker(&lock); | - |
26 | return keys(); never executed: return keys(); | 0 |
27 | } | - |
28 | | - |
29 | mutable QReadWriteLock lock; | - |
30 | }; | - |
31 | static QConnectionDict *dbDict() { static QGlobalStatic<QConnectionDict > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QConnectionDict *x = new QConnectionDict; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QConnectionDict > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); } partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:9 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:9 | yes Evaluation Count:2300 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:9 | no Evaluation Count:0 |
never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:2309 | 0-2309 |
32 | | - |
33 | class QSqlDatabasePrivate | - |
34 | { | - |
35 | public: | - |
36 | QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0): | - |
37 | ref(1), | - |
38 | q(d), | - |
39 | driver(dr), | - |
40 | port(-1) | - |
41 | { | - |
42 | precisionPolicy = QSql::LowPrecisionDouble; | - |
43 | } executed: } Execution Count:45 | 45 |
44 | QSqlDatabasePrivate(const QSqlDatabasePrivate &other); | - |
45 | ~QSqlDatabasePrivate(); | - |
46 | void init(const QString& type); | - |
47 | void copy(const QSqlDatabasePrivate *other); | - |
48 | void disable(); | - |
49 | | - |
50 | QAtomicInt ref; | - |
51 | QSqlDatabase *q; | - |
52 | QSqlDriver* driver; | - |
53 | QString dbname; | - |
54 | QString uname; | - |
55 | QString pword; | - |
56 | QString hname; | - |
57 | QString drvName; | - |
58 | int port; | - |
59 | QString connOptions; | - |
60 | QString connName; | - |
61 | QSql::NumericalPrecisionPolicy precisionPolicy; | - |
62 | | - |
63 | static QSqlDatabasePrivate *shared_null(); | - |
64 | static QSqlDatabase database(const QString& name, bool open); | - |
65 | static void addDatabase(const QSqlDatabase &db, const QString & name); | - |
66 | static void removeDatabase(const QString& name); | - |
67 | static void invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn = true); | - |
68 | static DriverDict &driverDict(); | - |
69 | static void cleanConnections(); | - |
70 | }; | - |
71 | | - |
72 | QSqlDatabasePrivate::QSqlDatabasePrivate(const QSqlDatabasePrivate &other) : ref(1) | - |
73 | { | - |
74 | q = other.q; | - |
75 | dbname = other.dbname; | - |
76 | uname = other.uname; | - |
77 | pword = other.pword; | - |
78 | hname = other.hname; | - |
79 | drvName = other.drvName; | - |
80 | port = other.port; | - |
81 | connOptions = other.connOptions; | - |
82 | driver = other.driver; | - |
83 | precisionPolicy = other.precisionPolicy; | - |
84 | } | 0 |
85 | | - |
86 | QSqlDatabasePrivate::~QSqlDatabasePrivate() | - |
87 | { | - |
88 | if (driver != shared_null()->driver) evaluated: driver != shared_null()->driver yes Evaluation Count:32 | yes Evaluation Count:13 |
| 13-32 |
89 | delete driver; executed: delete driver; Execution Count:32 | 32 |
90 | } executed: } Execution Count:45 | 45 |
91 | | - |
92 | void QSqlDatabasePrivate::cleanConnections() | - |
93 | { | - |
94 | QConnectionDict *dict = dbDict(); | - |
95 | qt_noop(); | - |
96 | QWriteLocker locker(&dict->lock); | - |
97 | | - |
98 | QConnectionDict::iterator it = dict->begin(); | - |
99 | while (it != dict->end()) { evaluated: it != dict->end() yes Evaluation Count:6 | yes Evaluation Count:22 |
| 6-22 |
100 | invalidateDb(it.value(), it.key(), false); | - |
101 | ++it; | - |
102 | } executed: } Execution Count:6 | 6 |
103 | dict->clear(); | - |
104 | } executed: } Execution Count:22 | 22 |
105 | | - |
106 | static bool qDriverDictInit = false; | - |
107 | static void cleanDriverDict() | - |
108 | { | - |
109 | qDeleteAll(QSqlDatabasePrivate::driverDict()); | - |
110 | QSqlDatabasePrivate::driverDict().clear(); | - |
111 | QSqlDatabasePrivate::cleanConnections(); | - |
112 | qDriverDictInit = false; | - |
113 | } executed: } Execution Count:22 | 22 |
114 | | - |
115 | DriverDict &QSqlDatabasePrivate::driverDict() | - |
116 | { | - |
117 | static DriverDict dict; | - |
118 | if (!qDriverDictInit) { evaluated: !qDriverDictInit yes Evaluation Count:22 | yes Evaluation Count:87 |
| 22-87 |
119 | qDriverDictInit = true; | - |
120 | qAddPostRoutine(cleanDriverDict); | - |
121 | } executed: } Execution Count:22 | 22 |
122 | return dict; executed: return dict; Execution Count:109 | 109 |
123 | } | - |
124 | | - |
125 | QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null() | - |
126 | { | - |
127 | static QSqlNullDriver dr; | - |
128 | static QSqlDatabasePrivate n(__null, &dr); | - |
129 | return &n; executed: return &n; Execution Count:8087 | 8087 |
130 | } | - |
131 | | - |
132 | void QSqlDatabasePrivate::invalidateDb(const QSqlDatabase &db, const QString &name, bool doWarn) | - |
133 | { | - |
134 | if (db.d->ref.load() != 1 && doWarn) { evaluated: db.d->ref.load() != 1 yes Evaluation Count:1 | yes Evaluation Count:35 |
partially evaluated: doWarn yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-35 |
135 | QMessageLogger("kernel/qsqldatabase.cpp", 234, __PRETTY_FUNCTION__).warning("QSqlDatabasePrivate::removeDatabase: connection '%s' is still in use, " | - |
136 | "all queries will cease to work.", name.toLocal8Bit().constData()); | - |
137 | db.d->disable(); | - |
138 | db.d->connName.clear(); | - |
139 | } executed: } Execution Count:1 | 1 |
140 | } executed: } Execution Count:36 | 36 |
141 | | - |
142 | void QSqlDatabasePrivate::removeDatabase(const QString &name) | - |
143 | { | - |
144 | QConnectionDict *dict = dbDict(); | - |
145 | qt_noop(); | - |
146 | QWriteLocker locker(&dict->lock); | - |
147 | | - |
148 | if (!dict->contains(name)) partially evaluated: !dict->contains(name) no Evaluation Count:0 | yes Evaluation Count:30 |
| 0-30 |
149 | return; | 0 |
150 | | - |
151 | invalidateDb(dict->take(name), name); | - |
152 | } executed: } Execution Count:30 | 30 |
153 | | - |
154 | void QSqlDatabasePrivate::addDatabase(const QSqlDatabase &db, const QString &name) | - |
155 | { | - |
156 | QConnectionDict *dict = dbDict(); | - |
157 | qt_noop(); | - |
158 | QWriteLocker locker(&dict->lock); | - |
159 | | - |
160 | if (dict->contains(name)) { partially evaluated: dict->contains(name) no Evaluation Count:0 | yes Evaluation Count:36 |
| 0-36 |
161 | invalidateDb(dict->take(name), name); | - |
162 | QMessageLogger("kernel/qsqldatabase.cpp", 261, __PRETTY_FUNCTION__).warning("QSqlDatabasePrivate::addDatabase: duplicate connection name '%s', old " | - |
163 | "connection removed.", name.toLocal8Bit().data()); | - |
164 | } | 0 |
165 | dict->insert(name, db); | - |
166 | db.d->connName = name; | - |
167 | } executed: } Execution Count:36 | 36 |
168 | | - |
169 | | - |
170 | | - |
171 | QSqlDatabase QSqlDatabasePrivate::database(const QString& name, bool open) | - |
172 | { | - |
173 | const QConnectionDict *dict = dbDict(); | - |
174 | qt_noop(); | - |
175 | | - |
176 | dict->lock.lockForRead(); | - |
177 | QSqlDatabase db = dict->value(name); | - |
178 | dict->lock.unlock(); | - |
179 | if (db.isValid() && !db.isOpen() && open) { evaluated: db.isValid() yes Evaluation Count:1957 | yes Evaluation Count:262 |
evaluated: !db.isOpen() yes Evaluation Count:25 | yes Evaluation Count:1932 |
evaluated: open yes Evaluation Count:5 | yes Evaluation Count:20 |
| 5-1957 |
180 | if (!db.open()) partially evaluated: !db.open() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
181 | QMessageLogger("kernel/qsqldatabase.cpp", 280, __PRETTY_FUNCTION__).warning() << "QSqlDatabasePrivate::database: unable to open database:" << db.lastError().text(); never executed: QMessageLogger("kernel/qsqldatabase.cpp", 280, __PRETTY_FUNCTION__).warning() << "QSqlDatabasePrivate::database: unable to open database:" << db.lastError().text(); | 0 |
182 | | - |
183 | } executed: } Execution Count:5 | 5 |
184 | return db; executed: return db; Execution Count:2219 | 2219 |
185 | } | - |
186 | | - |
187 | | - |
188 | | - |
189 | | - |
190 | | - |
191 | void QSqlDatabasePrivate::copy(const QSqlDatabasePrivate *other) | - |
192 | { | - |
193 | q = other->q; | - |
194 | dbname = other->dbname; | - |
195 | uname = other->uname; | - |
196 | pword = other->pword; | - |
197 | hname = other->hname; | - |
198 | drvName = other->drvName; | - |
199 | port = other->port; | - |
200 | connOptions = other->connOptions; | - |
201 | precisionPolicy = other->precisionPolicy; | - |
202 | } executed: } Execution Count:7 | 7 |
203 | | - |
204 | void QSqlDatabasePrivate::disable() | - |
205 | { | - |
206 | if (driver != shared_null()->driver) { partially evaluated: driver != shared_null()->driver yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
207 | delete driver; | - |
208 | driver = shared_null()->driver; | - |
209 | } executed: } Execution Count:1 | 1 |
210 | } executed: } Execution Count:1 | 1 |
211 | QSqlDatabase QSqlDatabase::addDatabase(const QString &type, const QString &connectionName) | - |
212 | { | - |
213 | QSqlDatabase db(type); | - |
214 | QSqlDatabasePrivate::addDatabase(db, connectionName); | - |
215 | return db; executed: return db; Execution Count:29 | 29 |
216 | } | - |
217 | QSqlDatabase QSqlDatabase::database(const QString& connectionName, bool open) | - |
218 | { | - |
219 | return QSqlDatabasePrivate::database(connectionName, open); executed: return QSqlDatabasePrivate::database(connectionName, open); Execution Count:2219 | 2219 |
220 | } | - |
221 | void QSqlDatabase::removeDatabase(const QString& connectionName) | - |
222 | { | - |
223 | QSqlDatabasePrivate::removeDatabase(connectionName); | - |
224 | } executed: } Execution Count:30 | 30 |
225 | | - |
226 | | - |
227 | | - |
228 | | - |
229 | | - |
230 | | - |
231 | | - |
232 | QStringList QSqlDatabase::drivers() | - |
233 | { | - |
234 | QStringList list; | - |
235 | if (QFactoryLoader *fl = loader()) { partially evaluated: QFactoryLoader *fl = loader() yes Evaluation Count:27 | no Evaluation Count:0 |
| 0-27 |
236 | typedef QMultiMap<int, QString> PluginKeyMap; | - |
237 | typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; | - |
238 | | - |
239 | const PluginKeyMap keyMap = fl->keyMap(); | - |
240 | const PluginKeyMapConstIterator cend = keyMap.constEnd(); | - |
241 | for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) evaluated: it != cend yes Evaluation Count:270 | yes Evaluation Count:27 |
| 27-270 |
242 | if (!list.contains(it.value())) partially evaluated: !list.contains(it.value()) yes Evaluation Count:270 | no Evaluation Count:0 |
| 0-270 |
243 | list << it.value(); executed: list << it.value(); Execution Count:270 | 270 |
244 | } executed: } Execution Count:27 | 27 |
245 | | - |
246 | | - |
247 | DriverDict dict = QSqlDatabasePrivate::driverDict(); | - |
248 | for (DriverDict::const_iterator i = dict.constBegin(); i != dict.constEnd(); ++i) { evaluated: i != dict.constEnd() yes Evaluation Count:1 | yes Evaluation Count:27 |
| 1-27 |
249 | if (!list.contains(i.key())) partially evaluated: !list.contains(i.key()) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
250 | list << i.key(); executed: list << i.key(); Execution Count:1 | 1 |
251 | } executed: } Execution Count:1 | 1 |
252 | | - |
253 | return list; executed: return list; Execution Count:27 | 27 |
254 | } | - |
255 | void QSqlDatabase::registerSqlDriver(const QString& name, QSqlDriverCreatorBase *creator) | - |
256 | { | - |
257 | delete QSqlDatabasePrivate::driverDict().take(name); | - |
258 | if (creator) partially evaluated: creator yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
259 | QSqlDatabasePrivate::driverDict().insert(name, creator); executed: QSqlDatabasePrivate::driverDict().insert(name, creator); Execution Count:1 | 1 |
260 | } executed: } Execution Count:1 | 1 |
261 | bool QSqlDatabase::contains(const QString& connectionName) | - |
262 | { | - |
263 | return dbDict()->contains_ts(connectionName); executed: return dbDict()->contains_ts(connectionName); Execution Count:2 | 2 |
264 | } | - |
265 | QStringList QSqlDatabase::connectionNames() | - |
266 | { | - |
267 | return dbDict()->keys_ts(); never executed: return dbDict()->keys_ts(); | 0 |
268 | } | - |
269 | QSqlDatabase::QSqlDatabase(const QString &type) | - |
270 | { | - |
271 | d = new QSqlDatabasePrivate(this); | - |
272 | d->init(type); | - |
273 | } executed: } Execution Count:36 | 36 |
274 | | - |
275 | | - |
276 | | - |
277 | | - |
278 | | - |
279 | | - |
280 | | - |
281 | QSqlDatabase::QSqlDatabase(QSqlDriver *driver) | - |
282 | { | - |
283 | d = new QSqlDatabasePrivate(this, driver); | - |
284 | } | 0 |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | | - |
290 | | - |
291 | QSqlDatabase::QSqlDatabase() | - |
292 | { | - |
293 | d = QSqlDatabasePrivate::shared_null(); | - |
294 | d->ref.ref(); | - |
295 | } executed: } Execution Count:1281 | 1281 |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | QSqlDatabase::QSqlDatabase(const QSqlDatabase &other) | - |
301 | { | - |
302 | d = other.d; | - |
303 | d->ref.ref(); | - |
304 | } executed: } Execution Count:18205 | 18205 |
305 | | - |
306 | | - |
307 | | - |
308 | | - |
309 | QSqlDatabase &QSqlDatabase::operator=(const QSqlDatabase &other) | - |
310 | { | - |
311 | qAtomicAssign(d, other.d); | - |
312 | return *this; executed: return *this; Execution Count:969 | 969 |
313 | } | - |
314 | | - |
315 | | - |
316 | | - |
317 | | - |
318 | | - |
319 | | - |
320 | | - |
321 | void QSqlDatabasePrivate::init(const QString &type) | - |
322 | { | - |
323 | drvName = type; | - |
324 | | - |
325 | if (!driver) { partially evaluated: !driver yes Evaluation Count:36 | no Evaluation Count:0 |
| 0-36 |
326 | } executed: } Execution Count:36 | 36 |
327 | | - |
328 | if (!driver) { partially evaluated: !driver yes Evaluation Count:36 | no Evaluation Count:0 |
| 0-36 |
329 | DriverDict dict = QSqlDatabasePrivate::driverDict(); | - |
330 | for (DriverDict::const_iterator it = dict.constBegin(); | - |
331 | it != dict.constEnd() && !driver; ++it) { evaluated: it != dict.constEnd() yes Evaluation Count:1 | yes Evaluation Count:36 |
partially evaluated: !driver yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-36 |
332 | if (type == it.key()) { partially evaluated: type == it.key() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
333 | driver = ((QSqlDriverCreatorBase*)(*it))->createObject(); | - |
334 | } executed: } Execution Count:1 | 1 |
335 | } executed: } Execution Count:1 | 1 |
336 | } executed: } Execution Count:36 | 36 |
337 | | - |
338 | | - |
339 | if (!driver && loader()) evaluated: !driver yes Evaluation Count:35 | yes Evaluation Count:1 |
partially evaluated: loader() yes Evaluation Count:35 | no Evaluation Count:0 |
| 0-35 |
340 | driver = qLoadPlugin<QSqlDriver, QSqlDriverPlugin>(loader(), type); executed: driver = qLoadPlugin<QSqlDriver, QSqlDriverPlugin>(loader(), type); Execution Count:35 | 35 |
341 | | - |
342 | | - |
343 | if (!driver) { evaluated: !driver yes Evaluation Count:3 | yes Evaluation Count:33 |
| 3-33 |
344 | QMessageLogger("kernel/qsqldatabase.cpp", 785, __PRETTY_FUNCTION__).warning("QSqlDatabase: %s driver not loaded", type.toLatin1().data()); | - |
345 | QMessageLogger("kernel/qsqldatabase.cpp", 786, __PRETTY_FUNCTION__).warning("QSqlDatabase: available drivers: %s", | - |
346 | QSqlDatabase::drivers().join(QLatin1Char(' ')).toLatin1().data()); | - |
347 | if (QCoreApplication::instance() == 0) evaluated: QCoreApplication::instance() == 0 yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
348 | QMessageLogger("kernel/qsqldatabase.cpp", 789, __PRETTY_FUNCTION__).warning("QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins"); executed: QMessageLogger("kernel/qsqldatabase.cpp", 789, __PRETTY_FUNCTION__).warning("QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins"); Execution Count:1 | 1 |
349 | driver = shared_null()->driver; | - |
350 | } executed: } Execution Count:3 | 3 |
351 | } executed: } Execution Count:36 | 36 |
352 | | - |
353 | | - |
354 | | - |
355 | | - |
356 | | - |
357 | | - |
358 | | - |
359 | QSqlDatabase::~QSqlDatabase() | - |
360 | { | - |
361 | if (!d->ref.deref()) { evaluated: !d->ref.deref() yes Evaluation Count:36 | yes Evaluation Count:19486 |
| 36-19486 |
362 | close(); | - |
363 | delete d; | - |
364 | } executed: } Execution Count:36 | 36 |
365 | } executed: } Execution Count:19522 | 19522 |
366 | QSqlQuery QSqlDatabase::exec(const QString & query) const | - |
367 | { | - |
368 | QSqlQuery r(d->driver->createResult()); | - |
369 | if (!query.isEmpty()) { partially evaluated: !query.isEmpty() yes Evaluation Count:16 | no Evaluation Count:0 |
| 0-16 |
370 | r.exec(query); | - |
371 | d->driver->setLastError(r.lastError()); | - |
372 | } executed: } Execution Count:16 | 16 |
373 | return r; executed: return r; Execution Count:16 | 16 |
374 | } | - |
375 | bool QSqlDatabase::open() | - |
376 | { | - |
377 | return d->driver->open(d->dbname, d->uname, d->pword, d->hname, | 48 |
378 | d->port, d->connOptions); executed: return d->driver->open(d->dbname, d->uname, d->pword, d->hname, d->port, d->connOptions); Execution Count:48 | 48 |
379 | } | - |
380 | bool QSqlDatabase::open(const QString& user, const QString& password) | - |
381 | { | - |
382 | setUserName(user); | - |
383 | return d->driver->open(d->dbname, user, password, d->hname, | 1 |
384 | d->port, d->connOptions); executed: return d->driver->open(d->dbname, user, password, d->hname, d->port, d->connOptions); Execution Count:1 | 1 |
385 | } | - |
386 | void QSqlDatabase::close() | - |
387 | { | - |
388 | d->driver->close(); | - |
389 | } executed: } Execution Count:76 | 76 |
390 | | - |
391 | | - |
392 | | - |
393 | | - |
394 | | - |
395 | | - |
396 | bool QSqlDatabase::isOpen() const | - |
397 | { | - |
398 | return d->driver->isOpen(); executed: return d->driver->isOpen(); Execution Count:2016 | 2016 |
399 | } | - |
400 | | - |
401 | | - |
402 | | - |
403 | | - |
404 | | - |
405 | | - |
406 | | - |
407 | bool QSqlDatabase::isOpenError() const | - |
408 | { | - |
409 | return d->driver->isOpenError(); executed: return d->driver->isOpenError(); Execution Count:10 | 10 |
410 | } | - |
411 | bool QSqlDatabase::transaction() | - |
412 | { | - |
413 | if (!d->driver->hasFeature(QSqlDriver::Transactions)) partially evaluated: !d->driver->hasFeature(QSqlDriver::Transactions) no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
414 | return false; never executed: return false; | 0 |
415 | return d->driver->beginTransaction(); executed: return d->driver->beginTransaction(); Execution Count:5 | 5 |
416 | } | - |
417 | bool QSqlDatabase::commit() | - |
418 | { | - |
419 | if (!d->driver->hasFeature(QSqlDriver::Transactions)) partially evaluated: !d->driver->hasFeature(QSqlDriver::Transactions) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
420 | return false; never executed: return false; | 0 |
421 | return d->driver->commitTransaction(); executed: return d->driver->commitTransaction(); Execution Count:4 | 4 |
422 | } | - |
423 | bool QSqlDatabase::rollback() | - |
424 | { | - |
425 | if (!d->driver->hasFeature(QSqlDriver::Transactions)) partially evaluated: !d->driver->hasFeature(QSqlDriver::Transactions) no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
426 | return false; never executed: return false; | 0 |
427 | return d->driver->rollbackTransaction(); executed: return d->driver->rollbackTransaction(); Execution Count:1 | 1 |
428 | } | - |
429 | void QSqlDatabase::setDatabaseName(const QString& name) | - |
430 | { | - |
431 | if (isValid()) partially evaluated: isValid() yes Evaluation Count:26 | no Evaluation Count:0 |
| 0-26 |
432 | d->dbname = name; executed: d->dbname = name; Execution Count:26 | 26 |
433 | } executed: } Execution Count:26 | 26 |
434 | void QSqlDatabase::setUserName(const QString& name) | - |
435 | { | - |
436 | if (isValid()) partially evaluated: isValid() yes Evaluation Count:24 | no Evaluation Count:0 |
| 0-24 |
437 | d->uname = name; executed: d->uname = name; Execution Count:24 | 24 |
438 | } executed: } Execution Count:24 | 24 |
439 | void QSqlDatabase::setPassword(const QString& password) | - |
440 | { | - |
441 | if (isValid()) partially evaluated: isValid() yes Evaluation Count:23 | no Evaluation Count:0 |
| 0-23 |
442 | d->pword = password; executed: d->pword = password; Execution Count:23 | 23 |
443 | } executed: } Execution Count:23 | 23 |
444 | void QSqlDatabase::setHostName(const QString& host) | - |
445 | { | - |
446 | if (isValid()) partially evaluated: isValid() yes Evaluation Count:23 | no Evaluation Count:0 |
| 0-23 |
447 | d->hname = host; executed: d->hname = host; Execution Count:23 | 23 |
448 | } executed: } Execution Count:23 | 23 |
449 | void QSqlDatabase::setPort(int port) | - |
450 | { | - |
451 | if (isValid()) partially evaluated: isValid() yes Evaluation Count:21 | no Evaluation Count:0 |
| 0-21 |
452 | d->port = port; executed: d->port = port; Execution Count:21 | 21 |
453 | } executed: } Execution Count:21 | 21 |
454 | | - |
455 | | - |
456 | | - |
457 | | - |
458 | | - |
459 | | - |
460 | | - |
461 | QString QSqlDatabase::databaseName() const | - |
462 | { | - |
463 | return d->dbname; executed: return d->dbname; Execution Count:127 | 127 |
464 | } | - |
465 | | - |
466 | | - |
467 | | - |
468 | | - |
469 | | - |
470 | | - |
471 | QString QSqlDatabase::userName() const | - |
472 | { | - |
473 | return d->uname; executed: return d->uname; Execution Count:2 | 2 |
474 | } | - |
475 | | - |
476 | | - |
477 | | - |
478 | | - |
479 | | - |
480 | | - |
481 | QString QSqlDatabase::password() const | - |
482 | { | - |
483 | return d->pword; executed: return d->pword; Execution Count:2 | 2 |
484 | } | - |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | | - |
491 | QString QSqlDatabase::hostName() const | - |
492 | { | - |
493 | return d->hname; executed: return d->hname; Execution Count:11573 | 11573 |
494 | } | - |
495 | | - |
496 | | - |
497 | | - |
498 | | - |
499 | | - |
500 | | - |
501 | QString QSqlDatabase::driverName() const | - |
502 | { | - |
503 | return d->drvName; executed: return d->drvName; Execution Count:35246 | 35246 |
504 | } | - |
505 | | - |
506 | | - |
507 | | - |
508 | | - |
509 | | - |
510 | | - |
511 | | - |
512 | int QSqlDatabase::port() const | - |
513 | { | - |
514 | return d->port; executed: return d->port; Execution Count:11547 | 11547 |
515 | } | - |
516 | QSqlDriver* QSqlDatabase::driver() const | - |
517 | { | - |
518 | return d->driver; executed: return d->driver; Execution Count:3707 | 3707 |
519 | } | - |
520 | QSqlError QSqlDatabase::lastError() const | - |
521 | { | - |
522 | return d->driver->lastError(); executed: return d->driver->lastError(); Execution Count:29 | 29 |
523 | } | - |
524 | QStringList QSqlDatabase::tables(QSql::TableType type) const | - |
525 | { | - |
526 | return d->driver->tables(type); executed: return d->driver->tables(type); Execution Count:50 | 50 |
527 | } | - |
528 | QSqlIndex QSqlDatabase::primaryIndex(const QString& tablename) const | - |
529 | { | - |
530 | return d->driver->primaryIndex(tablename); executed: return d->driver->primaryIndex(tablename); Execution Count:187 | 187 |
531 | } | - |
532 | QSqlRecord QSqlDatabase::record(const QString& tablename) const | - |
533 | { | - |
534 | return d->driver->record(tablename); executed: return d->driver->record(tablename); Execution Count:328 | 328 |
535 | } | - |
536 | void QSqlDatabase::setConnectOptions(const QString &options) | - |
537 | { | - |
538 | if (isValid()) partially evaluated: isValid() yes Evaluation Count:22 | no Evaluation Count:0 |
| 0-22 |
539 | d->connOptions = options; executed: d->connOptions = options; Execution Count:22 | 22 |
540 | } executed: } Execution Count:22 | 22 |
541 | | - |
542 | | - |
543 | | - |
544 | | - |
545 | | - |
546 | | - |
547 | | - |
548 | QString QSqlDatabase::connectOptions() const | - |
549 | { | - |
550 | return d->connOptions; never executed: return d->connOptions; | 0 |
551 | } | - |
552 | bool QSqlDatabase::isDriverAvailable(const QString& name) | - |
553 | { | - |
554 | return drivers().contains(name); never executed: return drivers().contains(name); | 0 |
555 | } | - |
556 | QSqlDatabase QSqlDatabase::addDatabase(QSqlDriver* driver, const QString& connectionName) | - |
557 | { | - |
558 | QSqlDatabase db(driver); | - |
559 | QSqlDatabasePrivate::addDatabase(db, connectionName); | - |
560 | return db; never executed: return db; | 0 |
561 | } | - |
562 | | - |
563 | | - |
564 | | - |
565 | | - |
566 | | - |
567 | | - |
568 | | - |
569 | bool QSqlDatabase::isValid() const | - |
570 | { | - |
571 | return d->driver && d->driver != d->shared_null()->driver; executed: return d->driver && d->driver != d->shared_null()->driver; Execution Count:6756 | 6756 |
572 | } | - |
573 | QSqlDatabase QSqlDatabase::cloneDatabase(const QSqlDatabase &other, const QString &connectionName) | - |
574 | { | - |
575 | if (!other.isValid()) partially evaluated: !other.isValid() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
576 | return QSqlDatabase(); never executed: return QSqlDatabase(); | 0 |
577 | | - |
578 | QSqlDatabase db(other.driverName()); | - |
579 | db.d->copy(other.d); | - |
580 | QSqlDatabasePrivate::addDatabase(db, connectionName); | - |
581 | return db; executed: return db; Execution Count:7 | 7 |
582 | } | - |
583 | QString QSqlDatabase::connectionName() const | - |
584 | { | - |
585 | return d->connName; executed: return d->connName; Execution Count:4 | 4 |
586 | } | - |
587 | void QSqlDatabase::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy) | - |
588 | { | - |
589 | if(driver()) partially evaluated: driver() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
590 | driver()->setNumericalPrecisionPolicy(precisionPolicy); executed: driver()->setNumericalPrecisionPolicy(precisionPolicy); Execution Count:2 | 2 |
591 | d->precisionPolicy = precisionPolicy; | - |
592 | } executed: } Execution Count:2 | 2 |
593 | QSql::NumericalPrecisionPolicy QSqlDatabase::numericalPrecisionPolicy() const | - |
594 | { | - |
595 | if(driver()) partially evaluated: driver() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
596 | return driver()->numericalPrecisionPolicy(); executed: return driver()->numericalPrecisionPolicy(); Execution Count:1 | 1 |
597 | else | - |
598 | return d->precisionPolicy; never executed: return d->precisionPolicy; | 0 |
599 | } | - |
600 | | - |
601 | | - |
602 | | - |
603 | QDebug operator<<(QDebug dbg, const QSqlDatabase &d) | - |
604 | { | - |
605 | if (!d.isValid()) { never evaluated: !d.isValid() | 0 |
606 | dbg.nospace() << "QSqlDatabase(invalid)"; | - |
607 | return dbg.space(); never executed: return dbg.space(); | 0 |
608 | } | - |
609 | | - |
610 | dbg.nospace() << "QSqlDatabase(driver=\"" << d.driverName() << "\", database=\"" | - |
611 | << d.databaseName() << "\", host=\"" << d.hostName() << "\", port=" << d.port() | - |
612 | << ", user=\"" << d.userName() << "\", open=" << d.isOpen() << ")"; | - |
613 | return dbg.space(); never executed: return dbg.space(); | 0 |
614 | } | - |
615 | | - |
616 | | - |
617 | | - |
618 | | - |
| | |