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 4CFA86EC58; Tue, 25 May 2021 14:13:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4CFA86EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621941196; bh=f8tD0DCOOWhVWYhjWaTBxvdtwFaopF1ws9PlpqkfZ4U=; 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=p+7d3SLHqWyO+WWGO23zkjfYSlFAv8SDR/67jfDOOfMwEiW9t+5+JwpvdqPCvicfA 0arQE2kBwRKcKLhH8O9tXVDBKktu5L3Eyko7M6U+Fr16nT5k0nwi75CcmsNfzjzZ3B 47Yv30OLQtbULx72pPdMjxYduy1YXEN/L9EVuNcM= 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 155AC6EC58 for ; Tue, 25 May 2021 14:13:15 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 155AC6EC58 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1llUzq-0005el-CG; Tue, 25 May 2021 14:13:14 +0300 Date: Tue, 25 May 2021 14:13:13 +0300 To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org Message-ID: <20210525111313.GA35119@tarantool.org> References: <3f495b512c6d1a0e494c111ad37083f98c9988ad.1619540891.git.imeevma@gmail.com> <2ee164bc-76e0-0a42-aaa1-64583c3d7105@tarantool.org> <20210517121811.GA177791@tarantool.org> <20210524105630.GA82983@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91B019B01C53E51AF6F63A46F26EE68FD6CF19A7203B0589400894C459B0CD1B9F6762B4766C6EEB879219C3A966DAE2E3AC9C414743C08FF985936BB30EC2273 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79D9C320A40CA82D4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F790063771C846A5973DEE7E8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8696E921BA8456DAC3E849BC64A9CC8B4117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAE9A1BBD95851C5BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735201E561CDFBCA1751F2CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B66F6A3E018CF4DC80089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A59A94185C4C1DAEB2B32A28EEED8A43691DB5B7C266DDFA8DD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA753C350047980234DB410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34AF12ADB97C97CD89490BDC7377FC3B0B1199C2687ACEAF54BA62517D5CAA370A04BBBDE89BF8273B1D7E09C32AA3244CAE7BABD123E280088E38424741D3B54B30363D8B7DA7DD44729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojV3CWresp27eqyQW49UvJig== X-Mailru-Sender: 689FA8AB762F73936BC43F508A063822822432110E11C92B415E376DF4A73A3483D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B 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: Mergen Imeev via Tarantool-patches Reply-To: Mergen Imeev Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi! Thank you for the review! My answers and diff below. On Mon, May 24, 2021 at 05:26:22PM +0200, Vladislav Shpilevoy wrote: > 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(). > No, mem_destroy() is called for MEM "to". > > 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. > Fixed. > > + 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. > Fixed. > > 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(). > Fixed. > > pRec->aMem[i].db = db; > > } > > p->ppRec[0] = pRec; > Diff: diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c index 1bd70c37f..03fbffc7f 100644 --- a/src/box/sql/mem.c +++ b/src/box/sql/mem.c @@ -1357,7 +1357,7 @@ mem_concat(struct Mem *a, struct Mem *b, struct Mem *result) if (sqlVdbeMemGrow(result, size, result == a) != 0) return -1; - result->type = a->type == MEM_TYPE_STR ? MEM_TYPE_STR : MEM_TYPE_BIN; + result->type = a->type; result->flags = 0; if (result->type == MEM_TYPE_BIN) result->field_type = FIELD_TYPE_VARBINARY; @@ -2401,7 +2401,7 @@ sql_vdbemem_finalize(struct Mem *mem, struct func *func) Mem t; memset(&t, 0, sizeof(t)); t.type = MEM_TYPE_NULL; - t.flags = 0; + assert(t.flags == 0); 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 1aa201466..2c5099616 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -94,7 +94,7 @@ valueNew(sql * db, struct ValueNewStat4Ctx *p) ROUND8(sizeof(UnpackedRecord))); for (uint32_t i = 0; i < part_count; i++) { pRec->aMem[i].type = MEM_NULL; - pRec->aMem[i].flags = 0; + assert(pRec->aMem[i].flags == 0); pRec->aMem[i].db = db; } p->ppRec[0] = pRec;