switch (op) {
case MDB_GET_CURRENT:
- if (!mc->mc_flags & C_INITIALIZED) {
+ if (!(mc->mc_flags & C_INITIALIZED)) {
rc = EINVAL;
} else {
MDB_page *mp = mc->mc_pg[mc->mc_top];
}
}
done:
+ /* If we succeeded and the key didn't exist before, make sure
+ * the cursor is marked valid.
+ */
+ if (!rc && insert)
+ mc->mc_flags |= C_INITIALIZED;
return rc;
}
if (F_ISSET(mc->mc_txn->mt_flags, MDB_TXN_RDONLY))
return EACCES;
- if (!mc->mc_flags & C_INITIALIZED)
+ if (!(mc->mc_flags & C_INITIALIZED))
return EINVAL;
rc = mdb_cursor_touch(mc);