00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "myisam_priv.h"
00019
00020 using namespace drizzled;
00021
00022 internal::ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf)
00023 {
00024 uint32_t i;
00025 internal::ha_checksum crc=0;
00026 MI_COLUMNDEF *rec=info->s->rec;
00027
00028 for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length)
00029 {
00030 const unsigned char *pos;
00031 ulong length;
00032 switch (rec->type) {
00033 case FIELD_BLOB:
00034 {
00035 length=_mi_calc_blob_length(rec->length-
00036 portable_sizeof_char_ptr,
00037 buf);
00038 memcpy(&pos, buf+rec->length - portable_sizeof_char_ptr, sizeof(char*));
00039 break;
00040 }
00041 case FIELD_VARCHAR:
00042 {
00043 uint32_t pack_length= ha_varchar_packlength(rec->length-1);
00044 if (pack_length == 1)
00045 length= (ulong) *(unsigned char*) buf;
00046 else
00047 length= uint2korr(buf);
00048 pos= buf+pack_length;
00049 break;
00050 }
00051 default:
00052 length=rec->length;
00053 pos=buf;
00054 break;
00055 }
00056 crc=internal::my_checksum(crc, pos ? pos : (unsigned char*) "", length);
00057 }
00058 return crc;
00059 }
00060
00061
00062 internal::ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *pos)
00063 {
00064 return internal::my_checksum(0, pos, info->s->base.reclength);
00065 }