From a3de7c29ae2d3d365fabe4c436d09e3dbb6d1535 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 24 May 2013 11:08:25 -0700 Subject: [PATCH] ITS#7604 fix modrdn, base-scope search --- servers/slapd/back-mdb/add.c | 2 +- servers/slapd/back-mdb/dn2id.c | 3 ++- servers/slapd/back-mdb/modrdn.c | 2 +- servers/slapd/back-mdb/proto-mdb.h | 1 + servers/slapd/back-mdb/search.c | 1 + servers/slapd/back-mdb/tools.c | 2 +- 6 files changed, 7 insertions(+), 4 deletions(-) diff --git a/servers/slapd/back-mdb/add.c b/servers/slapd/back-mdb/add.c index 332d5c6b21..289eb321a2 100644 --- a/servers/slapd/back-mdb/add.c +++ b/servers/slapd/back-mdb/add.c @@ -338,7 +338,7 @@ txnReturn: op->ora_e->e_id = eid; /* dn2id index */ - rs->sr_err = mdb_dn2id_add( op, mcd, mcd, pid, 1, op->ora_e ); + rs->sr_err = mdb_dn2id_add( op, mcd, mcd, pid, 1, 1, op->ora_e ); mdb_cursor_close( mcd ); if ( rs->sr_err != 0 ) { Debug( LDAP_DEBUG_TRACE, diff --git a/servers/slapd/back-mdb/dn2id.c b/servers/slapd/back-mdb/dn2id.c index 22187b957a..d630741ef1 100644 --- a/servers/slapd/back-mdb/dn2id.c +++ b/servers/slapd/back-mdb/dn2id.c @@ -86,6 +86,7 @@ mdb_dn2id_add( MDB_cursor *mcd, ID pid, ID nsubs, + int upsub, Entry *e ) { struct mdb_info *mdb = (struct mdb_info *) op->o_bd->be_private; @@ -156,7 +157,7 @@ mdb_dn2id_add( op->o_tmpfree( d, op->o_tmpmemctx ); /* Add our subtree count to all superiors */ - if ( rc == 0 && nsubs && pid ) { + if ( rc == 0 && upsub && pid ) { ID subs; nid = pid; do { diff --git a/servers/slapd/back-mdb/modrdn.c b/servers/slapd/back-mdb/modrdn.c index de3a219721..f70457bdaf 100644 --- a/servers/slapd/back-mdb/modrdn.c +++ b/servers/slapd/back-mdb/modrdn.c @@ -492,7 +492,7 @@ txnReturn: /* add new DN */ rs->sr_err = mdb_dn2id_add( op, mc, mc, np ? np->e_id : p->e_id, - np ? nsubs : 0, &dummy ); + nsubs, np != NULL, &dummy ); if ( rs->sr_err != 0 ) { Debug(LDAP_DEBUG_TRACE, "<=- " LDAP_XSTRING(mdb_modrdn) diff --git a/servers/slapd/back-mdb/proto-mdb.h b/servers/slapd/back-mdb/proto-mdb.h index a0d84da3eb..5228d26a82 100644 --- a/servers/slapd/back-mdb/proto-mdb.h +++ b/servers/slapd/back-mdb/proto-mdb.h @@ -82,6 +82,7 @@ int mdb_dn2id_add( MDB_cursor *mcd, ID pid, ID nsubs, + int upsub, Entry *e ); int mdb_dn2id_delete( diff --git a/servers/slapd/back-mdb/search.c b/servers/slapd/back-mdb/search.c index 24f3ee4cbc..286d5e734e 100644 --- a/servers/slapd/back-mdb/search.c +++ b/servers/slapd/back-mdb/search.c @@ -538,6 +538,7 @@ dn2entry_retry: /* select candidates */ if ( op->oq_search.rs_scope == LDAP_SCOPE_BASE ) { rs->sr_err = base_candidate( op->o_bd, base, candidates ); + scopes[0].mid = 0; ncand = 1; } else { if ( op->ors_scope == LDAP_SCOPE_ONELEVEL ) { diff --git a/servers/slapd/back-mdb/tools.c b/servers/slapd/back-mdb/tools.c index 10e40f706d..7c3a423b68 100644 --- a/servers/slapd/back-mdb/tools.c +++ b/servers/slapd/back-mdb/tools.c @@ -471,7 +471,7 @@ static int mdb_tool_next_id( "=> mdb_tool_next_id: %s\n", text->bv_val, 0, 0 ); return rc; } - rc = mdb_dn2id_add( op, mcp, mcd, pid, 1, e ); + rc = mdb_dn2id_add( op, mcp, mcd, pid, 1, 1, e ); if ( rc ) { snprintf( text->bv_val, text->bv_len, "dn2id_add failed: %s (%d)", -- 2.39.5