[Tarantool-patches] [PATCH v2 4/4] sql: introduce mem_cmp_msgpack()

Mergen Imeev imeevma at tarantool.org
Wed Jul 14 09:51:37 MSK 2021


Hi! Thank you for the review! My answers and diff below.

On Tue, Jul 13, 2021 at 10:39:04PM +0200, Vladislav Shpilevoy wrote:
> Thanks for the fixes!
> 
> > diff --git a/src/box/sql.c b/src/box/sql.c
> > index 790ca7f70..c1271ee0a 100644
> > --- a/src/box/sql.c
> > +++ b/src/box/sql.c
> > @@ -765,10 +765,14 @@ tarantoolsqlIdxKeyCompare(struct BtCursor *cursor,
> >  			}
> >  		}
> >  		next_fieldno = fieldno + 1;
> > -		rc = sqlVdbeCompareMsgpack(&p, unpacked, i);
> > +		struct key_part *part = &unpacked->key_def->parts[i];
> > +		struct Mem *mem = unpacked->aMem + i;
> > +		struct coll *coll = part->coll;
> > +		/* In case of fail make rc equal to 0. */
> 
> The comment isn't really necessary I would say. Does not
> help much. The same in the other place below.
> 
Dropped.

> > +		if (mem_cmp_msgpack(mem, &p, &rc, coll) != 0)
> > +			rc = 0;
> >  		if (rc != 0) {
> > -			if (unpacked->key_def->parts[i].sort_order !=
> > -			    SORT_ORDER_ASC)
> > +			if (part->sort_order == SORT_ORDER_ASC)
> 
> Why did you change != to ==?
> 
I did this because function sqlVdbeCompareMsgpack() compared packed value as
left operand and MEM as right operand. In mem_cmp_msgpack() order was reversed,
now MEM is left operand and packed value is right operand.

> > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> > index da27cd191..8e176e418 100644
> > --- a/src/box/sql/mem.c
> > +++ b/src/box/sql/mem.c
> > @@ -2721,13 +2586,16 @@ sqlVdbeRecordCompareMsgpack(const void *key1,
> >  	n = MIN(n, key2->nField);
> >  
> >  	for (i = 0; i != n; i++) {
> > -		rc = sqlVdbeCompareMsgpack((const char**)&key1, key2, i);
> > +		struct key_part *part = &key2->key_def->parts[i];
> > +		struct Mem *mem = key2->aMem + i;
> > +		struct coll *coll = part->coll;
> > +		/* In case of fail make rc equal to 0. */
> > +		if (mem_cmp_msgpack(mem, (const char **)&key1, &rc, coll) != 0)
> > +			rc = 0;



Diff:


diff --git a/src/box/sql.c b/src/box/sql.c
index c1271ee0a..7471c3832 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -768,7 +768,6 @@ tarantoolsqlIdxKeyCompare(struct BtCursor *cursor,
 		struct key_part *part = &unpacked->key_def->parts[i];
 		struct Mem *mem = unpacked->aMem + i;
 		struct coll *coll = part->coll;
-		/* In case of fail make rc equal to 0. */
 		if (mem_cmp_msgpack(mem, &p, &rc, coll) != 0)
 			rc = 0;
 		if (rc != 0) {
diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
index 8e176e418..62993fa4f 100644
--- a/src/box/sql/mem.c
+++ b/src/box/sql/mem.c
@@ -2589,7 +2589,6 @@ sqlVdbeRecordCompareMsgpack(const void *key1,
 		struct key_part *part = &key2->key_def->parts[i];
 		struct Mem *mem = key2->aMem + i;
 		struct coll *coll = part->coll;
-		/* In case of fail make rc equal to 0. */
 		if (mem_cmp_msgpack(mem, (const char **)&key1, &rc, coll) != 0)
 			rc = 0;
 		if (rc != 0) {


More information about the Tarantool-patches mailing list