From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id C8FD224F18 for ; Fri, 5 Jul 2019 12:35:43 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZwSrTXyIVGKZ for ; Fri, 5 Jul 2019 12:35:43 -0400 (EDT) Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [94.100.177.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id EA22624EED for ; Fri, 5 Jul 2019 12:35:42 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 2/6] sql: separate VDBE memory holding positive and negative ints Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Content-Type: text/html; charset=us-ascii From: n.pettik In-Reply-To: <09e60c9d-8a1e-38d8-a474-cfcbc586f9f4@tarantool.org> Date: Fri, 5 Jul 2019 19:33:15 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <6DEB0818-06BC-4DAE-8ACE-1BA6EF728BE0@tarantool.org> References: <0e009036b6c6ce9e2d1f2ff66063291cb60e1387.1559919361.git.korablev@tarantool.org> <6f7ec2c9-c325-601a-234f-97d6c6ced195@tarantool.org> <09e60c9d-8a1e-38d8-a474-cfcbc586f9f4@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Vladislav Shpilevoy

diff --git = a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 83c0e90f1..2be42faf2 = 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ = -260,7 +260,7 @@ allocateCursor(
int
mem_apply_numeric_type(struct = Mem *record)
{
- if ((record->flags & = (MEM_Str | MEM_Int | MEM_Real | MEM_UInt)) !=3D MEM_Str)
+ if = ((record->flags & MEM_Str) =3D=3D 0)
return = -1;
= int64_t integer_value;
bool is_neg;
@@ -936,7 +936,7 = @@ case OP_Return: { =           /* in1 = */
case OP_InitCoroutine: {     /* jump = */
= assert(pOp->p1>0 && =  pOp->p1<=3D(p->nMem+1 - p->nCursor));
= assert(pOp->p2>=3D0 && = pOp->p2<p->nOp);
- assert(pOp->p3>=3D0 = && pOp->p3<p->nOp);
+ assert(pOp->p3>0 && = pOp->p3<p->nOp);
pOut =3D = &aMem[pOp->p1];
= assert(!VdbeMemDynamic(pOut));
mem_set_u64(pOut, pOp->p3 - = 1);
@@ -1061,10 +1061,12 @@ case OP_Halt: {
*/
case = OP_Integer: {         /* out2 = */
= pOut =3D out2Prerelease(p, pOp);
- if (pOp->p1 < 0)
+ if = (pOp->p1 < 0) {
pOut->u.i =3D = pOp->p1;
- = else
+ = = assert((pOut->flags & MEM_Int) !=3D 0);
+ } else = {
= = mem_set_u64(pOut, pOp->p1);
+ }
break;
}

@@ -3307,8 = +3309,7 @@ case OP_SeekGT: {       /* = jump, in3 */
= = * the seek, so convert it.
*/
pIn3 =3D = &aMem[reg_ipk];
- if ((pIn3->flags & = (MEM_Int | MEM_UInt | MEM_Real |
-    MEM_Str)) =3D=3D= MEM_Str)
+ = = if ((pIn3->flags & MEM_Str) !=3D 0)
= mem_apply_numeric_type(pIn3);
int64_t i;
if = ((pIn3->flags & MEM_Int) =3D=3D MEM_Int) {
@@ -4921,9 +4922,8 = @@ case OP_OffsetLimit: {    /* in1, out2, in3 */
case = OP_IfNotZero: {        /* jump, in1 = */
= pIn1 =3D &aMem[pOp->p1];
assert((pIn1->flags & = MEM_UInt) !=3D 0);
- = VdbeBranchTaken(pIn1->u.u<0, 2);
- if = (pIn1->u.u) {
- if (pIn1->u.u > 0) = pIn1->u.u--;
+ if (pIn1->u.u > 0) = {
+ = = pIn1->u.u--;
goto jump_to_p2;
= }
= break;
@@ -4938,8 +4938,8 @@ case OP_IfNotZero: { =        /* jump, in1 */
case = OP_DecrJumpZero: {      /* jump, in1 = */
= pIn1 =3D &aMem[pOp->p1];
assert((pIn1->flags & = MEM_UInt) !=3D 0);
- if = (pIn1->u.i>SMALLEST_INT64) pIn1->u.u--;
- = VdbeBranchTaken(pIn1->u.i=3D=3D0, 2);
+ if = (pIn1->u.u > 0)
+ pIn1->u.u--;
if = (pIn1->u.u =3D=3D 0) goto jump_to_p2;
= break;
}

Thx, = applied.

=