[Tarantool-patches] [PATCH v4 1/5] sql: set field_type in mem_set_*() functions

imeevma at tarantool.org imeevma at tarantool.org
Mon Jul 13 08:32:59 MSK 2020


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



More information about the Tarantool-patches mailing list