Improve Rhizome list cursor

Separate function rhizome_list_commit() which, if not called, causes the
next list re-query to include the last row that was fetched with
rhizome_list_next(), rather than excluding it.
This commit is contained in:
Andrew Bettison 2013-11-08 18:29:49 +10:30
parent 32ce7f5ed9
commit a62b6f9250
2 changed files with 10 additions and 4 deletions

View File

@ -631,6 +631,7 @@ struct rhizome_list_cursor {
int rhizome_list_open(sqlite_retry_state *, struct rhizome_list_cursor *); int rhizome_list_open(sqlite_retry_state *, struct rhizome_list_cursor *);
int rhizome_list_next(sqlite_retry_state *, struct rhizome_list_cursor *); int rhizome_list_next(sqlite_retry_state *, struct rhizome_list_cursor *);
void rhizome_list_commit(struct rhizome_list_cursor *);
void rhizome_list_release(struct rhizome_list_cursor *); void rhizome_list_release(struct rhizome_list_cursor *);
/* one manifest is required per candidate, plus a few spare. /* one manifest is required per candidate, plus a few spare.

View File

@ -1487,10 +1487,6 @@ int rhizome_list_next(sqlite_retry_state *retry, struct rhizome_list_cursor *c)
int64_t q_inserttime = sqlite3_column_int64(c->_statement, 3); int64_t q_inserttime = sqlite3_column_int64(c->_statement, 3);
const char *q_author = (const char *) sqlite3_column_text(c->_statement, 4); const char *q_author = (const char *) sqlite3_column_text(c->_statement, 4);
c->rowid = sqlite3_column_int64(c->_statement, 5); c->rowid = sqlite3_column_int64(c->_statement, 5);
if (c->rowid > c->_rowid_first)
c->_rowid_first = c->rowid;
if (c->_rowid_last == 0 || c->rowid < c->_rowid_last)
c->_rowid_last = c->rowid;
sid_t *author = NULL; sid_t *author = NULL;
if (q_author) { if (q_author) {
author = alloca(sizeof *author); author = alloca(sizeof *author);
@ -1528,6 +1524,15 @@ int rhizome_list_next(sqlite_retry_state *retry, struct rhizome_list_cursor *c)
OUT(); OUT();
} }
void rhizome_list_commit(struct rhizome_list_cursor *c)
{
assert(c->rowid != 0);
if (c->rowid > c->_rowid_first)
c->_rowid_first = c->rowid;
if (c->_rowid_last == 0 || c->rowid < c->_rowid_last)
c->_rowid_last = c->rowid;
}
void rhizome_list_release(struct rhizome_list_cursor *c) void rhizome_list_release(struct rhizome_list_cursor *c)
{ {
if (c->manifest) { if (c->manifest) {