mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 15:24:16 +01:00
155193a6e2
Fixed bug in duplicate key handling for block records during repair All read-row methods now return error number in case of error Don't calculate checksum for null fields Fixed bug when running maria_read_log with -o BUILD/SETUP.sh: Added STACK_DIRECTION BUILD/compile-pentium-debug-max: Moved STACK_DIRECTION to SETUP include/myisam.h: Added extra parameter to write_key storage/maria/ma_blockrec.c: Added applying of undo for updates Fixed indentation Removed some not needed casts Fixed wrong logging of CLR record Split ma_update_block_record to two functions to be able to reuse it from undo-applying Simplify filling of packed fields ma_record_block_record) now returns error number on failure Sligtly changed log record information for undo-update storage/maria/ma_check.c: Fixed bug in duplicate key handling for block records during repair storage/maria/ma_checksum.c: Don't calculate checksum for null fields storage/maria/ma_dynrec.c: _ma_read_dynamic_reocrd() now returns error number on error Rest of the changes are code simplification and indentation fixes storage/maria/ma_locking.c: Added comment storage/maria/ma_loghandler.c: More debugging Removed printing of total_record_length as this was always same as record_length storage/maria/ma_open.c: Allocate bitmap for changed fields storage/maria/ma_packrec.c: read_record now returns error number on error storage/maria/ma_recovery.c: Fixed wrong arguments to undo_row_update storage/maria/ma_statrec.c: read_record now returns error number on error (not 1) Code simplification storage/maria/ma_test1.c: Added exit possibility after update phase (to test undo of updates) storage/maria/maria_def.h: Include bitmap header file storage/maria/maria_read_log.c: Fixed bug when running with -o
72 lines
2.2 KiB
C
72 lines
2.2 KiB
C
/* Copyright (C) 2006 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
/* Calculate a checksum for a row */
|
|
|
|
#include "maria_def.h"
|
|
|
|
ha_checksum _ma_checksum(MARIA_HA *info, const uchar *record)
|
|
{
|
|
ha_checksum crc=0;
|
|
MARIA_COLUMNDEF *column= info->s->columndef;
|
|
MARIA_COLUMNDEF *column_end= column+ info->s->base.fields;
|
|
|
|
if (info->s->base.null_bytes)
|
|
crc= my_checksum(crc, record, info->s->base.null_bytes);
|
|
|
|
for ( ; column != column_end ; column++)
|
|
{
|
|
const uchar *pos= record + column->offset;
|
|
ulong length;
|
|
|
|
if (record[column->null_pos] & column->null_bit)
|
|
continue; /* Null field */
|
|
|
|
switch (column->type) {
|
|
case FIELD_BLOB:
|
|
{
|
|
uint blob_size_length= column->length- portable_sizeof_char_ptr;
|
|
length= _ma_calc_blob_length(blob_size_length, pos);
|
|
if (length)
|
|
{
|
|
memcpy((char*) &pos, pos + blob_size_length, sizeof(char*));
|
|
crc= my_checksum(crc, pos, length);
|
|
}
|
|
continue;
|
|
}
|
|
case FIELD_VARCHAR:
|
|
{
|
|
uint pack_length= column->fill_length;
|
|
if (pack_length == 1)
|
|
length= (ulong) *(uchar*) pos;
|
|
else
|
|
length= uint2korr(pos);
|
|
pos+= pack_length; /* Skip length information */
|
|
break;
|
|
}
|
|
default:
|
|
length= column->length;
|
|
break;
|
|
}
|
|
crc= my_checksum(crc, pos, length);
|
|
}
|
|
return crc;
|
|
}
|
|
|
|
|
|
ha_checksum _ma_static_checksum(MARIA_HA *info, const uchar *pos)
|
|
{
|
|
return my_checksum(0, pos, info->s->base.reclength);
|
|
}
|