int _mi_write_keypage(MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t page, int level, uchar *buff) { uint length; DBUG_ENTER("_mi_write_keypage"); if (page < info->s->base.keystart || page+keyinfo->block_length > info->state->key_file_length || (page & (MI_MIN_KEY_BLOCK_LENGTH-1))) { DBUG_PRINT("error",("Trying to write inside key status region: key_start: %lu length: %lu page: %lu", (long) info->s->base.keystart, (long) info->state->key_file_length, (long) page)); set_my_errno(EINVAL); DBUG_RETURN((-1)); } DBUG_PRINT("page",("write page at: %lu",(long) page)); DBUG_DUMP("buff",(uchar*) buff,mi_getint(buff)); if ((length=keyinfo->block_length) > IO_SIZE*2 && info->state->key_file_length != page+length) length= ((mi_getint(buff)+IO_SIZE-1) & (uint) ~(IO_SIZE-1)); DBUG_RETURN((key_cache_write(info->s->key_cache, keycache_thread_var(), info->s->kfile,page, level, (uchar*) buff,length, (uint) keyinfo->block_length, (int) ((info->lock_type != F_UNLCK) || info->s->delay_key_write)))); } /* mi_write_keypage */
int _nisam_write_keypage(register N_INFO *info, register N_KEYDEF *keyinfo, my_off_t page, uchar *buff) { reg3 uint length; #ifndef QQ /* Safety check */ if (page < info->s->base.keystart || page+keyinfo->base.block_length > info->s->state.key_file_length || page & (nisam_block_size-1)) { DBUG_PRINT("error",("Trying to write outside key region: %lu", (long) page)); my_errno=EINVAL; return(-1); } DBUG_PRINT("page",("write page at: %lu",(long) page,buff)); DBUG_DUMP("buff",(byte*) buff,getint(buff)); #endif if ((length=keyinfo->base.block_length) > IO_SIZE*2 && info->s->state.key_file_length != page+length) length= ((getint(buff)+IO_SIZE-1) & (uint) ~(IO_SIZE-1)); #ifdef HAVE_purify { length=getint(buff); bzero((byte*) buff+length,keyinfo->base.block_length-length); length=keyinfo->base.block_length; } #endif return (key_cache_write(info->s->kfile,page,(byte*) buff,length, (uint) keyinfo->base.block_length, (int) (info->lock_type != F_UNLCK))); } /* nisam_write_keypage */
int _nisam_dispose(register N_INFO *info, N_KEYDEF *keyinfo, my_off_t pos) { uint keynr= (uint) (keyinfo - info->s->keyinfo); ulong old_link; /* ulong is ok here */ DBUG_ENTER("_nisam_dispose"); old_link=info->s->state.key_del[keynr]; info->s->state.key_del[keynr]=(ulong) pos; DBUG_RETURN(key_cache_write(info->s->kfile,pos,(byte*) &old_link, sizeof(long), (uint) keyinfo->base.block_length, (int) (info->lock_type != F_UNLCK))); } /* _nisam_dispose */
int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos, int level) { my_off_t old_link; char buff[8]; DBUG_ENTER("_mi_dispose"); DBUG_PRINT("enter",("pos: %ld", (long) pos)); old_link=info->s->state.key_del[keyinfo->block_size]; info->s->state.key_del[keyinfo->block_size]=pos; mi_sizestore(buff,old_link); info->s->state.changed|= STATE_NOT_SORTED_PAGES; DBUG_RETURN(key_cache_write(info->s->key_cache, info->s->kfile, pos , level, buff, sizeof(buff), (uint) keyinfo->block_length, (int) (info->lock_type != F_UNLCK))); } /* _mi_dispose */
int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_off_t page, int level, uchar *buff) { reg3 uint length; DBUG_ENTER("_mi_write_keypage"); #ifndef FAST /* Safety check */ if (page < info->s->base.keystart || page+keyinfo->block_length > info->state->key_file_length || (page & (MI_MIN_KEY_BLOCK_LENGTH-1))) { DBUG_PRINT("error",("Trying to write inside key status region: key_start: %lu length: %lu page: %lu", (long) info->s->base.keystart, (long) info->state->key_file_length, (long) page)); my_errno=EINVAL; DBUG_RETURN((-1)); } DBUG_PRINT("page",("write page at: %lu",(long) page)); DBUG_DUMP("buff",(byte*) buff,mi_getint(buff)); #endif if ((length=keyinfo->block_length) > IO_SIZE*2 && info->state->key_file_length != page+length) length= ((mi_getint(buff)+IO_SIZE-1) & (uint) ~(IO_SIZE-1)); #ifdef HAVE_purify { length=mi_getint(buff); bzero((byte*) buff+length,keyinfo->block_length-length); length=keyinfo->block_length; } #endif DBUG_RETURN((key_cache_write(info->s->key_cache, info->s->kfile,page, level, (byte*) buff,length, (uint) keyinfo->block_length, (int) ((info->lock_type != F_UNLCK) || info->s->delay_key_write)))); } /* mi_write_keypage */