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 B88D76ECE3; Tue, 2 Nov 2021 14:39:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B88D76ECE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635853164; bh=YIl3ydzNvn+IfhU5g0a/xb+fAOy1LzhmBbrCxKVoLCA=; 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=Zg8x0/VahunpF3jceSTHevXPXtW5Zu3/QTxZiaW9+4ycftja/yUacrVHKFYB4rKxk 2HR2wZD3dA6+6+cV1CGscx0uP0OLKcgMfkyCeBY84oq9fG5IwjKwDqtWd82qa1DWhF 2Nq281sEMBMo1x7v8JTbBhz8NZYsobDF3VhrJx0o= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [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 D9DBE6ECE3 for ; Tue, 2 Nov 2021 14:39:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D9DBE6ECE3 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mhs8Q-0003A8-9C; Tue, 02 Nov 2021 14:39:22 +0300 Date: Tue, 2 Nov 2021 14:39:21 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Message-ID: <20211102113921.GB104458@tarantool.org> References: <4308263e-95f4-9c97-f284-a4ff4136ec26@tarantool.org> <20211025083009.GD36295@tarantool.org> <256a19c0-6b2b-33ad-1086-0e318cc362ec@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <256a19c0-6b2b-33ad-1086-0e318cc362ec@tarantool.org> X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD98893113B6235BE9154FDE3298F0A37FC272DDC0DDA52D3DE182A05F53808504062FDED67BEDCB0AF912D607F161BFD25F11CDEF119913366F9FDF4DFE7B0E905 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7370F4F695FFFC24BEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063790C8302959DAAF098638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D86DC62A8C3BBA59471054BAE5951E4A6D117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC60CDF180582EB8FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B953A8A48A05D51F175ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A54E377E777B5B221F7066D3870A4CA69C80C407C2DE27D112D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA752DA3D96DA0CEF5C48E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D75CEA0D7A80616E1151145CBB724790BC4E66FD07891A8B5FD51099DB38C34E3FC2C188EEE793D81D7E09C32AA3244C2F99F8BB7618A16EDA29E0A51B4206FF95A9E0DC41E9A4CF729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojyQYxHpRvLO7z5p2+PRg5FA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D6EFB4C7843BAE2623584D2CBA2E30F4F83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 04/21] sql: refactor LENGTH() function 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 Sat, Oct 30, 2021 at 01:42:49AM +0200, Vladislav Shpilevoy wrote: > >>> diff --git a/src/box/sql/func.c b/src/box/sql/func.c > >>> index e5d763be1..863dbf1c4 100644 > >>> --- a/src/box/sql/func.c > >>> +++ b/src/box/sql/func.c > >>> @@ -833,6 +833,19 @@ func_hex(struct sql_context *ctx, int argc, struct Mem *argv) > >>> mem_set_str_allocated(ctx->pOut, str, size); > >>> } > >>> > >>> +/** Implementation of the OCTET_LENGTH() function. */ > >>> +static void > >>> +func_octet_length(struct sql_context *ctx, int argc, struct Mem *argv) > >> > >> Why is the function LENGTH defined as 'octet_length' instead of just 'length'? > > ANSI defines two functions: CHAR_LENGTH() (with CHARACTER_LENGTH() as the other > > name) and OCTET_LENGTH(). The first accepts only STRING values and returns the > > length in characters or length in octets (depending on the USING clause). The > > second accepts VARBINARY or STRING and returns the length in octets. > > > > We have a LENGTH() function that returns the character length if the argument is > > STRING, and the octet length if the argument is VARBINARY. > > > > Since I am planning to introduce the USING clause, I find it better to use the > > CHAR_LENGTH() and OCTET_LENGTH() implementations for LENGTH() depending on the > > type of the argument. The func_octet_length() function will be used cases such > > as this: > > SELECT char_length(string_value USING OCTETS); > > > > At the moment, I have no plans to introduce OCTET_LENGTH(). > > Does ANSI define 'USING' or 'OCTET_LENGTH'? Or both? ANSI defines both. However CHAR_LENGTH(s USING ) defined for STRING argument only, and OCTET_SIZE() defined for both STRING and VARBINARY.