]> git.sur5r.net Git - openldap/commitdiff
More fixes for MDB_LAST
authorHoward Chu <hyc@symas.com>
Tue, 2 Apr 2013 02:49:40 +0000 (19:49 -0700)
committerHoward Chu <hyc@symas.com>
Tue, 2 Apr 2013 02:49:40 +0000 (19:49 -0700)
Make sure C_INITIALIZED gets set on successful call

libraries/liblmdb/mdb.c
libraries/liblmdb/mtest.c

index 5980384d8d48036f4ce13d9f901903a4bf881dc0..28f34522f7cac11924444b64ed6d149b707f20e3 100644 (file)
@@ -4669,9 +4669,9 @@ mdb_cursor_last(MDB_cursor *mc, MDB_val *key, MDB_val *data)
        }
        assert(IS_LEAF(mc->mc_pg[mc->mc_top]));
 
-       mc->mc_flags |= C_INITIALIZED|C_EOF;
        mc->mc_ki[mc->mc_top] = NUMKEYS(mc->mc_pg[mc->mc_top]) - 1;
        }
+       mc->mc_flags |= C_INITIALIZED|C_EOF;
        leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
 
        if (IS_LEAF2(mc->mc_pg[mc->mc_top])) {
index 42b865850738b47157c93ad595624e396a85f660..55cdd43c38711793e77737da77e5f967032dbcaa 100644 (file)
@@ -101,6 +101,11 @@ int main(int argc,char * argv[])
                                (int) key.mv_size,  (char *) key.mv_data,
                                (int) data.mv_size, (char *) data.mv_data);
                }
+               printf("Cursor last\n");
+               rc = mdb_cursor_get(cursor, &key, &data, MDB_LAST);
+               printf("key: %.*s, data: %.*s\n",
+                       (int) key.mv_size,  (char *) key.mv_data,
+                       (int) data.mv_size, (char *) data.mv_data);
                printf("Cursor prev\n");
                while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_PREV)) == 0) {
                        printf("key: %.*s, data: %.*s\n",