- if( lastOp == opFind && lastFind.id >= 0 ) {// chk find/delete
- char *kp = 0;
- if_ret( db->addrRead_(lastFind,kp) );
- if( !compare(this->key,kp) ) last = &lastFind;
- }
- ret = chkFind(this->key,last);
- if_ret( ret );
- if( ret ) {
- ret = 0; pageId s = last->id;
- keyBlock *sbb; Page *spp; char *sn;
- if_err( db->indexRead(s,1,sbb,spp,sn) );
- int slen = spp->iused() - kdSz;
- if( slen >= kdSz ) { // at least 1 key will remain
- if( lastAccess.id >= 0 ) { // found here
- spp->iused(slen); // delete
- int k = lastAccess.offset - sizeof(keyBlock);
- if( slen > k ) {
- char *kp = sn + k;
- memmove(kp,kp+kdSz,slen-k);
- }
- ret = 1;
- }
- else
- r = s; // search just this block
- }
+ pgRef loc;
+ ret = chkDelete(loc, key);
+ if( ret == errNotFound ) { // in exterior block
+ r = loc.id; ret = 0;