| 106 | } |
| 107 | |
| 108 | struct db_stmt *db_datastore_next(const tal_t *ctx, |
| 109 | struct db_stmt *stmt, |
| 110 | const char **startkey, |
| 111 | const char ***key, |
| 112 | const u8 **data, |
| 113 | u64 *generation) |
| 114 | { |
| 115 | if (!db_step(stmt)) |
| 116 | return tal_free(stmt); |
| 117 | |
| 118 | *key = db_col_datastore_key(ctx, stmt, "key"); |
| 119 | |
| 120 | /* We select from startkey onwards, so once we're past it, stop */ |
| 121 | if (startkey && !datastore_key_startswith(*key, startkey)) { |
| 122 | db_col_ignore(stmt, "data"); |
| 123 | db_col_ignore(stmt, "generation"); |
| 124 | return tal_free(stmt); |
| 125 | } |
| 126 | |
| 127 | if (data) |
| 128 | *data = db_col_arr(ctx, stmt, "data", u8); |
| 129 | else |
| 130 | db_col_ignore(stmt, "data"); |
| 131 | |
| 132 | if (generation) |
| 133 | *generation = db_col_u64(stmt, "generation"); |
| 134 | else |
| 135 | db_col_ignore(stmt, "generation"); |
| 136 | |
| 137 | return stmt; |
| 138 | } |
| 139 | |
| 140 | struct db_stmt *db_datastore_first(const tal_t *ctx, |
| 141 | struct db *db, |
no test coverage detected