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 8FA646C185; Tue, 30 Mar 2021 02:13:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8FA646C185 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617059638; bh=vMiYVxD4KlQAKJEgG2pRyirm2Z/fn/UWK+1Cd4k8u3Y=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=o8jug6Z6UFh6OA3oWHo0LP7wIE4108VkutWrTl95Hh0NhS6RHxgkqFwhzCYMETtfH A/pGwHSbwpDsAs095UisqRoLzvC1ch2qN3vgn3l65paAZceLjoHt2CGYEKbruJzFhG 5dz0zJw+BxtNzqbPSY3y29yzzk54pkTosybd848E= Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 0508A6BD17 for ; Tue, 30 Mar 2021 02:08:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0508A6BD17 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lR0zS-0003Hr-CH; Tue, 30 Mar 2021 02:08:10 +0300 To: imeevma@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: Message-ID: <3503a9ee-e704-d29b-7988-e4631bb11fae@tarantool.org> Date: Tue, 30 Mar 2021 01:08:09 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9ED7173E37F4E32947287414FD1D04A09E656A5F3377C994A182A05F5380850408A8E20E2CD0552163EF94126F110A17ECDA018216B3DD0830FCC3DCCE292340C X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79145AB6E9E75F07EEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063727599E9BE65898D58638F802B75D45FF914D58D5BE9E6BC131B5C99E7648C95CE99938B3FD79E1DF4A601AEDFBBFD10B2C2B362008443E04A471835C12D1D9774AD6D5ED66289B5259CC434672EE6371117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7328B01A8D746D8839FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F790063735872C767BF85DA227C277FBC8AE2E8B706619B2D358707475ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A528FA559829F95800EF96EAE06A853FD8E1603B5B67548E63D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34EE6683D9E546CC62D2F3AFF7077F9EFDCF826E7DE588C522098AE8CCA62A4BA4639FE83E3361C5DF1D7E09C32AA3244CE52D536BEB38C036C394EA9E6CDD38293A92A9747B6CC886FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojljIiQOC84rRgBardse8MBQ== X-Mailru-Sender: 689FA8AB762F73936BC43F508A0638221D66275DC5069EC3492EDB3592655ED63841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 46/53] sql: introduce mem_implicit_cast() 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the patch! > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 559bf6121..1baf4c482 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -1071,6 +1093,140 @@ mem_explicit_cast(struct Mem *mem, enum field_type type) <...> > + > +int > +mem_implicit_cast_old(struct Mem *mem, enum field_type type) What is this? > +{ > + if (mem_is_null(mem)) > + return 0; > + switch (type) { > + case FIELD_TYPE_UNSIGNED: > + if ((mem->flags & MEM_UInt) != 0) > + return 0; > + if ((mem->flags & MEM_Real) != 0) > + return mem_convert_double_to_unsigned_lossless(mem); > + if ((mem->flags & MEM_Str) != 0) > + return mem_convert_varstring_to_unsigned(mem); > + return -1; > + case FIELD_TYPE_STRING: > + if ((mem->flags & (MEM_Str | MEM_Blob)) != 0) > + return 0; > + if ((mem->flags & (MEM_Int | MEM_UInt)) != 0) > + return mem_convert_integer_to_string(mem); > + if ((mem->flags & MEM_Real) != 0) > + return mem_convert_double_to_string(mem); > + return -1; > + case FIELD_TYPE_DOUBLE: > + if ((mem->flags & MEM_Real) != 0) > + return 0; > + if ((mem->flags & (MEM_Int | MEM_UInt)) != 0) > + return mem_convert_integer_to_double(mem); > + if ((mem->flags & MEM_Str) != 0) > + return mem_convert_varstring_to_double(mem); > + return -1; > + case FIELD_TYPE_INTEGER: > + if ((mem->flags & (MEM_Int | MEM_UInt)) != 0) > + return 0; > + if ((mem->flags & MEM_Str) != 0) > + return mem_convert_varstring_to_integer(mem); > + if (mem_is_double(mem)) > + return mem_convert_double_to_integer_lossless(mem); > + return -1; > + case FIELD_TYPE_BOOLEAN: > + if ((mem->flags & MEM_Bool) != 0) > + return 0; > + return -1; > + case FIELD_TYPE_VARBINARY: > + if ((mem->flags & MEM_Blob) != 0) > + return 0; > + return -1; > + case FIELD_TYPE_NUMBER: > + if ((mem->flags & (MEM_Int | MEM_UInt | MEM_Real)) != 0) > + return 0; > + if ((mem->flags & MEM_Str) != 0) > + return mem_convert_to_number(mem); > + return -1; > + case FIELD_TYPE_MAP: > + if (mem_is_map(mem)) > + return 0; > + return -1; > + case FIELD_TYPE_ARRAY: > + if (mem_is_array(mem)) > + return 0; > + return -1; > + case FIELD_TYPE_SCALAR: > + if ((mem->flags & MEM_Blob) != 0 && > + (mem->flags & MEM_Subtype) != 0) > + return -1; > + return 0; > + default: > + break; > + } > + return -1; > +}