[Tarantool-patches] [PATCH v5 20/52] sql: introduce mem_compare()

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Thu Apr 15 02:20:21 MSK 2021


Nice fixes!

Consider mine below:

====================
diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
index 9de57bcb4..a7c2c16cb 100644
--- a/src/box/sql/mem.c
+++ b/src/box/sql/mem.c
@@ -481,7 +481,7 @@ mem_rem(const struct Mem *left, const struct Mem *right, struct Mem *result)
 int
 mem_cmp_bool(const struct Mem *a, const struct Mem *b, int *result)
 {
-	if ((a->flags & MEM_Bool) == 0 || (b->flags & MEM_Bool) == 0)
+	if ((a->flags & b->flags & MEM_Bool) == 0)
 		return -1;
 	if (a->u.b == b->u.b)
 		*result = 0;
@@ -495,7 +495,7 @@ mem_cmp_bool(const struct Mem *a, const struct Mem *b, int *result)
 int
 mem_cmp_bin(const struct Mem *a, const struct Mem *b, int *result)
 {
-	if ((a->flags & MEM_Blob) == 0 || (b->flags & MEM_Blob) == 0)
+	if ((a->flags & b->flags & MEM_Blob) == 0)
 		return -1;
 	int an = a->n;
 	int bn = b->n;
@@ -640,7 +640,7 @@ mem_cmp_str(const struct Mem *left, const struct Mem *right, int *result,
 			sql_snprintf(BUF_SIZE, b, "%!.15g", right->u.r);
 		bn = strlen(b);
 	}
-	if (coll) {
+	if (coll != NULL) {
 		*result = coll->cmp(a, an, b, bn, coll);
 		return 0;
 	}


More information about the Tarantool-patches mailing list