@ -1424,17 +1424,19 @@ typedef struct MDB_xcursor {
unsigned char mx_dbflag ;
unsigned char mx_dbflag ;
} MDB_xcursor ;
} MDB_xcursor ;
/** Check if there is an inited xcursor, so #XCURSOR_REFRESH() is proper */
/** Check if there is an inited xcursor */
# define XCURSOR_INITED(mc) \
# define XCURSOR_INITED(mc) \
( ( mc ) - > mc_xcursor & & ( ( mc ) - > mc_xcursor - > mx_cursor . mc_flags & C_INITIALIZED ) )
( ( mc ) - > mc_xcursor & & ( ( mc ) - > mc_xcursor - > mx_cursor . mc_flags & C_INITIALIZED ) )
/** Update sub-page pointer, if any, in \b mc->mc_xcursor . Needed
/** Update the xcursor's sub-page pointer, if any, in \b mc. Needed
* when the node which contains the sub - page may have moved . Called
* when the node which contains the sub - page may have moved . Called
* with \ b mp = mc - > mc_pg [ mc - > mc_top ] , \ b ki = mc - > mc_ki [ mc - > mc_ top ] .
* with leaf page \ b mp = mc - > mc_pg [ \ b top ] .
*/
*/
# define XCURSOR_REFRESH(mc, mp, ki ) do { \
# define XCURSOR_REFRESH(mc, top, mp ) do { \
MDB_page * xr_pg = ( mp ) ; \
MDB_page * xr_pg = ( mp ) ; \
MDB_node * xr_node = NODEPTR ( xr_pg , ki ) ; \
MDB_node * xr_node ; \
if ( ! XCURSOR_INITED ( mc ) | | ( mc ) - > mc_ki [ top ] > = NUMKEYS ( xr_pg ) ) break ; \
xr_node = NODEPTR ( xr_pg , ( mc ) - > mc_ki [ top ] ) ; \
if ( ( xr_node - > mn_flags & ( F_DUPDATA | F_SUBDATA ) ) = = F_DUPDATA ) \
if ( ( xr_node - > mn_flags & ( F_DUPDATA | F_SUBDATA ) ) = = F_DUPDATA ) \
( mc ) - > mc_xcursor - > mx_cursor . mc_pg [ 0 ] = NODEDATA ( xr_node ) ; \
( mc ) - > mc_xcursor - > mx_cursor . mc_pg [ 0 ] = NODEDATA ( xr_node ) ; \
} while ( 0 )
} while ( 0 )
@ -2773,8 +2775,8 @@ done:
if ( m2 = = mc ) continue ;
if ( m2 = = mc ) continue ;
if ( m2 - > mc_pg [ mc - > mc_top ] = = mp ) {
if ( m2 - > mc_pg [ mc - > mc_top ] = = mp ) {
m2 - > mc_pg [ mc - > mc_top ] = np ;
m2 - > mc_pg [ mc - > mc_top ] = np ;
if ( XCURSOR_INITED ( m2 ) & & IS_LEAF ( np ) )
if ( IS_LEAF ( np ) )
XCURSOR_REFRESH ( m2 , np , m2 - > mc_ki [ mc - > mc_top ] ) ;
XCURSOR_REFRESH ( m2 , mc - > mc_top , np ) ;
}
}
}
}
}
}
@ -7772,8 +7774,7 @@ new_sub:
if ( m3 - > mc_ki [ i ] > = mc - > mc_ki [ i ] & & insert_key ) {
if ( m3 - > mc_ki [ i ] > = mc - > mc_ki [ i ] & & insert_key ) {
m3 - > mc_ki [ i ] + + ;
m3 - > mc_ki [ i ] + + ;
}
}
if ( XCURSOR_INITED ( m3 ) )
XCURSOR_REFRESH ( m3 , i , mp ) ;
XCURSOR_REFRESH ( m3 , mp , m3 - > mc_ki [ i ] ) ;
}
}
}
}
}
}
@ -7815,7 +7816,6 @@ put_sub:
MDB_xcursor * mx = mc - > mc_xcursor ;
MDB_xcursor * mx = mc - > mc_xcursor ;
unsigned i = mc - > mc_top ;
unsigned i = mc - > mc_top ;
MDB_page * mp = mc - > mc_pg [ i ] ;
MDB_page * mp = mc - > mc_pg [ i ] ;
int nkeys = NUMKEYS ( mp ) ;
for ( m2 = mc - > mc_txn - > mt_cursors [ mc - > mc_dbi ] ; m2 ; m2 = m2 - > mc_next ) {
for ( m2 = mc - > mc_txn - > mt_cursors [ mc - > mc_dbi ] ; m2 ; m2 = m2 - > mc_next ) {
if ( m2 = = mc | | m2 - > mc_snum < mc - > mc_snum ) continue ;
if ( m2 = = mc | | m2 - > mc_snum < mc - > mc_snum ) continue ;
@ -7823,8 +7823,8 @@ put_sub:
if ( m2 - > mc_pg [ i ] = = mp ) {
if ( m2 - > mc_pg [ i ] = = mp ) {
if ( m2 - > mc_ki [ i ] = = mc - > mc_ki [ i ] ) {
if ( m2 - > mc_ki [ i ] = = mc - > mc_ki [ i ] ) {
mdb_xcursor_init2 ( m2 , mx , new_dupdata ) ;
mdb_xcursor_init2 ( m2 , mx , new_dupdata ) ;
} else if ( ! insert_key & & m2 - > mc_ki [ i ] < nkeys ) {
} else if ( ! insert_key ) {
XCURSOR_REFRESH ( m2 , mp , m2 - > mc_ki [ i ] ) ;
XCURSOR_REFRESH ( m2 , i , mp ) ;
}
}
}
}
}
}
@ -8787,8 +8787,8 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
m3 - > mc_ki [ csrc - > mc_top ] = cdst - > mc_ki [ cdst - > mc_top ] ;
m3 - > mc_ki [ csrc - > mc_top ] = cdst - > mc_ki [ cdst - > mc_top ] ;
m3 - > mc_ki [ csrc - > mc_top - 1 ] + + ;
m3 - > mc_ki [ csrc - > mc_top - 1 ] + + ;
}
}
if ( XCURSOR_INITED ( m3 ) & & IS_LEAF ( mps ) )
if ( IS_LEAF ( mps ) )
XCURSOR_REFRESH ( m3 , m3 - > mc_pg [ csrc - > mc_top ] , m3 - > mc_ki [ csrc - > mc_top ] ) ;
XCURSOR_REFRESH ( m3 , csrc - > mc_top , m3 - > mc_pg [ csrc - > mc_top ] ) ;
}
}
} else
} else
/* Adding on the right, bump others down */
/* Adding on the right, bump others down */
@ -8809,8 +8809,8 @@ mdb_node_move(MDB_cursor *csrc, MDB_cursor *cdst, int fromleft)
} else {
} else {
m3 - > mc_ki [ csrc - > mc_top ] - - ;
m3 - > mc_ki [ csrc - > mc_top ] - - ;
}
}
if ( XCURSOR_INITED ( m3 ) & & IS_LEAF ( mps ) )
if ( IS_LEAF ( mps ) )
XCURSOR_REFRESH ( m3 , m3 - > mc_pg [ csrc - > mc_top ] , m3 - > mc_ki [ csrc - > mc_top ] ) ;
XCURSOR_REFRESH ( m3 , csrc - > mc_top , m3 - > mc_pg [ csrc - > mc_top ] ) ;
}
}
}
}
}
}
@ -9011,8 +9011,8 @@ mdb_page_merge(MDB_cursor *csrc, MDB_cursor *cdst)
m3 - > mc_ki [ top - 1 ] > csrc - > mc_ki [ top - 1 ] ) {
m3 - > mc_ki [ top - 1 ] > csrc - > mc_ki [ top - 1 ] ) {
m3 - > mc_ki [ top - 1 ] - - ;
m3 - > mc_ki [ top - 1 ] - - ;
}
}
if ( XCURSOR_INITED ( m3 ) & & IS_LEAF ( psrc ) )
if ( IS_LEAF ( psrc ) )
XCURSOR_REFRESH ( m3 , m3 - > mc_pg [ top ] , m3 - > mc_ki [ top ] ) ;
XCURSOR_REFRESH ( m3 , top , m3 - > mc_pg [ top ] ) ;
}
}
}
}
{
{
@ -9275,8 +9275,7 @@ mdb_cursor_del0(MDB_cursor *mc)
} else if ( m3 - > mc_ki [ mc - > mc_top ] > ki ) {
} else if ( m3 - > mc_ki [ mc - > mc_top ] > ki ) {
m3 - > mc_ki [ mc - > mc_top ] - - ;
m3 - > mc_ki [ mc - > mc_top ] - - ;
}
}
if ( XCURSOR_INITED ( m3 ) )
XCURSOR_REFRESH ( m3 , mc - > mc_top , mp ) ;
XCURSOR_REFRESH ( m3 , m3 - > mc_pg [ mc - > mc_top ] , m3 - > mc_ki [ mc - > mc_top ] ) ;
}
}
}
}
}
}
@ -9813,8 +9812,8 @@ mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, pgno_t newpgno
m3 - > mc_ki [ ptop ] > = mc - > mc_ki [ ptop ] ) {
m3 - > mc_ki [ ptop ] > = mc - > mc_ki [ ptop ] ) {
m3 - > mc_ki [ ptop ] + + ;
m3 - > mc_ki [ ptop ] + + ;
}
}
if ( XCURSOR_INITED ( m3 ) & & IS_LEAF ( mp ) )
if ( IS_LEAF ( mp ) )
XCURSOR_REFRESH ( m3 , m3 - > mc_pg [ m c - > mc_top ] , m3 - > mc_ki [ mc - > mc_top ] ) ;
XCURSOR_REFRESH ( m3 , mc - > mc_top , m3 - > mc_pg [ mc - > mc_top ] ) ;
}
}
}
}
DPRINTF ( ( " mp left: %d, rp left: %d " , SIZELEFT ( mp ) , SIZELEFT ( rp ) ) ) ;
DPRINTF ( ( " mp left: %d, rp left: %d " , SIZELEFT ( mp ) , SIZELEFT ( rp ) ) ) ;