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 81ECE2C9C9 for ; Thu, 11 Oct 2018 11:09:05 -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 MrPaREmqMF3C for ; Thu, 11 Oct 2018 11:09:05 -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 8E9572A765 for ; Thu, 11 Oct 2018 11:09:04 -0400 (EDT) From: "n.pettik" Message-Id: Content-Type: multipart/alternative; boundary="Apple-Mail=_48BD3E21-CB96-4CA4-ACEC-E383ECB6BB29" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH v2 1/1] sql: cleanup on failed creation operation Date: Thu, 11 Oct 2018 18:09:01 +0300 In-Reply-To: References: <433c416428f1ef575324236be22c27962db3f8b5.1536346889.git.imeevma@gmail.com> <74ed5f5b-d74f-0933-ccf0-c0d9861f0842@tarantool.org> <30e818b1-2916-58cc-9074-2764de0d6fad@tarantool.org> <80242351-a576-dde6-034e-f19c899a9cc9@tarantool.org> <51918bf1-14ea-45aa-4e1e-901d2ee9c532@tarantool.org> <1AF44E5C-F76B-4783-8578-FC4AFA437E66@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: Imeev Mergen --Apple-Mail=_48BD3E21-CB96-4CA4-ACEC-E383ECB6BB29 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 >>> +-- >>> +-- Check that _space, _index and _sequence have the same number of >>> +-- records. >>> +-- >>> +space_count =3D=3D #box.space._space:select() >>> +index_count =3D=3D #box.space._index:select() >>> +sequence_count =3D=3D #box.space._sequence:select() >>> + >>> +box.schema.user.drop('tmp=E2=80=99) >> I see no tests involving FK constraints. Add them as well. >>=20 > Added. > diff --git a/test/sql/drop-table.test.lua = b/test/sql/drop-table.test.lua > index 1bc8894..f86e3d8 100644 > --- a/test/sql/drop-table.test.lua > +++ b/test/sql/drop-table.test.lua >=20 > +-- Give user right to write in _sequence. Still have not enough > +-- rights to write in _fk_constraint. > +-- > +box.schema.user.grant('tmp', 'write', 'space', '_sequence') > +box.session.su('tmp') > + > +box.sql.execute('CREATE TABLE t3(a INTEGER PRIMARY KEY);') > +-- > +-- Error: user do not have rights to write in _fk_constraint. > +-- > +box.sql.execute('CREATE TABLE t4(x INTEGER PRIMARY KEY REFERENCES = t3);') > +box.sql.execute('DROP TABLE t3;=E2=80=99) You misunderstood me a bit. I mean following test: fk_count =3D #box.space._fk_constraints:select() box.sql.execute('CREATE TABLE t4(x INTEGER PRIMARY KEY REFERENCES t3, a = INT UNIQUE, c INT REFERENCES t3);=E2=80=99) Here creation of last FK fails - for instance due to type mismatch. Then, number of created FK constraints (and indexes) should be = unchanged: fk_count =3D=3D #box.space._fk_constraints:select() index_count =3D=3D #box.space._fk_constraints:select() Note that FK constraints are created after indexes. --Apple-Mail=_48BD3E21-CB96-4CA4-ACEC-E383ECB6BB29 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

+--
+-- Check that _space, _index and _sequence have the same number of
+-- records.
+--
+space_count =3D=3D #box.space._space:select()
+index_count =3D=3D #box.space._index:select()
+sequence_count =3D=3D #box.space._sequence:select()
+
+box.schema.user.drop('tmp=E2=80=99)
I see no tests involving FK =
constraints. Add them as well.

Added.


diff --git a/test/sql/drop-table.test.lua = b/test/sql/drop-table.test.lua
index 1bc8894..f86e3d8 100644
--- a/test/sql/drop-table.test.lua
+++ b/test/sql/drop-table.test.lua

+-- Give user right to write in _sequence. Still = have not enough
+-- rights to write = in _fk_constraint.
+--
+box.schema.user.grant('tmp', 'write', 'space', = '_sequence')
+box.session.su('tmp')
+
+box.sql.execute('CREATE TABLE t3(a INTEGER PRIMARY = KEY);')
+--
+-- Error: user do not have rights to write in = _fk_constraint.
+--
+box.sql.execute('CREATE TABLE t4(x INTEGER = PRIMARY KEY REFERENCES t3);')
+box.sql.execute('DROP TABLE t3;=E2=80=99)

You = misunderstood me a bit. I mean following test:

fk_count =3D #box.space._fk_constraints:select()

box.sql.execute('CREATE TABLE t4(x INTEGER = PRIMARY KEY REFERENCES t3, a INT UNIQUE, c INT REFERENCES = t3);=E2=80=99)

Here creation = of last FK fails - for instance due to type = mismatch.
Then, number of created FK constraints (and = indexes) should be unchanged:

fk_count =3D=3D #box.space._fk_constraints:select()
index_count = =3D=3D #box.space._fk_constraints:select()

Note that FK constraints are created after = indexes.

= --Apple-Mail=_48BD3E21-CB96-4CA4-ACEC-E383ECB6BB29--