From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 05E1646971A for ; Thu, 5 Dec 2019 15:36:06 +0300 (MSK) Date: Thu, 5 Dec 2019 15:36:06 +0300 From: Nikita Pettik Message-ID: <20191205123606.GC15510@tarantool.org> References: <607d553a38e634e3e1dd9d8fe2bb7be03effc8d3.1572975628.git.imeevma@gmail.com> <20191121011955.GA4142@tarantool.org> <20191123114805.GA18119@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191123114805.GA18119@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH v1 1/1] sql: allow to convert big real values to integer List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org On 23 Nov 14:48, Mergen Imeev wrote: > > BTW below I see path which is executed when > > is_forced == false. And it is also about same wrong conversion. Please > > check it as well and add test case. > > > I found that is_forced variable did nothing it this code. > Removed it from code along with "if" checked it. If it is unused, please move this refactoring to a separate patch. > diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c > index ab86be9..450e21d 100644 > --- a/src/box/sql/vdbe.c > +++ b/src/box/sql/vdbe.c > @@ -322,13 +322,16 @@ mem_apply_type(struct Mem *record, enum field_type type) > if ((record->flags & MEM_UInt) == MEM_UInt) > return 0; > if ((record->flags & MEM_Real) == MEM_Real) { > - int64_t i = (int64_t) record->u.r; > - if (i == record->u.r) > - mem_set_int(record, record->u.r, > - record->u.r <= -1); > + double d = record->u.r; > + int64_t i = (int64_t) d; > + uint64_t u = (uint64_t) d; > + if (i == d) > + mem_set_int(record, d, d <= -1); Nit: mem_set_int(record, i, i <= -1;); > + else if (u == d) > + mem_set_u64(record, d); Nit: mem_set_u64(record, u);