[Tarantool-patches] [PATCH v3 1/2] sql: refactor sqlVdbeMemIntegerify() function

imeevma at tarantool.org imeevma at tarantool.org
Mon Dec 9 16:34:14 MSK 2019


The sqlVdbeMemIntegerify() function accepts the is_forced flag as
one of the arguments. But this flag is actually useless, because
regardless of whether it is TRUE or FALSE, the function will do
the same. This patch removes the is_forced argument from the
function. There will be no test, since the result of the function
has not changed.

Part of #4526
---
 src/box/sql/vdbe.c    | 2 +-
 src/box/sql/vdbeInt.h | 2 +-
 src/box/sql/vdbemem.c | 9 ++-------
 3 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index ab86be9..8ea1df8 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -328,7 +328,7 @@ mem_apply_type(struct Mem *record, enum field_type type)
 					    record->u.r <= -1);
 			return 0;
 		}
-		if (sqlVdbeMemIntegerify(record, false) != 0)
+		if (sqlVdbeMemIntegerify(record) != 0)
 			return -1;
 		if ((record->flags & MEM_Int) == MEM_Int) {
 			if (type == FIELD_TYPE_UNSIGNED)
diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h
index 0f32b4c..d70f683 100644
--- a/src/box/sql/vdbeInt.h
+++ b/src/box/sql/vdbeInt.h
@@ -506,7 +506,7 @@ int sqlVdbeMemMakeWriteable(Mem *);
 int sqlVdbeMemStringify(Mem *);
 int sqlVdbeIntValue(Mem *, int64_t *, bool *is_neg);
 
-int sqlVdbeMemIntegerify(Mem *, bool is_forced);
+int sqlVdbeMemIntegerify(struct Mem *pMem);
 int sqlVdbeRealValue(Mem *, double *);
 
 int
diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c
index 2d37b62..e2e2b7a 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -554,7 +554,7 @@ mem_apply_integer_type(Mem *pMem)
  * Convert pMem to type integer.  Invalidate any prior representations.
  */
 int
-sqlVdbeMemIntegerify(Mem * pMem, bool is_forced)
+sqlVdbeMemIntegerify(struct Mem *pMem)
 {
 	assert(EIGHT_BYTE_ALIGNMENT(pMem));
 
@@ -563,11 +563,6 @@ sqlVdbeMemIntegerify(Mem * pMem, bool is_forced)
 	if (sqlVdbeIntValue(pMem, &i, &is_neg) == 0) {
 		mem_set_int(pMem, i, is_neg);
 		return 0;
-	} else if ((pMem->flags & MEM_Real) != 0 && is_forced) {
-		if (pMem->u.r >= INT64_MAX || pMem->u.r < INT64_MIN)
-			return -1;
-		mem_set_int(pMem, pMem->u.r, pMem->u.r <= -1);
-		return 0;
 	}
 
 	double d;
@@ -735,7 +730,7 @@ sqlVdbeMemCast(Mem * pMem, enum field_type type)
 			MemSetTypeFlag(pMem, MEM_UInt);
 			return 0;
 		}
-		if (sqlVdbeMemIntegerify(pMem, true) != 0)
+		if (sqlVdbeMemIntegerify(pMem) != 0)
 			return -1;
 		if (type == FIELD_TYPE_UNSIGNED &&
 		    (pMem->flags & MEM_UInt) == 0)
-- 
2.7.4



More information about the Tarantool-patches mailing list