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 42FD027A7D for ; Wed, 13 Feb 2019 14:43:30 -0500 (EST) 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 qOvMYrpbVxjj for ; Wed, 13 Feb 2019 14:43:30 -0500 (EST) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 9757F27A30 for ; Wed, 13 Feb 2019 14:43:29 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: [tarantool-patches] Re: [PATCH] sql: prohibit duplication of FK action clause From: "n.pettik" In-Reply-To: <68664d5ad6be9959c4364a288ccc2feed84cd8b4.1550037810.git.kyukhin@tarantool.org> Date: Wed, 13 Feb 2019 22:43:26 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <50B90E82-7ECC-4C12-B7EF-132E77EDDDEC@tarantool.org> References: <68664d5ad6be9959c4364a288ccc2feed84cd8b4.1550037810.git.kyukhin@tarantool.org> 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: Kirill Yukhin > On 13 Feb 2019, at 09:08, Kirill Yukhin wrote: >=20 > The patch prohibits duplication of action clause for foreign > key constraints. It is now syntax error to specify, say, > ON UPDATE clause for the same FK twice. > The patch also remove ON INSERT caluse at all, since it > ultimately is no-op and leads to nothing but confusion. >=20 > Closes #3475 > --- > https://github.com/tarantool/tarantool/issues/3475 > = https://github.com/tarantool/tarantool/commits/kyukhin/gh-3475-fk-duplicat= e-action-clause Travis status is completely negative. Please, make sure it is green before sending patch. > src/box/sql/parse.y | 10 +++++++-- > test/sql/gh-3475-fk-duplicate-clause.result | 32 = +++++++++++++++++++++++++++ > test/sql/gh-3475-fk-duplicate-clause.test.lua | 13 +++++++++++ > 3 files changed, 53 insertions(+), 2 deletions(-) > create mode 100644 test/sql/gh-3475-fk-duplicate-clause.result > create mode 100644 test/sql/gh-3475-fk-duplicate-clause.test.lua >=20 > diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y > index 32ef685..7938afd 100644 > --- a/src/box/sql/parse.y > +++ b/src/box/sql/parse.y > @@ -283,10 +283,16 @@ autoinc(X) ::=3D AUTOINCR. {X =3D 1;} > // > %type refargs {int} > refargs(A) ::=3D . { A =3D FKEY_NO_ACTION; } > -refargs(A) ::=3D refargs(A) refarg(Y). { A =3D (A & ~Y.mask) | = Y.value; } > +refargs(A) ::=3D refargs(A) refarg(Y). { if ((A & Y.mask) =3D=3D 0) { > + A =3D (A & ~Y.mask) | = Y.value; > + } else { > + sqlite3ErrorMsg(pParse, > + "near = \"%T\": duplicate FK action clause.", > + = &pParse->sLastToken); > + } > + } Please, fix indentation, it looks extremely awful. Lets use 2 spaces as a default indent (as almost everywhere in parse.y). > diff --git a/test/sql/gh-3475-fk-duplicate-clause.test.lua = b/test/sql/gh-3475-fk-duplicate-clause.test.lua > new file mode 100644 > index 0000000..447c104 > --- /dev/null > +++ b/test/sql/gh-3475-fk-duplicate-clause.test.lua > @@ -0,0 +1,13 @@ > +test_run =3D require('test_run').new() > +engine =3D test_run:get_cfg('engine') > +box.sql.execute('pragma sql_default_engine=3D\''..engine..'\=E2=80=99')= Should this test be engine-dependent? > + > +box.cfg{} > + > +box.sql.execute("CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE)") > +box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES = t1(b) ON UPDATE CASCADE ON UPDATE CASCADE)") > +box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES = t1(b) ON DELETE CASCADE ON DELETE CASCADE)") > +box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES = t1(b) ON DELETE CASCADE ON UPDATE CASCADE)=E2=80=9D) What about next cases: box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES = t1(b) ON DELETE CASCADE ON DELETE RESTRICT)=E2=80=9D) box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES = t1(b) ON DELETE CASCADE ON UPDATE CASCADE ON DELETE RESTRICT )=E2=80=9D) Sorry, can=E2=80=99t check myself since can=E2=80=99t build your branch.