Commit 59343fc8 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1619

get cmp function for ints working correctly

git-svn-id: file:///svn/mysql/tokudb-engine/src@10727 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0c2ffe6c
...@@ -96,7 +96,7 @@ uchar* unpack_toku_int(uchar* to_mysql, uchar* from_tokudb, u_int32_t num_bytes) ...@@ -96,7 +96,7 @@ uchar* unpack_toku_int(uchar* to_mysql, uchar* from_tokudb, u_int32_t num_bytes)
return from_tokudb+num_bytes; return from_tokudb+num_bytes;
} }
int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) { int cmp_toku_int (uchar* a_buf, uchar* b_buf, bool is_unsigned, u_int32_t num_bytes) {
int ret_val = 0; int ret_val = 0;
// //
// case for unsigned integers // case for unsigned integers
...@@ -106,30 +106,32 @@ int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) { ...@@ -106,30 +106,32 @@ int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) {
u_int64_t a_big_num, b_big_num = 0; u_int64_t a_big_num, b_big_num = 0;
switch (num_bytes) { switch (num_bytes) {
case (1): case (1):
a_num = *a; a_num = *a_buf;
b_num = *b; b_num = *b_buf;
case (2): case (2):
a_num = uint2korr(a); a_num = uint2korr(a_buf);
b_num = uint2korr(b); b_num = uint2korr(b_buf);
case (3): case (3):
a_num = uint3korr(a); a_num = uint3korr(a_buf);
b_num = uint3korr(b); b_num = uint3korr(b_buf);
ret_val = a-b; ret_val = a_num-b_num;
goto exit; goto exit;
case (4): case (4):
a_num = uint4korr(a); printf("a: %d, %d, %d, %d\n", a_buf[0], a_buf[1], a_buf[2], a_buf[3]);
b_num = uint4korr(b); printf("a: %d, %d, %d, %d\n", a_buf[0], a_buf[1], a_buf[2], a_buf[3]);
if (a < b) { a_num = uint4korr(a_buf);
b_num = uint4korr(b_buf);
if (a_num < b_num) {
ret_val = -1; goto exit; ret_val = -1; goto exit;
} }
if (a > b) { if (a_num > b_num) {
ret_val = 1; goto exit; ret_val = 1; goto exit;
} }
ret_val = 0; ret_val = 0;
goto exit; goto exit;
case (8): case (8):
a_big_num = uint8korr(a); a_big_num = uint8korr(a_buf);
b_big_num = uint8korr(b); b_big_num = uint8korr(b_buf);
if (a_big_num < b_big_num) { if (a_big_num < b_big_num) {
ret_val = -1; goto exit; ret_val = -1; goto exit;
} }
...@@ -150,19 +152,19 @@ int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) { ...@@ -150,19 +152,19 @@ int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) {
int64_t a_big_num, b_big_num = 0; int64_t a_big_num, b_big_num = 0;
switch (num_bytes) { switch (num_bytes) {
case (1): case (1):
a_num = *(signed char *)a; a_num = *(signed char *)a_buf;
b_num = *(signed char *)b; b_num = *(signed char *)b_buf;
case (2): case (2):
a_num = sint2korr(a); a_num = sint2korr(a_buf);
b_num = sint2korr(b); b_num = sint2korr(b_buf);
case (3): case (3):
a_num = sint3korr(a); a_num = sint3korr(a_buf);
b_num = sint3korr(b); b_num = sint3korr(b_buf);
ret_val = a-b; ret_val = a_num - b_num;
goto exit; goto exit;
case (4): case (4):
a_num = sint4korr(a); a_num = sint4korr(a_buf);
b_num = sint4korr(b); b_num = sint4korr(b_buf);
if (a_num < b_num) { if (a_num < b_num) {
ret_val = -1; goto exit; ret_val = -1; goto exit;
} }
...@@ -172,8 +174,8 @@ int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) { ...@@ -172,8 +174,8 @@ int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) {
ret_val = 0; ret_val = 0;
goto exit; goto exit;
case (8): case (8):
a_big_num = sint8korr(a); a_big_num = sint8korr(a_buf);
b_big_num = sint8korr(b); b_big_num = sint8korr(b_buf);
if (a_big_num < b_big_num) { if (a_big_num < b_big_num) {
ret_val = -1; goto exit; ret_val = -1; goto exit;
} }
...@@ -191,6 +193,7 @@ int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) { ...@@ -191,6 +193,7 @@ int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes) {
// //
assert(false); assert(false);
exit: exit:
printf("ret_val %d\n", ret_val);
return ret_val; return ret_val;
} }
......
...@@ -27,7 +27,7 @@ int compare_field(uchar* a_buf, Field* a_field, uchar* b_buf, Field* b_field); ...@@ -27,7 +27,7 @@ int compare_field(uchar* a_buf, Field* a_field, uchar* b_buf, Field* b_field);
uchar* pack_toku_int (uchar* to_tokudb, uchar* from_mysql, u_int32_t num_bytes); uchar* pack_toku_int (uchar* to_tokudb, uchar* from_mysql, u_int32_t num_bytes);
uchar* unpack_toku_int(uchar* to_mysql, uchar* from_tokudb, u_int32_t num_bytes); uchar* unpack_toku_int(uchar* to_mysql, uchar* from_tokudb, u_int32_t num_bytes);
int cmp_toku_int (uchar* a, uchar* b, bool is_signed, u_int32_t num_bytes); int cmp_toku_int (uchar* a, uchar* b, bool is_unsigned, u_int32_t num_bytes);
// //
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment