Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | class QSqlQueryPrivate | - |
8 | { | - |
9 | public: | - |
10 | QSqlQueryPrivate(QSqlResult* result); | - |
11 | ~QSqlQueryPrivate(); | - |
12 | QAtomicInt ref; | - |
13 | QSqlResult* sqlResult; | - |
14 | | - |
15 | static QSqlQueryPrivate* shared_null(); | - |
16 | }; | - |
17 | | - |
18 | static 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) no Evaluation Count:0 | yes Evaluation Count:8 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:8 | yes Evaluation Count:1427 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-1435 |
19 | static 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) no Evaluation Count:0 | yes Evaluation Count:9 |
partially evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:9 | no Evaluation Count:0 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:9 | no Evaluation Count:0 |
never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:9 | 0-9 |
20 | static 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) no Evaluation Count:0 | yes Evaluation Count:9 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:9 | yes Evaluation Count:2182 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:9 | no Evaluation Count:0 |
never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:2191 | 0-2191 |
21 | | - |
22 | QSqlQueryPrivate* 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 | | - |
32 | QSqlQueryPrivate::QSqlQueryPrivate(QSqlResult* result) | - |
33 | : ref(1), sqlResult(result) | - |
34 | { | - |
35 | if (!sqlResult) evaluated: !sqlResult 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 | | - |
39 | QSqlQueryPrivate::~QSqlQueryPrivate() | - |
40 | { | - |
41 | QSqlResult *nr = nullResult(); | - |
42 | if (!nr || sqlResult == nr) partially evaluated: !nr no Evaluation Count:0 | yes Evaluation Count:2183 |
evaluated: sqlResult == nr 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 |
46 | QSqlQuery::QSqlQuery(QSqlResult *result) | - |
47 | { | - |
48 | d = new QSqlQueryPrivate(result); | - |
49 | } executed: } Execution Count:2175 | 2175 |
50 | | - |
51 | | - |
52 | | - |
53 | | - |
54 | | - |
55 | QSqlQuery::~QSqlQuery() | - |
56 | { | - |
57 | if (!d->ref.deref()) evaluated: !d->ref.deref() 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 | | - |
65 | QSqlQuery::QSqlQuery(const QSqlQuery& other) | - |
66 | { | - |
67 | d = other.d; | - |
68 | d->ref.ref(); | - |
69 | } executed: } Execution Count:1 | 1 |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | static void qInit(QSqlQuery *q, const QString& query, QSqlDatabase db) | - |
75 | { | - |
76 | QSqlDatabase database = db; | - |
77 | if (!database.isValid()) evaluated: !database.isValid() 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() 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() 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 |
85 | QSqlQuery::QSqlQuery(const QString& query, QSqlDatabase db) | - |
86 | { | - |
87 | d = QSqlQueryPrivate::shared_null(); | - |
88 | qInit(this, query, db); | - |
89 | } executed: } Execution Count:1109 | 1109 |
90 | QSqlQuery::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 | | - |
101 | QSqlQuery& QSqlQuery::operator=(const QSqlQuery& other) | - |
102 | { | - |
103 | qAtomicAssign(d, other.d); | - |
104 | return *this; executed: return *this; Execution Count:2016 | 2016 |
105 | } | - |
106 | bool QSqlQuery::isNull(int field) const | - |
107 | { | - |
108 | if (d->sqlResult->isActive() && d->sqlResult->isValid()) partially evaluated: d->sqlResult->isActive() yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: d->sqlResult->isValid() 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 | } | - |
112 | bool QSqlQuery::exec(const QString& query) | - |
113 | { | - |
114 | if (d->ref.load() != 1) { evaluated: d->ref.load() != 1 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() yes Evaluation Count:2 | yes Evaluation Count:2555 |
partially evaluated: driver()->isOpenError() 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() 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 | } | - |
140 | QVariant QSqlQuery::value(int index) const | - |
141 | { | - |
142 | if (isActive() && isValid() && (index > -1)) partially evaluated: isActive() yes Evaluation Count:9361 | no Evaluation Count:0 |
partially evaluated: isValid() yes Evaluation Count:9361 | no Evaluation Count:0 |
partially evaluated: (index > -1) 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 | } | - |
147 | QVariant QSqlQuery::value(const QString& name) const | - |
148 | { | - |
149 | int index = d->sqlResult->record().indexOf(name); | - |
150 | if (index > -1) partially evaluated: index > -1 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 | } | - |
155 | int QSqlQuery::at() const | - |
156 | { | - |
157 | return d->sqlResult->at(); executed: return d->sqlResult->at(); Execution Count:11209 | 11209 |
158 | } | - |
159 | QString QSqlQuery::lastQuery() const | - |
160 | { | - |
161 | return d->sqlResult->lastQuery(); executed: return d->sqlResult->lastQuery(); Execution Count:124 | 124 |
162 | } | - |
163 | | - |
164 | | - |
165 | | - |
166 | | - |
167 | | - |
168 | const 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 | | - |
177 | const QSqlResult* QSqlQuery::result() const | - |
178 | { | - |
179 | return d->sqlResult; executed: return d->sqlResult; Execution Count:155 | 155 |
180 | } | - |
181 | bool QSqlQuery::seek(int index, bool relative) | - |
182 | { | - |
183 | if (!isSelect() || !isActive()) partially evaluated: !isSelect() no Evaluation Count:0 | yes Evaluation Count:3874 |
partially evaluated: !isActive() 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 yes Evaluation Count:3873 | yes Evaluation Count:1 |
| 1-3873 |
187 | if (index < 0) { evaluated: index < 0 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; | 0 |
201 | case QSql::AfterLastRow: | - |
202 | if (index < 0) { never evaluated: index < 0 | 0 |
203 | d->sqlResult->fetchLast(); | - |
204 | actualIdx = at() + index; | - |
205 | } else { | 0 |
206 | return false; never executed: return false; | 0 |
207 | } | - |
208 | break; | 0 |
209 | default: | - |
210 | if ((at() + index) < 0) { partially evaluated: (at() + index) < 0 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() yes Evaluation Count:2 | yes Evaluation Count:3871 |
evaluated: actualIdx < at() 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) yes Evaluation Count:1223 | yes Evaluation Count:2649 |
evaluated: at() != QSql::BeforeFirstRow yes Evaluation Count:1221 | yes Evaluation Count:2 |
| 2-2649 |
224 | if (!d->sqlResult->fetchNext()) { partially evaluated: !d->sqlResult->fetchNext() 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) yes Evaluation Count:39 | yes Evaluation Count:2612 |
| 39-2612 |
231 | if (!d->sqlResult->fetchPrevious()) { partially evaluated: !d->sqlResult->fetchPrevious() 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) 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 | } | - |
243 | bool QSqlQuery::next() | - |
244 | { | - |
245 | if (!isSelect() || !isActive()) evaluated: !isSelect() yes Evaluation Count:4 | yes Evaluation Count:3412 |
partially evaluated: !isActive() 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() 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 | } | 0 |
262 | bool QSqlQuery::previous() | - |
263 | { | - |
264 | if (!isSelect() || !isActive()) partially evaluated: !isSelect() no Evaluation Count:0 | yes Evaluation Count:3 |
partially evaluated: !isActive() no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
265 | return false; never executed: return false; | 0 |
266 | if (isForwardOnly()) { evaluated: isForwardOnly() 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() 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 | } | 0 |
286 | bool QSqlQuery::first() | - |
287 | { | - |
288 | if (!isSelect() || !isActive()) evaluated: !isSelect() yes Evaluation Count:1 | yes Evaluation Count:18 |
partially evaluated: !isActive() 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() yes Evaluation Count:3 | yes Evaluation Count:15 |
evaluated: at() > QSql::BeforeFirstRow 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 | } | - |
298 | bool QSqlQuery::last() | - |
299 | { | - |
300 | if (!isSelect() || !isActive()) partially evaluated: !isSelect() no Evaluation Count:0 | yes Evaluation Count:8 |
partially evaluated: !isActive() 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 | } | - |
306 | int QSqlQuery::size() const | - |
307 | { | - |
308 | if (isActive() && d->sqlResult->driver()->hasFeature(QSqlDriver::QuerySize)) evaluated: isActive() yes Evaluation Count:5 | yes Evaluation Count:1 |
partially evaluated: d->sqlResult->driver()->hasFeature(QSqlDriver::QuerySize) 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 | } | - |
312 | int QSqlQuery::numRowsAffected() const | - |
313 | { | - |
314 | if (isActive()) evaluated: isActive() 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 | } | - |
318 | QSqlError 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 | | - |
328 | bool QSqlQuery::isValid() const | - |
329 | { | - |
330 | return d->sqlResult->isValid(); executed: return d->sqlResult->isValid(); Execution Count:9863 | 9863 |
331 | } | - |
332 | bool 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 | | - |
342 | bool 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 | | - |
353 | bool QSqlQuery::isForwardOnly() const | - |
354 | { | - |
355 | return d->sqlResult->isForwardOnly(); executed: return d->sqlResult->isForwardOnly(); Execution Count:4288 | 4288 |
356 | } | - |
357 | void QSqlQuery::setForwardOnly(bool forward) | - |
358 | { | - |
359 | d->sqlResult->setForwardOnly(forward); | - |
360 | } executed: } Execution Count:646 | 646 |
361 | QSqlRecord QSqlQuery::record() const | - |
362 | { | - |
363 | QSqlRecord rec = d->sqlResult->record(); | - |
364 | | - |
365 | if (isValid()) { evaluated: isValid() yes Evaluation Count:94 | yes Evaluation Count:403 |
| 94-403 |
366 | for (int i = 0; i < rec.count(); ++i) evaluated: i < rec.count() 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 | | - |
377 | void QSqlQuery::clear() | - |
378 | { | - |
379 | *this = QSqlQuery(driver()->createResult()); | - |
380 | } executed: } Execution Count:397 | 397 |
381 | bool QSqlQuery::prepare(const QString& query) | - |
382 | { | - |
383 | if (d->ref.load() != 1) { evaluated: d->ref.load() != 1 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() 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() no Evaluation Count:0 | yes Evaluation Count:226 |
partially evaluated: driver()->isOpenError() 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() 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 | } | - |
411 | bool QSqlQuery::exec() | - |
412 | { | - |
413 | d->sqlResult->resetBindCount(); | - |
414 | | - |
415 | if (d->sqlResult->lastError().isValid()) evaluated: d->sqlResult->lastError().isValid() 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 | } | - |
420 | bool QSqlQuery::execBatch(BatchExecutionMode mode) | - |
421 | { | - |
422 | return d->sqlResult->execBatch(mode == ValuesAsColumns); never executed: return d->sqlResult->execBatch(mode == ValuesAsColumns); | 0 |
423 | } | - |
424 | void 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 | | - |
437 | void QSqlQuery::bindValue(int pos, const QVariant& val, QSql::ParamType paramType) | - |
438 | { | - |
439 | d->sqlResult->bindValue(pos, val, paramType); | - |
440 | } executed: } Execution Count:71 | 71 |
441 | void 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 | | - |
451 | QVariant 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 | | - |
459 | QVariant QSqlQuery::boundValue(int pos) const | - |
460 | { | - |
461 | return d->sqlResult->boundValue(pos); executed: return d->sqlResult->boundValue(pos); Execution Count:1 | 1 |
462 | } | - |
463 | QMap<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() 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 | } | - |
472 | QString QSqlQuery::executedQuery() const | - |
473 | { | - |
474 | return d->sqlResult->executedQuery(); executed: return d->sqlResult->executedQuery(); Execution Count:1 | 1 |
475 | } | - |
476 | QVariant QSqlQuery::lastInsertId() const | - |
477 | { | - |
478 | return d->sqlResult->lastInsertId(); executed: return d->sqlResult->lastInsertId(); Execution Count:7 | 7 |
479 | } | - |
480 | void QSqlQuery::setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy) | - |
481 | { | - |
482 | d->sqlResult->setNumericalPrecisionPolicy(precisionPolicy); | - |
483 | } executed: } Execution Count:6 | 6 |
484 | | - |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | QSql::NumericalPrecisionPolicy QSqlQuery::numericalPrecisionPolicy() const | - |
491 | { | - |
492 | return d->sqlResult->numericalPrecisionPolicy(); never executed: return d->sqlResult->numericalPrecisionPolicy(); | 0 |
493 | } | - |
494 | void QSqlQuery::finish() | - |
495 | { | - |
496 | if (isActive()) { partially evaluated: isActive() 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 |
503 | bool 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 | | - |
| | |