| 574 | // --------------------------------------------------------------------------- |
| 575 | |
| 576 | bool DiskChunkCache::get_links(sqlite3_int64 chunk_id, sqlite3_int64 &link_id, |
| 577 | sqlite3_int64 &prev, sqlite3_int64 &next, |
| 578 | sqlite3_int64 &head, sqlite3_int64 &tail) { |
| 579 | auto stmt = |
| 580 | prepare("SELECT id, prev, next FROM linked_chunks WHERE chunk_id = ?"); |
| 581 | if (!stmt) |
| 582 | return false; |
| 583 | stmt->bindInt64(chunk_id); |
| 584 | { |
| 585 | const auto ret = stmt->execute(); |
| 586 | if (ret != SQLITE_ROW) { |
| 587 | pj_log(ctx_, PJ_LOG_ERROR, "%s", sqlite3_errmsg(hDB_)); |
| 588 | return false; |
| 589 | } |
| 590 | } |
| 591 | link_id = stmt->getInt64(); |
| 592 | prev = stmt->getInt64(); |
| 593 | next = stmt->getInt64(); |
| 594 | |
| 595 | stmt = prepare("SELECT head, tail FROM linked_chunks_head_tail"); |
| 596 | { |
| 597 | const auto ret = stmt->execute(); |
| 598 | if (ret != SQLITE_ROW) { |
| 599 | pj_log(ctx_, PJ_LOG_ERROR, "%s", sqlite3_errmsg(hDB_)); |
| 600 | return false; |
| 601 | } |
| 602 | } |
| 603 | head = stmt->getInt64(); |
| 604 | tail = stmt->getInt64(); |
| 605 | return true; |
| 606 | } |
| 607 | |
| 608 | // --------------------------------------------------------------------------- |
| 609 | |