From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 36F4C6F3D0; Wed, 1 Sep 2021 11:52:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 36F4C6F3D0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1630486359; bh=t409DvQcqwoG8c/qcAt/rfmFH7jJEW2vKIND58aIe2U=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Yg74JTHj4x3rcYGDvzFzALNzJUx0eXs14HJ1LDyrRo6UcGRcAq3vzXhHJGCD8X9xf eR0+gZhvsO3/leS53zKzGmE+1Rp2JUhposT3MHbbwf4QAhqKRiof3WbW25/AlPRO8A P99P7fs8KcfODFNQZ5U4DWUuXXBCRN2O3z3swUzo= Received: from smtpng2.i.mail.ru (smtpng2.i.mail.ru [94.100.179.3]) (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 6FCD66F3D0 for ; Wed, 1 Sep 2021 11:52:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6FCD66F3D0 Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1mLLz2-0007Fu-Gz; Wed, 01 Sep 2021 11:52:36 +0300 Date: Wed, 1 Sep 2021 11:52:35 +0300 To: Timur Safin Cc: tarantool-patches@dev.tarantool.org Message-ID: <20210901085235.GA112149@tarantool.org> References: <6229320676324201d74e78ac1f2832b79fd159cb.1630303937.git.imeevma@gmail.com> <017301d79ea0$eba3de60$c2eb9b20$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <017301d79ea0$eba3de60$c2eb9b20$@tarantool.org> X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9EE8D69D3379D80C4F2809F464D146B007F92475D298E3533182A05F538085040D6F71C434A3189399EA260D5024FDA93CD6BB9D060BF8D1541E86B12C689A8D0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7922D113DFDC6D5A3EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063748D05F5E01EE6C998638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D875FE9DE94AB15F2B5D4EB9B0E9DD7202117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B66F6A3E018CF4DC80089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A52743B68FB9B1E1DF7E69EAAC10375EE301260211B541C0DAD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA756888F6138A55F47E410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D346B71C4B0698719D7A8456E399E7FA33761AD62CB75379FFF62DA1C56BDCDEB6A1CFA4100A8C02D081D7E09C32AA3244C5DEA2DB1717BA1F332783294F18C4BB58580396430872480729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojKvNUqyKacB3zoRt4k4pcgw== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D7E605AA4E620B4E7F20B7CCA7BD29AED83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 1/1] sql: fix comparison between DECIMAL and big DOUBLE X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thank you for the review! My answer below. On Tue, Aug 31, 2021 at 10:46:40PM +0300, Timur Safin wrote: > > From: imeevma@tarantool.org > > Subject: [PATCH v1 1/1] sql: fix comparison between DECIMAL and big > > DOUBLE > > > > This patch fixes comparison between DECIMAL value and DOUBLE values > > greater or equal to 1e38 or less or equal to -1e38. Now any DOUBLE > > value > > greater or equal to 1e38 is more than any DECIMAL value and DOUBLE > > value less or equal to -1e38 is less than any DECIMAL value. > > > > Closes #6376 > ... > > diff --git a/changelogs/unreleased/gh-6376-fix-incorrect-dec-inf- > > cmp.md b/changelogs/unreleased/gh-6376-fix-incorrect-dec-inf-cmp.md > > new file mode 100644 > > index 000000000..70de655f1 > > --- /dev/null > > +++ b/changelogs/unreleased/gh-6376-fix-incorrect-dec-inf-cmp.md > > @@ -0,0 +1,3 @@ > > +## bugfix/sql > > + > > +* Fixed wrong comparison between DECIMAL and large DOUBLE values > > (gh-6376). > > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > > index 4c40f15dc..a3ab31af5 100644 > > --- a/src/box/sql/mem.c > > +++ b/src/box/sql/mem.c > > @@ -2451,9 +2451,9 @@ mem_cmp_num(const struct Mem *a, const struct > > Mem *b) > > } > > case MEM_TYPE_DOUBLE: { > > if (b->u.r >= 1e38) > > - return 1; > > - if (b->u.r <= -1e38) > > return -1; > > + if (b->u.r <= -1e38) > > + return 1; > > Well, while we are here. I do understand that these kind of constants > already spreading all corners of mem.c when you deal with decimals, > but it's not entirely clear that this all about DECIMAL_MAX_DIGITS > limitation in our decimal implementation. > And beyond all of that - hardcoded constant are evil. Could you please > introduce any symbolic constant defines for such DECIMAL_MAX_DIGITS- > derivative values? And use them wherever possible. > > (I'm not insisting on fixing whole mem.c, that might be done separately, > but at least this tricky case worth it) > I agree that this is not good, but I think that addition of double constant for decimal in SQL is not good idea. I think it is better to move all these operations to decimal.c/.h. Could you fill an issue? If you cannot, I will do it myself a bit later. I also agree that I was wrong when I didn't introduce new functions for decimal, but at that time I feared that I will spend too much time on tests for these functions, and decided to leave this for later. In general, I have quite a few questions about functions in decimal.c/.h and I plan to ask them in the mentioned issue. > > decimal_t dec; > > decimal_t *d = decimal_from_double(&dec, b->u.r); > > assert(d != NULL && d == &dec); > > Thanks, > Timur >