Tarantool development patches archive
 help / color / mirror / Atom feed
From: imeevma@tarantool.org
To: korablev@tarantool.org, tsafin@tarantool.org,
	tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v5 01/17] sql: set field_type in mem_set_*() functions
Date: Tue, 14 Jul 2020 18:48:11 +0300	[thread overview]
Message-ID: <b4463892128e9c6338a33b9960e4ff853a3caf6f.1594741192.git.imeevma@gmail.com> (raw)
In-Reply-To: <cover.1594741192.git.imeevma@gmail.com>

After this patch, the mem_set _*() functions will set the mem field type
along with its MEM type flag. This will allow us to be sure that the MEM
type and field type are set correctly, which is important when
converting values from one type to another.

Needed for #3809
---
 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

  reply	other threads:[~2020-07-14 15:48 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 15:48 [Tarantool-patches] [PATCH v5 00/17] sql: change implicit cast for assignment imeevma
2020-07-14 15:48 ` imeevma [this message]
2020-07-15 12:22   ` [Tarantool-patches] [PATCH v5 01/17] sql: set field_type in mem_set_*() functions Nikita Pettik
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 02/17] sql: change implicit cast for assignment imeevma
2020-07-15 13:41   ` Mergen Imeev
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 03/17] sql: use ApplyType to check function arguments imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 04/17] sql: check args of abs() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 05/17] sql: check args of avg(), sum() and total() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 06/17] sql: check args of char() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 07/17] sql: check args of length() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 08/17] sql: check operands of LIKE imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 09/17] sql: check args of lower() and upper() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 10/17] sql: check args of position() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 11/17] sql: check args of randomblob() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 12/17] sql: check args of replace() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 13/17] sql: check args of round() imeevma
2020-07-14 15:48 ` [Tarantool-patches] [PATCH v5 14/17] sql: check args of soundex() imeevma
2020-07-14 15:49 ` [Tarantool-patches] [PATCH v5 15/17] sql: check args of substr() imeevma
2020-07-14 15:49 ` [Tarantool-patches] [PATCH v5 16/17] sql: check args of unicode() imeevma
2020-07-14 15:49 ` [Tarantool-patches] [PATCH v5 17/17] sql: check args of zeroblob() imeevma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4463892128e9c6338a33b9960e4ff853a3caf6f.1594741192.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=tsafin@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v5 01/17] sql: set field_type in mem_set_*() functions' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox