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 6F7C670293; Sat, 30 Oct 2021 02:42:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6F7C670293 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635550965; bh=GZkLI8qssHeDljqNmPH8A4R2YA1JA01NRahqsbQFPTw=; 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=h9/QXAX6P5YXMouJurtdZA1AuKQ7bdct4eDAAaS46jqvaq+bDSq+lC0DhI4XAHYWx 0gtRXxEzNKTwkGacG+zFF8JT4QF6QY9VBQByVGE+nEXQaan02LSWGQUTkDul4hVDBs SUJvksPEe8GXKdi0i+GyoFAQD2AU24tF/Iu9UmsQ= 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 7CD2470293 for ; Sat, 30 Oct 2021 02:42:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7CD2470293 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mgbWF-0007Uy-O6; Sat, 30 Oct 2021 02:42:44 +0300 Message-ID: Date: Sat, 30 Oct 2021 01:42:42 +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: <7a6d7ca687a6e4d06b087af5f2e442042b38cf7b.1633713432.git.imeevma@gmail.com> <52e168e4-1559-fd6c-c5a6-d98e3c2d678a@tarantool.org> <20211025080212.GA36295@tarantool.org> In-Reply-To: <20211025080212.GA36295@tarantool.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD98893113B6235BE911D7469FFCDA0599442A966A949E08E0F182A05F53808504016DB28A387B3606390076EDF8103BFFE2F9F543BED935848FC0E705D538869E4 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70CB15FA6C489297DEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063792EDBE6976DC04EF8F08D7030A58E5AD1A62830130A00468AEEEE3FBA3A834EE7353EFBB55337566A496FB89EAD9B8BE5E7C00E23323B5141DA5EAA3096A3E37A471835C12D1D9774AD6D5ED66289B5259CC434672EE6371117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658359CC434672EE6371117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637F765F39FA4E70FFE43847C11F186F3C59DAA53EE0834AAEE X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505C29A494506F32D847E2B9A033E0372E5 X-C1DE0DAB: 0D63561A33F958A524AFA4BCACC822D7627DA5073295E57728431EACCC1E3F82D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75C69C5C0DDE134364410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34D9DC20663B80603FB3C2E83259DA7D7AC8F2DD70ECFA347492004296D44D693939039E39AF622F8A1D7E09C32AA3244C3196392925C44B5B9FF7970E4F2DDA7ACE0B41342B755BCD729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj4X0lO6iC8i930vXRkmkjcg== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D0EA43868D77BB25F844B53E7FE9B14253841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 01/21] sql: refactor CHAR() 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" Hi! Thanks for the fixes! See 3 comments below. > diff --git a/src/box/sql/func.c b/src/box/sql/func.c > index afe34f7f0..dee28b852 100644 > --- a/src/box/sql/func.c > +++ b/src/box/sql/func.c > @@ -717,6 +717,57 @@ func_substr_characters(struct sql_context *ctx, int argc, struct Mem *argv) > ctx->is_aborted = true; > } > > +/** > + * Implementation of the CHAR() function. > + * > + * This function takes zero or more arguments, each of which is an integer. It > + * constructs a string where each character of the string is the unicode > + * character for the corresponding integer argument. > + * > + * If an argument is negative or greater than 0x10ffff, the symbol "�" is used. > + * Symbol '\0' used instead of NULL argument. > + */ > +static void > +func_char(struct sql_context *ctx, int argc, struct Mem *argv) > +{ > + if (argc == 0) > + return mem_set_str_static(ctx->pOut, "", 0); > + struct region *region = &fiber()->gc; > + size_t svp = region_used(region); > + UChar32 *buf = region_alloc(region, argc * sizeof(*buf)); 1. Would be better to use region_alloc_array(). Otherwise you risk to get misaligned data. > + if (buf == NULL) { > + ctx->is_aborted = true; 2. Need to use diag_set() here. > + return; > + } > + int len = 0; > + for (int i = 0; i < argc; ++i) { > + if (mem_is_null(&argv[i])) > + buf[i] = 0; > + else if (!mem_is_uint(&argv[i]) || argv[i].u.u > 0x10ffff) > + buf[i] = 0xfffd; > + else > + buf[i] = argv[i].u.u; > + len += U8_LENGTH(buf[i]); > + } > + > + char *str = sqlDbMallocRawNN(sql_get(), len); > + if (str == NULL) { > + ctx->is_aborted = true; 3. region leaks here, doesn't it?