ITS#10233 - fix idl intersection

The `mdb_idl_intersection()` and `wt_idl_intersection()` functions derived from back-bdb return wrong results.

expect:
[1, 3] ∩ [2] = []

actual:
[1, 3] ∩ [2] = [2]

also
- Add scope checking for back-wt
- fix compiler warning
This commit is contained in:
HAMANO Tsukasa 2024-06-26 10:51:17 +09:00 committed by Quanah Gibson-Mount
parent 836cb913ef
commit efa9f173d2
4 changed files with 11 additions and 9 deletions

View File

@ -727,7 +727,9 @@ mdb_idl_intersection(
if ( idmin > idmax ) {
a[0] = 0;
return 0;
} else if ( idmin == idmax ) {
} else if ( idmin == idmax &&
(( MDB_IDL_FIRST(a) == MDB_IDL_LAST(b)) ||
( MDB_IDL_FIRST(b) == MDB_IDL_LAST(a)))) {
a[0] = 1;
a[1] = idmin;
return 0;

View File

@ -232,7 +232,7 @@ int wt_entry_return(
return 0;
}
/* Our entries are allocated in two blocks; the data comes from
/* Our entries are allocated in two blocks; the data comes from
* the db itself and the Entry structure and associated pointers
* are allocated in entry_decode. The db data pointer is saved
* in e_bv.
@ -256,6 +256,7 @@ int wt_entry_return(
}
entry_free( e );
return 0;
}
int wt_entry_release(

View File

@ -53,13 +53,10 @@ void wt_idl_dump( ID *ids )
} else {
ID i;
Debug( LDAP_DEBUG_ANY, "IDL: size %ld", (long) ids[0] );
Debug( LDAP_DEBUG_ANY, "IDL: size %ld\n", (long) ids[0] );
for( i=1; i<=ids[0]; i++ ) {
if( i % 16 == 1 ) {
Debug( LDAP_DEBUG_ANY, "\n" );
}
Debug( LDAP_DEBUG_ANY, " %02lx", (long) ids[i] );
Debug( LDAP_DEBUG_ANY, " %ld\n", (long) ids[i] );
}
Debug( LDAP_DEBUG_ANY, "\n" );
@ -282,7 +279,9 @@ wt_idl_intersection(
if ( idmin > idmax ) {
a[0] = 0;
return 0;
} else if ( idmin == idmax ) {
} else if ( idmin == idmax &&
(( WT_IDL_FIRST(a) == WT_IDL_LAST(b)) ||
( WT_IDL_FIRST(b) == WT_IDL_LAST(a)))) {
a[0] = 1;
a[1] = idmin;
return 0;

View File

@ -606,7 +606,7 @@ loop_begin:
if ( id == base->e_id ) scopeok = 1;
break;
case LDAP_SCOPE_ONELEVEL:
scopeok = 1;
scopeok = dnIsSuffixScope(&e->e_nname, &base->e_nname, LDAP_SCOPE_ONELEVEL);
break;
case LDAP_SCOPE_CHILDREN:
if ( id == base->e_id ) break;