| 496 | } |
| 497 | |
| 498 | bool SQLiteBatch::ReadAtCursor(CDataStream& key, CDataStream& value, bool& complete) |
| 499 | { |
| 500 | complete = false; |
| 501 | |
| 502 | if (!m_cursor_init) return false; |
| 503 | |
| 504 | int res = sqlite3_step(m_cursor_stmt); |
| 505 | if (res == SQLITE_DONE) { |
| 506 | complete = true; |
| 507 | return true; |
| 508 | } |
| 509 | if (res != SQLITE_ROW) { |
| 510 | LogPrintf("SQLiteBatch::ReadAtCursor: Unable to execute cursor step: %s\n", sqlite3_errstr(res)); |
| 511 | return false; |
| 512 | } |
| 513 | |
| 514 | // Leftmost column in result is index 0 |
| 515 | const std::byte* key_data{BytePtr(sqlite3_column_blob(m_cursor_stmt, 0))}; |
| 516 | size_t key_data_size(sqlite3_column_bytes(m_cursor_stmt, 0)); |
| 517 | key.write({key_data, key_data_size}); |
| 518 | const std::byte* value_data{BytePtr(sqlite3_column_blob(m_cursor_stmt, 1))}; |
| 519 | size_t value_data_size(sqlite3_column_bytes(m_cursor_stmt, 1)); |
| 520 | value.write({value_data, value_data_size}); |
| 521 | return true; |
| 522 | } |
| 523 | |
| 524 | void SQLiteBatch::CloseCursor() |
| 525 | { |