kernel/qsqlquery.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7class QSqlQueryPrivate -
8{ -
9public: -
10 QSqlQueryPrivate(QSqlResult* result); -
11 ~QSqlQueryPrivate(); -
12 QAtomicInt ref; -
13 QSqlResult* sqlResult; -
14 -
15 static QSqlQueryPrivate* shared_null(); -
16}; -
17 -
18static QSqlQueryPrivate *nullQueryPrivate() { static QGlobalStatic<QSqlQueryPrivate > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QSqlQueryPrivate *x = new QSqlQueryPrivate (0); if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QSqlQueryPrivate > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:1435
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:1427
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-1435
19static QSqlNullDriver *nullDriver() { static QGlobalStatic<QSqlNullDriver > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QSqlNullDriver *x = new QSqlNullDriver; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QSqlNullDriver > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
partially evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:9
0-9
20static QSqlNullResult *nullResult() { static QGlobalStatic<QSqlNullResult > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QSqlNullResult *x = new QSqlNullResult (nullDriver()); if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QSqlNullResult > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2182
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:2191
0-2191
21 -
22QSqlQueryPrivate* QSqlQueryPrivate::shared_null() -
23{ -
24 QSqlQueryPrivate *null = nullQueryPrivate(); -
25 null->ref.ref(); -
26 return null;
executed: return null;
Execution Count:1435
1435
27} -
28 -
29 -
30 -
31 -
32QSqlQueryPrivate::QSqlQueryPrivate(QSqlResult* result) -
33 : ref(1), sqlResult(result) -
34{ -
35 if (!sqlResult)
evaluated: !sqlResult
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2175
8-2175
36 sqlResult = nullResult();
executed: sqlResult = nullResult();
Execution Count:8
8
37}
executed: }
Execution Count:2183
2183
38 -
39QSqlQueryPrivate::~QSqlQueryPrivate() -
40{ -
41 QSqlResult *nr = nullResult(); -
42 if (!nr || sqlResult == nr)
partially evaluated: !nr
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2183
evaluated: sqlResult == nr
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:2175
0-2183
43 return;
executed: return;
Execution Count:8
8
44 delete sqlResult; -
45}
executed: }
Execution Count:2175
2175
46QSqlQuery::QSqlQuery(QSqlResult *result) -
47{ -
48 d = new QSqlQueryPrivate(result); -
49}
executed: }
Execution Count:2175
2175
50 -
51 -
52 -
53 -
54 -
55QSqlQuery::~QSqlQuery() -
56{ -
57 if (!d->ref.deref())
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:1597
yes
Evaluation Count:2014
1597-2014
58 delete d;
executed: delete d;
Execution Count:1597
1597
59}
executed: }
Execution Count:3611
3611
60 -
61 -
62 -
63 -
64 -
65QSqlQuery::QSqlQuery(const QSqlQuery& other) -
66{ -
67 d = other.d; -
68 d->ref.ref(); -
69}
executed: }
Execution Count:1
1
70 -
71 -
72 -
73 -
74static void qInit(QSqlQuery *q, const QString& query, QSqlDatabase db) -
75{ -
76 QSqlDatabase database = db; -
77 if (!database.isValid())
evaluated: !database.isValid()
TRUEFALSE
yes
Evaluation Count:773
yes
Evaluation Count:662
662-773
78 database = QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection), false);
executed: database = QSqlDatabase::database(QLatin1String(QSqlDatabase::defaultConnection), false);
Execution Count:773
773
79 if (database.isValid()) {
evaluated: database.isValid()
TRUEFALSE
yes
Evaluation Count:1175
yes
Evaluation Count:260
260-1175
80 *q = QSqlQuery(database.driver()->createResult()); -
81 }
executed: }
Execution Count:1175
1175
82 if (!query.isEmpty())
evaluated: !query.isEmpty()
TRUEFALSE
yes
Evaluation Count:540
yes
Evaluation Count:895
540-895
83 q->exec(query);
executed: q->exec(query);
Execution Count:540
540
84}
executed: }
Execution Count:1435
1435
85QSqlQuery::QSqlQuery(const QString& query, QSqlDatabase db) -
86{ -
87 d = QSqlQueryPrivate::shared_null(); -
88 qInit(this, query, db); -
89}
executed: }
Execution Count:1109
1109
90QSqlQuery::QSqlQuery(QSqlDatabase db) -
91{ -
92 d = QSqlQueryPrivate::shared_null(); -
93 qInit(this, QString(), db); -
94}
executed: }
Execution Count:326
326
95 -
96 -
97 -
98 -
99 -
100 -
101QSqlQuery& QSqlQuery::operator=(const QSqlQuery& other) -
102{ -
103 qAtomicAssign(d, other.d); -
104 return *this;
executed: return *this;
Execution Count:2016
2016
105} -
106bool QSqlQuery::isNull(int field) const -
107{ -
108 if (d->sqlResult->isActive() && d->sqlResult->isValid())
partially evaluated: d->sqlResult->isActive()
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
partially evaluated: d->sqlResult->isValid()
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
109 return d->sqlResult->isNull(field);
executed: return d->sqlResult->isNull(field);
Execution Count:5
5
110 return true;
never executed: return true;
0
111} -
112bool QSqlQuery::exec(const QString& query) -
113{ -
114 if (d->ref.load() != 1) {
evaluated: d->ref.load() != 1
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:2552
5-2552
115 bool fo = isForwardOnly(); -
116 *this = QSqlQuery(driver()->createResult()); -
117 d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy()); -
118 setForwardOnly(fo); -
119 } else {
executed: }
Execution Count:5
5
120 d->sqlResult->clear(); -
121 d->sqlResult->setActive(false); -
122 d->sqlResult->setLastError(QSqlError()); -
123 d->sqlResult->setAt(QSql::BeforeFirstRow); -
124 d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy()); -
125 }
executed: }
Execution Count:2552
2552
126 d->sqlResult->setQuery(query.trimmed()); -
127 if (!driver()->isOpen() || driver()->isOpenError()) {
evaluated: !driver()->isOpen()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2555
partially evaluated: driver()->isOpenError()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2555
0-2555
128 QMessageLogger("kernel/qsqlquery.cpp", 368, __PRETTY_FUNCTION__).warning("QSqlQuery::exec: database not open"); -
129 return false;
executed: return false;
Execution Count:2
2
130 } -
131 if (query.isEmpty()) {
partially evaluated: query.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2555
0-2555
132 QMessageLogger("kernel/qsqlquery.cpp", 372, __PRETTY_FUNCTION__).warning("QSqlQuery::exec: empty query"); -
133 return false;
never executed: return false;
0
134 } -
135 -
136 -
137 -
138 return d->sqlResult->reset(query);
executed: return d->sqlResult->reset(query);
Execution Count:2555
2555
139} -
140QVariant QSqlQuery::value(int index) const -
141{ -
142 if (isActive() && isValid() && (index > -1))
partially evaluated: isActive()
TRUEFALSE
yes
Evaluation Count:9361
no
Evaluation Count:0
partially evaluated: isValid()
TRUEFALSE
yes
Evaluation Count:9361
no
Evaluation Count:0
partially evaluated: (index > -1)
TRUEFALSE
yes
Evaluation Count:9361
no
Evaluation Count:0
0-9361
143 return d->sqlResult->data(index);
executed: return d->sqlResult->data(index);
Execution Count:9361
9361
144 QMessageLogger("kernel/qsqlquery.cpp", 404, __PRETTY_FUNCTION__).warning("QSqlQuery::value: not positioned on a valid record"); -
145 return QVariant();
never executed: return QVariant();
0
146} -
147QVariant QSqlQuery::value(const QString& name) const -
148{ -
149 int index = d->sqlResult->record().indexOf(name); -
150 if (index > -1)
partially evaluated: index > -1
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
151 return value(index);
executed: return value(index);
Execution Count:5
5
152 QMessageLogger("kernel/qsqlquery.cpp", 422, __PRETTY_FUNCTION__).warning("QSqlQuery::value: unknown field name '%s'", QString(name).toLocal8Bit().constData()); -
153 return QVariant();
never executed: return QVariant();
0
154} -
155int QSqlQuery::at() const -
156{ -
157 return d->sqlResult->at();
executed: return d->sqlResult->at();
Execution Count:11209
11209
158} -
159QString QSqlQuery::lastQuery() const -
160{ -
161 return d->sqlResult->lastQuery();
executed: return d->sqlResult->lastQuery();
Execution Count:124
124
162} -
163 -
164 -
165 -
166 -
167 -
168const QSqlDriver *QSqlQuery::driver() const -
169{ -
170 return d->sqlResult->driver();
executed: return d->sqlResult->driver();
Execution Count:6693
6693
171} -
172 -
173 -
174 -
175 -
176 -
177const QSqlResult* QSqlQuery::result() const -
178{ -
179 return d->sqlResult;
executed: return d->sqlResult;
Execution Count:155
155
180} -
181bool QSqlQuery::seek(int index, bool relative) -
182{ -
183 if (!isSelect() || !isActive())
partially evaluated: !isSelect()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3874
partially evaluated: !isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3874
0-3874
184 return false;
never executed: return false;
0
185 int actualIdx; -
186 if (!relative) {
evaluated: !relative
TRUEFALSE
yes
Evaluation Count:3873
yes
Evaluation Count:1
1-3873
187 if (index < 0) {
evaluated: index < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3872
1-3872
188 d->sqlResult->setAt(QSql::BeforeFirstRow); -
189 return false;
executed: return false;
Execution Count:1
1
190 } -
191 actualIdx = index; -
192 } else {
executed: }
Execution Count:3872
3872
193 switch (at()) { -
194 case QSql::BeforeFirstRow: -
195 if (index > 0)
never evaluated: index > 0
0
196 actualIdx = index;
never executed: actualIdx = index;
0
197 else { -
198 return false;
never executed: return false;
0
199 } -
200 break;
never executed: break;
0
201 case QSql::AfterLastRow: -
202 if (index < 0) {
never evaluated: index < 0
0
203 d->sqlResult->fetchLast(); -
204 actualIdx = at() + index; -
205 } else {
never executed: }
0
206 return false;
never executed: return false;
0
207 } -
208 break;
never executed: break;
0
209 default: -
210 if ((at() + index) < 0) {
partially evaluated: (at() + index) < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
211 d->sqlResult->setAt(QSql::BeforeFirstRow); -
212 return false;
never executed: return false;
0
213 } -
214 actualIdx = at() + index; -
215 break;
executed: break;
Execution Count:1
1
216 } -
217 }
executed: }
Execution Count:1
1
218 -
219 if (isForwardOnly() && actualIdx < at()) {
evaluated: isForwardOnly()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3871
evaluated: actualIdx < at()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-3871
220 QMessageLogger("kernel/qsqlquery.cpp", 557, __PRETTY_FUNCTION__).warning("QSqlQuery::seek: cannot seek backwards in a forward only query"); -
221 return false;
executed: return false;
Execution Count:1
1
222 } -
223 if (actualIdx == (at() + 1) && at() != QSql::BeforeFirstRow) {
evaluated: actualIdx == (at() + 1)
TRUEFALSE
yes
Evaluation Count:1223
yes
Evaluation Count:2649
evaluated: at() != QSql::BeforeFirstRow
TRUEFALSE
yes
Evaluation Count:1221
yes
Evaluation Count:2
2-2649
224 if (!d->sqlResult->fetchNext()) {
partially evaluated: !d->sqlResult->fetchNext()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1221
0-1221
225 d->sqlResult->setAt(QSql::AfterLastRow); -
226 return false;
never executed: return false;
0
227 } -
228 return true;
executed: return true;
Execution Count:1221
1221
229 } -
230 if (actualIdx == (at() - 1)) {
evaluated: actualIdx == (at() - 1)
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:2612
39-2612
231 if (!d->sqlResult->fetchPrevious()) {
partially evaluated: !d->sqlResult->fetchPrevious()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39
0-39
232 d->sqlResult->setAt(QSql::BeforeFirstRow); -
233 return false;
never executed: return false;
0
234 } -
235 return true;
executed: return true;
Execution Count:39
39
236 } -
237 if (!d->sqlResult->fetch(actualIdx)) {
evaluated: !d->sqlResult->fetch(actualIdx)
TRUEFALSE
yes
Evaluation Count:270
yes
Evaluation Count:2342
270-2342
238 d->sqlResult->setAt(QSql::AfterLastRow); -
239 return false;
executed: return false;
Execution Count:270
270
240 } -
241 return true;
executed: return true;
Execution Count:2342
2342
242} -
243bool QSqlQuery::next() -
244{ -
245 if (!isSelect() || !isActive())
evaluated: !isSelect()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3412
partially evaluated: !isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3412
0-3412
246 return false;
executed: return false;
Execution Count:4
4
247 bool b = false; -
248 switch (at()) { -
249 case QSql::BeforeFirstRow: -
250 b = d->sqlResult->fetchFirst(); -
251 return b;
executed: return b;
Execution Count:694
694
252 case QSql::AfterLastRow: -
253 return false;
executed: return false;
Execution Count:13
13
254 default: -
255 if (!d->sqlResult->fetchNext()) {
evaluated: !d->sqlResult->fetchNext()
TRUEFALSE
yes
Evaluation Count:831
yes
Evaluation Count:1874
831-1874
256 d->sqlResult->setAt(QSql::AfterLastRow); -
257 return false;
executed: return false;
Execution Count:831
831
258 } -
259 return true;
executed: return true;
Execution Count:1874
1874
260 } -
261}
never executed: }
0
262bool QSqlQuery::previous() -
263{ -
264 if (!isSelect() || !isActive())
partially evaluated: !isSelect()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
partially evaluated: !isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
265 return false;
never executed: return false;
0
266 if (isForwardOnly()) {
evaluated: isForwardOnly()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
267 QMessageLogger("kernel/qsqlquery.cpp", 664, __PRETTY_FUNCTION__).warning("QSqlQuery::seek: cannot seek backwards in a forward only query"); -
268 return false;
executed: return false;
Execution Count:1
1
269 } -
270 -
271 bool b = false; -
272 switch (at()) { -
273 case QSql::BeforeFirstRow: -
274 return false;
never executed: return false;
0
275 case QSql::AfterLastRow: -
276 b = d->sqlResult->fetchLast(); -
277 return b;
executed: return b;
Execution Count:1
1
278 default: -
279 if (!d->sqlResult->fetchPrevious()) {
partially evaluated: !d->sqlResult->fetchPrevious()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
280 d->sqlResult->setAt(QSql::BeforeFirstRow); -
281 return false;
never executed: return false;
0
282 } -
283 return true;
executed: return true;
Execution Count:1
1
284 } -
285}
never executed: }
0
286bool QSqlQuery::first() -
287{ -
288 if (!isSelect() || !isActive())
evaluated: !isSelect()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:18
partially evaluated: !isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
289 return false;
executed: return false;
Execution Count:1
1
290 if (isForwardOnly() && at() > QSql::BeforeFirstRow) {
evaluated: isForwardOnly()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:15
evaluated: at() > QSql::BeforeFirstRow
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-15
291 QMessageLogger("kernel/qsqlquery.cpp", 699, __PRETTY_FUNCTION__).warning("QSqlQuery::seek: cannot seek backwards in a forward only query"); -
292 return false;
executed: return false;
Execution Count:2
2
293 } -
294 bool b = false; -
295 b = d->sqlResult->fetchFirst(); -
296 return b;
executed: return b;
Execution Count:16
16
297} -
298bool QSqlQuery::last() -
299{ -
300 if (!isSelect() || !isActive())
partially evaluated: !isSelect()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
partially evaluated: !isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
301 return false;
never executed: return false;
0
302 bool b = false; -
303 b = d->sqlResult->fetchLast(); -
304 return b;
executed: return b;
Execution Count:8
8
305} -
306int QSqlQuery::size() const -
307{ -
308 if (isActive() && d->sqlResult->driver()->hasFeature(QSqlDriver::QuerySize))
evaluated: isActive()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
partially evaluated: d->sqlResult->driver()->hasFeature(QSqlDriver::QuerySize)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
309 return d->sqlResult->size();
never executed: return d->sqlResult->size();
0
310 return -1;
executed: return -1;
Execution Count:6
6
311} -
312int QSqlQuery::numRowsAffected() const -
313{ -
314 if (isActive())
evaluated: isActive()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:2
2-15
315 return d->sqlResult->numRowsAffected();
executed: return d->sqlResult->numRowsAffected();
Execution Count:15
15
316 return -1;
executed: return -1;
Execution Count:2
2
317} -
318QSqlError QSqlQuery::lastError() const -
319{ -
320 return d->sqlResult->lastError();
executed: return d->sqlResult->lastError();
Execution Count:11076
11076
321} -
322 -
323 -
324 -
325 -
326 -
327 -
328bool QSqlQuery::isValid() const -
329{ -
330 return d->sqlResult->isValid();
executed: return d->sqlResult->isValid();
Execution Count:9863
9863
331} -
332bool QSqlQuery::isActive() const -
333{ -
334 return d->sqlResult->isActive();
executed: return d->sqlResult->isActive();
Execution Count:17429
17429
335} -
336 -
337 -
338 -
339 -
340 -
341 -
342bool QSqlQuery::isSelect() const -
343{ -
344 return d->sqlResult->isSelect();
executed: return d->sqlResult->isSelect();
Execution Count:7322
7322
345} -
346 -
347 -
348 -
349 -
350 -
351 -
352 -
353bool QSqlQuery::isForwardOnly() const -
354{ -
355 return d->sqlResult->isForwardOnly();
executed: return d->sqlResult->isForwardOnly();
Execution Count:4288
4288
356} -
357void QSqlQuery::setForwardOnly(bool forward) -
358{ -
359 d->sqlResult->setForwardOnly(forward); -
360}
executed: }
Execution Count:646
646
361QSqlRecord QSqlQuery::record() const -
362{ -
363 QSqlRecord rec = d->sqlResult->record(); -
364 -
365 if (isValid()) {
evaluated: isValid()
TRUEFALSE
yes
Evaluation Count:94
yes
Evaluation Count:403
94-403
366 for (int i = 0; i < rec.count(); ++i)
evaluated: i < rec.count()
TRUEFALSE
yes
Evaluation Count:231
yes
Evaluation Count:94
94-231
367 rec.setValue(i, value(i));
executed: rec.setValue(i, value(i));
Execution Count:231
231
368 }
executed: }
Execution Count:94
94
369 return rec;
executed: return rec;
Execution Count:497
497
370} -
371 -
372 -
373 -
374 -
375 -
376 -
377void QSqlQuery::clear() -
378{ -
379 *this = QSqlQuery(driver()->createResult()); -
380}
executed: }
Execution Count:397
397
381bool QSqlQuery::prepare(const QString& query) -
382{ -
383 if (d->ref.load() != 1) {
evaluated: d->ref.load() != 1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:224
2-224
384 bool fo = isForwardOnly(); -
385 *this = QSqlQuery(driver()->createResult()); -
386 setForwardOnly(fo); -
387 d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy()); -
388 } else {
executed: }
Execution Count:2
2
389 d->sqlResult->setActive(false); -
390 d->sqlResult->setLastError(QSqlError()); -
391 d->sqlResult->setAt(QSql::BeforeFirstRow); -
392 d->sqlResult->setNumericalPrecisionPolicy(d->sqlResult->numericalPrecisionPolicy()); -
393 }
executed: }
Execution Count:224
224
394 if (!driver()) {
partially evaluated: !driver()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:226
0-226
395 QMessageLogger("kernel/qsqlquery.cpp", 934, __PRETTY_FUNCTION__).warning("QSqlQuery::prepare: no driver"); -
396 return false;
never executed: return false;
0
397 } -
398 if (!driver()->isOpen() || driver()->isOpenError()) {
partially evaluated: !driver()->isOpen()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:226
partially evaluated: driver()->isOpenError()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:226
0-226
399 QMessageLogger("kernel/qsqlquery.cpp", 938, __PRETTY_FUNCTION__).warning("QSqlQuery::prepare: database not open"); -
400 return false;
never executed: return false;
0
401 } -
402 if (query.isEmpty()) {
partially evaluated: query.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:226
0-226
403 QMessageLogger("kernel/qsqlquery.cpp", 942, __PRETTY_FUNCTION__).warning("QSqlQuery::prepare: empty query"); -
404 return false;
never executed: return false;
0
405 } -
406 -
407 -
408 -
409 return d->sqlResult->savePrepare(query);
executed: return d->sqlResult->savePrepare(query);
Execution Count:226
226
410} -
411bool QSqlQuery::exec() -
412{ -
413 d->sqlResult->resetBindCount(); -
414 -
415 if (d->sqlResult->lastError().isValid())
evaluated: d->sqlResult->lastError().isValid()
TRUEFALSE
yes
Evaluation Count:92073
yes
Evaluation Count:24651
24651-92073
416 d->sqlResult->setLastError(QSqlError());
executed: d->sqlResult->setLastError(QSqlError());
Execution Count:92073
92073
417 -
418 return d->sqlResult->exec();
executed: return d->sqlResult->exec();
Execution Count:116724
116724
419} -
420bool QSqlQuery::execBatch(BatchExecutionMode mode) -
421{ -
422 return d->sqlResult->execBatch(mode == ValuesAsColumns);
never executed: return d->sqlResult->execBatch(mode == ValuesAsColumns);
0
423} -
424void QSqlQuery::bindValue(const QString& placeholder, const QVariant& val, -
425 QSql::ParamType paramType -
426) -
427{ -
428 d->sqlResult->bindValue(placeholder, val, paramType); -
429}
executed: }
Execution Count:46
46
430 -
431 -
432 -
433 -
434 -
435 -
436 -
437void QSqlQuery::bindValue(int pos, const QVariant& val, QSql::ParamType paramType) -
438{ -
439 d->sqlResult->bindValue(pos, val, paramType); -
440}
executed: }
Execution Count:71
71
441void QSqlQuery::addBindValue(const QVariant& val, QSql::ParamType paramType) -
442{ -
443 d->sqlResult->addBindValue(val, paramType); -
444}
executed: }
Execution Count:233361
233361
445 -
446 -
447 -
448 -
449 -
450 -
451QVariant QSqlQuery::boundValue(const QString& placeholder) const -
452{ -
453 return d->sqlResult->boundValue(placeholder);
never executed: return d->sqlResult->boundValue(placeholder);
0
454} -
455 -
456 -
457 -
458 -
459QVariant QSqlQuery::boundValue(int pos) const -
460{ -
461 return d->sqlResult->boundValue(pos);
executed: return d->sqlResult->boundValue(pos);
Execution Count:1
1
462} -
463QMap<QString,QVariant> QSqlQuery::boundValues() const -
464{ -
465 QMap<QString,QVariant> map; -
466 -
467 const QVector<QVariant> values(d->sqlResult->boundValues()); -
468 for (int i = 0; i < values.count(); ++i)
evaluated: i < values.count()
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:52
52-104
469 map[d->sqlResult->boundValueName(i)] = values.at(i);
executed: map[d->sqlResult->boundValueName(i)] = values.at(i);
Execution Count:104
104
470 return map;
executed: return map;
Execution Count:52
52
471} -
472QString QSqlQuery::executedQuery() const -
473{ -
474 return d->sqlResult->executedQuery();
executed: return d->sqlResult->executedQuery();
Execution Count:1
1
475} -
476QVariant QSqlQuery::lastInsertId() const -
477{ -
478 return d->sqlResult->lastInsertId();
executed: return d->sqlResult->lastInsertId();
Execution Count:7
7
479} -
480void QSqlQuery::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy) -
481{ -
482 d->sqlResult->setNumericalPrecisionPolicy(precisionPolicy); -
483}
executed: }
Execution Count:6
6
484 -
485 -
486 -
487 -
488 -
489 -
490QSql::NumericalPrecisionPolicy QSqlQuery::numericalPrecisionPolicy() const -
491{ -
492 return d->sqlResult->numericalPrecisionPolicy();
never executed: return d->sqlResult->numericalPrecisionPolicy();
0
493} -
494void QSqlQuery::finish() -
495{ -
496 if (isActive()) {
partially evaluated: isActive()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
497 d->sqlResult->setLastError(QSqlError()); -
498 d->sqlResult->setAt(QSql::BeforeFirstRow); -
499 d->sqlResult->detachFromResultSet(); -
500 d->sqlResult->setActive(false); -
501 }
executed: }
Execution Count:3
3
502}
executed: }
Execution Count:3
3
503bool QSqlQuery::nextResult() -
504{ -
505 if (isActive())
never evaluated: isActive()
0
506 return d->sqlResult->nextResult();
never executed: return d->sqlResult->nextResult();
0
507 return false;
never executed: return false;
0
508} -
509 -
510 -
511 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial