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 01D996BD00; Tue, 30 Mar 2021 02:10:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 01D996BD00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617059458; bh=39UeF2QUMBQLPgZE60XDU/kd22wfLT3z1idojUQcqvE=; 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=GkCU1nb60927Egg7Fiprd/0lZcuLhLJTjfXDYLPANsIFPGXmLNBGvkIUf8EAKmwM3 Ca6s8YvaVlkRMtlbHZr25rbO6z6ibpvKdlDqv7kG8zrLj8Zg7W72w+UrBMjC5HGxF9 JKiCPSlbq2ucEUh4s/GHTBpMcku0kiTTplYEqrVk= 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 4A1036BD11 for ; Tue, 30 Mar 2021 02:06:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4A1036BD11 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1lR0yD-0002YF-GU; Tue, 30 Mar 2021 02:06:53 +0300 To: imeevma@tarantool.org, tsafin@tarantool.org Cc: tarantool-patches@dev.tarantool.org References: Message-ID: <9d95f074-bd5d-16d9-1fdf-70919bf66ce8@tarantool.org> Date: Tue, 30 Mar 2021 01:06:52 +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: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9ED7173E37F4E329498ADEA61F680B110809A4DE3E6FC56EA182A05F53808504039A01A3CF88C86D6B605A94EECC2282E2FDAE177BC13D33B81E2D13DF6DA2E13 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE706EA9E10470DC775EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637BBCE7257090F96C9EA1F7E6F0F101C67CDEEF6D7F21E0D1D174C73DBBBFC7664AF392B77D6B6B3818B3DE18F6952A0B6ED40CBA2074A4D48389733CBF5DBD5E913377AFFFEAFD269A417C69337E82CC2CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C0A3E989B1926288338941B15DA834481F9449624AB7ADAF372E808ACE2090B5E14AD6D5ED66289B5259CC434672EE6371089D37D7C0E48F6C8AA50765F7900637AD0424077D726551EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A2AD77751E876CB595E8F7B195E1C97831604167623C6AC6DE7532C244D99A2447 X-C1DE0DAB: 0D63561A33F958A58CBA2FE08659A47AD918B2E40274F4C54BEB0AA08DA0FCE7D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7502E6951B79FF9A3F410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34AAC3D1FDB34D04889F5EF0CA5D57DFF5B80E4E68F28AD8B69AC2781EC3AF0CCCBF45EAA1516602CA1D7E09C32AA3244C521A4A5A58083FC758F42CFC076156B0408A6A02710B7304FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojljIiQOC84rTPma+QaaZnww== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822CB7E98C378B26F7CAA06662580FF20173841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 38/53] sql: introduce mem_*_aggregate() 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! See 2 comments below. > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index 078de0e62..0211069c6 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -613,6 +613,29 @@ mem_set_frame(struct Mem *mem, struct VdbeFrame *frame) > mem->field_type = field_type_MAX; > } > > +int > +mem_prepare_aggregate(struct Mem *mem, struct func *func, int size) 1. Why is this called 'prepare' when the other setters are called 'set'? Maybe use 'set' here as well? > +{ > + if (size <= 0) { > + mem_clear(mem); > + return 0; > + } > + if (sqlVdbeMemGrow(mem, size, 0) != 0) > + return -1; > + memset(mem->z, 0, size); > + mem->n = size; > + mem->flags = MEM_Agg; > + mem->u.func = func; > + mem->field_type = field_type_MAX; > + return 0; > +} > + > +void * > +mem_get_aggregate(struct Mem *mem) > +{ > + return (void *)mem->z; 2. Void cast should work implicitly here I think. But what is more interesting is why do you even need the getter? The other mem types don't have getters for the union fields, and it is fine I suppose. Would be too much. This one does not even check if the type is an aggregate.