Tarantool development patches archive
 help / color / mirror / Atom feed
From: imeevma@tarantool.org
To: alexander.turenko@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH v1 1/1] lua: allow to push -2^63 in INTEGER field
Date: Thu, 28 Nov 2019 17:11:49 +0300	[thread overview]
Message-ID: <b2eab25df3c08ecb958924179d0f970d8d624b80.1574950131.git.imeevma@gmail.com> (raw)

This patch fixes a bug that appeared due to commit 3a13be1d.
---
https://github.com/tarantool/tarantool/tree/imeevma/small_fixes

 src/lua/utils.c             |  2 +-
 test/engine/insert.result   | 28 ++++++++++++++++++++++++++++
 test/engine/insert.test.lua |  8 ++++++++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/lua/utils.c b/src/lua/utils.c
index 7f7bf47..bad5f7b 100644
--- a/src/lua/utils.c
+++ b/src/lua/utils.c
@@ -667,7 +667,7 @@ luaL_tofield(struct lua_State *L, struct luaL_serializer *cfg, int index,
 		} else if (num >= 0 && num < exp2(64)) {
 			field->type = MP_UINT;
 			field->ival = (uint64_t) num;
-		} else if (num > -exp2(63) && num < exp2(63)) {
+		} else if (num >= -exp2(63) && num < exp2(63)) {
 			field->type = MP_INT;
 			field->ival = (int64_t) num;
 		} else {
diff --git a/test/engine/insert.result b/test/engine/insert.result
index 1015b6a..d678e28 100644
--- a/test/engine/insert.result
+++ b/test/engine/insert.result
@@ -730,3 +730,31 @@ s:drop()
 fiber = nil
 ---
 ...
+format = {{name = 'i', type = 'integer'}}
+---
+...
+s = box.schema.space.create('s', {format = format, engine = engine})
+---
+...
+_ = s:create_index('ii')
+---
+...
+s:insert({-2^63})
+---
+- [-9223372036854775808]
+...
+s:insert({-2^64})
+---
+- error: 'Tuple field 1 type does not match one required by operation: expected integer'
+...
+s:insert({2^63})
+---
+- [9223372036854775808]
+...
+s:insert({2^64})
+---
+- error: 'Tuple field 1 type does not match one required by operation: expected integer'
+...
+s:drop()
+---
+...
diff --git a/test/engine/insert.test.lua b/test/engine/insert.test.lua
index 39b1501..d6df60e 100644
--- a/test/engine/insert.test.lua
+++ b/test/engine/insert.test.lua
@@ -123,3 +123,11 @@ s:select{}
 s:drop()
 fiber = nil
 
+format = {{name = 'i', type = 'integer'}}
+s = box.schema.space.create('s', {format = format, engine = engine})
+_ = s:create_index('ii')
+s:insert({-2^63})
+s:insert({-2^64})
+s:insert({2^63})
+s:insert({2^64})
+s:drop()
-- 
2.7.4

             reply	other threads:[~2019-11-28 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-28 14:11 imeevma [this message]
2019-12-06  0:41 ` Alexander Turenko

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=b2eab25df3c08ecb958924179d0f970d8d624b80.1574950131.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v1 1/1] lua: allow to push -2^63 in INTEGER field' \
    /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