Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] [PATCH 1/3] sql: fix value of mask to map VDBE memory type
Date: Tue, 19 Feb 2019 11:28:21 +0300	[thread overview]
Message-ID: <c6fc6893306fa7d1cc1f7687f99ea77bd7eae46a.1550532805.git.korablev@tarantool.org> (raw)
In-Reply-To: <cover.1550532805.git.korablev@tarantool.org>
In-Reply-To: <cover.1550532805.git.korablev@tarantool.org>

Accidentally, mask which is used to map type of VDBE memory cell into
outer API types was replaced with MEM_TypeMask. But value of the latter
is larger then possible values of VDBE memory cells types. Hence, if it
is applied to memory cell, not only pure types is taken into
consideration, but some additional flags (such as MEM_Zero) as well.
Overall, it results in wrong type calculation for zeroed blobs, for
instance. Lets return back previous mask.

Follow-up #3698
Needed for #3544
---
 src/box/sql/vdbeInt.h | 9 +++++++++
 src/box/sql/vdbeapi.c | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h
index d003d6bb3..933867469 100644
--- a/src/box/sql/vdbeInt.h
+++ b/src/box/sql/vdbeInt.h
@@ -253,6 +253,15 @@ struct Mem {
 #define MEM_Zero 0x0000
 #endif
 
+/**
+ * In contrast to Mem_TypeMask, this one allows to get
+ * pure type of memory cell, i.e. without _Dyn/_Zero and other
+ * auxiliary flags.
+ */
+enum {
+	MEM_PURE_TYPE_MASK = 0x1f
+};
+
 
 /* Return TRUE if Mem X contains dynamically allocated content - anything
  * that needs to be deallocated to avoid a leak.
diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c
index 7a11bcb0a..250afc20d 100644
--- a/src/box/sql/vdbeapi.c
+++ b/src/box/sql/vdbeapi.c
@@ -280,7 +280,7 @@ sql_value_type(sql_value * pVal)
 		SQL_INTEGER,	/* 0x1e */
 		SQL_NULL,	/* 0x1f */
 	};
-	return aType[pVal->flags & MEM_TypeMask];
+	return aType[pVal->flags & MEM_PURE_TYPE_MASK];
 }
 
 /* Make a copy of an sql_value object
-- 
2.15.1

  reply	other threads:[~2019-02-19  8:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19  8:28 [tarantool-patches] [PATCH 0/3] Concatenation operator type fixes Nikita Pettik
2019-02-19  8:28 ` Nikita Pettik [this message]
2019-02-19  8:28 ` [tarantool-patches] [PATCH 2/3] sql: allow only string-like arguments for concatenation Nikita Pettik
2019-02-19  8:28 ` [tarantool-patches] [PATCH 3/3] sql: fix resulting type for concatenation operator Nikita Pettik
2019-02-22 15:54 ` [tarantool-patches] Re: [PATCH 0/3] Concatenation operator type fixes Vladislav Shpilevoy
2019-02-25 11:42 ` Kirill Yukhin

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=c6fc6893306fa7d1cc1f7687f99ea77bd7eae46a.1550532805.git.korablev@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH 1/3] sql: fix value of mask to map VDBE memory type' \
    /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