]> git.sur5r.net Git - openldap/commitdiff
Add MDB_PREV_MULTIPLE
authorHoward Chu <hyc@openldap.org>
Thu, 7 Jan 2016 18:28:29 +0000 (18:28 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 7 Jan 2016 18:28:29 +0000 (18:28 +0000)
Logical counterpart to GET_MULTIPLE, NEXT_MULTIPLE

libraries/liblmdb/lmdb.h
libraries/liblmdb/mdb.c

index d616cabf95112feb5ef4e905adfdfea4c5de9df2..98e8c5127dcdf3073cb55cd0dcc0b1ec2a7142d7 100644 (file)
@@ -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
index 09f5132599de72945d06fceaacd7dd4f9e9d5977..5ef095f719cafd6c7fd184ea1ac375c08e441083 100644 (file)
@@ -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: