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 A2C396EC6F; Sat, 13 Feb 2021 18:26:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A2C396EC6F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1613229987; bh=PsJ8IyH/7uBihn7bBCOyXN6rO6gVw0Q9YTutQx/47KA=; 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=FP86fsdx1uJx3OC6uIi6yHRY3dXrGRP4Va0AIc6U/un6RLtZTKdIDGM+heEjNSCZF EKV/S4tS7mDuLhmFlV+gM4hG/hqz6jrNTeUrq6acpwT3RI9WVbVV0OFT24E+MlNA1B 8p9PDsuLtJ9iSiHaCtLOQ+pwymNwkjTvvTCH7yIo= Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [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 0DB3B6EC6F for ; Sat, 13 Feb 2021 18:26:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0DB3B6EC6F Received: by smtpng2.m.smailru.net with esmtpa (envelope-from ) id 1lAwoP-0004L5-Re; Sat, 13 Feb 2021 18:26:22 +0300 Date: Sat, 13 Feb 2021 18:26:20 +0300 To: Timur Safin Cc: s.ostanevich@corp.mail.ru, tarantool-patches@dev.tarantool.org Message-ID: <20210213152620.GB110441@tarantool.org> References: <5768b1a39f75742621495dc6093f2e8b0596c46b.1612166870.git.imeevma@gmail.com> <047f01d6fec7$b5a90bb0$20fb2310$@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <047f01d6fec7$b5a90bb0$20fb2310$@tarantool.org> X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD981647AC6901E234B663C574FBA2C95D46270E7B1163DBA8E182A05F53808504053087CCDC6F0FE099A3C277DAE4787B68FC61802D001A0B3687A199E5B475A4D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FBB2043146276655EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375F0BD5CF353A411D8638F802B75D45FF5571747095F342E8C7A0BC55FA0FE5FC97BDA337793EA4450EFC4D149B98B8F5A7E3DAB729995FCA389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0A29E2F051442AF778941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6F459A8243F1D1D44CC7F00164DA146DA6F5DAA56C3B73B23C77107234E2CFBA567F23339F89546C55F5C1EE8F4F765FC3241B8C6B78F28F975ECD9A6C639B01BBD4B6F7A4D31EC0BC0CAF46E325F83A522CA9DD8327EE4930A3850AC1BE2E735C6EABA9B74D0DA47B5C8C57E37DE458B4C7702A67D5C3316FA3894348FB808DB853643B3A886106C3B503F486389A921A5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A580EB9A067E131DAE690D149FA11AB2D53F95CE52D58543C3D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75448CF9D3A7B2C848410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34697E0FA301E2821595AF0DD77E2C6975F5D9EC20454F96F3E8FA2179218CF8C05C3F30732227A2001D7E09C32AA3244CF9616FDDE932463D29876602BBB69D96A995755A1445935EFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+JvDbeHF34wIwi2DsvGFjg== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638227C657AB7E3A263F3347C0704A500963883D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 10/10] sql: refactor vdbe.c 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" On Tue, Feb 09, 2021 at 12:41:15PM +0300, Timur Safin wrote: > > > : From: imeevma@tarantool.org > : Subject: [PATCH v1 10/10] sql: refactor vdbe.c > : > : --- > : src/box/sql/vdbe.c | 453 +++++++++++++++++++++------------------------ > : 1 file changed, 206 insertions(+), 247 deletions(-) > : > : diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c > : index 1707c216e..7d4a0b297 100644 > : --- a/src/box/sql/vdbe.c > : +++ b/src/box/sql/vdbe.c > : @@ -311,17 +311,17 @@ mem_apply_numeric_type(struct Mem *record) > : static int > : mem_apply_type(struct Mem *record, enum field_type type) > : { > : - if ((record->flags & MEM_Null) != 0) > : + if (mem_is_null(record)) > : return 0; > : assert(type < field_type_MAX); > : switch (type) { > : case FIELD_TYPE_INTEGER: > : case FIELD_TYPE_UNSIGNED: > : - if ((record->flags & (MEM_Bool | MEM_Blob)) != 0) > : + if (mem_is_bool(record) || mem_is_binary(record)) > : return -1; > : - if ((record->flags & MEM_UInt) == MEM_UInt) > : + if (mem_is_pos_int(record)) > > Is it actually only about positive integers, and not (un)signed > integers in general? Why it's called mem_is_pos_int? Not mem_is_uint? > For positive integer it is true that mem_is_uint() is actually better, however I decided to left it as mem_is_pos_int() so it would be named in the same style as mem_is_neg_int(). I mean, both named to this way to show that they checks mem_type defined by implementation. The mem_is_neg_int() function is actually checks that MEM is negative integer, not just signed integer. The MEM_Int type is similar to MP_INT which allows only negative integers. I wonder if it is possible to make VDBE only work with functions that check only the field type? I mean mem_is_integer(), mem_is_unsigned(), mem_is_scalar() and so on. In this case, we don't need implementation-defined MEM type checking functions. I cannot say yet if this is possible. > : @@ -337,29 +337,29 @@ mem_apply_type(struct Mem *record, enum field_type > : type) > : } > : return 0; > : } > : - if ((record->flags & MEM_Str) != 0) { > : + if (mem_is_string(record)) { > : bool is_neg; > : int64_t i; > : if (sql_atoi64(record->z, &i, &is_neg, record->n) != 0) > : return -1; > : mem_set_int(record, i, is_neg); > : } > : - if ((record->flags & MEM_Int) == MEM_Int) { > : + if (mem_is_neg_int(record)) { > > The same question - why not mem_is_signed_int? Or simply mem_is_int? > Answered above. > : @@ -442,12 +432,12 @@ mem_is_type_compatible(struct Mem *mem, enum > : field_type type) > : static int > : mem_convert_to_double(struct Mem *mem) > : { > : - if ((mem->flags & MEM_Real) != 0) > : + if (mem_is_double(mem)) > : return 0; > : - if ((mem->flags & (MEM_Int | MEM_UInt)) == 0) > : + if (!mem_is_integer(mem)) > > Oh, I see there is already mem_is_integer, thus subtypes better to be > Explicitly named mem_is_unsigned_int and mem_is_signed_int (not pos/neg) > Answered above. > > : return -1; > : double d; > : - if ((mem->flags & MEM_Int) != 0) > : + if (mem_is_neg_int(mem)) > : d = (double)mem->u.i; > : else > : d = (double)mem->u.u; > > Timur >