From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 DA064445320 for ; Mon, 13 Jul 2020 08:33:00 +0300 (MSK) From: imeevma@tarantool.org Date: Mon, 13 Jul 2020 08:32:59 +0300 Message-Id: <511253f302641d67f2de57b0fe2f0e2c7d1a11a6.1594618005.git.imeevma@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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: korablev@tarantool.org, tsafin@tarantool.org, tarantool-patches@dev.tarantool.org After this patch, the mem_set _*() functions will set the mem field type along with its MEM type flag. --- 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