| 341 | return rc == SQLITE_DONE; |
| 342 | } |
| 343 | int check(bool verbose) { |
| 344 | int errors = 0; |
| 345 | int tables[] = { 1, table, freetable }; |
| 346 | TraceEvent("BTreeIntegrityCheckBegin").detail("Filename", filename); |
| 347 | char* e = sqlite3BtreeIntegrityCheck(btree, tables, 3, 1000, &errors, verbose); |
| 348 | if (!(g_network->isSimulated() && VFSAsyncFile::checkInjectedError())) { |
| 349 | TraceEvent((errors || e) ? SevError : SevInfo, "BTreeIntegrityCheckResults") |
| 350 | .detail("Filename", filename) |
| 351 | .detail("ErrorTotal", errors); |
| 352 | if (e != nullptr) { |
| 353 | // e is a string containing 1 or more lines. Create a separate trace event for each line. |
| 354 | char* lineStart = e; |
| 355 | while (lineStart != nullptr) { |
| 356 | char* lineEnd = strstr(lineStart, "\n"); |
| 357 | if (lineEnd != nullptr) { |
| 358 | *lineEnd = '\0'; |
| 359 | ++lineEnd; |
| 360 | } |
| 361 | |
| 362 | // If the line length found is not zero then print a trace event |
| 363 | if (*lineStart != '\0') |
| 364 | TraceEvent(SevError, "BTreeIntegrityCheck") |
| 365 | .detail("Filename", filename) |
| 366 | .detail("ErrorDetail", lineStart); |
| 367 | lineStart = lineEnd; |
| 368 | } |
| 369 | } |
| 370 | CODE_PROBE(true, "BTree integrity checked"); |
| 371 | } |
| 372 | if (e) |
| 373 | sqlite3_free(e); |
| 374 | |
| 375 | return errors; |
| 376 | } |
| 377 | int checkAllPageChecksums(); |
| 378 | }; |
| 379 |
no test coverage detected