From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Stanislav Zudin Subject: [PATCH 09/13] sql: fixes errors Date: Fri, 15 Mar 2019 18:45:38 +0300 Message-Id: <85476cfaec30d5958cfbd24c89ad4475bea2d3ed.1552663061.git.szudin@tarantool.org> In-Reply-To: References: In-Reply-To: References: To: tarantool-patches@freelists.org, vdavydov.dev@gmail.com Cc: Stanislav Zudin List-ID: Fixes an error in sql_value_type() and wrong arguments order in arithmetic operations. --- src/box/sql/vdbe.c | 10 +++++----- src/box/sql/vdbeapi.c | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index d4bd845fb..ad2ce1787 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -1677,11 +1677,11 @@ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ bIntint = 1; enum arithmetic_result arr; switch( pOp->opcode) { - case OP_Add: arr = sqlAddInt64(&iB, is_signedA, iA, is_signedB); break; - case OP_Subtract: arr = sqlSubInt64(&iB, is_signedA, iA, is_signedB); break; - case OP_Multiply: arr = sqlMulInt64(&iB, is_signedA, iA, is_signedB); break; - case OP_Divide: arr = sqlDivInt64(&iB, is_signedA, iA, is_signedB); break; - default: arr = sqlRemInt64(&iB, is_signedA, iA, is_signedB); break; + case OP_Add: arr = sqlAddInt64(&iB, is_signedB, iA, is_signedA); break; + case OP_Subtract: arr = sqlSubInt64(&iB, is_signedB, iA, is_signedA); break; + case OP_Multiply: arr = sqlMulInt64(&iB, is_signedB, iA, is_signedA); break; + case OP_Divide: arr = sqlDivInt64(&iB, is_signedB, iA, is_signedA); break; + default: arr = sqlRemInt64(&iB, is_signedB, iA, is_signedA); break; } switch(arr){ diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 6a3413954..06140569c 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -319,7 +319,8 @@ sql_value_type(sql_value * pVal) * type bits, to make them applicable for * array indexing. */ - u32 offset = (pVal->flags >> 12) | (pVal->flags & MEM_PURE_TYPE_MASK); + u32 offset = ((pVal->flags & MEM_Unsigned) >> 12) | + (pVal->flags & MEM_PURE_TYPE_MASK); assert(offset < 0x40); return aType[offset]; } -- 2.17.1