mariadb/storage/myisam/mi_checksum.c
monty@mysql.com/narttu.mysql.fi 7887babe69 Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1
- Reserver namespace and place in frm for TABLE_CHECKSUM and PAGE_CHECKSUM create options
- Added syncing of directory when creating .frm files
- Portability fixes
- Added missing cast that could cause bugs
- Code cleanups
- Made some bit functions inline
- Moved things out of myisam.h to my_handler.h to make them more accessable
- Renamed some myisam variables and defines to make them more globaly usable (as they are used outside of MyISAM)
- Fixed bugs in error conditions
- Use compiler time asserts instead of run time
- Fixed indentation
HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP as the old name was wrong
(Added a define for old value to ensure we don't break any old code)
Added HA_EXTRA_PREPARE_FOR_RENAME as a signal for rename (before we used a DROP signal which is wrong)
- Initialize error messages early to get better errors when mysqld or an engine fails to start
- Fix windows bug that query_performance_frequency was not initialized if registry code failed
- thread_stack -> my_thread_stack_size
2007-10-11 18:07:40 +03:00

64 lines
1.7 KiB
C

/* Copyright (C) 2000-2001, 2003-2004 MySQL 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 "myisamdef.h"
ha_checksum mi_checksum(MI_INFO *info, const uchar *buf)
{
uint i;
ha_checksum crc=0;
MI_COLUMNDEF *rec=info->s->rec;
for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length)
{
const uchar *pos;
ulong length;
switch (rec->type) {
case FIELD_BLOB:
{
length=_mi_calc_blob_length(rec->length-
portable_sizeof_char_ptr,
buf);
memcpy((char*) &pos, buf+rec->length- portable_sizeof_char_ptr,
sizeof(char*));
break;
}
case FIELD_VARCHAR:
{
uint pack_length= HA_VARCHAR_PACKLENGTH(rec->length-1);
if (pack_length == 1)
length= (ulong) *(uchar*) buf;
else
length= uint2korr(buf);
pos= buf+pack_length;
break;
}
default:
length=rec->length;
pos=buf;
break;
}
crc=my_checksum(crc, pos ? pos : (uchar*) "", length);
}
return crc;
}
ha_checksum mi_static_checksum(MI_INFO *info, const uchar *pos)
{
return my_checksum(0, pos, info->s->base.reclength);
}