From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) (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 1C1A8445320 for ; Mon, 13 Jul 2020 13:36:17 +0300 (MSK) Date: Mon, 13 Jul 2020 10:36:16 +0000 From: Nikita Pettik Message-ID: <20200713103616.GA15396@tarantool.org> References: <511253f302641d67f2de57b0fe2f0e2c7d1a11a6.1594618005.git.imeevma@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <511253f302641d67f2de57b0fe2f0e2c7d1a11a6.1594618005.git.imeevma@gmail.com> Subject: Re: [Tarantool-patches] [PATCH v4 1/5] sql: set field_type in mem_set_*() functions List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: imeevma@tarantool.org Cc: tarantool-patches@dev.tarantool.org On 13 Jul 08:32, imeevma@tarantool.org wrote: > After this patch, the mem_set _*() functions will set the mem field type > along with its MEM type flag. Nice. All tests seem passing. So what was the problem in this refactoring? I 'member you said that it couldn't be done with ease. LGTM but I would put justification in commit message. > --- > src/box/sql/vdbemem.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c > index 2e0d0bc3b..8e9ebf7ab 100644 > --- a/src/box/sql/vdbemem.c > +++ b/src/box/sql/vdbemem.c > @@ -829,6 +829,7 @@ mem_set_bool(struct Mem *mem, bool value) > sqlVdbeMemSetNull(mem); > mem->u.b = value; > mem->flags = MEM_Bool; > + mem->field_type = FIELD_TYPE_BOOLEAN; > } > > void > @@ -839,6 +840,7 @@ mem_set_i64(struct Mem *mem, int64_t value) > mem->u.i = value; > int flag = value < 0 ? MEM_Int : MEM_UInt; > MemSetTypeFlag(mem, flag); > + mem->field_type = FIELD_TYPE_INTEGER; > } > > void > @@ -848,6 +850,7 @@ mem_set_u64(struct Mem *mem, uint64_t value) > sqlVdbeMemSetNull(mem); > mem->u.u = value; > MemSetTypeFlag(mem, MEM_UInt); > + mem->field_type = FIELD_TYPE_UNSIGNED; > } > > void > @@ -863,6 +866,7 @@ mem_set_int(struct Mem *mem, int64_t value, bool is_neg) > mem->u.u = value; > MemSetTypeFlag(mem, MEM_UInt); > } > + mem->field_type = FIELD_TYPE_INTEGER; > } > > void > @@ -873,6 +877,7 @@ mem_set_double(struct Mem *mem, double value) > return; > mem->u.r = value; > MemSetTypeFlag(mem, MEM_Real); > + mem->field_type = FIELD_TYPE_DOUBLE; > } > > /* > @@ -1068,6 +1073,11 @@ sqlVdbeMemSetStr(Mem * pMem, /* Memory cell to set to string value */ > > pMem->n = nByte; > pMem->flags = flags; > + assert((pMem->flags & (MEM_Str | MEM_Blob)) != 0); > + if ((pMem->flags & MEM_Str) != 0) > + pMem->field_type = FIELD_TYPE_STRING; > + else > + pMem->field_type = FIELD_TYPE_VARBINARY; > > if (nByte > iLimit) { > diag_set(ClientError, ER_SQL_EXECUTE, "string or binary string"\ > -- > 2.25.1 >