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
|
|
1802.10.2
by Monty Taylor
Update all of the copyright headers to include the correct address. |
14 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
|
1
by brian
clean slate |
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" |
2241.4.36
by Stewart Smith
move my_checksum() into myisam (only used there). This patch keeps the internal namespace for the ha_checksum typedef, which should possibly be changed |
19 |
#include <zlib.h> |
1
by brian
clean slate |
20 |
|
1280.1.10
by Monty Taylor
Put everything in drizzled into drizzled namespace. |
21 |
using namespace drizzled; |
22 |
||
2241.4.36
by Stewart Smith
move my_checksum() into myisam (only used there). This patch keeps the internal namespace for the ha_checksum typedef, which should possibly be changed |
23 |
/*
|
24 |
Calculate a long checksum for a memoryblock.
|
|
25 |
||
26 |
SYNOPSIS
|
|
27 |
my_checksum()
|
|
28 |
crc start value for crc
|
|
29 |
pos pointer to memory block
|
|
30 |
length length of the block
|
|
31 |
*/
|
|
32 |
||
2241.4.37
by Stewart Smith
remove the drizzled::internal namespace prefix from teh typedef for ha_checksum - it's just for myisam now |
33 |
static ha_checksum my_checksum(ha_checksum crc, const unsigned char *pos, size_t length) |
2241.4.36
by Stewart Smith
move my_checksum() into myisam (only used there). This patch keeps the internal namespace for the ha_checksum typedef, which should possibly be changed |
34 |
{
|
2241.4.37
by Stewart Smith
remove the drizzled::internal namespace prefix from teh typedef for ha_checksum - it's just for myisam now |
35 |
return ha_checksum(crc32((uint32_t)crc, pos, uInt(length))); |
2241.4.36
by Stewart Smith
move my_checksum() into myisam (only used there). This patch keeps the internal namespace for the ha_checksum typedef, which should possibly be changed |
36 |
}
|
37 |
||
2241.4.37
by Stewart Smith
remove the drizzled::internal namespace prefix from teh typedef for ha_checksum - it's just for myisam now |
38 |
ha_checksum mi_checksum(MI_INFO *info, const unsigned char *buf) |
1
by brian
clean slate |
39 |
{
|
482
by Brian Aker
Remove uint. |
40 |
uint32_t i; |
2241.4.37
by Stewart Smith
remove the drizzled::internal namespace prefix from teh typedef for ha_checksum - it's just for myisam now |
41 |
ha_checksum crc=0; |
1
by brian
clean slate |
42 |
MI_COLUMNDEF *rec=info->s->rec; |
43 |
||
44 |
for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length) |
|
45 |
{
|
|
481
by Brian Aker
Remove all of uchar. |
46 |
const unsigned char *pos; |
1
by brian
clean slate |
47 |
ulong length; |
48 |
switch (rec->type) { |
|
49 |
case FIELD_BLOB: |
|
50 |
{
|
|
51 |
length=_mi_calc_blob_length(rec->length- |
|
52 |
portable_sizeof_char_ptr, |
|
53 |
buf); |
|
212.6.12
by Mats Kindahl
Removing redundant use of casts in MyISAM storage for memcmp(), memcpy(), memset(), and memmove(). |
54 |
memcpy(&pos, buf+rec->length - portable_sizeof_char_ptr, sizeof(char*)); |
1
by brian
clean slate |
55 |
break; |
56 |
}
|
|
57 |
case FIELD_VARCHAR: |
|
58 |
{
|
|
1892.5.2
by Gustaf Thorslund
Replaced macros with functions/templates. Part of blueprint: |
59 |
uint32_t pack_length= ha_varchar_packlength(rec->length-1); |
1
by brian
clean slate |
60 |
if (pack_length == 1) |
481
by Brian Aker
Remove all of uchar. |
61 |
length= (ulong) *(unsigned char*) buf; |
1
by brian
clean slate |
62 |
else
|
63 |
length= uint2korr(buf); |
|
64 |
pos= buf+pack_length; |
|
65 |
break; |
|
66 |
}
|
|
67 |
default: |
|
68 |
length=rec->length; |
|
69 |
pos=buf; |
|
70 |
break; |
|
71 |
}
|
|
2241.4.36
by Stewart Smith
move my_checksum() into myisam (only used there). This patch keeps the internal namespace for the ha_checksum typedef, which should possibly be changed |
72 |
crc=my_checksum(crc, pos ? pos : (unsigned char*) "", length); |
1
by brian
clean slate |
73 |
}
|
74 |
return crc; |
|
75 |
}
|
|
76 |
||
77 |
||
2241.4.37
by Stewart Smith
remove the drizzled::internal namespace prefix from teh typedef for ha_checksum - it's just for myisam now |
78 |
ha_checksum mi_static_checksum(MI_INFO *info, const unsigned char *pos) |
1
by brian
clean slate |
79 |
{
|
2241.4.36
by Stewart Smith
move my_checksum() into myisam (only used there). This patch keeps the internal namespace for the ha_checksum typedef, which should possibly be changed |
80 |
return my_checksum(0, pos, info->s->base.reclength); |
1
by brian
clean slate |
81 |
}
|