Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] [PATCH 3/6] test: fix sqltester methods to drop all tables/views
Date: Mon, 10 Dec 2018 00:30:23 +0300	[thread overview]
Message-ID: <8b2f2cd74db96ad55be39f0515ecf55193549356.1544387419.git.korablev@tarantool.org> (raw)
In-Reply-To: <cover.1544387419.git.korablev@tarantool.org>
In-Reply-To: <cover.1544387419.git.korablev@tarantool.org>

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/drop_all.test.lua b/test/sql-tap/drop_all.test.lua
index 86a2587eb..b08daf87c 100755
--- a/test/sql-tap/drop_all.test.lua
+++ b/test/sql-tap/drop_all.test.lua
@@ -22,7 +22,7 @@ test:do_test(
 test:do_test(
     prefix.."-1.1",
     function()
-        return #test:drop_all_views()
+        return test:drop_all_views()
     end,
     N
 )
@@ -30,7 +30,7 @@ test:do_test(
 test:do_test(
     prefix.."-1.1",
     function()
-        return #test:drop_all_tables()
+        return test:drop_all_tables()
     end,
     N
 )
diff --git a/test/sql-tap/identifier_case.test.lua b/test/sql-tap/identifier_case.test.lua
index 9e8107aef..1d248f9dc 100755
--- a/test/sql-tap/identifier_case.test.lua
+++ b/test/sql-tap/identifier_case.test.lua
@@ -64,7 +64,7 @@ test:do_test(
 test:do_test(
     test_prefix.."1.3.3",
     function ()
-        return #test:drop_all_tables()
+        return test:drop_all_tables()
     end,
     3)
 
@@ -112,7 +112,7 @@ end
 test:do_test(
     test_prefix.."2.3.1",
     function ()
-        return #test:drop_all_tables()
+        return test:drop_all_tables()
     end,
     6)
 
@@ -152,7 +152,7 @@ end
 test:do_test(
     test_prefix.."3.2.1",
     function ()
-        return #test:drop_all_tables()
+        return test:drop_all_tables()
     end,
     1)
 
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 = 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
 -- that different SQL statements generate exactly the same VDBE code.
 local function explain_no_trace(self, sql)
     tr = execsql(self, "EXPLAIN "..sql)
@@ -288,35 +288,27 @@ local function explain_no_trace(self, sql)
 end
 test.explain_no_trace = explain_no_trace
 json = require("json")
-function test.find_spaces_by_sql_statement(self, statement)
-    local spaces = box.space._space:select{}
-    local res = {}
-    for _, space in ipairs(spaces) do
-        local name_num = 3-- [3] is space name
-        local options_num = 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 = 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 = 0
+    for _, v in box.space._space:pairs() do
+        if v[1] >= 512 then
+            test:execsql(string.format([[DROP TABLE "%s";]], v[3]))
+            entry_count = entry_count + 1
+        end
     end
-    return tables
+    return entry_count
 end
 
 function test.drop_all_views(self)
-    local views = 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 = 0
+    for _, v in box.space._space:pairs() do
+        if v[1] > 512 and v[6]["view"] == true then
+            test:execsql(string.format([[DROP VIEW "%s";]], v[3]))
+            entry_count = entry_count + 1
+        end
     end
-    return views
+    return entry_count
 end
 
 function test.do_select_tests(self, label, tests)
-- 
2.15.1

  parent reply	other threads:[~2018-12-09 21:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-09 21:30 [tarantool-patches] [PATCH 0/6] Remove string of SQL statement from opts Nikita Pettik
2018-12-09 21:30 ` [tarantool-patches] [PATCH 1/6] sql: avoid calling sql_encode_table_opts() during trigger creation Nikita Pettik
2018-12-10 14:17   ` [tarantool-patches] " Vladislav Shpilevoy
2018-12-11 18:29     ` n.pettik
2018-12-09 21:30 ` [tarantool-patches] [PATCH 2/6] sql: don't update SQL string during renaming Nikita Pettik
2018-12-10 14:16   ` [tarantool-patches] " Vladislav Shpilevoy
2018-12-11 18:29     ` n.pettik
2018-12-12 12:36       ` Vladislav Shpilevoy
2018-12-13 12:42         ` n.pettik
2018-12-09 21:30 ` Nikita Pettik [this message]
2018-12-10 14:16   ` [tarantool-patches] Re: [PATCH 3/6] test: fix sqltester methods to drop all tables/views Vladislav Shpilevoy
2018-12-11 18:29     ` n.pettik
2018-12-09 21:30 ` [tarantool-patches] [PATCH 4/6] sql: don't add string of 'CREATE TABLE...' to space opts Nikita Pettik
2018-12-10 14:17   ` [tarantool-patches] " Vladislav Shpilevoy
2018-12-11 18:29     ` n.pettik
2018-12-09 21:30 ` [tarantool-patches] [PATCH 5/6] sql: don't add string of 'CREATE INDEX ...' to index opts Nikita Pettik
2018-12-10 14:18   ` [tarantool-patches] " Vladislav Shpilevoy
2018-12-11 18:29     ` n.pettik
2018-12-09 21:30 ` [tarantool-patches] [PATCH 6/6] Remove SQL string from " Nikita Pettik
2018-12-25 13:45 ` [tarantool-patches] Re: [PATCH 0/6] Remove string of SQL statement from opts Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b2f2cd74db96ad55be39f0515ecf55193549356.1544387419.git.korablev@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH 3/6] test: fix sqltester methods to drop all tables/views' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox