support sharding key type int64

This commit is contained in:
tsthght 2018-04-25 16:42:32 +08:00
parent 2817c857e3
commit db11d4af10
2 changed files with 13 additions and 7 deletions

View File

@ -339,9 +339,9 @@ partition_satisfies(sharding_partition_t *partition, struct condition_t cond)
g_warning(G_STRLOC ":error condition");
}
} else { /* int and datetime */
int low = (int)(int64_t) partition->low_value;
int high = (int)(int64_t) partition->value; /* high range OR hash value */
int val = cond.v.num;
int64_t low = (int64_t) partition->low_value;
int64_t high = (int64_t) partition->value; /* high range OR hash value */
int64_t val = cond.v.num;
switch (cond.op) {
case TK_EQ:
return val > low && val <= high;
@ -366,7 +366,7 @@ partition_satisfies(sharding_partition_t *partition, struct condition_t cond)
}
g_warning(G_STRLOC ":error reach here");
return false;
return FALSE;
}
/* filter out those which not satisfy cond */

View File

@ -684,9 +684,15 @@ cmp_shard_range_groups_int(gconstpointer a, gconstpointer b)
{
sharding_partition_t *item1 = *(sharding_partition_t **)a;
sharding_partition_t *item2 = *(sharding_partition_t **)b;
int n1 = (int)(int64_t) item1->value;
int n2 = (int)(int64_t) item2->value;
return n1 - n2;
int64_t n1 = (int64_t) item1->value;
int64_t n2 = (int64_t) item2->value;
if (n1 > n2) {
return 1;
} else if (n1 == n2) {
return 0;
} else {
return -1;
}
}
static gint