From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 18A2B216C9 for ; Mon, 8 Jul 2019 14:54:14 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NV_myQX6CnI4 for ; Mon, 8 Jul 2019 14:54:13 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id C278B20976 for ; Mon, 8 Jul 2019 14:54:13 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH v2 1/3] sql: remove unnecessary AUTOINCREMENT ID generation From: "n.pettik" In-Reply-To: <96975db4f246bc09a3801dd247f5ab65d7709a6f.1562239051.git.imeevma@gmail.com> Date: Mon, 8 Jul 2019 21:54:11 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <8FEB50DF-9030-41DB-B113-FDDE6EF3B1C1@tarantool.org> References: <96975db4f246bc09a3801dd247f5ab65d7709a6f.1562239051.git.imeevma@gmail.com> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Imeev Mergen > On 4 Jul 2019, at 14:42, imeevma@tarantool.org wrote: >=20 > Currently, if we perform something like > CREATE TABLE t (i INT PRIMARY KEY AUTOINCREMENT); > INSERT INTO t(a) VALUES (NULL); >=20 > we generate a new identifier in a special way. Describe this =E2=80=9Cspecial=E2=80=9D way. > src/box/sql/insert.c | 5 +---- > test/sql/gh-2981-check-autoinc.result | 32 = ++++++++++++++++++++++++++++++++ > test/sql/gh-2981-check-autoinc.test.lua | 11 ++++++++++- > 3 files changed, 43 insertions(+), 5 deletions(-) >=20 > diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c > index b353148..d2b4e17 100644 > --- a/src/box/sql/insert.c > +++ b/src/box/sql/insert.c > @@ -628,10 +628,7 @@ sqlInsert(Parse * pParse, /* Parser = context */ > if (j < 0 || nColumn =3D=3D 0 > || (pColumn && j >=3D pColumn->nId)) { > if (i =3D=3D (int) autoinc_fieldno) { > - sqlVdbeAddOp2(v, > - = OP_NextAutoincValue, > - = space->def->id, > - iRegStore); Why didn=E2=80=99t you delete OP_NextAutioncValue? > + sqlVdbeAddOp2(v, OP_Null, 0, = iRegStore); > continue; > } > struct Expr *dflt =3D NULL; >=20 > diff --git a/test/sql/gh-2981-check-autoinc.test.lua = b/test/sql/gh-2981-check-autoinc.test.lua > index 0eb8f73..ac5624e 100644 > --- a/test/sql/gh-2981-check-autoinc.test.lua > +++ b/test/sql/gh-2981-check-autoinc.test.lua > @@ -7,6 +7,8 @@ box.cfg{} > box.execute("CREATE TABLE t1 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 = INTEGER, CHECK (s1 <> 19));"); > box.execute("CREATE TABLE t2 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 = INTEGER, CHECK (s1 <> 19 AND s1 <> 25));"); > box.execute("CREATE TABLE t3 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 = INTEGER, CHECK (s1 < 10));=E2=80=9D); > +box.execute("CREATE TABLE t4 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, = s2 INTEGER, CHECK (s1 < 10));"); > +box.execute("CREATE TABLE t5 (s1 INTEGER PRIMARY KEY AUTOINCREMENT, = s2 INTEGER, CHECK (s1 <> 19));=E2=80=9D); Add explanation to these tests.. What do they verify? I build master branch and they are passed as well. > box.execute("insert into t1 values (18, null);") > box.execute("insert into t1(s2) values (null);") > @@ -19,7 +21,14 @@ box.execute("insert into t2(s2) values (null);") > box.execute("insert into t3 values (9, null)") > box.execute("insert into t3(s2) values (null)") >=20 > +box.execute("insert into t4 values (9, null)") > +box.execute("insert into t4 values (null, null)") > + > +box.execute("INSERT INTO t5 VALUES (18, NULL);") > +box.execute("INSERT INTO t5 SELECT NULL, NULL FROM t5;") > +