From: imeevma@tarantool.org To: v.shpilevoy@tarantool.org, tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH v1 1/1] sql: assertion in autoincrement column Date: Fri, 28 Sep 2018 19:14:40 +0300 [thread overview] Message-ID: <d12154540dfc7e9ea7f472dbc0fbe673e3747d8e.1538151123.git.imeevma@gmail.com> (raw) In some cases on attempt to insert inappropriate value in autoincrement column assertion was thrown. Now it is fixed. Closes #3670 --- Branch: https://github.com/tarantool/tarantool/tree/imeevma/gh-3670-assertion-in-autoincrement-column Issue: https://github.com/tarantool/tarantool/issues/3670 src/box/sql/vdbe.c | 7 +++++-- test/sql-tap/autoinc.test.lua | 27 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 00ffb0c..632fa52 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -3758,10 +3758,13 @@ case OP_FCopy: { /* out2 */ /* Flag is set and register is NULL -> do nothing */ } else { assert(memIsValid(pIn1)); - assert(pIn1->flags & MEM_Int); pOut = &aMem[pOp->p2]; - MemSetTypeFlag(pOut, MEM_Int); + /* + * Flag should be MEM_Int but in some cases it can + * have an other value. See gh-3670. + */ + MemSetTypeFlag(pOut, pIn1->flags); pOut->u.i = pIn1->u.i; } diff --git a/test/sql-tap/autoinc.test.lua b/test/sql-tap/autoinc.test.lua index dda7061..bd40de9 100755 --- a/test/sql-tap/autoinc.test.lua +++ b/test/sql-tap/autoinc.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(46) +test:plan(48) --!./tcltestrunner.lua -- 2004 November 12 @@ -801,4 +801,29 @@ test:do_test( -- </autoinc-a69637.2> }) +-- gh-3670: Assertion with large number in autoincrement column +test:do_catchsql_test( + "autoinc-gh-3670-1", + [[ + CREATE TABLE t0 (s1 INT PRIMARY KEY AUTOINCREMENT); + INSERT INTO t0 VALUES (2147483647); + INSERT INTO t0 SELECT max(s1)*max(s1)*max(s1) FROM t0; + ]], { + -- <autoinc-10.2> + 1, "datatype mismatch" + -- </autoinc-10.2> + }) + +test:do_catchsql_test( + "autoinc-gh-3670-2", + [[ + CREATE TABLE t1 (s1 INT PRIMARY KEY AUTOINCREMENT, s2 CHAR); + INSERT INTO t1 VALUES (1, 'a'); + INSERT INTO t1 SELECT s2, s2 FROM t1; + ]], { + -- <autoinc-10.2> + 1, "datatype mismatch" + -- </autoinc-10.2> + }) + test:finish_test() -- 2.7.4
next reply other threads:[~2018-09-28 16:14 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-09-28 16:14 imeevma [this message] 2018-09-29 4:27 ` [tarantool-patches] " Konstantin Osipov 2018-10-05 16:41 ` Imeev Mergen 2018-10-05 16:45 ` Imeev Mergen [not found] ` <665AF75C-4542-4DE1-BFCA-F480367585A6@gmail.com> 2018-10-11 16:22 ` Imeev Mergen 2018-10-11 16:38 ` n.pettik 2018-10-03 15:19 ` Vladislav Shpilevoy 2018-10-05 16:40 ` Imeev Mergen 2018-10-10 10:21 ` Vladislav Shpilevoy 2018-10-10 12:22 ` Imeev Mergen 2018-11-01 14:40 ` 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=d12154540dfc7e9ea7f472dbc0fbe673e3747d8e.1538151123.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v1 1/1] sql: assertion in autoincrement column' \ /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