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 5D30771229; Fri, 29 Oct 2021 01:13:08 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5D30771229 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635459188; bh=uveTlbOBp+dQMyPqMDXjxIXhWW0nbq91I+TEKgxpe1M=; 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=Fl0525OIsI6H8EFTFBFWFJBvmpFw2KJTqxUQKJyxZudVn8R+JEaGrV+GFoD2ns5Yp X3Aufyue1x9v3b9StnRhJDhEJRcSn1vG2FMWOQLeXn4oPpXfWDWZLLkhWAvy/L55wZ XpX5yFBBSHIL1je/6Uzn7sAX1WIJUlRcAb8tSD4k= 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 4187A71229 for ; Fri, 29 Oct 2021 01:13:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4187A71229 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mgDdy-0000gC-Jw; Fri, 29 Oct 2021 01:13:06 +0300 Message-ID: <2de89866-74d1-f6c3-0587-807518e72cf8@tarantool.org> Date: Fri, 29 Oct 2021 00:13:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Content-Language: en-US To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org References: <20211020171553.GF203963@tarantool.org> In-Reply-To: <20211020171553.GF203963@tarantool.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9E6B4260954843F6F90DB626B449E13ED0C1EBEE6449431F900894C459B0CD1B99FCEDABBD19DC414F3A13C966325D58D08357E0F7F63E000862BB7B6EB49490E X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A2F2DCC785917A3AEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E31772672C957B658638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D88C1F26EC44F0D993ABACEE79DE23FDC1117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B8C7ADC89C2F0B2A5A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C5E1C53F199C2BB95B5C8C57E37DE458BEDA766A37F9254B7 X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC345847D397C50E778A33F078A371151D42C66DD241A9668939383C40884BD73B3B03 X-C1DE0DAB: 0D63561A33F958A5570BF0A5FA5A1ECD1624F34238E928B402EB5CF4640D5144D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75C29D03FC76C37677410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348BF433665406F390AEFFF5EC61BD05014923BE7ABFAD54EDD63C5301FCAF2979947B01D1F26239261D7E09C32AA3244C17233D456BD55E050A0F7218E2A0DEDBE8FBBEFAE1C4874C729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojdMRfVmNkPDjMwkygQBPpmA== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D016D12B6CAD503CF81A821FA1767AD8C3841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 7/8] sql: rework SUBSTR() 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: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the fixes! > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index 80b075dcf..65bf03250 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > + > +static void > +func_substr_octets(struct sql_context *ctx, int argc, struct Mem *argv) > +{ > + assert(argc == 2 || argc == 3); > + if (mem_is_any_null(&argv[0], &argv[1])) > + return; > + assert(mem_is_bytes(&argv[0]) && mem_is_int(&argv[1])); > + > + bool is_str = mem_is_str(&argv[0]); > + uint64_t size = argv[0].n; > + > + if (argc == 2) { > + uint64_t start = mem_is_uint(&argv[1]) && argv[1].u.u > 1 ? > + argv[1].u.u - 1 : 0; > + if (start >= size) > + return return_empty_str(ctx, is_str); > + char *s = &argv[0].z[start]; > + uint64_t n = size - start; > + ctx->is_aborted = is_str ? mem_copy_str(ctx->pOut, s, n) != 0 : > + mem_copy_bin(ctx->pOut, s, n) != 0; > + return; > + } > + > + assert(argc == 3); > + if (mem_is_null(&argv[2])) > + return; > + assert(mem_is_int(&argv[2])); > + if (!mem_is_uint(&argv[2])) { > + diag_set(ClientError, ER_SQL_EXECUTE, "Length of the result " > + "cannot be less than 0"); > + ctx->is_aborted = true; > + return; > + } > + uint64_t start; > + uint64_t length; > + if (substr_normalize(argv[1].u.i, !mem_is_uint(&argv[1]), argv[2].u.u, > + &start, &length) != 0) { The second line of the call is misaligned.