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 4CCFB6EC40; Thu, 23 Sep 2021 01:49:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4CCFB6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1632350994; bh=vwrmRdmOT/Y4UZEzsldNxxBauSA8aaWHIj+2nkFYsrQ=; 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=QNHFgr4oWqnfhH02OMwed+6DXHJMv7CbYtjz54mHSRG/9Q339XtbfotY/mX2/ulum Ck4s0eYxEtjlEDg7MX6ICQvpe+tkZBSU2aJ3gHX5HQwu1nr3DPLuVikd84M3YhZeQp TsznImVN2SYeiNSKlUfE1mnnul/75cgZHs0HM8EU= 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 F0E4C6EC40 for ; Thu, 23 Sep 2021 01:49:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F0E4C6EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mTB3p-00053w-83; Thu, 23 Sep 2021 01:49:53 +0300 To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: <265692b0b90cd9ce0a5362b55e81f7a2d598ad19.1632220375.git.imeevma@gmail.com> Message-ID: <527aac58-f3f4-bae9-3057-187edee7d8d4@tarantool.org> Date: Thu, 23 Sep 2021 00:49:52 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <265692b0b90cd9ce0a5362b55e81f7a2d598ad19.1632220375.git.imeevma@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD91AE02D33A9C88A2F7B0FCECE251A4B9EABD2FC9AA46919D800894C459B0CD1B9D710764B0D7E1AB610A6B98CE67A3125DC443D2BA0B873E5168CA2B421C46119 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE755BE8F535441E38CEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378B6D775AC58C227F8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8C61C822231516D540E19D1535E41F7E0117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505146249CD04DF8AE9794EE30CF6F1B773 X-C1DE0DAB: 0D63561A33F958A5C42D3882FC5A669FE74FC8A17205E99F1CC79374C281019DD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA759D2A03B9C34326B3410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3450C5E6D685282BA1CA6F0D89511EFCA3A9D1B4E8D080BF0BF699771E046799F67AA7C2D3AFE2E94C1D7E09C32AA3244C1BD75FDD515FB7D852DA6CEDEF4E1B4C6C24832127668422729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojYVPXnTWjYf65K+UT5ChOWg== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D2D5A3E405994510C3D1B94B49C9CFF793841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 12/15] sql: rework GROUP_CONCAT() 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/func.c b/src/box/sql/func.c > index f699aa927..001a8641c 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -213,6 +213,52 @@ fin_minmax(struct sql_context *ctx) > mem_copy(ctx->pOut, ctx->pMem); > } > > +/** Implementation of the GROUP_CONCAT() function. */ > +static void > +step_group_concat(struct sql_context *ctx, int argc, struct Mem **argv) > +{ > + assert(argc == 1 || argc == 2); > + (void)argc; > + if (argv[0]->type == MEM_TYPE_NULL) > + return; > + assert(mem_is_str(argv[0]) || mem_is_bin(argv[0])); > + if (ctx->pMem->type == MEM_TYPE_NULL) { > + if (mem_copy_str(ctx->pMem, argv[0]->z, argv[0]->n) != 0) 1. What if the argument is zeroblob with no actual memory allocated yet? > + ctx->is_aborted = true; > + return; > + } > + const char *sep = NULL; > + int sep_len = 0; > + if (argc == 1) { > + sep = ","; > + sep_len = 1; > + } else if (argv[1]->type == MEM_TYPE_NULL) { > + sep = ""; > + sep_len = 0; > + } else { > + assert(mem_is_same_type(argv[0], argv[0])); > + sep = argv[1]->z; > + sep_len = argv[1]->n; > + } > + if (sep_len > 0) { > + if (mem_append(ctx->pMem, sep, sep_len) != 0) { 2. Will it work if sep_len == 0? If yes, then I would propose to drop the len check here and call the append always. > + ctx->is_aborted = true; > + return; > + }