~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2000-2001, 2003-2004 MySQL AB
2
3
   This program is free software; you can redistribute it and/or modify
4
   it under the terms of the GNU General Public License as published by
5
   the Free Software Foundation; version 2 of the License.
6
7
   This program is distributed in the hope that it will be useful,
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
   GNU General Public License for more details.
11
12
   You should have received a copy of the GNU General Public License
13
   along with this program; if not, write to the Free Software
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
/* Calculate a checksum for a row */
17
1130.3.28 by Monty Taylor
Moved heapdef.h and myisamdef.h to *_priv.h for easier filtering for include guard check.
18
#include "myisam_priv.h"
1 by brian
clean slate
19
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
20
using namespace drizzled;
21
22
internal::ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf)
1 by brian
clean slate
23
{
482 by Brian Aker
Remove uint.
24
  uint32_t i;
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
25
  internal::ha_checksum crc=0;
1 by brian
clean slate
26
  MI_COLUMNDEF *rec=info->s->rec;
27
28
  for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length)
29
  {
481 by Brian Aker
Remove all of uchar.
30
    const unsigned char *pos;
1 by brian
clean slate
31
    ulong length;
32
    switch (rec->type) {
33
    case FIELD_BLOB:
34
    {
35
      length=_mi_calc_blob_length(rec->length-
36
					portable_sizeof_char_ptr,
37
					buf);
212.6.12 by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove().
38
      memcpy(&pos, buf+rec->length - portable_sizeof_char_ptr, sizeof(char*));
1 by brian
clean slate
39
      break;
40
    }
41
    case FIELD_VARCHAR:
42
    {
482 by Brian Aker
Remove uint.
43
      uint32_t pack_length= HA_VARCHAR_PACKLENGTH(rec->length-1);
1 by brian
clean slate
44
      if (pack_length == 1)
481 by Brian Aker
Remove all of uchar.
45
        length= (ulong) *(unsigned char*) buf;
1 by brian
clean slate
46
      else
47
        length= uint2korr(buf);
48
      pos= buf+pack_length;
49
      break;
50
    }
51
    default:
52
      length=rec->length;
53
      pos=buf;
54
      break;
55
    }
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
56
    crc=internal::my_checksum(crc, pos ? pos : (unsigned char*) "", length);
1 by brian
clean slate
57
  }
58
  return crc;
59
}
60
61
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
62
internal::ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *pos)
1 by brian
clean slate
63
{
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
64
  return internal::my_checksum(0, pos, info->s->base.reclength);
1 by brian
clean slate
65
}