Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record current cursor #31

Open
stephenmathieson opened this issue Jan 13, 2014 · 5 comments
Open

Record current cursor #31

stephenmathieson opened this issue Jan 13, 2014 · 5 comments

Comments

@stephenmathieson
Copy link
Member

Sophia gets confused when there's more than one cursor open on the same db.

Thoughts on sphia_t->cursor?

The following fails to remove "mykey" (assuming it's there).

void test_case() {
  void *c = sp_cursor(self->db, SPGT, NULL, 0);
  int count = sphia_count(self);
  sp_destroy(c);

  assert(0 == sphia_rm(self, "mykey"));
}
@jwerle
Copy link
Member

jwerle commented Jan 13, 2014

I love it!

@stephenmathieson
Copy link
Member Author

OK, cool. Should sphia_free destroy it if it's open?

EDIT: is there a way to check if a cursor is open?

@jwerle
Copy link
Member

jwerle commented Jan 13, 2014

I think it should. We should consider sphia_cursor which can handle closing and opening new cursors, etc. I'm not sure how to check if one is open but I can dive into the source and check it out

@stephenmathieson
Copy link
Member Author

I meant if (check_if_cursor_is_open(self->cursor)) sp_destroy(self->cursor);. I'm just not sure how to implement check_if_cursor_is_open.

Instead of sphia_cursor, I think we should just fail if there's an open cursor attached to self. For example:

int whatever(sphia_t *self) {
  if (magic(self->cursor)) {
    self->error = "Cursor already open, dummy!";
    return -1;
  }
  // . . . 
  return 0;
}

@jwerle
Copy link
Member

jwerle commented Jan 13, 2014

Hmm, yeah I like this too. We just have to experiment !

@stephenmathieson stephenmathieson removed their assignment Apr 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants