Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Imeev Mergen <imeevma@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v3 1/2] sql: move autoincrement in vdbe
Date: Mon, 27 Aug 2018 17:27:22 +0300	[thread overview]
Message-ID: <2E717CA0-3AA6-464D-8938-47B3058A557C@tarantool.org> (raw)
In-Reply-To: <2ab414e943955a89905f4f7919406d74d348a078.1535107514.git.imeevma@gmail.com>


> This patch expands changes made in issue #2981. Now NULL
> in primary key always replaced by generated value inside
> of vdbe.

Nitpicking: during VDBE execution.

> It allows us to get last_insert_id with easy.

Nitpicking: with ease.

Actually I can’t understand purpose of this patch.
These manipulations with NULL are quite tricky.
Could you please explain in details what the bug was
about and how you fix it. Thx.

> --- a/test/sql/gh-2981-check-autoinc.test.lua
> +++ b/test/sql/gh-2981-check-autoinc.test.lua
> @@ -7,6 +7,7 @@ box.cfg{}
> box.sql.execute("CREATE TABLE t1 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 INTEGER, CHECK (s1 <> 19));");
> box.sql.execute("CREATE TABLE t2 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 INTEGER, CHECK (s1 <> 19 AND s1 <> 25));");
> box.sql.execute("CREATE TABLE t3 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 INTEGER, CHECK (s1 < 10));");
> +box.sql.execute("CREATE TABLE t4 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 INTEGER, CHECK (s1 <> 19));");
> 
> box.sql.execute("insert into t1 values (18, null);")
> box.sql.execute("insert into t1(s2) values (null);")
> @@ -19,7 +20,10 @@ box.sql.execute("insert into t2(s2) values (null);")
> box.sql.execute("insert into t3 values (9, null)")
> box.sql.execute("insert into t3(s2) values (null)")
> 
> +box.sql.execute("insert into t4 values (18, null);")
> +box.sql.execute("insert into t4 values (null, null);”)

I have doubts concerning this test. Firstly, AFAIK sequence
doesn’t guarantee that new values == prev_value + 1.
Thus, basically this test can fail. Moreover, why next
INSERT(NULL, NULL) doesn’t fail? For me it seems counterintuitive.
I mean I understand that sequence generator increased but insertion
failed and so forth. But does user expect such behaviour?
For instance, in MySQL this doesn’t result in error at all:

CREATE TABLE t4 (s1 int PRIMARY KEY AUTO_INCREMENT, s2 INTEGER, CHECK (s1 <> 19)) \\

insert into t4 values (18, null) \\
insert into t4 values (null, null) \\
insert into t4 values (null, null) \\
select * from t4\\

  	mysql version
1	5.7.12-log

  	s1	s2
1	18	NULL
2	19	NULL
3	20	NULL

  reply	other threads:[~2018-08-27 14:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-24 10:57 [tarantool-patches] [PATCH v3 0/2] sql: return last_insert_id via IPROTO imeevma
2018-08-24 10:57 ` [tarantool-patches] [PATCH v3 1/2] sql: move autoincrement in vdbe imeevma
2018-08-27 14:27   ` n.pettik [this message]
2018-08-24 10:57 ` [tarantool-patches] [PATCH v3 2/2] sql: return last_insert_id via IPROTO imeevma
2018-08-27 14:25   ` [tarantool-patches] " n.pettik

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=2E717CA0-3AA6-464D-8938-47B3058A557C@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v3 1/2] sql: move autoincrement in vdbe' \
    /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