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 C19597030C; Mon, 24 May 2021 18:26:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C19597030C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621869985; bh=LYtmAjqFvQWgkjhFlLN8a8Gm2PBxaKlLm2n9LWiCKW0=; 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=fkzfVIJkiTcRAe1z5NfcbKgZX8FuUL7GR0N/4gSTqBd+QOn1gc9vzSnUYgIE2dt2f tTHLjhuBNXaM6HipUvvr+IfhBRw+9BtxFjf+CDxMGdHLTBuAlejYJh+mM5JzUElcUS i2kjeEJXd1YAA6wpqt6wpjT8OF9+0i5ToykEnhFU= Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [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 44E377030C for ; Mon, 24 May 2021 18:26:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 44E377030C Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1llCTH-000513-7V; Mon, 24 May 2021 18:26:23 +0300 To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org References: <3f495b512c6d1a0e494c111ad37083f98c9988ad.1619540891.git.imeevma@gmail.com> <2ee164bc-76e0-0a42-aaa1-64583c3d7105@tarantool.org> <20210517121811.GA177791@tarantool.org> <20210524105630.GA82983@tarantool.org> Message-ID: Date: Mon, 24 May 2021 17:26:22 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <20210524105630.GA82983@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91B019B01C53E51AF9418A6087D01078917D63D7C0371164600894C459B0CD1B95FD238C7D11890BBC7BAF06765DEF7B0C2FE3E072D433658889E25F54A9B433D X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79379E597596E9183EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374CC1EE7F84E0F1BE8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CD71485E192D427D401CCC45EEB841F8117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC60CDF180582EB8FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751FF04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B1CFA6D474D4A6A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A58624AE240CC89A2A41F478D24C7EA60AAF04A856341E9F7DD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA753C350047980234DB410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A2EC120135420F90858498857DCBE74C5DE65B238BCB6F73E4D17C7FF5E0B8CE979F49C8424A271D1D7E09C32AA3244C1A8AAE3EF3B42BAFD4872A83E5BCBDFEF2F5F14F68F1805B729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj+gjVyQcIK6IYuqa8JrVvSA== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822F1D54397DEA41713198FD8C0BA9771E23841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E267EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 3/3] sql: replace MEM-type flags by enum mem_type 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 4 new comments below, somehow I didn't notice them first time. > diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c > index b6ff6397f..1bd70c37f 100644 > --- a/src/box/sql/mem.c > +++ b/src/box/sql/mem.c > @@ -1236,7 +1297,8 @@ mem_move(struct Mem *to, struct Mem *from) > { > mem_destroy(to); > memcpy(to, from, sizeof(*to)); > - from->flags = MEM_Null; > + from->type = MEM_TYPE_NULL; > + from->flags = 0; 1. Flags are already 0 after mem_destroy(). > from->szMalloc = 0; > from->zMalloc = NULL; > } > @@ -1295,8 +1357,9 @@ mem_concat(struct Mem *a, struct Mem *b, struct Mem *result) > if (sqlVdbeMemGrow(result, size, result == a) != 0) > return -1; > > - result->flags = a->flags & (MEM_Str | MEM_Blob); > - if ((result->flags & MEM_Blob) != 0) > + result->type = a->type == MEM_TYPE_STR ? MEM_TYPE_STR : MEM_TYPE_BIN; 2. You could also make `result->type = a->type;`. Without `?:`. A->type is anyway either STR or BIN. > + result->flags = 0; > + if (result->type == MEM_TYPE_BIN) > result->field_type = FIELD_TYPE_VARBINARY; > if (result != a) > @@ -2322,12 +2395,13 @@ sql_vdbemem_finalize(struct Mem *mem, struct func *func) > assert(func != NULL); > assert(func->def->language == FUNC_LANGUAGE_SQL_BUILTIN); > assert(func->def->aggregate == FUNC_AGGREGATE_GROUP); > - assert((mem->flags & MEM_Null) != 0 || func == mem->u.func); > + assert(mem->type == MEM_TYPE_NULL || func == mem->u.func); > sql_context ctx; > memset(&ctx, 0, sizeof(ctx)); > Mem t; > memset(&t, 0, sizeof(t)); > - t.flags = MEM_Null; > + t.type = MEM_TYPE_NULL; > + t.flags = 0; 3. It is already 0 after memset() above. > t.db = mem->db; > t.field_type = field_type_MAX; > ctx.pOut = &t; > diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c > index ba5c08a00..1aa201466 100644 > --- a/src/box/sql/vdbemem.c > +++ b/src/box/sql/vdbemem.c > @@ -93,7 +93,8 @@ valueNew(sql * db, struct ValueNewStat4Ctx *p) > pRec->aMem = (Mem *)((char *) pRec + > ROUND8(sizeof(UnpackedRecord))); > for (uint32_t i = 0; i < part_count; i++) { > - pRec->aMem[i].flags = MEM_Null; > + pRec->aMem[i].type = MEM_NULL; > + pRec->aMem[i].flags = 0; 4. Flags are already 0 - the memory was allocated using sqlDbMallocZero(). > pRec->aMem[i].db = db; > } > p->ppRec[0] = pRec;