diff options
author | Howard Chu <hyc@openldap.org> | 2016-01-07 18:28:29 +0000 |
---|---|---|
committer | Howard Chu <hyc@openldap.org> | 2016-01-07 18:28:29 +0000 |
commit | 27b1c5f366dca98cfe6924dec5d7c989fbd91dba (patch) | |
tree | 12801e64100fb35b89ebd8789677c969b775c799 | |
parent | 5db0b54ca127eda9777771b3a5e3c956491e7660 (diff) | |
download | lmdb-27b1c5f366dca98cfe6924dec5d7c989fbd91dba.tar.gz lmdb-27b1c5f366dca98cfe6924dec5d7c989fbd91dba.tar.bz2 lmdb-27b1c5f366dca98cfe6924dec5d7c989fbd91dba.zip |
Add MDB_PREV_MULTIPLE
Logical counterpart to GET_MULTIPLE, NEXT_MULTIPLE
-rw-r--r-- | libraries/liblmdb/lmdb.h | 4 | ||||
-rw-r--r-- | libraries/liblmdb/mdb.c | 22 |
2 files changed, 25 insertions, 1 deletions
diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h index d616cab..98e8c51 100644 --- a/libraries/liblmdb/lmdb.h +++ b/libraries/liblmdb/lmdb.h @@ -392,7 +392,9 @@ typedef enum MDB_cursor_op { MDB_PREV_NODUP, /**< Position at last data item of previous key */ MDB_SET, /**< Position at specified key */ MDB_SET_KEY, /**< Position at specified key, return key + data */ - MDB_SET_RANGE /**< Position at first key greater than or equal to specified key. */ + MDB_SET_RANGE, /**< Position at first key greater than or equal to specified key. */ + MDB_PREV_MULTIPLE /**< Position at previous page and return key and up to + a page of duplicate data items. Only for #MDB_DUPFIXED */ } MDB_cursor_op; /** @defgroup errors Return Codes diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 09f5132..5ef095f 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -6997,6 +6997,28 @@ fetchm: } } break; + case MDB_PREV_MULTIPLE: + if (data == NULL) { + rc = EINVAL; + break; + } + if (!(mc->mc_db->md_flags & MDB_DUPFIXED)) { + rc = MDB_INCOMPATIBLE; + break; + } + if (!(mc->mc_flags & C_INITIALIZED)) + rc = mdb_cursor_first(mc, key, data); + else { + MDB_cursor *mx = &mc->mc_xcursor->mx_cursor; + if (mx->mc_flags & C_INITIALIZED) { + rc = mdb_cursor_sibling(mx, 0); + if (rc == MDB_SUCCESS) + goto fetchm; + } else { + rc = MDB_NOTFOUND; + } + } + break; case MDB_NEXT: case MDB_NEXT_DUP: case MDB_NEXT_NODUP: |