From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 dev.tarantool.org (Postfix) with ESMTPS id 4FB4446970E for ; Tue, 24 Dec 2019 04:23:08 +0300 (MSK) Date: Tue, 24 Dec 2019 04:23:07 +0300 From: Nikita Pettik Message-ID: <20191224012307.GA49851@tarantool.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH 2/2] sql: drop only generated sequence in DROP TABLE List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chris Sosnin Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org On 18 Dec 14:00, Chris Sosnin wrote: > create mode 100644 test/sql/autoincrement.result > create mode 100644 test/sql/autoincrement.test.lua > > diff --git a/test/sql/autoincrement.test.lua b/test/sql/autoincrement.test.lua Patch itself is LGTM (as obvious). But I am not a big fan of placing each test in separate file (at least when there's no specific issue for that). Moreover, in commit message it is said that this patch is follow-up to #4546, so could you move this test to gh-4546-sql-drop-grants.test.lua ? > new file mode 100644 > index 000000000..63a902aea > --- /dev/null > +++ b/test/sql/autoincrement.test.lua > @@ -0,0 +1,33 @@ > +test_run = require('test_run').new() > +engine = test_run:get_cfg('engine') > + > +-- > +-- Not automatic sequence should not be removed by DROP TABLE. > +-- > +box.schema.user.create('user1') > +test_space = box.schema.create_space('T', { \ > + engine = engine, \ > + format = {{'i', 'integer'}} \ > +}) > +seq = box.schema.sequence.create('S') > +ind = test_space:create_index('I', {sequence = 'S'}) > +box.schema.user.grant('user1', 'write', 'sequence', 'S') > +box.execute('DROP TABLE t'); > +seqs = box.space._sequence:select{} > +#seqs == 1 and seqs[1].name == seq.name or seqs > +seq:drop() > + > +-- > +-- Automatic sequence should be removed at DROP TABLE, together > +-- with all the grants. > +-- > +box.execute('CREATE TABLE t (id INTEGER PRIMARY KEY AUTOINCREMENT)') > +seqs = box.space._sequence:select{} > +#seqs == 1 or seqs > +seq = seqs[1].name > +box.schema.user.grant('user1', 'write', 'sequence', seq) > +box.execute('DROP TABLE t') > +seqs = box.space._sequence:select{} > +#seqs == 0 or seqs > + > +box.schema.user.drop('user1') > diff --git a/test/sql/gh-4546-sql-drop-grants.result b/test/sql/gh-4546-sql-drop-grants.result > index 1079d2ab4..9376c367d 100644 > --- a/test/sql/gh-4546-sql-drop-grants.result > +++ b/test/sql/gh-4546-sql-drop-grants.result > @@ -20,6 +20,12 @@ test_space = box.schema.create_space('T', { \ > }) > --- > ... > +seq = box.schema.sequence.create('S') > +--- > +... > +ind = test_space:create_index('I', {sequence = 'S'}) > +--- > +... > box.schema.user.grant('test_user1', 'read', 'space', 'T') > --- > ... > @@ -36,3 +42,13 @@ box.schema.user.drop('test_user1') > box.schema.user.drop('test_user2') > --- > ... > +seqs = box.space._sequence:select{} > +--- > +... > +#seqs == 1 and seqs[1].name == seq.name or seqs > +--- > +- true > +... > +seq:drop() > +--- > +... > diff --git a/test/sql/gh-4546-sql-drop-grants.test.lua b/test/sql/gh-4546-sql-drop-grants.test.lua > index 09cfeda19..ddb8cb0bb 100644 > --- a/test/sql/gh-4546-sql-drop-grants.test.lua > +++ b/test/sql/gh-4546-sql-drop-grants.test.lua > @@ -12,8 +12,13 @@ test_space = box.schema.create_space('T', { \ > engine = engine, \ > format = {{'i', 'integer'}} \ > }) > +seq = box.schema.sequence.create('S') > +ind = test_space:create_index('I', {sequence = 'S'}) > box.schema.user.grant('test_user1', 'read', 'space', 'T') > box.schema.user.grant('test_user2', 'write', 'space', 'T') > box.execute([[DROP TABLE T;]]) > box.schema.user.drop('test_user1') > box.schema.user.drop('test_user2') > +seqs = box.space._sequence:select{} > +#seqs == 1 and seqs[1].name == seq.name or seqs > +seq:drop() > -- > 2.21.0 (Apple Git-122.2) >