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 86CDC6F800; Tue, 31 Aug 2021 22:47:04 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 86CDC6F800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1630439224; bh=HMGn2AmXkF9yUCBCowvY+/v9UZsSKsgUnwB+1v7Pb8c=; h=To:Cc:References:In-Reply-To:Date:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=BDrp3B9SVraM8f1f0NtCmZQNE6ejzu6TdogLVDdFg4N6CbGQJ02ht4McGTfzUeDkn QFkttBvU8bFbbdw3PndDmy0UkNozSpwtziStV9XDQH40FwWlmXK3a1oidB6I0TdjIS w0++lHaNLSd+G93yiHeSyJUdoJGUZT39J5eNhgN0= Received: from smtp48.i.mail.ru (smtp48.i.mail.ru [94.100.177.108]) (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 447146F3FF for ; Tue, 31 Aug 2021 22:47:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 447146F3FF Received: by smtp48.i.mail.ru with esmtpa (envelope-from ) id 1mL9io-0007qR-HJ; Tue, 31 Aug 2021 22:47:02 +0300 To: Cc: References: <6229320676324201d74e78ac1f2832b79fd159cb.1630303937.git.imeevma@gmail.com> In-Reply-To: <6229320676324201d74e78ac1f2832b79fd159cb.1630303937.git.imeevma@gmail.com> Date: Tue, 31 Aug 2021 22:46:40 +0300 Message-ID: <017301d79ea0$eba3de60$c2eb9b20$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQFdeROkG3kzP8IUNOtGorQhC3xf66yCTiTg Content-Language: ru X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9EE8D69D3379D80C4A0C4B94001CDC0D26F864EBD62C7E1F9182A05F538085040EFBC78C8D7FFF25B2765740F40AA8BE56D7C47CA37D19314BD9173FD65DC9854 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7E50EC9128971FD6EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063752AC809489EC5B9C8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D857C39C9857D0A1F042DD01978E3C4DBC117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC3A703B70628EAD7BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD1828451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EEC65AC60A1F0286FE07FB45A5F6E725C8D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE30A6B3CD6EB70C81876E601842F6C81A1F004C906525384307823802FF610243DF43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C747589E6AAA3516243847C11F186F3C59DAA53EE0834AAEE X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458F0AFF96BAACF4158235E5A14AD4A4A4625E192CAD1D9E79DB8BF922E402C092C2EE1EB4830321D93 X-C1DE0DAB: 0D63561A33F958A5DFF48E7D388D3D57D6DDD4C8F8BBC266CEEC36D7D9E56729D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752546FE575EB473F1410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34F804B400765FFFF987634454D404E5BA555D2DFB53ABCD68CACB0A7F3E0ED79D9415C98A6546C7871D7E09C32AA3244C19BE8F3AE37634A9778A7D940390E77EB4DF56057A86259F729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojKvNUqyKacB1ufusuaiftLQ== X-Mailru-Sender: B5B6A6EBBD94DAD88AE996DFA43B41792EF6EC6BA35ED8C980A15ED8C0A61F509EA0A951FF19AFE55C2808D6142752370A8ED71B308007E3DC85537438B7E1A423D748DE48713E689437F6177E88F7363CDA0F3B3F5B9367 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: Timur Safin via Tarantool-patches Reply-To: Timur Safin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" > 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) > decimal_t dec; > decimal_t *d = decimal_from_double(&dec, b->u.r); > assert(d != NULL && d == &dec); Thanks, Timur