YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
extra= (ALIGN_SIZE(MARIA_MAX_DYN_BLOCK_HEADER)+MARIA_SPLIT_LENGTH+
MARIA_DYN_DELETE_BLOCK_HEADER);
reclength= (info->s->base.pack_reclength+
_ma_calc_total_blob_length(info,record)+ extra); #ifdef NOT_USED /* We now support big rows */ if (reclength > MARIA_DYN_MAX_ROW_LENGTH)
{
my_errno=HA_ERR_TO_BIG_ROW; return1;
} #endif
do
{ if (_ma_find_writepos(info,reclength,&filepos,&length)) goto err; if (_ma_write_part_record(info,filepos,length,
(info->append_insert_at_end ?
HA_OFFSET_ERROR : info->s->state.dellink),
(uchar**) &record,&reclength,&flag)) goto err;
} while (reclength);
DBUG_RETURN(0);
err:
DBUG_RETURN(1);
}
/* Get a block for data ; The given data-area must be used !! */
static my_bool unlink_deleted_block(MARIA_HA *info,
MARIA_BLOCK_INFO *block_info)
{
DBUG_ENTER("unlink_deleted_block"); if (block_info->filepos == info->s->state.dellink)
{ /* First deleted block; We can just use this ! */
info->s->state.dellink=block_info->next_filepos;
} else
{
MARIA_BLOCK_INFO tmp;
tmp.second_read=0; /* Unlink block from the previous block */ if (!(_ma_get_block_info(info, &tmp, info->dfile.file,
block_info->prev_filepos)
& BLOCK_DELETED))
DBUG_RETURN(1); /* Something is wrong */
mi_sizestore(tmp.header+4,block_info->next_filepos); if (info->s->file_write(info, tmp.header+4,8,
block_info->prev_filepos+4, MYF(MY_NABP)))
DBUG_RETURN(1); /* Unlink block from next block */ if (block_info->next_filepos != HA_OFFSET_ERROR)
{ if (!(_ma_get_block_info(info, &tmp, info->dfile.file,
block_info->next_filepos)
& BLOCK_DELETED))
DBUG_RETURN(1); /* Something is wrong */
mi_sizestore(tmp.header+12,block_info->prev_filepos); if (info->s->file_write(info, tmp.header+12,8,
block_info->next_filepos+12,
MYF(MY_NABP)))
DBUG_RETURN(1);
}
} /* We now have one less deleted block */
info->state->del--;
info->state->empty-= block_info->block_len;
info->s->state.split--;
/* First add a link from the last block to the new one */
error= update_backward_delete_link(info, info->s->state.dellink, filepos);
block_info.second_read=second_read; do
{ /* Remove block at 'filepos' */ if ((b_type= _ma_get_block_info(info, &block_info, info->dfile.file,
filepos))
& (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
BLOCK_FATAL_ERROR) ||
(length=(uint) (block_info.filepos-filepos) +block_info.block_len) <
MARIA_MIN_BLOCK_LENGTH)
{
_ma_set_fatal_error(info, HA_ERR_WRONG_IN_RECORD);
DBUG_RETURN(1);
} /* Check if next block is a delete block */
del_block.second_read=0;
remove_next_block=0; if (_ma_get_block_info(info, &del_block, info->dfile.file,
filepos + length) &
BLOCK_DELETED && del_block.block_len+length <
MARIA_DYN_MAX_BLOCK_LENGTH)
{ /* We can't remove this yet as this block may be the head block */
remove_next_block=1;
length+=del_block.block_len;
}
/* Now it's safe to unlink the deleted block directly after this one */ if (remove_next_block && unlink_deleted_block(info,&del_block))
error=1;
} while (!(b_type & BLOCK_LAST));
DBUG_RETURN(error);
}
/* Write a block to datafile */
int _ma_write_part_record(MARIA_HA *info,
my_off_t filepos, /* points at empty block */
ulong length, /* length of block */
my_off_t next_filepos,/* Next empty block */
uchar **record, /* pointer to record ptr */
ulong *reclength, /* length of *record */ int *flag) /* *flag == 0 if header */
{
ulong head_length,res_length,extra_length,long_block,del_length;
uchar *pos,*record_end;
my_off_t next_delete_block;
uchar temp[MARIA_SPLIT_LENGTH+MARIA_DYN_DELETE_BLOCK_HEADER];
DBUG_ENTER("_ma_write_part_record");
next_delete_block=HA_OFFSET_ERROR;
res_length=extra_length=0; if (length > *reclength + MARIA_SPLIT_LENGTH)
{ /* Splitt big block */
res_length=MY_ALIGN(length- *reclength - MARIA_EXTEND_BLOCK_LENGTH,
MARIA_DYN_ALIGN_SIZE);
length-= res_length; /* Use this for first part */
}
long_block= (length < 65520L && *reclength < 65520L) ? 0 : 1; if (length == *reclength+ 3 + long_block)
{ /* Block is exactly of the right length */
temp[0]=(uchar) (1+ *flag)+(uchar) long_block; /* Flag is 0 or 6 */ if (long_block)
{
mi_int3store(temp+1,*reclength);
head_length=4;
} else
{
mi_int2store(temp+1,*reclength);
head_length=3;
}
} elseif (length-long_block < *reclength+4)
{ /* To short block */ if (next_filepos == HA_OFFSET_ERROR)
next_filepos= (info->s->state.dellink != HA_OFFSET_ERROR &&
!info->append_insert_at_end ?
info->s->state.dellink : info->state->data_file_length); if (*flag == 0) /* First block */
{ if (*reclength > MARIA_MAX_BLOCK_LENGTH)
{
head_length= 16;
temp[0]=13;
mi_int4store(temp+1,*reclength);
mi_int3store(temp+5,length-head_length);
mi_sizestore(temp+8,next_filepos);
} else
{
head_length=5+8+long_block*2;
temp[0]=5+(uchar) long_block; if (long_block)
{
mi_int3store(temp+1,*reclength);
mi_int3store(temp+4,length-head_length);
mi_sizestore(temp+7,next_filepos);
} else
{
mi_int2store(temp+1,*reclength);
mi_int2store(temp+3,length-head_length);
mi_sizestore(temp+5,next_filepos);
}
}
} else
{
head_length=3+8+long_block;
temp[0]=11+(uchar) long_block; if (long_block)
{
mi_int3store(temp+1,length-head_length);
mi_sizestore(temp+4,next_filepos);
} else
{
mi_int2store(temp+1,length-head_length);
mi_sizestore(temp+3,next_filepos);
}
}
} else
{ /* Block with empty info last */
head_length=4+long_block;
extra_length= length- *reclength-head_length;
temp[0]= (uchar) (3+ *flag)+(uchar) long_block; /* 3,4 or 9,10 */ if (long_block)
{
mi_int3store(temp+1,*reclength);
temp[4]= (uchar) (extra_length);
} else
{
mi_int2store(temp+1,*reclength);
temp[3]= (uchar) (extra_length);
}
length= *reclength+head_length; /* Write only what is needed */
}
DBUG_DUMP("header", temp, head_length);
/* Make a long block for one write */
record_end= *record+length-head_length;
del_length=(res_length ? MARIA_DYN_DELETE_BLOCK_HEADER : 0);
bmove((*record-head_length), temp, head_length);
memcpy(temp,record_end,(size_t) (extra_length+del_length));
bzero(record_end, extra_length);
if (res_length)
{ /* Check first if we can join this block with the next one */
MARIA_BLOCK_INFO del_block;
my_off_t next_block=filepos+length+extra_length+res_length;
/* Create a delete link of the last part of the block */
pos=record_end+extra_length;
pos[0]= '\0';
mi_int3store(pos+1,res_length);
mi_sizestore(pos+4,info->s->state.dellink);
bfill(pos+12,8,255); /* End link */
next_delete_block=info->s->state.dellink;
info->s->state.dellink= filepos+length+extra_length;
info->state->del++;
info->state->empty+=res_length;
info->s->state.split++;
} if (info->opt_flag & WRITE_CACHE_USED &&
info->update & HA_STATE_WRITE_AT_END)
{ if (info->update & HA_STATE_EXTEND_BLOCK)
{
info->update&= ~HA_STATE_EXTEND_BLOCK; if (my_block_write(&info->rec_cache, *record-head_length,
length+extra_length+del_length,filepos)) goto err;
} elseif (my_b_write(&info->rec_cache, *record-head_length,
length+extra_length+del_length)) goto err;
} else
{
info->rec_cache.seek_not_done=1; if (info->s->file_write(info, *record-head_length,
length+extra_length+
del_length,filepos,info->s->write_flag)) goto err;
}
memcpy(record_end,temp,(size_t) (extra_length+del_length));
*record=record_end;
*reclength-=(length-head_length);
*flag=6;
if (del_length)
{ /* link the next delete block to this */ if (update_backward_delete_link(info, next_delete_block,
info->s->state.dellink)) goto err;
}
/* comparewithjustthereclengthaswe'regoing togetsomespacefromtheoldreplacedrecord
*/ if (unlikely(info->s->base.max_data_file_length -
info->state->data_file_length < reclength))
{ /* If new record isn't longer, we can go on safely */ if (info->cur_row.total_length < reclength)
{ if (info->s->base.max_data_file_length - info->state->data_file_length +
info->state->empty - info->state->del * MARIA_MAX_DYN_BLOCK_HEADER <
reclength - info->cur_row.total_length + MARIA_MAX_DYN_BLOCK_HEADER)
{
my_errno=HA_ERR_RECORD_FILE_FULL; goto err;
}
}
} /* Remember length for updated row if it's updated again */
info->cur_row.total_length= reclength;
while (reclength > 0)
{ if (filepos != info->s->state.dellink)
{
block_info.next_filepos= HA_OFFSET_ERROR; if ((error= _ma_get_block_info(info, &block_info, info->dfile.file,
filepos))
& (BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
BLOCK_FATAL_ERROR))
{
DBUG_PRINT("error",("Got wrong block info")); if (!(error & BLOCK_FATAL_ERROR))
_ma_set_fatal_error(info, HA_ERR_WRONG_IN_RECORD); goto err;
}
length=(ulong) (block_info.filepos-filepos) + block_info.block_len; if (length < reclength)
{
uint tmp=MY_ALIGN(reclength - length + 3 +
MY_TEST(reclength >= 65520L), MARIA_DYN_ALIGN_SIZE); /* Don't create a block bigger than MARIA_MAX_BLOCK_LENGTH */
tmp= MY_MIN(length+tmp, MARIA_MAX_BLOCK_LENGTH)-length; /* Check if we can extend this block */ if (block_info.filepos + block_info.block_len ==
info->state->data_file_length &&
info->state->data_file_length <
info->s->base.max_data_file_length-tmp)
{ /* extend file */
DBUG_PRINT("info",("Extending file with %d bytes",tmp)); if (info->cur_row.nextpos == info->state->data_file_length)
info->cur_row.nextpos+= tmp;
info->state->data_file_length+= tmp;
info->update|= HA_STATE_WRITE_AT_END | HA_STATE_EXTEND_BLOCK;
length+=tmp; if (info->s->tracked &&
_ma_update_tmp_file_size(&info->s->track_data,
MY_ALIGN(info->state->data_file_length,
MARIA_TRACK_INCREMENT_SIZE))) goto err;
} elseif (length < MARIA_MAX_BLOCK_LENGTH - MARIA_MIN_BLOCK_LENGTH)
{ /* Checkifnextblockisadeletedblock AbovewehaveMARIA_MIN_BLOCK_LENGTHtoavoidtheproblemwhere thenextblockissosmallitcan'tbesplitedwhichcould causeproblems
*/
MARIA_BLOCK_INFO del_block;
del_block.second_read=0; if (_ma_get_block_info(info, &del_block, info->dfile.file,
block_info.filepos + block_info.block_len) &
BLOCK_DELETED)
{ /* Use; Unlink it and extend the current block */
DBUG_PRINT("info",("Extending current block")); if (unlink_deleted_block(info,&del_block)) goto err; if ((length+=del_block.block_len) > MARIA_MAX_BLOCK_LENGTH)
{ /* Newblockwastoobig,linkoverflowpartbackto deletelist
*/
my_off_t next_pos;
ulong rest_length= length-MARIA_MAX_BLOCK_LENGTH;
set_if_bigger(rest_length, MARIA_MIN_BLOCK_LENGTH);
next_pos= del_block.filepos+ del_block.block_len - rest_length;
if (update_backward_delete_link(info, info->s->state.dellink,
next_pos))
DBUG_RETURN(1);
/* create delete link for data that didn't fit into the page */
del_block.header[0]=0;
mi_int3store(del_block.header+1, rest_length);
mi_sizestore(del_block.header+4,info->s->state.dellink);
bfill(del_block.header+12,8,255); if (info->s->file_write(info, del_block.header, 20,
next_pos, MYF(MY_NABP)))
DBUG_RETURN(1);
info->s->state.dellink= next_pos;
info->s->state.split++;
info->state->del++;
info->state->empty+= rest_length;
length-= rest_length;
}
}
}
}
} else
{ if (_ma_find_writepos(info,reclength,&filepos,&length)) goto err;
} if (_ma_write_part_record(info,filepos,length,block_info.next_filepos,
&record,&reclength,&flag)) goto err; if ((filepos=block_info.next_filepos) == HA_OFFSET_ERROR)
{ /* Start writing data on deleted blocks */
filepos=info->s->state.dellink;
}
}
if (block_info.next_filepos != HA_OFFSET_ERROR) if (delete_dynamic_record(info,block_info.next_filepos,1)) goto err;
file= info->dfile.file;
block_of_record= 0; /* First block of record is numbered as zero. */
block_info.second_read= 0; do
{ /* A corrupted table can have wrong pointers. (Bug# 19835) */ if (filepos == HA_OFFSET_ERROR) goto panic; if (info->opt_flag & WRITE_CACHE_USED &&
(info->rec_cache.pos_in_file < filepos +
MARIA_BLOCK_INFO_HEADER_LENGTH) &&
flush_io_cache(&info->rec_cache)) goto err;
info->rec_cache.seek_not_done=1; if ((b_type= _ma_get_block_info(info, &block_info, file, filepos)) &
(BLOCK_DELETED | BLOCK_ERROR | BLOCK_SYNC_ERROR |
BLOCK_FATAL_ERROR))
{ if (b_type & (BLOCK_SYNC_ERROR | BLOCK_DELETED))
my_errno=HA_ERR_RECORD_DELETED; goto err;
} if (block_of_record++ == 0) /* First block */
{
info->cur_row.total_length= block_info.rec_len; if (block_info.rec_len > (uint) share->base.max_pack_length) goto panic; if (share->base.blobs)
{ if (_ma_alloc_buffer(&info->rec_buff, &info->rec_buff_size,
block_info.rec_len +
share->base.extra_rec_buff_size,
MY_WME | share->malloc_flag)) goto err;
}
to= info->rec_buff;
left_length=block_info.rec_len;
} if (left_length < block_info.data_len || ! block_info.data_len) goto panic; /* Wrong linked record */ /* copy information that is already read */
{
uint offset= (uint) (block_info.filepos - filepos);
uint prefetch_len= (sizeof(block_info.header) - offset);
filepos+= sizeof(block_info.header);
if (prefetch_len > block_info.data_len)
prefetch_len= block_info.data_len; if (prefetch_len)
{
memcpy(to, block_info.header + offset, prefetch_len);
block_info.data_len-= prefetch_len;
left_length-= prefetch_len;
to+= prefetch_len;
}
} /* read rest of record from file */ if (block_info.data_len)
{ if (info->opt_flag & WRITE_CACHE_USED &&
info->rec_cache.pos_in_file < filepos + block_info.data_len &&
flush_io_cache(&info->rec_cache)) goto err; /* Whatapitythatthismethodisnotcalled'file_pread'andthat thereisnoequivalentwithoutseeking.Weareattheright positionalready.:(
*/ if (share->file_read(info, to, block_info.data_len,
filepos, MYF(MY_NABP))) goto panic;
left_length-=block_info.data_len;
to+=block_info.data_len;
}
filepos= block_info.next_filepos;
} while (left_length);
info->update|= HA_STATE_AKTIV; /* We have a aktive record */
fast_ma_writeinfo(info);
DBUG_RETURN(_ma_rec_unpack(info,buf,info->rec_buff,block_info.rec_len) !=
MY_FILE_ERROR ? 0 : my_errno);
/* The following blocks are identical to 1-6 without rec_len */ case7:
info->data_len=info->block_len=mi_uint2korr(header+1);
info->filepos=filepos+3; return return_val | BLOCK_LAST; case8:
info->data_len=info->block_len=mi_uint3korr(header+1);
info->filepos=filepos+4; return return_val | BLOCK_LAST;
err: if (!handler->in_check_table)
{ /* We may be scanning the table for new rows; Don't give an error */
_ma_set_fatal_error(handler, HA_ERR_WRONG_IN_RECORD);
} return BLOCK_ERROR;
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.99Angebot
(vorverarbeitet am 2026-10-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.