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 EF59F2113D for ; Tue, 11 Dec 2018 13:29:25 -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 ByzlEC8akeWL for ; Tue, 11 Dec 2018 13:29:25 -0500 (EST) 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 A38DC20C3D for ; Tue, 11 Dec 2018 13:29:25 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: [tarantool-patches] Re: [PATCH 3/6] test: fix sqltester methods to drop all tables/views From: "n.pettik" In-Reply-To: <9464fa79-cbd0-7a46-60b7-98394a5a3766@tarantool.org> Date: Tue, 11 Dec 2018 21:29:23 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <8b2f2cd74db96ad55be39f0515ecf55193549356.1544387419.git.korablev@tarantool.org> <9464fa79-cbd0-7a46-60b7-98394a5a3766@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: Vladislav Shpilevoy > On 10 Dec 2018, at 17:16, Vladislav Shpilevoy = wrote: >=20 > Thanks for the patch! See 3 comments below. >=20 > On 10/12/2018 00:30, Nikita Pettik wrote: >> Since we are going to remove string of SQL "CREATE TABLE ..." = statement >> from space's opts, lets rework methods in sqltester to drop all = tables >> and views in order to avoid relying on this parameter. >> Part of #2647 >> --- >> test/sql-tap/drop_all.test.lua | 4 ++-- >> test/sql-tap/identifier_case.test.lua | 6 +++--- >> test/sql-tap/lua/sqltester.lua | 38 = ++++++++++++++--------------------- >> 3 files changed, 20 insertions(+), 28 deletions(-) >> diff --git a/test/sql-tap/lua/sqltester.lua = b/test/sql-tap/lua/sqltester.lua >> index 8751ef820..672d2e67d 100644 >> --- a/test/sql-tap/lua/sqltester.lua >> +++ b/test/sql-tap/lua/sqltester.lua >> @@ -277,7 +277,7 @@ end >> test.catchsql2 =3D catchsql2 >> -- Show the VDBE program for an SQL statement but omit the Trace >> --- opcode at the beginning. This procedure can be used to prove >> +-- opcode at the beginning. This procedure can be used to PROVE >=20 > 1. ??? Oops, fixed: diff --git a/test/sql-tap/lua/sqltester.lua = b/test/sql-tap/lua/sqltester.lua index 672d2e67d..076510932 100644 --- a/test/sql-tap/lua/sqltester.lua +++ b/test/sql-tap/lua/sqltester.lua @@ -277,7 +277,7 @@ end test.catchsql2 =3D catchsql2 =20 -- Show the VDBE program for an SQL statement but omit the Trace --- opcode at the beginning. This procedure can be used to PROVE +-- opcode at the beginning. This procedure can be used to prove >=20 >> -- that different SQL statements generate exactly the same VDBE = code. >> local function explain_no_trace(self, sql) >> tr =3D execsql(self, "EXPLAIN "..sql) >> @@ -288,35 +288,27 @@ local function explain_no_trace(self, sql) >> end >> test.explain_no_trace =3D explain_no_trace >> json =3D require("json") >> -function test.find_spaces_by_sql_statement(self, statement) >> - local spaces =3D box.space._space:select{} >> - local res =3D {} >> - for _, space in ipairs(spaces) do >> - local name_num =3D 3-- [3] is space name >> - local options_num =3D 6-- [6] is space options >> - if not space[name_num]:startswith("_") and = space[options_num]["sql"] then >> - if string.find(space[options_num]["sql"], statement) = then >> - table.insert(res, space[name_num]) >> - end >> - end >> - end >> - return res >> -end >> function test.drop_all_tables(self) >> - local tables =3D test:find_spaces_by_sql_statement("CREATE = TABLE") >> - for _, table in ipairs(tables) do >> - test:execsql(string.format([[DROP TABLE "%s";]], table)) >> + local entry_count =3D 0 >> + for _, v in box.space._space:pairs() do >> + if v[1] >=3D 512 then >> + test:execsql(string.format([[DROP TABLE "%s";]], v[3])) >> + entry_count =3D entry_count + 1 >=20 > 2. Since DD integration is finished, can we do box.space[v3]:drop() > instead of executing SQL? I think it can help us to find more bugs. > And it is faster. Seems like: @@ -293,7 +293,7 @@ function test.drop_all_tables(self) local entry_count =3D 0 for _, v in box.space._space:pairs() do if v[1] >=3D 512 then - test:execsql(string.format([[DROP TABLE "%s";]], v[3])) + box.space[v[3]]:drop() entry_count =3D entry_count + 1 end end @@ -303,8 +303,8 @@ end function test.drop_all_views(self) local entry_count =3D 0 for _, v in box.space._space:pairs() do - if v[1] > 512 and v[6]["view"] =3D=3D true then - test:execsql(string.format([[DROP VIEW "%s";]], v[3])) + if v[1] > 512 and v[6].view =3D=3D true then + box.space[v[3]]:drop() entry_count =3D entry_count + 1 end >=20 >> + end >> end >> - return tables >> + return entry_count >> end >> function test.drop_all_views(self) >> - local views =3D test:find_spaces_by_sql_statement("CREATE VIEW") >> - for _, view in ipairs(views) do >> - test:execsql(string.format([[DROP VIEW "%s";]], view)) >> + local entry_count =3D 0 >> + for _, v in box.space._space:pairs() do >> + if v[1] > 512 and v[6]["view"] =3D=3D true then >=20 > 3. IMO .view looks better than ["view"], but I do not insist. Up to > you. I don=E2=80=99t really care, so let's use your approach (see above).