From: Claude Brisson Date: Wed, 10 Apr 2013 12:40:49 +0000 (+0200) Subject: ITS#7570 fix MDB_GET_MULTIPLE and MDB_NEXT_MULTIPLE X-Git-Tag: OPENLDAP_REL_ENG_2_4_36~69^2~15 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=372b3ddb85bef953fb548fbf2b9ef0cba4e3c8ed;p=openldap ITS#7570 fix MDB_GET_MULTIPLE and MDB_NEXT_MULTIPLE --- diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb/mdb.c index 8a2875cf08..2a1a7b82c6 100644 --- a/libraries/liblmdb/mdb.c +++ b/libraries/liblmdb/mdb.c @@ -4377,6 +4377,8 @@ mdb_cursor_next(MDB_cursor *mc, MDB_val *key, MDB_val *data, MDB_cursor_op op) rc = mdb_cursor_first(&mc->mc_xcursor->mx_cursor, data, NULL); if (rc != MDB_SUCCESS) return rc; + } else if (mc->mc_db->md_flags & MDB_DUPSORT) { + mc->mc_xcursor->mx_cursor.mc_flags &= ~C_INITIALIZED; } } @@ -4790,8 +4792,9 @@ mdb_cursor_get(MDB_cursor *mc, MDB_val *key, MDB_val *data, break; } rc = MDB_SUCCESS; - if (!(mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) || - (mc->mc_xcursor->mx_cursor.mc_flags & C_EOF)) + if (!(mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED)) + goto fetch; + if (mc->mc_xcursor->mx_cursor.mc_flags & C_EOF) break; goto fetchm; case MDB_NEXT_MULTIPLE: @@ -4803,7 +4806,7 @@ mdb_cursor_get(MDB_cursor *mc, MDB_val *key, MDB_val *data, if (!(mc->mc_flags & C_INITIALIZED)) rc = mdb_cursor_first(mc, key, data); else - rc = mdb_cursor_next(mc, key, data, MDB_NEXT_DUP); + rc = mdb_cursor_next(mc, key, data, MDB_NEXT_NODUP); if (rc == MDB_SUCCESS) { if (mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) { MDB_cursor *mx; @@ -4814,7 +4817,11 @@ fetchm: data->mv_data = METADATA(mx->mc_pg[mx->mc_top]); mx->mc_ki[mx->mc_top] = NUMKEYS(mx->mc_pg[mx->mc_top])-1; } else { - rc = MDB_NOTFOUND; + MDB_node *leaf; +fetch: + leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]); + data->mv_size = NODEDSZ(leaf); + data->mv_data = NODEDATA(leaf); } } break;