Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH v3] luacheck: change global vars to local in sql-tap
@ 2020-12-14 18:10 Artem Starshov
  2020-12-14 19:20 ` Alexander V. Tikhonov
  2020-12-16 12:03 ` Kirill Yukhin
  0 siblings, 2 replies; 3+ messages in thread
From: Artem Starshov @ 2020-12-14 18:10 UTC (permalink / raw)
  To: Alexander Turenko; +Cc: tarantool-patches

Fixed luacheck warning 111 (setting non-standard global variable)
in test/sql-tap directory.
Enabled this directory for checking W111 in
config file(.luacheckrc).

Changed almost all variables in test/sql-tap from globals
to locals. In any cases, where variables need to be global,
added explicit _G. prefix (table of globals).

Fixes #5173
Part-of #5464
---
Changes in v3:
    - inline "globals" suppressions changed to _G usage
    - removed some unnecessary suppressions
    - rebased to master and corrected newly appeared tests

See LGTM from AlexTu: https://lists.tarantool.org/pipermail/tarantool-patches/2020-December/021194.html
Branch:https://github.com/tarantool/tarantool/tree/artemreyt/gh-5173-fix-luacheck-warnings-sql-tap
Issue: https://github.com/tarantool/tarantool/issues/5173

 .luacheckrc                                   | 54 +++++++++++++++-
 test/sql-tap/aggnested.test.lua               |  2 +-
 test/sql-tap/alias.test.lua                   | 16 ++---
 test/sql-tap/alter.test.lua                   | 14 ++---
 test/sql-tap/alter2.test.lua                  |  2 +-
 test/sql-tap/analyze1.test.lua                |  4 +-
 test/sql-tap/analyze3.test.lua                |  4 +-
 test/sql-tap/analyze4.test.lua                |  2 +-
 test/sql-tap/analyze5.test.lua                | 16 +++--
 test/sql-tap/analyze6.test.lua                |  4 +-
 test/sql-tap/analyze7.test.lua                |  2 +-
 test/sql-tap/analyze8.test.lua                |  5 +-
 test/sql-tap/analyze9.test.lua                | 42 ++++++++-----
 test/sql-tap/analyzeC.test.lua                |  4 +-
 test/sql-tap/analyzeD.test.lua                |  4 +-
 test/sql-tap/analyzeE.test.lua                |  4 +-
 test/sql-tap/analyzeF.test.lua                | 18 +++---
 test/sql-tap/atof1.test.lua                   |  2 +-
 test/sql-tap/autoinc.test.lua                 |  2 +-
 test/sql-tap/autoindex1.test.lua              |  4 +-
 test/sql-tap/autoindex4.test.lua              |  2 +-
 test/sql-tap/autoindex5.test.lua              |  2 +-
 test/sql-tap/badutf1.test.lua                 |  2 +-
 test/sql-tap/between.test.lua                 |  3 +-
 test/sql-tap/bigrow1.test.lua                 |  2 +-
 test/sql-tap/blob.test.lua                    | 18 ++++--
 test/sql-tap/boundary1.test.lua               |  2 +-
 test/sql-tap/boundary2.test.lua               |  2 +-
 test/sql-tap/boundary3.test.lua               |  2 +-
 test/sql-tap/cast.test.lua                    |  3 +-
 test/sql-tap/check.test.lua                   |  4 +-
 test/sql-tap/coalesce.test.lua                |  2 +-
 test/sql-tap/collation.test.lua               |  2 +-
 test/sql-tap/collation_unicode.test.lua       |  2 +-
 test/sql-tap/colname.test.lua                 |  2 +-
 test/sql-tap/contrib01.test.lua               |  2 +-
 test/sql-tap/count.test.lua                   |  6 +-
 test/sql-tap/cse.test.lua                     |  4 +-
 test/sql-tap/date.test.lua                    |  2 +-
 test/sql-tap/debug_mode_only.test.lua         |  2 +-
 test/sql-tap/default.test.lua                 |  2 +-
 test/sql-tap/delete1.test.lua                 |  7 ++-
 test/sql-tap/delete3.test.lua                 |  2 +-
 test/sql-tap/delete4.test.lua                 |  4 +-
 test/sql-tap/distinct.test.lua                |  2 +-
 test/sql-tap/distinctagg.test.lua             |  2 +-
 test/sql-tap/drop_all.test.lua                |  2 +-
 test/sql-tap/e_delete.test.lua                |  2 +-
 test/sql-tap/e_expr.test.lua                  | 15 ++---
 test/sql-tap/e_select1.test.lua               |  7 ++-
 test/sql-tap/eqp.test.lua                     |  2 +-
 test/sql-tap/explain.test.lua                 |  6 +-
 test/sql-tap/fkey1.test.lua                   |  2 +-
 test/sql-tap/fkey2.test.lua                   |  2 +-
 test/sql-tap/fkey3.test.lua                   |  2 +-
 test/sql-tap/fkey4.test.lua                   |  2 +-
 test/sql-tap/func.test.lua                    | 23 +++----
 test/sql-tap/func2.test.lua                   | 62 +++++++++----------
 test/sql-tap/func3.test.lua                   |  4 +-
 test/sql-tap/func5.test.lua                   |  4 +-
 ...2360-omit-truncate-in-transaction.test.lua |  2 +-
 test/sql-tap/gh-2549-many-columns.test.lua    |  6 +-
 test/sql-tap/gh-2723-concurrency.test.lua     |  4 +-
 .../gh-2884-forbid-rowid-syntax.test.lua      |  2 +-
 test/sql-tap/gh-2996-indexed-by.test.lua      |  4 +-
 .../gh-3083-ephemeral-unref-tuples.test.lua   |  2 +-
 ...gh-3251-string-pattern-comparison.test.lua |  2 +-
 test/sql-tap/gh-3297-ephemeral-rowid.test.lua |  2 +-
 .../gh-3307-xfer-optimization-issue.test.lua  |  2 +-
 .../gh-3332-tuple-format-leak.test.lua        |  2 +-
 test/sql-tap/gh-3350-skip-scan.test.lua       |  2 +-
 .../sql-tap/gh-4659-block-hash-index.test.lua |  6 +-
 ...-4766-wrong-cast-from-blob-to-int.test.lua |  4 +-
 .../gh-5231-box-execute-writes-in-ro.test.lua |  2 +-
 .../gh2127-indentifier-max-length.test.lua    |  2 +-
 .../sql-tap/gh2130-index-refer-table.test.lua |  2 +-
 test/sql-tap/gh2140-trans.test.lua            |  4 +-
 test/sql-tap/gh2168-temp-tables.test.lua      |  2 +-
 .../gh2250-trigger-chain-limit.test.lua       | 14 ++---
 test/sql-tap/gh2259-in-stmt-trans.test.lua    |  2 +-
 .../gh2548-select-compound-limit.test.lua     | 14 ++---
 test/sql-tap/hexlit.test.lua                  |  2 +-
 test/sql-tap/icu.test.lua                     |  2 +-
 test/sql-tap/identifier-characters.test.lua   |  4 +-
 test/sql-tap/identifier_case.test.lua         |  2 +-
 test/sql-tap/in1.test.lua                     |  2 +-
 test/sql-tap/in2.test.lua                     |  4 +-
 test/sql-tap/in3.test.lua                     |  4 +-
 test/sql-tap/in4.test.lua                     |  2 +-
 test/sql-tap/in5.test.lua                     |  4 +-
 test/sql-tap/index1.test.lua                  |  7 ++-
 test/sql-tap/index2.test.lua                  |  2 +-
 test/sql-tap/index3.test.lua                  |  2 +-
 test/sql-tap/index4.test.lua                  |  4 +-
 test/sql-tap/index6.test.lua                  |  2 +-
 test/sql-tap/index7.test.lua                  |  8 +--
 test/sql-tap/insert1.test.lua                 |  8 +--
 test/sql-tap/insert3.test.lua                 |  2 +-
 test/sql-tap/intpkey.test.lua                 |  4 +-
 test/sql-tap/join.test.lua                    |  6 +-
 test/sql-tap/join2.test.lua                   |  2 +-
 test/sql-tap/join3.test.lua                   | 10 +--
 test/sql-tap/join4.test.lua                   |  2 +-
 test/sql-tap/join5.test.lua                   |  2 +-
 test/sql-tap/join6.test.lua                   |  2 +-
 test/sql-tap/keyword1.test.lua                |  4 +-
 test/sql-tap/like2.test.lua                   |  2 +-
 test/sql-tap/like3.test.lua                   |  2 +-
 test/sql-tap/limit.test.lua                   |  6 +-
 test/sql-tap/lua-tables.test.lua              | 12 ++--
 test/sql-tap/lua/sqltester.lua                |  6 +-
 test/sql-tap/lua_sql.test.lua                 |  8 +--
 test/sql-tap/minmax2.test.lua                 | 36 ++++++-----
 test/sql-tap/minmax3.test.lua                 |  2 +-
 test/sql-tap/minmax4.test.lua                 |  2 +-
 test/sql-tap/misc1.test.lua                   |  6 +-
 test/sql-tap/misc3.test.lua                   |  2 +-
 test/sql-tap/misc5.test.lua                   |  3 +-
 test/sql-tap/null.test.lua                    |  2 +-
 test/sql-tap/numcast.test.lua                 |  2 +-
 test/sql-tap/offset1.test.lua                 |  2 +-
 test/sql-tap/orderby1.test.lua                |  4 +-
 test/sql-tap/orderby2.test.lua                |  4 +-
 test/sql-tap/orderby3.test.lua                |  4 +-
 test/sql-tap/orderby4.test.lua                |  4 +-
 test/sql-tap/orderby5.test.lua                |  4 +-
 test/sql-tap/orderby6.test.lua                |  4 +-
 test/sql-tap/orderby8.test.lua                |  4 +-
 test/sql-tap/orderby9.test.lua                |  4 +-
 test/sql-tap/position.test.lua                |  2 +-
 test/sql-tap/pragma.test.lua                  |  2 +-
 test/sql-tap/printf2.test.lua                 |  2 +-
 test/sql-tap/quote.test.lua                   |  2 +-
 test/sql-tap/randexpr1.test.lua               |  2 +-
 test/sql-tap/resolver01.test.lua              |  2 +-
 test/sql-tap/select1.test.lua                 | 12 ++--
 test/sql-tap/select2.test.lua                 |  2 +-
 test/sql-tap/select3.test.lua                 |  4 +-
 test/sql-tap/select4.test.lua                 |  2 +-
 test/sql-tap/select5.test.lua                 |  2 +-
 test/sql-tap/select6.test.lua                 |  6 +-
 test/sql-tap/select7.test.lua                 |  6 +-
 test/sql-tap/select8.test.lua                 |  4 +-
 test/sql-tap/select9.test.lua                 |  6 +-
 test/sql-tap/selectA.test.lua                 |  4 +-
 test/sql-tap/selectB.test.lua                 |  2 +-
 test/sql-tap/selectC.test.lua                 |  2 +-
 test/sql-tap/selectE.test.lua                 |  2 +-
 test/sql-tap/selectF.test.lua                 |  4 +-
 test/sql-tap/selectG.test.lua                 |  4 +-
 test/sql-tap/sort.test.lua                    |  5 +-
 test/sql-tap/sql-errors.test.lua              | 13 ++--
 test/sql-tap/start-transaction.test.lua       |  2 +-
 test/sql-tap/subquery.test.lua                |  9 +--
 test/sql-tap/subquery2.test.lua               |  4 +-
 test/sql-tap/subselect.test.lua               |  2 +-
 test/sql-tap/substr.test.lua                  |  2 +-
 test/sql-tap/table.test.lua                   |  2 +-
 test/sql-tap/tkt-02a8e81d44.test.lua          |  2 +-
 test/sql-tap/tkt-31338dca7e.test.lua          |  2 +-
 test/sql-tap/tkt-385a5b56b9.test.lua          |  4 +-
 test/sql-tap/tkt-38cb5df375.test.lua          |  4 +-
 test/sql-tap/tkt-3998683a16.test.lua          |  2 +-
 test/sql-tap/tkt-3a77c9714e.test.lua          |  4 +-
 test/sql-tap/tkt-4a03edc4c8.test.lua          |  2 +-
 test/sql-tap/tkt-4c86b126f2.test.lua          |  2 +-
 test/sql-tap/tkt-4dd95f6943.test.lua          |  4 +-
 test/sql-tap/tkt-4ef7e3cfca.test.lua          |  4 +-
 test/sql-tap/tkt-54844eea3f.test.lua          |  4 +-
 test/sql-tap/tkt-752e1646fc.test.lua          |  2 +-
 test/sql-tap/tkt-7a31705a7e6.test.lua         |  2 +-
 test/sql-tap/tkt-7bbfb7d442.test.lua          |  4 +-
 test/sql-tap/tkt-80ba201079.test.lua          |  4 +-
 test/sql-tap/tkt-80e031a00f.test.lua          |  2 +-
 test/sql-tap/tkt-868145d012.test.lua          |  2 +-
 test/sql-tap/tkt-8c63ff0ec.test.lua           |  4 +-
 test/sql-tap/tkt-91e2e8ba6f.test.lua          |  4 +-
 test/sql-tap/tkt-9a8b09f8e6.test.lua          |  4 +-
 test/sql-tap/tkt-a7b7803e.test.lua            |  2 +-
 test/sql-tap/tkt-a8a0d2996a.test.lua          |  4 +-
 test/sql-tap/tkt-b1d3a2e531.test.lua          |  4 +-
 test/sql-tap/tkt-b351d95f9.test.lua           |  2 +-
 test/sql-tap/tkt-b75a9ca6b0.test.lua          |  4 +-
 test/sql-tap/tkt-ba7cbfaedc.test.lua          |  4 +-
 test/sql-tap/tkt-bd484a090c.test.lua          |  4 +-
 test/sql-tap/tkt-d635236375.test.lua          |  4 +-
 test/sql-tap/tkt-f973c7ac31.test.lua          |  2 +-
 test/sql-tap/tkt-fa7bf5ec.test.lua            |  2 +-
 test/sql-tap/tkt1443.test.lua                 |  2 +-
 test/sql-tap/tkt1444.test.lua                 |  2 +-
 test/sql-tap/tkt1449.test.lua                 |  2 +-
 test/sql-tap/tkt1473.test.lua                 |  2 +-
 test/sql-tap/tkt1501.test.lua                 |  2 +-
 test/sql-tap/tkt1514.test.lua                 |  2 +-
 test/sql-tap/tkt1537.test.lua                 |  2 +-
 test/sql-tap/tkt2141.test.lua                 |  2 +-
 test/sql-tap/tkt2192.test.lua                 |  2 +-
 test/sql-tap/tkt2339.test.lua                 |  2 +-
 test/sql-tap/tkt2391.test.lua                 |  2 +-
 test/sql-tap/tkt2640.test.lua                 |  2 +-
 test/sql-tap/tkt2767.test.lua                 |  2 +-
 test/sql-tap/tkt2822.test.lua                 |  2 +-
 test/sql-tap/tkt2832.test.lua                 |  2 +-
 test/sql-tap/tkt2927.test.lua                 |  2 +-
 test/sql-tap/tkt2942.test.lua                 |  2 +-
 test/sql-tap/tkt3201.test.lua                 |  2 +-
 test/sql-tap/tkt3298.test.lua                 |  2 +-
 test/sql-tap/tkt3334.test.lua                 |  2 +-
 test/sql-tap/tkt3346.test.lua                 |  2 +-
 test/sql-tap/tkt3357.test.lua                 |  2 +-
 test/sql-tap/tkt3419.test.lua                 |  2 +-
 test/sql-tap/tkt3424.test.lua                 |  2 +-
 test/sql-tap/tkt3442.test.lua                 |  2 +-
 test/sql-tap/tkt3493.test.lua                 |  2 +-
 test/sql-tap/tkt3508.test.lua                 |  2 +-
 test/sql-tap/tkt3522.test.lua                 |  2 +-
 test/sql-tap/tkt3527.test.lua                 |  2 +-
 test/sql-tap/tkt3541.test.lua                 |  2 +-
 test/sql-tap/tkt3554.test.lua                 |  2 +-
 test/sql-tap/tkt3581.test.lua                 |  2 +-
 test/sql-tap/tkt3731.test.lua                 |  2 +-
 test/sql-tap/tkt3773.test.lua                 |  2 +-
 test/sql-tap/tkt3791.test.lua                 |  2 +-
 test/sql-tap/tkt3841.test.lua                 |  2 +-
 test/sql-tap/tkt3879.test.lua                 |  2 +-
 test/sql-tap/tkt3911.test.lua                 |  2 +-
 test/sql-tap/tkt3935.test.lua                 |  2 +-
 test/sql-tap/tokenize.test.lua                |  2 +-
 test/sql-tap/transitive1.test.lua             |  2 +-
 test/sql-tap/trigger1.test.lua                |  5 +-
 test/sql-tap/trigger2.test.lua                | 11 ++--
 test/sql-tap/trigger4.test.lua                |  2 +-
 test/sql-tap/trigger5.test.lua                |  2 +-
 test/sql-tap/trigger7.test.lua                | 10 +--
 test/sql-tap/trigger8.test.lua                |  6 +-
 test/sql-tap/trigger9.test.lua                |  4 +-
 test/sql-tap/triggerA.test.lua                |  6 +-
 test/sql-tap/triggerB.test.lua                |  4 +-
 test/sql-tap/triggerC.test.lua                |  6 +-
 test/sql-tap/triggerD.test.lua                |  2 +-
 test/sql-tap/types.test.lua                   |  4 +-
 test/sql-tap/types2.test.lua                  |  2 +-
 test/sql-tap/unicode.test.lua                 |  2 +-
 test/sql-tap/unique.test.lua                  |  2 +-
 test/sql-tap/update.test.lua                  |  4 +-
 test/sql-tap/view.test.lua                    |  2 +-
 test/sql-tap/where2.test.lua                  | 15 ++---
 test/sql-tap/where3.test.lua                  | 19 +++---
 test/sql-tap/where4.test.lua                  |  4 +-
 test/sql-tap/where5.test.lua                  |  2 +-
 test/sql-tap/where6.test.lua                  |  2 +-
 test/sql-tap/where7.test.lua                  | 16 ++---
 test/sql-tap/whereA.test.lua                  |  2 +-
 test/sql-tap/whereC.test.lua                  |  4 +-
 test/sql-tap/whereD.test.lua                  |  4 +-
 test/sql-tap/whereF.test.lua                  |  4 +-
 test/sql-tap/whereG.test.lua                  |  4 +-
 test/sql-tap/whereI.test.lua                  |  4 +-
 test/sql-tap/whereK.test.lua                  |  4 +-
 test/sql-tap/with1.test.lua                   |  6 +-
 test/sql-tap/with2.test.lua                   |  4 +-
 261 files changed, 633 insertions(+), 549 deletions(-)

diff --git a/.luacheckrc b/.luacheckrc
index 6fe34c2e1..29db9eeeb 100644
--- a/.luacheckrc
+++ b/.luacheckrc
@@ -30,12 +30,64 @@ exclude_files = {
     "build/**/*.lua",
     -- Third-party source code.
     "test-run/**/*.lua",
-    "test/**/*.lua",
+    "test/app/**/*.lua",
+    "test/app-tap/**/*.lua",
+    "test/box/**/*.lua",
+    "test/box-py/**/*.lua",
+    "test/box-tap/**/*.lua",
+    "test/engine/**/*.lua",
+    "test/engine_long/**/*.lua",
+    "test/long_run-py/**/*.lua",
+    "test/luajit-tap/**/*.lua",
+    "test/replication/**/*.lua",
+    "test/replication-py/**/*.lua",
+    "test/sql/**/*.lua",
+    "test/swim/**/*.lua",
+    "test/var/**/*.lua",
+    "test/vinyl/**/*.lua",
+    "test/wal_off/**/*.lua",
+    "test/xlog/**/*.lua",
+    "test/xlog-py/**/*.lua",
     "third_party/**/*.lua",
     ".rocks/**/*.lua",
     ".git/**/*.lua",
 }
 
+files["test/sql-tap/**/*.lua"] = {
+    ignore = {
+        -- Accessing an undefined global variable.
+        "113",
+        -- Unused local variable.
+        "211",
+        -- Unused argument.
+        "212",
+        -- Unused loop variable.
+        "213",
+        -- Local variable is set but never accessed.
+        "231",
+        -- "Value assigned to a local variable is unused."
+        "311",
+        -- Unreachable code.
+        "511",
+        -- Loop can be executed at most once.
+        "512",
+        -- An empty if branch.
+        "542",
+        -- A line consists of nothing but whitespace.
+        "611",
+        -- A line contains trailing whitespace.
+        "612",
+        -- Trailing whitespace in a string.
+        "613",
+        -- Trailing whitespace in a comment.
+        "614",
+        -- Inconsistent indentation (SPACE followed by TAB).
+        "621",
+        -- Line is too long.
+        "631"
+    }
+}
+
 files["src/lua/help.lua"] = {
     -- Globals defined for interactive mode.
     globals = {"help", "tutorial"},
diff --git a/test/sql-tap/aggnested.test.lua b/test/sql-tap/aggnested.test.lua
index 67a9ba891..8a79e0df2 100755
--- a/test/sql-tap/aggnested.test.lua
+++ b/test/sql-tap/aggnested.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(7)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/alias.test.lua b/test/sql-tap/alias.test.lua
index 75391b305..27a611d19 100755
--- a/test/sql-tap/alias.test.lua
+++ b/test/sql-tap/alias.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(9)
 
 --!./tcltestrunner.lua
@@ -24,7 +24,7 @@ test:plan(9)
 -- A procedure to return a sequence of increasing integers.
 --
 
-counter = 0
+_G.counter = 0
 
 -- Function is declared as deterministic deliberately.
 -- Otherwise it would be called as much as it occurs in a query.
@@ -54,7 +54,7 @@ test:do_test(
 test:do_test(
     "alias-1.2",
     function()
-        counter = 0
+        _G.counter = 0
         return test:execsql([[
             SELECT x, sequence() AS y FROM t1 WHERE y> 0 order by x desc
         ]])
@@ -67,7 +67,7 @@ test:do_test(
 test:do_test(
     "alias-1.3",
     function()
-        counter = 0
+        _G.counter = 0
         return test:execsql([[
             SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y<99  order by x desc
         ]])
@@ -80,7 +80,7 @@ test:do_test(
 test:do_test(
     "alias-1.4",
     function()
-        counter = 0
+        _G.counter = 0
         return test:execsql([[
             SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y<99 AND y!=55  order by x desc
         ]])
@@ -108,7 +108,7 @@ test:do_test(
 test:do_test(
     "alias-1.6",
     function()
-        counter = 0
+        _G.counter = 0
         return test:execsql([[
             SELECT x, sequence() AS y FROM t1 WHERE y BETWEEN 0 AND 99 order by x desc
         ]])
@@ -121,7 +121,7 @@ test:do_test(
 test:do_test(
     "alias-1.7",
     function()
-        counter = 0
+        _G.counter = 0
         return test:execsql([[
             SELECT x, sequence() AS y FROM t1 WHERE y BETWEEN 0 AND 99 order by x desc
         ]])
@@ -147,7 +147,7 @@ test:do_test(
 test:do_test(
     "alias-1.9",
     function()
-        counter = 0
+        _G.counter = 0
         return test:execsql([[
             SELECT x, sequence() AS y FROM t1 ORDER BY -y
         ]])
diff --git a/test/sql-tap/alter.test.lua b/test/sql-tap/alter.test.lua
index 615b9d8a6..2fece6649 100755
--- a/test/sql-tap/alter.test.lua
+++ b/test/sql-tap/alter.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(50)
 
 test:do_execsql_test(
@@ -90,11 +90,11 @@ test:do_catchsql_test(
 test:do_test(
     "alter-2.3.prepare",
     function()
-        format = {}
+        local format = {}
         format[1] = { name = 'id', type = 'integer'}
         format[2] = { name = 'f2', type = 'number'}
-        s = box.schema.create_space('t', {format = format})
-        i = s:create_index('i', {parts= {1, 'integer'}})
+        local s = box.schema.create_space('t', {format = format})
+        s:create_index('i', {parts= {1, 'integer'}})
 
         s:replace{1, 4}
         s:replace{2, 2}
@@ -520,10 +520,10 @@ test:do_catchsql_test(
 test:do_test(
     "alter-8.1.0",
     function()
-        format = {}
+        local format = {}
         format[1] = { name = 'id', type = 'scalar'}
         format[2] = { name = 'f2', type = 'scalar'}
-        s = box.schema.create_space('T', {format = format})
+        box.schema.create_space('T', {format = format})
     end,
     {})
 
@@ -560,7 +560,7 @@ test:do_catchsql_test(
 test:do_test(
     "alter-8.3.2",
     function()
-        i = box.space.T.index[1]
+        local i = box.space.T.index[1]
         return i.id
     end, 1)
 
diff --git a/test/sql-tap/alter2.test.lua b/test/sql-tap/alter2.test.lua
index 759acc9c3..b4e8b8810 100755
--- a/test/sql-tap/alter2.test.lua
+++ b/test/sql-tap/alter2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(26)
 
 -- This suite is aimed to test ALTER TABLE ADD CONSTRAINT statement.
diff --git a/test/sql-tap/analyze1.test.lua b/test/sql-tap/analyze1.test.lua
index f274cee16..18770a086 100755
--- a/test/sql-tap/analyze1.test.lua
+++ b/test/sql-tap/analyze1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(38)
 
 --!./tcltestrunner.lua
@@ -384,7 +384,7 @@ test:do_execsql_test(
         -- </analyze-5.0>
     })
 
-stat = "_sql_stat4"
+local stat = "_sql_stat4"
 
 test:do_execsql_test(
     "analyze-5.1",
diff --git a/test/sql-tap/analyze3.test.lua b/test/sql-tap/analyze3.test.lua
index dcbea1da5..c36cfc83b 100755
--- a/test/sql-tap/analyze3.test.lua
+++ b/test/sql-tap/analyze3.test.lua
@@ -1,8 +1,8 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(37)
 
-testprefix = "analyze3"
+local testprefix = "analyze3"
 
 --!./tcltestrunner.lua
 -- 2009 August 06
diff --git a/test/sql-tap/analyze4.test.lua b/test/sql-tap/analyze4.test.lua
index 7d7498faf..8327b78c7 100755
--- a/test/sql-tap/analyze4.test.lua
+++ b/test/sql-tap/analyze4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/analyze5.test.lua b/test/sql-tap/analyze5.test.lua
index 45e76492a..1d6665ad0 100755
--- a/test/sql-tap/analyze5.test.lua
+++ b/test/sql-tap/analyze5.test.lua
@@ -1,8 +1,8 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(88)
 
-json = require("json")
+local json = require("json")
 
 --!./tcltestrunner.lua
 -- 2011 January 19
@@ -21,13 +21,13 @@ json = require("json")
 -- with many repeated values and only a few distinct values.
 --
 
-testprefix = "analyze5"
+local testprefix = "analyze5"
 local function eqp(sql)
     return test:execsql("EXPLAIN QUERY PLAN"..sql)
 end
 
 local function alpha(blob)
-    ret = ""
+    local ret = ""
     for _, c in ipairs(X(37, "X!cmd", [=[["split",["blob"],""]]=])) do
         if X(39, "X!cmd", [=[["string","is","alpha",["c"]]]=])
  then
@@ -64,13 +64,14 @@ test:do_test(
         -- test:execsql("CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, t INT ,u INT ,v TEXT COLLATE nocase,w INT ,x INT ,y INT ,z INT )")
         test:execsql("CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, t TEXT ,u TEXT ,v TEXT ,w TEXT ,x TEXT ,y TEXT ,z NUMBER)")
         for i=0,999 do -- _ in X(0, "X!for", [=[["set i 0","$i < 1000","incr i"]]=]) do
+            local y
             if  ((i >= 25) and (i <= 50)) then
                 y = 1
             else
                 y = 0
             end
 
-            z = 0
+            local z = 0
             if i >= 400 then
                 z = 1
             end
@@ -81,6 +82,7 @@ test:do_test(
                 z = z + 1
             end
             
+            local x, w, t, u
             x = z
             w = z
             t = (z + 0.5)
@@ -99,7 +101,7 @@ test:do_test(
             -- if X(65, "X!cmd", [=[["expr","$i%2"]]=]) then
             --    v = u
             -- end
-            v = 'NULL'
+            local v = 'NULL'
             test:execsql("INSERT INTO t1 (t,u,v,w,x,y,z) VALUES('"..t.."','"..u.."','"..v.."','"..w.."','"..x.."','"..y.."','"..z.."')")
         end
         test:execsql([[
@@ -252,6 +254,7 @@ for i, v in pairs({
     test:do_test(
         "analyze5-1."..i.."b",
         function()
+            local w2, a1, a2, res
             w2 = v[1]:gsub('y', '+y'):gsub('z', '+z')
             a1 = test:execsql("SELECT id FROM t1 NOT INDEXED WHERE "..w2.." ORDER BY +id")
             a2 = test:execsql("SELECT id FROM t1 WHERE "..v[1].." ORDER BY +id")
@@ -298,6 +301,7 @@ for i, v in pairs({
     test:do_test(
         "analyze5-1."..i.."b",
         function()
+            local a1, a2, res
             a1 = test:execsql("SELECT id FROM t1 NOT INDEXED WHERE "..v.." ORDER BY +id")
             a2 = test:execsql("SELECT id FROM t1 WHERE "..v.." ORDER BY +id")
             if (test.is_deeply_regex(a1, a1))
diff --git a/test/sql-tap/analyze6.test.lua b/test/sql-tap/analyze6.test.lua
index 1ba084e35..5ec40d22b 100755
--- a/test/sql-tap/analyze6.test.lua
+++ b/test/sql-tap/analyze6.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(13)
 
 --!./tcltestrunner.lua
@@ -21,7 +21,7 @@ test:plan(13)
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
 
-testprefix = "analyze6"
+local testprefix = "analyze6"
 
 test:do_test(
     "analyze6-1.0",
diff --git a/test/sql-tap/analyze7.test.lua b/test/sql-tap/analyze7.test.lua
index 22bad4e17..203a0c3f9 100755
--- a/test/sql-tap/analyze7.test.lua
+++ b/test/sql-tap/analyze7.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(14)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/analyze8.test.lua b/test/sql-tap/analyze8.test.lua
index 92ac993c5..5c80a7b2f 100755
--- a/test/sql-tap/analyze8.test.lua
+++ b/test/sql-tap/analyze8.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(15)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(15)
 -- in this file is testing the capabilities of sql_stat3.
 --
 
-testprefix = "analyze8"
+local testprefix = "analyze8"
 
 -- Scenario:
 --
@@ -39,6 +39,7 @@ test:do_test(
             CREATE INDEX t1c ON t1(c);
         ]])
         for i=0, 1000 do
+            local a, b, c
             if (i % 2 == 0)
             then
                 a = i
diff --git a/test/sql-tap/analyze9.test.lua b/test/sql-tap/analyze9.test.lua
index 02eb49f69..1d7c8b632 100755
--- a/test/sql-tap/analyze9.test.lua
+++ b/test/sql-tap/analyze9.test.lua
@@ -1,8 +1,8 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(121)
 
-testprefix = "analyze9"
+local testprefix = "analyze9"
 
 --!./tcltestrunner.lua
 -- 2013 August 3
@@ -46,8 +46,8 @@ test:do_execsql_test(
         -- </1.1>
     })
 
-msgpack_decode_sample = function(txt)
-    msgpack = require('msgpack')
+local function msgpack_decode_sample(txt)
+    local msgpack = require('msgpack')
     local i = 1
     local decoded_str = ''
     while msgpack.decode(txt)[i] ~= nil do
@@ -63,6 +63,7 @@ msgpack_decode_sample = function(txt)
     end
     return decoded_str
 end
+_G.msgpack_decode_sample = msgpack_decode_sample
 
 box.internal.sql_create_function("msgpack_decode_sample", "TEXT", msgpack_decode_sample)
 
@@ -134,14 +135,15 @@ test:do_test(
     })
 
 -- Analogue of function from tcl
-lindex = function(str, pos)
+local function lindex(str, pos)
     return string.sub(str, pos+1, pos+1)
 end
+_G.lindex = lindex
 
 box.internal.sql_create_function("lindex", "TEXT", lindex)
 
 -- Analogue of function from tcl
-lrange = function(str, first, last)
+local function lrange(str, first, last)
     local res_tokens = ""
     local i = 1
     for token in string.gmatch(str, "[^%s]+") do
@@ -156,24 +158,27 @@ lrange = function(str, first, last)
     end
     return res_tokens
 end
+_G.lrange = lrange
 
 box.internal.sql_create_function("lrange", "TEXT", lrange)
 
-generate_tens = function(n)
-    tens = {}
+local function generate_tens(n)
+    local tens = {}
     for i = 1, n do
         tens[i] = 10
     end
     return tens
 end
+_G.generate_tens = generate_tens
 
-generate_tens_str = function(n)
-    tens = {}
+local function generate_tens_str(n)
+    local tens = {}
     for i = 1, n do
         tens[i] = "10"
     end
     return tens
 end
+_G.generate_tens_str = generate_tens_str
 
 -- Each value of "a" occurs exactly 10 times in the table.
 --
@@ -236,7 +241,7 @@ test:do_execsql_test(
         CREATE INDEX i1 ON t1(c, b, a);
     ]])
 
-insert_filler_rows_n = function(iStart, nCopy, nVal)
+local function insert_filler_rows_n(iStart, nCopy, nVal)
     for i = 0, nVal-1 do
         local iVal = iStart+i
         for j = 0, nCopy-1 do
@@ -244,6 +249,7 @@ insert_filler_rows_n = function(iStart, nCopy, nVal)
         end
     end
 end
+_G.insert_filler_rows_n = insert_filler_rows_n
 
 box.internal.sql_create_function("insert_filler_rows_n", "INT", insert_filler_rows_n)
 
@@ -718,7 +724,7 @@ test:do_test(
             else
                 a = "\"DEF\""
             end
-            b = i % 5
+            local b = i % 5
             test:execsql(string.format("INSERT INTO t4 VALUES(null, '%s', '%s')", a, b))
         test:execsql("ANALYZE")
         end
@@ -769,7 +775,7 @@ test:do_test(
             else
                 a = "\"DEF\""
             end
-            b = i % 5
+            local b = i % 5
             test:execsql(string.format("INSERT INTO t4 VALUES(null, '%s', '%s')", a, b))
         test:execsql("ANALYZE")
         end
@@ -830,7 +836,7 @@ test:do_test(
             else
                 a = "\"DEF\""
             end
-            b = i % 5
+            local b = i % 5
             test:execsql(string.format("INSERT INTO t4 VALUES(null, 'abcdef', '%s', '%s')", a, b))
         test:execsql("ANALYZE")
         end
@@ -881,7 +887,7 @@ test:do_test(
             else
                 a = "\"DEF\""
             end
-            b = i % 5
+            local b = i % 5
             test:execsql(string.format("INSERT INTO t4 VALUES(null, 'abcdef', '%s', '%s')", a, b))
         test:execsql("ANALYZE")
         end
@@ -1246,9 +1252,10 @@ test:do_test(
 
 ---------------------------------------------------------------------------
 
-r = function()
+local function r()
     return math.random(1, 15)
 end
+_G.r = r
 
 box.internal.sql_create_function("r", "NUM", r)
 
@@ -1376,7 +1383,7 @@ test:do_execsql_test(
     })
 
 
-int_to_char = function(i)
+local function int_to_char(i)
     local ret = ""
     local char = "abcdefghij"
     local divs = {1000, 100, 10, 1}
@@ -1385,6 +1392,7 @@ int_to_char = function(i)
     end
     return ret
 end
+_G.int_to_char = int_to_char
 
 box.internal.sql_create_function("int_to_char", "TEXT", int_to_char)
 
diff --git a/test/sql-tap/analyzeC.test.lua b/test/sql-tap/analyzeC.test.lua
index 16d6233de..baae809a6 100755
--- a/test/sql-tap/analyzeC.test.lua
+++ b/test/sql-tap/analyzeC.test.lua
@@ -1,8 +1,8 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(20)
 
-testprefix = "analyzeC"
+local testprefix = "analyzeC"
 
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/analyzeD.test.lua b/test/sql-tap/analyzeD.test.lua
index 1f00e80e0..579cb350a 100755
--- a/test/sql-tap/analyzeD.test.lua
+++ b/test/sql-tap/analyzeD.test.lua
@@ -1,8 +1,8 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(15)
 
-testprefix = "analyzeD"
+local testprefix = "analyzeD"
 
 --!./tcltestrunner.lua
 -- 2005 July 22
diff --git a/test/sql-tap/analyzeE.test.lua b/test/sql-tap/analyzeE.test.lua
index c0a33ad86..2da0c885f 100755
--- a/test/sql-tap/analyzeE.test.lua
+++ b/test/sql-tap/analyzeE.test.lua
@@ -1,8 +1,8 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(48)
 
-testprefix = "analyzeE"
+local testprefix = "analyzeE"
 
 --!./tcltestrunner.lua
 -- 2014-10-08
diff --git a/test/sql-tap/analyzeF.test.lua b/test/sql-tap/analyzeF.test.lua
index 8f6fb5c97..e56437902 100755
--- a/test/sql-tap/analyzeF.test.lua
+++ b/test/sql-tap/analyzeF.test.lua
@@ -1,8 +1,8 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(18)
 
-testprefix = "analyzeF"
+local testprefix = "analyzeF"
 
 --!./tcltestrunner.lua
 -- 2015-03-12
@@ -43,10 +43,10 @@ test:do_execsql_test(
 -- without the sql_DETERMINISTIC flag set.
 --
 
-where_clauses_x = {"x = 4 AND y = 19", "x = '4' AND y = '19'", 
+local where_clauses_x = {"x = 4 AND y = 19", "x = '4' AND y = '19'",
 	"x = substr('145', 2, 1) AND y = substr('5195', 2, 2)"}
 
-where_clauses_y = {"x = 19 AND y = 4", "x = '19' AND y = '4'", 
+local where_clauses_y = {"x = 19 AND y = 4", "x = '19' AND y = '4'",
 	"x = substr('5195', 2, 2) AND y = substr('145', 2, 1)",
 	"x = substr('5195', 2, 2+0) AND y = substr('145', 2, 1+0)",
 	"x = substr('145', 2, 1+0) AND y = substr('5195', 2, 2+0)",
@@ -56,7 +56,7 @@ where_clauses_y = {"x = 19 AND y = 4", "x = '19' AND y = '4'",
 
 
 for test_number, where in ipairs(where_clauses_x) do
-    res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1X (X=?)"}
+    local res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1X (X=?)"}
     test:do_eqp_test(
         "1.1."..test_number,
         "SELECT * FROM t1 WHERE "..where.."", {
@@ -67,7 +67,7 @@ end
 
 
 for test_number, where in ipairs(where_clauses_y) do
-    res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1Y (Y=?)"}
+    local res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1Y (Y=?)"}
     test:do_eqp_test(
         "1.2."..test_number,
         "SELECT * FROM t1 WHERE "..where.."", {
@@ -113,11 +113,11 @@ box.internal.sql_create_function("det4", "NUM", det4)
 
 box.internal.sql_create_function("det19", "NUM", det19)
 
-where_clause_x = {"x = det4() AND y = det19()"}
+where_clauses_x = {"x = det4() AND y = det19()"}
 where_clauses_y = {"x = det19() AND y = det4()"}
 
 for test_number, where in ipairs(where_clauses_y) do
-    res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1Y (Y=?)"}
+    local res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1Y (Y=?)"}
     test:do_eqp_test(
         "3.1."..test_number,
         "SELECT * FROM t1 WHERE "..where.."", {
@@ -126,7 +126,7 @@ for test_number, where in ipairs(where_clauses_y) do
 end
 
 for test_number, where in ipairs(where_clauses_x) do
-    res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1X (X=?)"}
+    local res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1X (X=?)"}
     test:do_eqp_test(
         "3.2."..test_number,
         "SELECT * FROM t1 WHERE "..where.."", {
diff --git a/test/sql-tap/atof1.test.lua b/test/sql-tap/atof1.test.lua
index fe045427d..78aca6557 100755
--- a/test/sql-tap/atof1.test.lua
+++ b/test/sql-tap/atof1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(9999)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/autoinc.test.lua b/test/sql-tap/autoinc.test.lua
index 07442b60a..0ea1961fd 100755
--- a/test/sql-tap/autoinc.test.lua
+++ b/test/sql-tap/autoinc.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(57)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/autoindex1.test.lua b/test/sql-tap/autoindex1.test.lua
index 94b824331..99d44a2bc 100755
--- a/test/sql-tap/autoindex1.test.lua
+++ b/test/sql-tap/autoindex1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(8)
 
 --
@@ -36,7 +36,7 @@ test:do_eqp_test(
         {1,0,0,"SEARCH TABLE T2 USING EPHEMERAL INDEX (C=?) (~20 rows)"}
     })
 
-result = test:execsql([[SELECT b, (SELECT d FROM t2 WHERE c = a) FROM t1;]])
+local result = test:execsql([[SELECT b, (SELECT d FROM t2 WHERE c = a) FROM t1;]])
 
 test:do_eqp_test(
     "autoindex-1.2", [[
diff --git a/test/sql-tap/autoindex4.test.lua b/test/sql-tap/autoindex4.test.lua
index e22f49c67..c2ca723b8 100755
--- a/test/sql-tap/autoindex4.test.lua
+++ b/test/sql-tap/autoindex4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(8)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/autoindex5.test.lua b/test/sql-tap/autoindex5.test.lua
index b1fddf37f..a7c7bb9a7 100755
--- a/test/sql-tap/autoindex5.test.lua
+++ b/test/sql-tap/autoindex5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/badutf1.test.lua b/test/sql-tap/badutf1.test.lua
index 9079dfe25..654629bf7 100755
--- a/test/sql-tap/badutf1.test.lua
+++ b/test/sql-tap/badutf1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(23)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/between.test.lua b/test/sql-tap/between.test.lua
index 60d9ae1d6..550976b86 100755
--- a/test/sql-tap/between.test.lua
+++ b/test/sql-tap/between.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(11)
 
 --!./tcltestrunner.lua
@@ -29,6 +29,7 @@ test:do_test(
             CREATE TABLE t1(w int primary key, x int, y int, z int);
         ]])
         for i = 1, 100, 1 do
+            local w, x, y, z
             w = i
             x = math.floor((math.log(i)/math.log(2)))
             y = (((i * i) + (2 * i)) + 1)
diff --git a/test/sql-tap/bigrow1.test.lua b/test/sql-tap/bigrow1.test.lua
index e712cd52b..6e4c21959 100755
--- a/test/sql-tap/bigrow1.test.lua
+++ b/test/sql-tap/bigrow1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(60)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/blob.test.lua b/test/sql-tap/blob.test.lua
index d4845bbd4..e9c513988 100755
--- a/test/sql-tap/blob.test.lua
+++ b/test/sql-tap/blob.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(20)
 
 --!./tcltestrunner.lua
@@ -33,35 +33,35 @@ end
 test:do_test(
     "blob-1.0",
     function()
-        blob = test:execsql "SELECT X'01020304';"
+        local blob = test:execsql "SELECT X'01020304';"
         return bin_to_hex(test.lindex(blob, 0))
     end, "01020304")
 
 test:do_test(
     "blob-1.1",
     function()
-        blob = test:execsql "SELECT x'ABCDEF';"
+        local blob = test:execsql "SELECT x'ABCDEF';"
         return bin_to_hex(test.lindex(blob, 0))
     end, "ABCDEF")
 
 test:do_test(
     "blob-1.2",
     function()
-        blob = test:execsql "SELECT x'';"
+        local blob = test:execsql "SELECT x'';"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "blob-1.3",
     function()
-        blob = test:execsql "SELECT x'abcdEF12';"
+        local blob = test:execsql "SELECT x'abcdEF12';"
         return bin_to_hex(test.lindex(blob, 0))
     end, "ABCDEF12")
 
 test:do_test(
     "blob-1.3.2",
     function()
-        blob = test:execsql "SELECT x'0123456789abcdefABCDEF';"
+        local blob = test:execsql "SELECT x'0123456789abcdefABCDEF';"
         return bin_to_hex(test.lindex(blob, 0))
     end, "0123456789ABCDEFABCDEF")
 
@@ -174,6 +174,7 @@ test:do_test(
             INSERT INTO t1 VALUES(X'123456', x'7890ab');
             INSERT INTO t1 VALUES(X'CDEF12', x'345678');
         ]]
+        local blobs, blobs2
         blobs = test:execsql "SELECT * FROM t1"
         blobs2 = {  }
         for _, b in ipairs(blobs) do
@@ -193,6 +194,7 @@ test:do_test(
         test:execsql [[
             CREATE INDEX i1 ON t1(a);
         ]]
+        local blobs, blobs2
         blobs = test:execsql "SELECT * FROM t1"
         blobs2 = {  }
         for _, b in ipairs(blobs) do
@@ -208,6 +210,7 @@ test:do_test(
 test:do_test(
     "blob-2.2",
     function()
+        local blobs, blobs2
         blobs = test:execsql "SELECT * FROM t1 where a = X'123456'"
         blobs2 = {  }
         for _, b in ipairs(blobs) do
@@ -223,6 +226,7 @@ test:do_test(
 test:do_test(
     "blob-2.3",
     function()
+        local blobs, blobs2
         blobs = test:execsql "SELECT * FROM t1 where a = X'CDEF12'"
         blobs2 = {  }
         for _, b in ipairs(blobs) do
@@ -238,6 +242,7 @@ test:do_test(
 test:do_test(
     "blob-2.4",
     function()
+        local blobs, blobs2
         blobs = test:execsql "SELECT * FROM t1 where a = X'CD12'"
         blobs2 = {  }
         for _, b in ipairs(blobs) do
@@ -269,6 +274,7 @@ if (0 > 0)
     test:do_test(
         "blob-3.2",
         function()
+            local blobs, blobs2
             blobs = test:execsql "SELECT * FROM t1"
             blobs2 = {  }
             for _, b in ipairs(blobs) do
diff --git a/test/sql-tap/boundary1.test.lua b/test/sql-tap/boundary1.test.lua
index ffd667c15..da093cd81 100755
--- a/test/sql-tap/boundary1.test.lua
+++ b/test/sql-tap/boundary1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1511)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/boundary2.test.lua b/test/sql-tap/boundary2.test.lua
index 0fa07e6cd..0574a4ea8 100755
--- a/test/sql-tap/boundary2.test.lua
+++ b/test/sql-tap/boundary2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3021)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/boundary3.test.lua b/test/sql-tap/boundary3.test.lua
index 2f42b9bfb..f5643f4ab 100755
--- a/test/sql-tap/boundary3.test.lua
+++ b/test/sql-tap/boundary3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1896)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/cast.test.lua b/test/sql-tap/cast.test.lua
index fb0790d04..4d7c92cfc 100755
--- a/test/sql-tap/cast.test.lua
+++ b/test/sql-tap/cast.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(79)
 
 --!./tcltestrunner.lua
@@ -789,6 +789,7 @@ if 0 > 0 then
 test:do_test(
     "cast-3.32.1",
     function()
+        local blob, DB, STMT
         blob = 1234567890
         DB = sql_connection_pointer("db")
         STMT = sql_prepare(DB, "SELECT CAST(? AS NUMBER)", -1, "TAIL")
diff --git a/test/sql-tap/check.test.lua b/test/sql-tap/check.test.lua
index 3dc28cf0d..cd9f24796 100755
--- a/test/sql-tap/check.test.lua
+++ b/test/sql-tap/check.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(61)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(61)
 -- $Id: check.test,v 1.13 2009/06/05 17:09:12 drh Exp $
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "check"
+local testprefix = "check"
 -- Only run these tests if the build includes support for CHECK constraints
 
 
diff --git a/test/sql-tap/coalesce.test.lua b/test/sql-tap/coalesce.test.lua
index 5501e6992..366e8667a 100755
--- a/test/sql-tap/coalesce.test.lua
+++ b/test/sql-tap/coalesce.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(9)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/collation.test.lua b/test/sql-tap/collation.test.lua
index f7099b222..d8e727f12 100755
--- a/test/sql-tap/collation.test.lua
+++ b/test/sql-tap/collation.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(192)
 
 local prefix = "collation-"
diff --git a/test/sql-tap/collation_unicode.test.lua b/test/sql-tap/collation_unicode.test.lua
index b6b189d98..7b4d777f0 100755
--- a/test/sql-tap/collation_unicode.test.lua
+++ b/test/sql-tap/collation_unicode.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(28 * 4)
 
 local prefix = "unicode-collation-"
diff --git a/test/sql-tap/colname.test.lua b/test/sql-tap/colname.test.lua
index 3901feea9..191396bcc 100755
--- a/test/sql-tap/colname.test.lua
+++ b/test/sql-tap/colname.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(79)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/contrib01.test.lua b/test/sql-tap/contrib01.test.lua
index 67dc2bdfa..74c5af54c 100755
--- a/test/sql-tap/contrib01.test.lua
+++ b/test/sql-tap/contrib01.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/count.test.lua b/test/sql-tap/count.test.lua
index 08c225bc5..9f4d759b5 100755
--- a/test/sql-tap/count.test.lua
+++ b/test/sql-tap/count.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(30)
 
 --!./tcltestrunner.lua
@@ -33,7 +33,7 @@ test:plan(30)
 --      SELECT count(*) FROM sql_master;
 --   }
 -- } {0}
-iTest = 0
+local iTest = 0
 local queries = {
     "/* no-op */",
     "CREATE INDEX i1 ON t1(a);"
@@ -105,7 +105,7 @@ for _, zIndex in ipairs(queries) do
         })
 
 end
-json = require("json")
+local json = require("json")
 local function uses_op_count(sql)
     if test:lsearch(test:execsql("EXPLAIN "..sql), "Count")>0 then
         return 1
diff --git a/test/sql-tap/cse.test.lua b/test/sql-tap/cse.test.lua
index 341b6de01..e09f955a0 100755
--- a/test/sql-tap/cse.test.lua
+++ b/test/sql-tap/cse.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(118)
 
 --!./tcltestrunner.lua
@@ -252,7 +252,7 @@ for i = 1, 99, 1 do
         table.insert(answer,j)
         table.insert(answer,r)
     end
-    sql = "SELECT "..table.concat(colset, ",").." FROM t2"
+    local sql = "SELECT "..table.concat(colset, ",").." FROM t2"
     test:do_test(
         "cse-2.2."..i,
         function()
diff --git a/test/sql-tap/date.test.lua b/test/sql-tap/date.test.lua
index 87fc80db0..b414b5397 100755
--- a/test/sql-tap/date.test.lua
+++ b/test/sql-tap/date.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 -- test:plan(1279)
 test:plan(0)
 
diff --git a/test/sql-tap/debug_mode_only.test.lua b/test/sql-tap/debug_mode_only.test.lua
index 2b3f6a1a0..71fd43a17 100755
--- a/test/sql-tap/debug_mode_only.test.lua
+++ b/test/sql-tap/debug_mode_only.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
 -- This file contains testcases which can only be valudated in debug mode.
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(30)
 
 local ffi = require("ffi")
diff --git a/test/sql-tap/default.test.lua b/test/sql-tap/default.test.lua
index f1def2b10..1832e3af7 100755
--- a/test/sql-tap/default.test.lua
+++ b/test/sql-tap/default.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(15)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/delete1.test.lua b/test/sql-tap/delete1.test.lua
index bfed3ba9d..f1658695f 100755
--- a/test/sql-tap/delete1.test.lua
+++ b/test/sql-tap/delete1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(10)
 
 --!./tcltestrunner.lua
@@ -132,11 +132,12 @@ test:do_test(
     })
 
 -- Tests for data dictionary integration.
-format = {}
+local format = {}
 format[1] = {name = 'id', type = 'scalar'}
 format[2] = {name = 'f', type = 'scalar'}
+local s
 s = box.schema.create_space('t', {format = format})
-i = s:create_index('i', {parts = {1, 'scalar'}})
+s:create_index('i', {parts = {1, 'scalar'}})
 
 test:do_test(
     "delete1-6.0",
diff --git a/test/sql-tap/delete3.test.lua b/test/sql-tap/delete3.test.lua
index b5968ae96..e9d1f5a21 100755
--- a/test/sql-tap/delete3.test.lua
+++ b/test/sql-tap/delete3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/delete4.test.lua b/test/sql-tap/delete4.test.lua
index 7c0eec15e..43585e603 100755
--- a/test/sql-tap/delete4.test.lua
+++ b/test/sql-tap/delete4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(14)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(14)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "delete4"
+local testprefix = "delete4"
 test:do_execsql_test(
     1.1,
     [[
diff --git a/test/sql-tap/distinct.test.lua b/test/sql-tap/distinct.test.lua
index ae35a0db5..02fe8a426 100755
--- a/test/sql-tap/distinct.test.lua
+++ b/test/sql-tap/distinct.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(56)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/distinctagg.test.lua b/test/sql-tap/distinctagg.test.lua
index 5454bf0ed..9b1346f7d 100755
--- a/test/sql-tap/distinctagg.test.lua
+++ b/test/sql-tap/distinctagg.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(6)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/drop_all.test.lua b/test/sql-tap/drop_all.test.lua
index b08daf87c..a03ce598f 100755
--- a/test/sql-tap/drop_all.test.lua
+++ b/test/sql-tap/drop_all.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 local prefix = "drop_all-"
 
diff --git a/test/sql-tap/e_delete.test.lua b/test/sql-tap/e_delete.test.lua
index a0c944327..d1cf2a79f 100755
--- a/test/sql-tap/e_delete.test.lua
+++ b/test/sql-tap/e_delete.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(18)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/e_expr.test.lua b/test/sql-tap/e_expr.test.lua
index 7ee7a2d98..f5b58cb79 100755
--- a/test/sql-tap/e_expr.test.lua
+++ b/test/sql-tap/e_expr.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(10641)
 
 --!./tcltestrunner.lua
@@ -1078,18 +1078,18 @@ test:do_execsql_test(
 -- MUST_WORK_TEST prepared statements
 if (0>0) then
     local function parameter_test(tn, sql, params, result)
-        stmt = sql_prepare_v2("db", sql, -1)
+        local stmt = sql_prepare_v2("db", sql, -1)
         for _ in X(0, "X!foreach", [=[["number name",["params"]]]=]) do
-            nm = sql_bind_parameter_name(stmt, number)
+            local nm = sql_bind_parameter_name(stmt, number)
             X(480, "X!cmd", [=[["do_test",[["tn"],".name.",["number"]],[["list","set","",["nm"]]],["name"]]]=])
             sql_bind_int(stmt, number, ((-1) * number))
         end
         sql_step(stmt)
-        res = {  }
+        local res = {  }
         for _ in X(0, "X!for", [=[["set i 0","$i < [sql_column_count $stmt]","incr i"]]=]) do
             table.insert(res,sql_column_text(stmt, i))
         end
-        rc = sql_finalize(stmt)
+        local rc = sql_finalize(stmt)
         X(491, "X!cmd", [=[["do_test",[["tn"],".rc"],[["list","set","",["rc"]]],"sql_OK"]]=])
         X(492, "X!cmd", [=[["do_test",[["tn"],".res"],[["list","set","",["res"]]],["result"]]]=])
     end
@@ -1126,7 +1126,7 @@ if (0>0) then
     test:do_test(
         "e_expr-11.7.1",
         function()
-            stmt = sql_prepare_v2("db", " SELECT ?, :a, @b, ?d ", -1)
+            local stmt = sql_prepare_v2("db", " SELECT ?, :a, @b, ?d ", -1)
             sql_step(stmt)
             return { sql_column_type(stmt, 0), sql_column_type(stmt, 1), sql_column_type(stmt, 2), sql_column_type(stmt, 3) }
         end, {
@@ -2119,7 +2119,7 @@ test:do_execsql_test(
 -- calling the application-defined SQL functions like(Y,X) or like(Y,X,Z).
 --
 local likeargs = {}
-function likefunc(...)
+local function likefunc(...)
     local args = {...}
     for i, v in ipairs(args) do
         table.insert(likeargs, v)
@@ -2489,6 +2489,7 @@ test:do_execsql_test(
         -- </e_expr-20.2>
     })
 
+local a, b, c
 a = 0
 b = 0
 c = 0
diff --git a/test/sql-tap/e_select1.test.lua b/test/sql-tap/e_select1.test.lua
index 578620fca..2a189582d 100755
--- a/test/sql-tap/e_select1.test.lua
+++ b/test/sql-tap/e_select1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(509)
 
 --!./tcltestrunner.lua
@@ -835,7 +835,7 @@ end
 -- MUST_WORK_TEST prepared statement
 if 0>0 then
 for _ in X(0, "X!foreach", [=[["tn select nCol","\n  1   \"SELECT a,b,c FROM z1\" 3\n  2   \"SELECT a,b,c FROM z1 NATURAL JOIN z3\"  3\n  3   \"SELECT z1.a,z1.b,z1.c FROM z1 NATURAL JOIN z3\" 3\n  4   \"SELECT z3.a,z3.b FROM z1 NATURAL JOIN z3\" 2\n  5   \"SELECT z1.a,z1.b,z1.c, z3.a,z3.b FROM z1 NATURAL JOIN z3\" 5\n  6   \"SELECT 1, 2, z1.a,z1.b,z1.c FROM z1\" 5\n  7   \"SELECT a, a,b,c, b, c FROM z1\" 6\n"]]=]) do
-    stmt = sql_prepare_v2("db", select, -1, "DUMMY")
+    local stmt = sql_prepare_v2("db", select, -1, "DUMMY")
     test:do_sql_column_count_test(
         "e_select-4.3."..tn,
         stmt, {
@@ -963,13 +963,14 @@ test:do_select_tests(
 if 0>0 then
 for _ in X(0, "X!foreach", [=[["tn select","\n  8.1  \"SELECT count(*) FROM a1\"\n  8.2  \"SELECT count(*) FROM a1 WHERE 0\"\n  8.3  \"SELECT count(*) FROM a1 WHERE 1\"\n  8.4  \"SELECT max(a1.one)+min(two), a1.one, two, * FROM a1, a2 WHERE 1\"\n  8.5  \"SELECT max(a1.one)+min(two), a1.one, two, * FROM a1, a2 WHERE 0\"\n"]]=]) do
     -- Set $nRow to the number of rows returned by $select:
+    local stmt, nRow
     stmt = sql_prepare_v2("db", select, -1, "DUMMY")
     nRow = 0
     while X(979, "X!cmd", [=[["expr","\"sql_ROW\" == [sql_step $::stmt]"]]=])
  do
         nRow = nRow + 1
     end
-    rc = sql_finalize(stmt)
+    local rc = sql_finalize(stmt)
     -- Test that $nRow==1 and that statement execution was successful
     -- (rc==sql_OK).
     X(983, "X!cmd", [=[["do_test",["e_select-4.",["tn"]],[["list","list",["rc"],["nRow"]]],"sql_OK 1"]]=])
diff --git a/test/sql-tap/eqp.test.lua b/test/sql-tap/eqp.test.lua
index 83ef947bb..6519fc4e9 100755
--- a/test/sql-tap/eqp.test.lua
+++ b/test/sql-tap/eqp.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(70)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/explain.test.lua b/test/sql-tap/explain.test.lua
index 9b8d8404a..117bda29d 100755
--- a/test/sql-tap/explain.test.lua
+++ b/test/sql-tap/explain.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 -- gh-3231: make sure that there is no redundant OP_Goto at the
@@ -21,7 +21,7 @@ test:do_execsql_test(
 test:do_test(
     "explain-1.1",
     function()
-        opcodes = test:execsql("EXPLAIN SELECT * FROM t1;")
+        local opcodes = test:execsql("EXPLAIN SELECT * FROM t1;")
         return opcodes[1]
     end,
         -- <explain-1.1>
@@ -32,7 +32,7 @@ test:do_test(
 test:do_test(
     "explain-1.2",
     function()
-        opcodes = test:execsql("EXPLAIN SELECT a + 1 FROM t1 WHERE id = 4 OR id = 5;")
+        local opcodes = test:execsql("EXPLAIN SELECT a + 1 FROM t1 WHERE id = 4 OR id = 5;")
         return opcodes[1]
     end,
         -- <explain-1.2>
diff --git a/test/sql-tap/fkey1.test.lua b/test/sql-tap/fkey1.test.lua
index d6ef473aa..960a0df84 100755
--- a/test/sql-tap/fkey1.test.lua
+++ b/test/sql-tap/fkey1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(25)
 
 -- This file implements regression tests for foreign keys.
diff --git a/test/sql-tap/fkey2.test.lua b/test/sql-tap/fkey2.test.lua
index bd3e0c78c..df9807ddc 100755
--- a/test/sql-tap/fkey2.test.lua
+++ b/test/sql-tap/fkey2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(116)
 
 -- This file implements regression tests for foreign keys.
diff --git a/test/sql-tap/fkey3.test.lua b/test/sql-tap/fkey3.test.lua
index 900ac321c..47958cf9c 100755
--- a/test/sql-tap/fkey3.test.lua
+++ b/test/sql-tap/fkey3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(25)
 
 -- This file implements regression tests for foreign keys.
diff --git a/test/sql-tap/fkey4.test.lua b/test/sql-tap/fkey4.test.lua
index 397e8b895..d4963f876 100755
--- a/test/sql-tap/fkey4.test.lua
+++ b/test/sql-tap/fkey4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(17)
 
 -- This file implements regression tests for foreign keys.
diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua
index 3c088920f..d14eef421 100755
--- a/test/sql-tap/func.test.lua
+++ b/test/sql-tap/func.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(14694)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(14694)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "func"
+local testprefix = "func"
 -- Create a table to work with.
 --
 test:do_test(
@@ -1048,7 +1048,7 @@ test:do_execsql_test(
 --
 -- MUST_WORK_TEST testfunc not implemented
 if 0 > 0 then
-DB = sql_connection_pointer("db")
+local DB = sql_connection_pointer("db")
 X(525, "X!cmd", [=[["sql_register_test_function",["::DB"],"testfunc"]]=])
 test:do_catchsql_test(
     "func-10.1",
@@ -1300,6 +1300,7 @@ test:do_execsql_test(
 test:do_test(
     "func-13.7",
     function()
+        local DB, sql, STMT, res
         DB = sql_connection_pointer("db")
         sql = "SELECT test_auxdata( ? , a ) FROM t4;"
         STMT = sql_prepare(DB, sql, -1, "TAIL")
@@ -1348,7 +1349,7 @@ test:do_execsql_test(
         -- </13.8.3>
     })
 
-V = "one"
+local V = "one"
 test:do_execsql_test(
     "13.8.4",
     [[
@@ -1454,7 +1455,7 @@ test:do_test(
         test:execsql([[
             CREATE TABLE tbl2(id integer primary key, a INT, b INT);
         ]])
-        STMT = sql_prepare(DB, "INSERT INTO tbl2 VALUES(1, ?, ?)", -1, "TAIL")
+        local STMT = sql_prepare(DB, "INSERT INTO tbl2 VALUES(1, ?, ?)", -1, "TAIL")
         sql_bind_blob(STMT, 1, "abc", 3)
         sql_step(STMT)
         sql_finalize(STMT)
@@ -2341,9 +2342,9 @@ if 0>0 then
 for i = 1, sql_LIMIT_FUNCTION_ARG, 1 do
     midargs = midargs .. ",'/"..i.."'"
     midres = midres .. "/"..i
-    result = digest.md5_hex(string.format("this%sprogram%sis%sfree%ssoftware%s",
+    local result = digest.md5_hex(string.format("this%sprogram%sis%sfree%ssoftware%s",
           midres,midres,midres,midres,midres))
-    sql = "SELECT md5sum(t1"..midargs..") FROM tbl1"
+    local sql = "SELECT md5sum(t1"..midargs..") FROM tbl1"
     test:do_test(
         "func-24.7."..i,
         function()
@@ -2468,7 +2469,7 @@ test:do_test(
 test:do_test(
     "func-26.2",
     function()
-        a = ""
+        local a = ""
         for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG","incr i"]]=]) do
             table.insert(a,i)
         end
@@ -2484,7 +2485,7 @@ test:do_test(
 test:do_test(
     "func-26.3",
     function()
-        a = ""
+        local a = ""
         for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG+1","incr i"]]=]) do
             table.insert(a,i)
         end
@@ -2500,7 +2501,7 @@ test:do_test(
 test:do_test(
     "func-26.4",
     function()
-        a = ""
+        local a = ""
         for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG-1","incr i"]]=]) do
             table.insert(a,i)
         end
@@ -2952,7 +2953,7 @@ test:do_catchsql_test(
         -- </func-76.4>
     })
 
-ffi = require('ffi')
+_G.ffi = require('ffi')
 box.schema.func.create('TOSTRING', {language = 'Lua', is_deterministic = true,
                                     body = 'function(a) return a end',
                                     param_list = {'any'}, returns = 'string',
diff --git a/test/sql-tap/func2.test.lua b/test/sql-tap/func2.test.lua
index c9bd3665f..95b8a1f5f 100755
--- a/test/sql-tap/func2.test.lua
+++ b/test/sql-tap/func2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(130)
 
 --!./tcltestrunner.lua
@@ -1027,7 +1027,7 @@ end
 test:do_test(
     "func2-3.1.1",
     function()
-        blob = test:execsql "SELECT x'1234'"
+        local blob = test:execsql "SELECT x'1234'"
         return bin_to_hex(test.lindex(blob, 0))
     end, "1234")
 
@@ -1065,203 +1065,203 @@ test:do_catchsql_test(
 test:do_test(
     "func2-3.2.0",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 0, 0)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 0, 0)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.2.1",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 0, 1)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 0, 1)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.2.2",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 0, 2)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 0, 2)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "12")
 
 test:do_test(
     "func2-3.2.3",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 0, 3)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 0, 3)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "1234")
 
 test:do_test(
     "func2-3.3.0",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 0)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 0)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.3.1",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 1)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 1)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "12")
 
 test:do_test(
     "func2-3.3.2",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 2)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 2)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "1234")
 
 test:do_test(
     "func2-3.3.3",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 3)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 3)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "1234")
 
 test:do_test(
     "func2-3.4.0",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 0)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 0)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.4.1",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 1)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 1)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "34")
 
 test:do_test(
     "func2-3.4.2",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 2)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 2)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "34")
 
 test:do_test(
     "func2-3.4.3",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 3)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 3)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "34")
 
 test:do_test(
     "func2-3.5.0",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 0)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 0)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.5.1",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 1)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 1)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "12")
 
 test:do_test(
     "func2-3.5.2",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 2)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 2)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "1234")
 
 test:do_test(
     "func2-3.5.3",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 3)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 3)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "1234")
 
 test:do_test(
     "func2-3.6.0",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 0)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 0)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.6.1",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -1, -1)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, -1)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "12")
 
 test:do_test(
     "func2-3.6.2",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -1, -2)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, -2)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "12")
 
 test:do_test(
     "func2-3.6.3",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -1, -3)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, -3)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "12")
 
 test:do_test(
     "func2-3.7.0",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 0)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 0)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.7.1",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -2, -1)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, -1)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.7.2",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', -2, -2)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, -2)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.8.0",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 0)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 0)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.8.1",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 1, -1)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, -1)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.8.2",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 1, -2)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, -2)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.9.0",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 2, 0)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 2, 0)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "")
 
 test:do_test(
     "func2-3.9.1",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 2, -1)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 2, -1)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "12")
 
 test:do_test(
     "func2-3.9.2",
     function()
-        blob = test:execsql "SELECT SUBSTR(x'1234', 2, -2)"
+        local blob = test:execsql "SELECT SUBSTR(x'1234', 2, -2)"
         return bin_to_hex(test.lindex(blob, 0))
     end, "12")
 
diff --git a/test/sql-tap/func3.test.lua b/test/sql-tap/func3.test.lua
index 95d96965e..7f1d8d33c 100755
--- a/test/sql-tap/func3.test.lua
+++ b/test/sql-tap/func3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(35)
 
 --!./tcltestrunner.lua
@@ -288,7 +288,7 @@ test:do_test(
 --
 -- gh-3929: sql: ANSI aliases for LENGTH().
 --
-suits = {}
+local suits = {}
 suits[1] = {str = '123456789', len = 9}
 suits[2] = {str = '\x80', len = 1}
 suits[3] = {str = '\x61\x62\x63', len = 3}
diff --git a/test/sql-tap/func5.test.lua b/test/sql-tap/func5.test.lua
index 8329e1735..c991e9163 100755
--- a/test/sql-tap/func5.test.lua
+++ b/test/sql-tap/func5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(22)
 
 --!./tcltestrunner.lua
@@ -69,7 +69,7 @@ test:do_execsql_test(
         -- </func5-2.1>
     })
 
-global_counter = 0
+_G.global_counter = 0
 
 box.schema.func.create('COUNTER1', {language = 'Lua', is_deterministic = false,
                        param_list = {'any'}, returns = 'integer',
diff --git a/test/sql-tap/gh-2360-omit-truncate-in-transaction.test.lua b/test/sql-tap/gh-2360-omit-truncate-in-transaction.test.lua
index aa2989bdc..27d9bd42e 100755
--- a/test/sql-tap/gh-2360-omit-truncate-in-transaction.test.lua
+++ b/test/sql-tap/gh-2360-omit-truncate-in-transaction.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
 
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 test:do_execsql_test(
diff --git a/test/sql-tap/gh-2549-many-columns.test.lua b/test/sql-tap/gh-2549-many-columns.test.lua
index ed8c9d9b2..ec994d58b 100755
--- a/test/sql-tap/gh-2549-many-columns.test.lua
+++ b/test/sql-tap/gh-2549-many-columns.test.lua
@@ -1,9 +1,10 @@
 #!/usr/bin/env tarantool
 -- The maximum number of columns in sql is 2000. This test checks it.
 
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
+local success_column_count, fail_column_count
 success_column_count = 2000
 fail_column_count = 2001
 
@@ -11,7 +12,7 @@ test:execsql("DROP TABLE IF EXISTS t1")
 test:execsql("DROP TABLE IF EXISts t2")
 
 local function form_create_statement(name, column_count)
-	create_statement = 'CREATE TABLE ' .. name .. '('
+	local create_statement = 'CREATE TABLE ' .. name .. '('
 	for i = 1,column_count do
 		if i > 1 then create_statement = create_statement .. ',' end
 		create_statement = create_statement .. 's' .. i .. ' INT'
@@ -21,6 +22,7 @@ local function form_create_statement(name, column_count)
 	return create_statement
 end
 
+local success_statement, fail_statement
 success_statement = form_create_statement("t1", success_column_count)
 fail_statement = form_create_statement("t2", fail_column_count)
 
diff --git a/test/sql-tap/gh-2723-concurrency.test.lua b/test/sql-tap/gh-2723-concurrency.test.lua
index 842142d2d..aa9be0130 100755
--- a/test/sql-tap/gh-2723-concurrency.test.lua
+++ b/test/sql-tap/gh-2723-concurrency.test.lua
@@ -1,12 +1,12 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 local fiber = require("fiber")
 local N = 20
 
 -- this test uses ddl which is not working concurrently
 -- see issue #2741
-ch = fiber.channel(N)
+local ch = fiber.channel(N)
 for id = 1, N do
     fiber.create(
         function ()
diff --git a/test/sql-tap/gh-2884-forbid-rowid-syntax.test.lua b/test/sql-tap/gh-2884-forbid-rowid-syntax.test.lua
index c628510c2..74356703a 100755
--- a/test/sql-tap/gh-2884-forbid-rowid-syntax.test.lua
+++ b/test/sql-tap/gh-2884-forbid-rowid-syntax.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 local ok = pcall(test.execsql, test, [[
diff --git a/test/sql-tap/gh-2996-indexed-by.test.lua b/test/sql-tap/gh-2996-indexed-by.test.lua
index 4c5a4d053..ed820ee1b 100755
--- a/test/sql-tap/gh-2996-indexed-by.test.lua
+++ b/test/sql-tap/gh-2996-indexed-by.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(13)
 
 -- gh-2996 - INDEXED BY clause wasn't working.
@@ -12,7 +12,7 @@ test:execsql [[
     CREATE INDEX t1ix1 on t1(b);
 ]]
 
-sample_size = 1000
+local sample_size = 1000
 local query = "INSERT INTO t1 VALUES "
 
 for i = 1, sample_size do
diff --git a/test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua b/test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua
index 3807ba665..0b7c3ca32 100755
--- a/test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua
+++ b/test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
 
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 test:do_test(
diff --git a/test/sql-tap/gh-3251-string-pattern-comparison.test.lua b/test/sql-tap/gh-3251-string-pattern-comparison.test.lua
index 641469211..483ab326d 100755
--- a/test/sql-tap/gh-3251-string-pattern-comparison.test.lua
+++ b/test/sql-tap/gh-3251-string-pattern-comparison.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(162)
 
 local prefix = "like-test-"
diff --git a/test/sql-tap/gh-3297-ephemeral-rowid.test.lua b/test/sql-tap/gh-3297-ephemeral-rowid.test.lua
index dd2b07cc5..5497f87f4 100755
--- a/test/sql-tap/gh-3297-ephemeral-rowid.test.lua
+++ b/test/sql-tap/gh-3297-ephemeral-rowid.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 -- Check that OP_NextIdEphemeral generates unique ids.
diff --git a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
index bb8a4989e..5b9df5c09 100755
--- a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
+++ b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(39)
 
 local function do_xfer_test(test, test_func, test_name, func, exp, opts)
diff --git a/test/sql-tap/gh-3332-tuple-format-leak.test.lua b/test/sql-tap/gh-3332-tuple-format-leak.test.lua
index 84e67b7ef..5e286ed0d 100755
--- a/test/sql-tap/gh-3332-tuple-format-leak.test.lua
+++ b/test/sql-tap/gh-3332-tuple-format-leak.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 test:do_test(
diff --git a/test/sql-tap/gh-3350-skip-scan.test.lua b/test/sql-tap/gh-3350-skip-scan.test.lua
index 4cecfe081..f4f9500fd 100755
--- a/test/sql-tap/gh-3350-skip-scan.test.lua
+++ b/test/sql-tap/gh-3350-skip-scan.test.lua
@@ -2,7 +2,7 @@
 
 -- gh-3350, gh-2859
 
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 local function lindex(str, pos)
diff --git a/test/sql-tap/gh-4659-block-hash-index.test.lua b/test/sql-tap/gh-4659-block-hash-index.test.lua
index f0f3cb983..c02d3eb7a 100755
--- a/test/sql-tap/gh-4659-block-hash-index.test.lua
+++ b/test/sql-tap/gh-4659-block-hash-index.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 -- gh-4782 - Raise an error in case space features HASH index.
@@ -8,13 +8,13 @@ test:plan(4)
 -- This is actually a stub until we are unable to employ
 -- HASH index while planning a query.
 
-f = {
+local f = {
     {'1', 'unsigned'},
     {'2', 'string'},
     {'3', 'array'}
 }
 
-s = box.schema.create_space("T1", {format = f})
+local s = box.schema.create_space("T1", {format = f})
 s:create_index('PK', {type = 'hash', parts = {'1'}})
 
 test:do_catchsql_test(
diff --git a/test/sql-tap/gh-4766-wrong-cast-from-blob-to-int.test.lua b/test/sql-tap/gh-4766-wrong-cast-from-blob-to-int.test.lua
index 929870d27..da8c2dcd6 100755
--- a/test/sql-tap/gh-4766-wrong-cast-from-blob-to-int.test.lua
+++ b/test/sql-tap/gh-4766-wrong-cast-from-blob-to-int.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --
@@ -21,7 +21,7 @@ test:do_execsql_test(
 -- Make sure that BLOB longer than 12287 bytes cannot be cast to
 -- INTEGER.
 --
-long_str = string.rep('0', 12284)
+local long_str = string.rep('0', 12284)
 test:do_execsql_test(
     "gh-4766-2",
     "SELECT CAST('" .. long_str .. "123'" .. " AS INTEGER);", {
diff --git a/test/sql-tap/gh-5231-box-execute-writes-in-ro.test.lua b/test/sql-tap/gh-5231-box-execute-writes-in-ro.test.lua
index 05c23c2f8..5fbef707b 100755
--- a/test/sql-tap/gh-5231-box-execute-writes-in-ro.test.lua
+++ b/test/sql-tap/gh-5231-box-execute-writes-in-ro.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
 
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(9)
 
 local expected_err = "Can't modify data because this instance is in read-only mode."
diff --git a/test/sql-tap/gh2127-indentifier-max-length.test.lua b/test/sql-tap/gh2127-indentifier-max-length.test.lua
index 46efffeed..112689327 100755
--- a/test/sql-tap/gh2127-indentifier-max-length.test.lua
+++ b/test/sql-tap/gh2127-indentifier-max-length.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 
 test:plan(4)
 
diff --git a/test/sql-tap/gh2130-index-refer-table.test.lua b/test/sql-tap/gh2130-index-refer-table.test.lua
index 2ced0fa07..40d2a47e5 100755
--- a/test/sql-tap/gh2130-index-refer-table.test.lua
+++ b/test/sql-tap/gh2130-index-refer-table.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(5)
 
 test:execsql " DROP TABLE IF EXISTS t1 "
diff --git a/test/sql-tap/gh2140-trans.test.lua b/test/sql-tap/gh2140-trans.test.lua
index 3843c97be..eeab34c17 100755
--- a/test/sql-tap/gh2140-trans.test.lua
+++ b/test/sql-tap/gh2140-trans.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(10)
 
 box.execute("DROP TABLE IF EXISTS t1")
@@ -29,7 +29,7 @@ test:do_execsql_test('rollback1_check',
 
 for _, verb in ipairs({'ROLLBACK', 'ABORT'}) do
     box.execute('DELETE FROM t2')
-    answer = "/Duplicate key exists in unique index 'unique_unnamed_T1_2' in space 'T1'/"
+    local answer = "/Duplicate key exists in unique index 'unique_unnamed_T1_2' in space 'T1'/"
     test:do_catchsql_test('insert1_'..verb,
                           [[START TRANSACTION;
                             INSERT INTO t2 VALUES (20, 2, 2);
diff --git a/test/sql-tap/gh2168-temp-tables.test.lua b/test/sql-tap/gh2168-temp-tables.test.lua
index 37db002a4..02b6b30b5 100755
--- a/test/sql-tap/gh2168-temp-tables.test.lua
+++ b/test/sql-tap/gh2168-temp-tables.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 test:do_catchsql_test(
diff --git a/test/sql-tap/gh2250-trigger-chain-limit.test.lua b/test/sql-tap/gh2250-trigger-chain-limit.test.lua
index 0a8a6c58d..d3e90539a 100755
--- a/test/sql-tap/gh2250-trigger-chain-limit.test.lua
+++ b/test/sql-tap/gh2250-trigger-chain-limit.test.lua
@@ -1,18 +1,18 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(8)
 
 for _, table_count in ipairs({30, 31}) do
     -- Clean up, create tables, add entries
     for i = 1,table_count do
         -- First table for uniform triggers check
-        drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';'
+        local drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';'
         box.execute(drop_string)
 
-        create_string = 'CREATE TABLE t' .. i .. ' (s1 INT UNIQUE, s2 INT, s3 INT PRIMARY KEY);'
+        local create_string = 'CREATE TABLE t' .. i .. ' (s1 INT UNIQUE, s2 INT, s3 INT PRIMARY KEY);'
         box.execute(create_string)
 
-        insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ', 0);'
+        local insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ', 0);'
         box.execute(insert_string)
 
         -- Second table for triggers mixture check
@@ -28,7 +28,7 @@ for _, table_count in ipairs({30, 31}) do
 
     -- And ON DELETE|UPDATE|INSERT triggers
     for i = 1,table_count-1 do
-        create_string = 'CREATE TRIGGER td' .. i
+        local create_string = 'CREATE TRIGGER td' .. i
         create_string = create_string .. ' BEFORE DELETE ON t' .. i
             .. ' FOR EACH ROW '
         create_string = create_string .. ' BEGIN DELETE FROM t' .. i+1
@@ -73,8 +73,8 @@ for _, table_count in ipairs({30, 31}) do
         box.execute(create_string)
     end
 
-    function check(sql)
-        msg = ''
+    local function check(sql)
+        local msg = ''
         local _, msg = pcall(function () test:execsql(sql) end)
         msg = tostring(msg)
         test:do_test(sql,
diff --git a/test/sql-tap/gh2259-in-stmt-trans.test.lua b/test/sql-tap/gh2259-in-stmt-trans.test.lua
index 6bd055074..10eaaaaa0 100755
--- a/test/sql-tap/gh2259-in-stmt-trans.test.lua
+++ b/test/sql-tap/gh2259-in-stmt-trans.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(20)
 
 box.execute("DROP TABLE IF EXISTS t1")
diff --git a/test/sql-tap/gh2548-select-compound-limit.test.lua b/test/sql-tap/gh2548-select-compound-limit.test.lua
index 76769d6ae..7ddf5b9f6 100755
--- a/test/sql-tap/gh2548-select-compound-limit.test.lua
+++ b/test/sql-tap/gh2548-select-compound-limit.test.lua
@@ -1,29 +1,29 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(9)
 
 -- box.cfg{wal_mode='none'}
 
-table_count = 31
+local table_count = 31
 
-select_string_last = ''
+local select_string_last = ''
 
 for _, term in ipairs({'UNION', 'UNION ALL', 'INTERSECT', 'EXCEPT'}) do
-    select_string = ''
+    local select_string = ''
     test:do_test("Positive COMPOUND "..term,
                  function()
                      for i = 1,table_count do
-                         drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';\n'
+                         local drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';\n'
                          test:execsql(drop_string)
                      end
 
                      for i = 1,table_count do
-                         create_string = 'CREATE TABLE t' .. i .. ' (s1 int primary key, s2 int);\n'
+                         local create_string = 'CREATE TABLE t' .. i .. ' (s1 int primary key, s2 int);\n'
                          test:execsql(create_string)
                      end
 
                      for i = 1,table_count do
-                         insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ');\n'
+                         local insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ');\n'
                          test:execsql(insert_string)
                      end
 
diff --git a/test/sql-tap/hexlit.test.lua b/test/sql-tap/hexlit.test.lua
index 220aa9117..a3cbeaa07 100755
--- a/test/sql-tap/hexlit.test.lua
+++ b/test/sql-tap/hexlit.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(128)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/icu.test.lua b/test/sql-tap/icu.test.lua
index ad37feba3..4e25ba7c5 100755
--- a/test/sql-tap/icu.test.lua
+++ b/test/sql-tap/icu.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(0)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/identifier-characters.test.lua b/test/sql-tap/identifier-characters.test.lua
index 27ed2f889..7b257921d 100755
--- a/test/sql-tap/identifier-characters.test.lua
+++ b/test/sql-tap/identifier-characters.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
-identifier = require("identifier")
+local test = require("sqltester")
+local identifier = require("identifier")
 test:plan(9)
 
 local test_prefix = "identifier_char-"
diff --git a/test/sql-tap/identifier_case.test.lua b/test/sql-tap/identifier_case.test.lua
index 2a00626fc..84b6078fd 100755
--- a/test/sql-tap/identifier_case.test.lua
+++ b/test/sql-tap/identifier_case.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(73)
 
 local test_prefix = "identifier_case-"
diff --git a/test/sql-tap/in1.test.lua b/test/sql-tap/in1.test.lua
index 570cc1779..e889844dc 100755
--- a/test/sql-tap/in1.test.lua
+++ b/test/sql-tap/in1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(80)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/in2.test.lua b/test/sql-tap/in2.test.lua
index 5782eab0c..dcdf4b0ed 100755
--- a/test/sql-tap/in2.test.lua
+++ b/test/sql-tap/in2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1999)
 
 --!./tcltestrunner.lua
@@ -29,7 +29,7 @@ test:do_execsql_test(
         -- </in2-1>
     })
 
-N = 2000
+local N = 2000
 -- MUST_WORK_TEST
 test:do_test(
     "in2-2",
diff --git a/test/sql-tap/in3.test.lua b/test/sql-tap/in3.test.lua
index a6d842962..7358f0a20 100755
--- a/test/sql-tap/in3.test.lua
+++ b/test/sql-tap/in3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(28)
 
 --!./tcltestrunner.lua
@@ -27,7 +27,7 @@ test:plan(28)
 -- implementation of the sql statement passed as a an argument.
 --
 local function nEphemeral(sql)
-    nEph = 0
+    local nEph = 0
     for _, op in ipairs(test:execsql("EXPLAIN "..sql.."")) do
         if (op == "OpenTEphemeral")
  then
diff --git a/test/sql-tap/in4.test.lua b/test/sql-tap/in4.test.lua
index 5c01ccdab..7374f926e 100755
--- a/test/sql-tap/in4.test.lua
+++ b/test/sql-tap/in4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(52)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/in5.test.lua b/test/sql-tap/in5.test.lua
index b4e6f8dae..a4972fc10 100755
--- a/test/sql-tap/in5.test.lua
+++ b/test/sql-tap/in5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(22)
 
 --!./tcltestrunner.lua
@@ -16,7 +16,7 @@ test:plan(22)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "in5"
+local testprefix = "in5"
 test:do_execsql_test(
     "in5-1.1",
     [[
diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua
index ce66b7c1e..ea25727a4 100755
--- a/test/sql-tap/index1.test.lua
+++ b/test/sql-tap/index1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(73)
 
 --!./tcltestrunner.lua
@@ -585,7 +585,7 @@ test:do_test(
         for i = 1, 50, 1 do
             test:execsql(string.format("INSERT INTO t3 VALUES('x%sx',%s,0.%s)", i, i, i))
         end
-        sql_search_count = 0
+        local sql_search_count = 0
         return X(381, "X!cmd", [=[["concat",[["execsql","SELECT c FROM t3 WHERE b==10"]],["sql_search_count"]]]=])
     end, {
         -- <index-11.1>
@@ -1011,10 +1011,11 @@ end
 test:do_test(
     "index-22.1.0",
     function()
+        local format
         format = {}
         format[1] = { name = 'id', type = 'scalar'}
         format[2] = { name = 'f2', type = 'scalar'}
-        s = box.schema.create_space('T', {format = format})
+        box.schema.create_space('T', {format = format})
     end,
     {})
 
diff --git a/test/sql-tap/index2.test.lua b/test/sql-tap/index2.test.lua
index 5c0b4c1ee..04bbe8b10 100755
--- a/test/sql-tap/index2.test.lua
+++ b/test/sql-tap/index2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(7)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/index3.test.lua b/test/sql-tap/index3.test.lua
index 6eb532411..909a184da 100755
--- a/test/sql-tap/index3.test.lua
+++ b/test/sql-tap/index3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/index4.test.lua b/test/sql-tap/index4.test.lua
index 37c0569eb..4ea713a58 100755
--- a/test/sql-tap/index4.test.lua
+++ b/test/sql-tap/index4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(7)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(7)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "index4"
+local testprefix = "index4"
 test:do_execsql_test(
     1.1,
     [[
diff --git a/test/sql-tap/index6.test.lua b/test/sql-tap/index6.test.lua
index 15ae49245..501478ff5 100755
--- a/test/sql-tap/index6.test.lua
+++ b/test/sql-tap/index6.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(14)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/index7.test.lua b/test/sql-tap/index7.test.lua
index c98f17218..de3589725 100755
--- a/test/sql-tap/index7.test.lua
+++ b/test/sql-tap/index7.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(12)
 
 --!./tcltestrunner.lua
@@ -20,12 +20,6 @@ test:plan(12)
 -- ["source",[["testdir"],"\/tester.tcl"]]
 
 
--- Capture the output of a pragma in a TEMP table.
---
-local function capture_pragma(db, tabname, sql)
-    once = 1
-end
-
 -- load_static_extension db wholenumber;
 -- do_test index7-1.1 {
 --   # Able to parse and manage partial indices
diff --git a/test/sql-tap/insert1.test.lua b/test/sql-tap/insert1.test.lua
index d28baf11a..75dbe92b0 100755
--- a/test/sql-tap/insert1.test.lua
+++ b/test/sql-tap/insert1.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
-yaml = require('yaml')
+local test = require("sqltester")
+local yaml = require('yaml')
 test:plan(28)
 
 --!./tcltestrunner.lua
@@ -307,7 +307,7 @@ test:do_execsql_test("insert-4.7", [[
   -- if X(0, "X!capable", [["explain"]]) then
     test:do_test("insert-5.3", function()
       -- verify that a temporary table is used to copy t4 to t4
-      x = test:execsql [[
+      local x = test:execsql [[
         EXPLAIN INSERT INTO t4 SELECT x+2 FROM t4;
       ]]
       return {test:lsearch(x, 'OpenTEphemeral') > 0} -- X(264, "X!cmd", [=[["expr","[lsearch $x OpenEphemeral]>0"]]=])
@@ -342,7 +342,7 @@ test:do_execsql_test("insert-4.7", [[
   -- if X(0, "X!capable", [["explain"]]) then
     test:do_test("insert-5.7", function()
       -- verify that no temporary table is used to copy test1 to t4
-      x = test:execsql [[
+      local x = test:execsql [[
         EXPLAIN INSERT INTO t4 SELECT one FROM test1;
       ]]
       return {test:lsearch(x, 'OpenTemp') > 0} -- X(298, "X!cmd", [=[["expr","[lsearch $x OpenTemp]>0"]]=])
diff --git a/test/sql-tap/insert3.test.lua b/test/sql-tap/insert3.test.lua
index b92bc508e..6e1c2b0e0 100755
--- a/test/sql-tap/insert3.test.lua
+++ b/test/sql-tap/insert3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(18)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/intpkey.test.lua b/test/sql-tap/intpkey.test.lua
index 684a24114..32baf6baf 100755
--- a/test/sql-tap/intpkey.test.lua
+++ b/test/sql-tap/intpkey.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(31)
 
 --!./tcltestrunner.lua
@@ -371,7 +371,7 @@ test:do_execsql_test(
 -- Do an SQL statement.  Append the search count to the end of the result.
 --
 local function count(sql)
-    sql_search_count = 0
+    local sql_search_count = 0
     local r = test:execsql(sql)
     table.insert(r, sql_search_count)
     return r
diff --git a/test/sql-tap/join.test.lua b/test/sql-tap/join.test.lua
index 840b780a3..1fc968307 100755
--- a/test/sql-tap/join.test.lua
+++ b/test/sql-tap/join.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
-NULL = require('msgpack').NULL
+local test = require("sqltester")
+local NULL = require('msgpack').NULL
 test:plan(92)
 
 --!./tcltestrunner.lua
@@ -1059,7 +1059,7 @@ test:do_execsql_test(
     ]])
 
 local function jointest(tn, nTbl, res)
-    sql = "SELECT 1 FROM "..string.rep("t14,", (nTbl - 1)).." t14;"
+    local sql = "SELECT 1 FROM "..string.rep("t14,", (nTbl - 1)).." t14;"
     test:do_catchsql_test(tn, sql, res)
     -- X(685, "X!cmd", [=[["uplevel",[["list","do_catchsql_test",["tn"],["sql"],["res"]]]]]=])
 end
diff --git a/test/sql-tap/join2.test.lua b/test/sql-tap/join2.test.lua
index c61ffd84f..d5747ea9c 100755
--- a/test/sql-tap/join2.test.lua
+++ b/test/sql-tap/join2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(7)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/join3.test.lua b/test/sql-tap/join3.test.lua
index 876b3121a..4aa8c94a3 100755
--- a/test/sql-tap/join3.test.lua
+++ b/test/sql-tap/join3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(129)
 
 --!./tcltestrunner.lua
@@ -36,7 +36,7 @@ for N=1, bitmask_size do
         function()
             test:execsql("CREATE TABLE t"..N.."(x INT primary key);")
             test:execsql(string.format("INSERT INTO t%s VALUES(%s)", N, N))
-            sql = "SELECT * FROM t1"
+            local sql = "SELECT * FROM t1"
             -- for _ in X(0, "X!for", [=[["set i 2","$i<=$N","incr i"]]=]) do
             for i=2,N do
                 sql = sql .. ", t"..i..""
@@ -56,12 +56,12 @@ for N=1, bitmask_size do
     test:do_test(
         "join3-2."..N,
         function()
-            sql = "SELECT * FROM t1"
+            local sql = "SELECT * FROM t1"
             --for _ in X(0, "X!for", [=[["set i 2","$i<=$N","incr i"]]=]) do
             for i=2, N do
                 sql = sql .. ", t"..i..""
             end
-            sep = "WHERE"
+            local sep = "WHERE"
             --for _ in X(0, "X!for", [=[["set i 1","$i<$N","incr i"]]=]) do
             for i=1, N - 1 do
                 sql = sql .. string.format(" %s t%s.x==t%s.x+1", sep, (i + 1), i)
@@ -78,7 +78,7 @@ end
 test:do_test(
     "join3-3.1",
     function()
-        sql = "SELECT * FROM t1 AS t0, t1"
+        local sql = "SELECT * FROM t1 AS t0, t1"
         for i=2, bitmask_size do
             sql = sql .. ", t"..i..""
         end
diff --git a/test/sql-tap/join4.test.lua b/test/sql-tap/join4.test.lua
index 7c0e912f1..da64c006c 100755
--- a/test/sql-tap/join4.test.lua
+++ b/test/sql-tap/join4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(8)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/join5.test.lua b/test/sql-tap/join5.test.lua
index c18be5230..8dd0b1eda 100755
--- a/test/sql-tap/join5.test.lua
+++ b/test/sql-tap/join5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(22)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/join6.test.lua b/test/sql-tap/join6.test.lua
index f6342a6d9..9ccb8673c 100755
--- a/test/sql-tap/join6.test.lua
+++ b/test/sql-tap/join6.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(14)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/keyword1.test.lua b/test/sql-tap/keyword1.test.lua
index e39b22087..4e5fc5fd8 100755
--- a/test/sql-tap/keyword1.test.lua
+++ b/test/sql-tap/keyword1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(184)
 
 --!./tcltestrunner.lua
@@ -239,7 +239,7 @@ for _, kw in ipairs(kwlist) do
 end
 
 for _, kw in ipairs(bannedkws) do
-    query = 'CREATE TABLE '..kw..'(a INT PRIMARY KEY);'
+    local query = 'CREATE TABLE '..kw..'(a INT PRIMARY KEY);'
     if kw == 'end' or kw == 'match' or kw == 'release' or kw == 'rename' or
        kw == 'replace' or kw == 'binary' or kw == 'character' or
        kw == 'smallint' then
diff --git a/test/sql-tap/like2.test.lua b/test/sql-tap/like2.test.lua
index 45341f851..70917d1e5 100755
--- a/test/sql-tap/like2.test.lua
+++ b/test/sql-tap/like2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(282)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/like3.test.lua b/test/sql-tap/like3.test.lua
index e7c25dba6..68e2b5642 100755
--- a/test/sql-tap/like3.test.lua
+++ b/test/sql-tap/like3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(7)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/limit.test.lua b/test/sql-tap/limit.test.lua
index a7d1451f7..4871e43db 100755
--- a/test/sql-tap/limit.test.lua
+++ b/test/sql-tap/limit.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(113)
 
 --!./tcltestrunner.lua
@@ -28,7 +28,7 @@ test:execsql [[
 ]]
 for i=1,32 do
     --for _ in X(0, "X!for", [=[["set i 1","$i<=32","incr i"]]=]) do
-    j = 0
+    local j = 0
     while bit.lshift(1, j) < i do
     -- for _ in X(0, "X!for", [=[["set j 0","(1<<$j)<$i","incr j"]]=]) do
         j = j + 1
@@ -694,7 +694,7 @@ test:do_catchsql_test(
 test:do_test(
     "limit-10.1",
     function()
-        limit = 10
+        local limit = 10
         return test:execsql [[
             SELECT x FROM t1 LIMIT 10;
         ]]
diff --git a/test/sql-tap/lua-tables.test.lua b/test/sql-tap/lua-tables.test.lua
index 07e0f6a1e..fa10d886d 100755
--- a/test/sql-tap/lua-tables.test.lua
+++ b/test/sql-tap/lua-tables.test.lua
@@ -1,22 +1,23 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(14)
 
 test:do_test(
     "lua-tables-prepare-1",
     function()
+        local format, s
         format = {}
         format[1] = { name = 'id', type = 'scalar'}
         format[2] = { name = 'f2', type = 'scalar'}
         s = box.schema.create_space('t', {format = format})
-        i = s:create_index('i', {parts={1, 'scalar'}})
+        s:create_index('i', {parts={1, 'scalar'}})
 
         s:replace{1, 4}
         s:replace{2, 2}
         s:replace{3, 3}
         s:replace{4, 3}
 
-        s1 = box.schema.create_space('t1')
+        local s1 = box.schema.create_space('t1')
         s1:create_index('i', {parts={1, 'scalar'}})
         s1:replace{1, 1}
     end,
@@ -52,6 +53,7 @@ test:do_catchsql_test(
 test:do_test(
     "lua-tables-prepare-6",
     function()
+        local format, s
         format = {{name = "CODE", type = "integer"},
             {name = "NAME", type = "scalar"}}
         s = box.schema.create_space("ELEMENT", {format = format})
@@ -130,7 +132,7 @@ test:do_execsql_test(
 test:do_test(
     "lua-tables-prepare-10",
     function()
-        sp = box.schema.space.create("TEST", {
+        local sp = box.schema.space.create("TEST", {
             engine = 'memtx',
             format = {
                 { name = 'ID', type = 'unsigned' },
@@ -165,7 +167,7 @@ test:do_eqp_test(
 test:do_test(
     "no-format-create-index-prep",
     function()
-        s = box.schema.create_space('T')
+        box.schema.create_space('T')
     end, {})
 
 test:do_catchsql_test(
diff --git a/test/sql-tap/lua/sqltester.lua b/test/sql-tap/lua/sqltester.lua
index 9b0218e63..169d2f271 100644
--- a/test/sql-tap/lua/sqltester.lua
+++ b/test/sql-tap/lua/sqltester.lua
@@ -177,7 +177,7 @@ end
 test.execsql = execsql
 
 local function catchsql(self, sql, expect)
-    r = {pcall(execsql, self, sql) }
+    local r = {pcall(execsql, self, sql) }
     if r[1] == true then
         r[1] = 0
     else
@@ -256,7 +256,7 @@ end
 test.sortsql = sortsql
 
 local function catchsql2(self, sql)
-    r = {pcall(execsql2, self, sql) }
+    local r = {pcall(execsql2, self, sql) }
     -- 0 means ok
     -- 1 means not ok
     r[1] = r[1] == true and 0 or 1
@@ -271,7 +271,7 @@ test.catchsql2 = catchsql2
 -- 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)
+    local tr = execsql(self, "EXPLAIN "..sql)
     for i=1,8 do
         table.remove(tr,1)
     end
diff --git a/test/sql-tap/lua_sql.test.lua b/test/sql-tap/lua_sql.test.lua
index 31c563f3a..b22f195ca 100755
--- a/test/sql-tap/lua_sql.test.lua
+++ b/test/sql-tap/lua_sql.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
-NULL = require('msgpack').NULL
+local test = require("sqltester")
+local NULL = require('msgpack').NULL
 test:plan(24)
 
 test:do_test(
@@ -51,7 +51,7 @@ for _, val in ipairs({
         {result})
 end
 
-from_sql_to_lua = {
+_G.from_sql_to_lua = {
     [1] = {1, 1},
     [2] = {"1", 1},
     [3] = {"1.5", 1.5},
@@ -82,7 +82,7 @@ for i = 1, #from_sql_to_lua, 1 do
         {1})
 end
 
-from_lua_to_sql = {
+_G.from_lua_to_sql = {
     [1] = {1, 1},
     [2] = {"1.5", 1.5},
     [3] = {"'1'", "1"},
diff --git a/test/sql-tap/minmax2.test.lua b/test/sql-tap/minmax2.test.lua
index 707d1c4da..f3d608aab 100755
--- a/test/sql-tap/minmax2.test.lua
+++ b/test/sql-tap/minmax2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(49)
 
 --!./tcltestrunner.lua
@@ -56,10 +56,12 @@ test:do_execsql_test(
         -- </minmax2-1.0>
     })
 
+_G.sql_search_count = 0
+
 test:do_test(
     "minmax2-1.1",
     function()
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql "SELECT min(x) FROM t1"
     end, {
         -- <minmax2-1.1>
@@ -76,7 +78,7 @@ test:do_test(
 test:do_test(
     "minmax2-1.3",
     function()
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql "SELECT max(x) FROM t1"
     end, {
         -- <minmax2-1.3>
@@ -94,7 +96,7 @@ test:do_test(
     "minmax2-1.5",
     function()
         test:execsql "CREATE INDEX t1i1 ON t1(x DESC)"
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql "SELECT min(x) FROM t1"
     end, {
         -- <minmax2-1.5>
@@ -105,13 +107,13 @@ test:do_test(
 test:do_test(
     "minmax2-1.6",
     function()
-        return box.stat.sql().sql_search_count - sql_search_count
+        return box.stat.sql().sql_search_count - _G.sql_search_count
     end, 1)
 
 test:do_test(
     "minmax2-1.7",
     function()
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql "SELECT max(x) FROM t1"
     end, {
         -- <minmax2-1.7>
@@ -122,13 +124,13 @@ test:do_test(
 test:do_test(
     "minmax2-1.8",
     function()
-        return box.stat.sql().sql_search_count - sql_search_count
+        return box.stat.sql().sql_search_count - _G.sql_search_count
     end, 0)
 
 test:do_test(
     "minmax2-1.9",
     function()
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql "SELECT max(y) FROM t1"
     end, {
         -- <minmax2-1.9>
@@ -139,7 +141,7 @@ test:do_test(
 test:do_test(
     "minmax2-1.10",
     function()
-        return box.stat.sql().sql_search_count - sql_search_count
+        return box.stat.sql().sql_search_count - _G.sql_search_count
     end, 19)
 
 test:do_test(
@@ -149,7 +151,7 @@ test:do_test(
             CREATE TABLE t2(a INTEGER PRIMARY KEY, b INT );
             INSERT INTO t2 SELECT x, y FROM t1;
         ]]
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql "SELECT min(a) FROM t2"
     end, {
         -- <minmax2-2.0>
@@ -160,13 +162,13 @@ test:do_test(
 test:do_test(
     "minmax2-2.1",
     function()
-        return box.stat.sql().sql_search_count - sql_search_count
+        return box.stat.sql().sql_search_count - _G.sql_search_count
     end, 0)
 
 test:do_test(
     "minmax2-2.2",
     function()
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql "SELECT max(a) FROM t2"
     end, {
         -- <minmax2-2.2>
@@ -177,7 +179,7 @@ test:do_test(
 test:do_test(
     "minmax2-2.3",
     function()
-        return box.stat.sql().sql_search_count - sql_search_count
+        return box.stat.sql().sql_search_count - _G.sql_search_count
     end, 0)
 
 test:do_test(
@@ -186,7 +188,7 @@ test:do_test(
         test:execsql "INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)"
 
 
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql "SELECT max(a) FROM t2"
     end, {
         -- <minmax2-3.0>
@@ -197,7 +199,7 @@ test:do_test(
 test:do_test(
     "minmax2-3.1",
     function()
-        return box.stat.sql().sql_search_count - sql_search_count
+        return box.stat.sql().sql_search_count - _G.sql_search_count
     end, 0)
 
 test:do_test(
@@ -206,7 +208,7 @@ test:do_test(
         test:execsql "INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)"
 
 
-        sql_search_count = box.stat.sql().sql_search_count
+        _G.sql_search_count = box.stat.sql().sql_search_count
         return test:execsql " SELECT b FROM t2 WHERE a=(SELECT max(a) FROM t2) "
 
 
@@ -220,7 +222,7 @@ test:do_test(
 test:do_test(
     "minmax2-3.3",
     function()
-        return box.stat.sql().sql_search_count - sql_search_count
+        return box.stat.sql().sql_search_count - _G.sql_search_count
     end, 1)
 
 test:do_execsql_test(
diff --git a/test/sql-tap/minmax3.test.lua b/test/sql-tap/minmax3.test.lua
index f1d9efc5a..90f4f6020 100755
--- a/test/sql-tap/minmax3.test.lua
+++ b/test/sql-tap/minmax3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(47)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/minmax4.test.lua b/test/sql-tap/minmax4.test.lua
index b600c9bfe..1674a7753 100755
--- a/test/sql-tap/minmax4.test.lua
+++ b/test/sql-tap/minmax4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(21)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/misc1.test.lua b/test/sql-tap/misc1.test.lua
index c0136d04c..c9b9cd7a8 100755
--- a/test/sql-tap/misc1.test.lua
+++ b/test/sql-tap/misc1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(59)
 
 --!./tcltestrunner.lua
@@ -583,7 +583,7 @@ if (0 > 0) then
             test:execsql("START TRANSACTION")
             test:execsql("UPDATE t1 SET a=0 WHERE 0")
             sql("db2", "test.db")
-            rc = X(371, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
+            local rc = X(371, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
             return table.insert(rc,msg) or rc
             -- v2 result: {1 {database is locked}}
         end, {
@@ -596,7 +596,7 @@ if (0 > 0) then
         "misc1-11.2",
         function()
             test:execsql("COMMIT")
-            rc = X(377, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
+            local rc = X(377, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
             db2("close")
             return table.insert(rc,msg) or rc
         end, {
diff --git a/test/sql-tap/misc3.test.lua b/test/sql-tap/misc3.test.lua
index d0e45e872..f27e83745 100755
--- a/test/sql-tap/misc3.test.lua
+++ b/test/sql-tap/misc3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 local json = require("json")
 test:plan(34)
 
diff --git a/test/sql-tap/misc5.test.lua b/test/sql-tap/misc5.test.lua
index 2725e6782..357c36ff6 100755
--- a/test/sql-tap/misc5.test.lua
+++ b/test/sql-tap/misc5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(31)
 
 --!./tcltestrunner.lua
@@ -289,6 +289,7 @@ test:do_test(
     "misc5-7.1",
     function()
         test:execsql "CREATE TABLE t1(x  INT primary key)"
+        local sql, tail
         sql = "INSERT INTO t1 VALUES("
         tail = ""
         for i = 0, 199, 1 do
diff --git a/test/sql-tap/null.test.lua b/test/sql-tap/null.test.lua
index 93589754c..a1f33f5ad 100755
--- a/test/sql-tap/null.test.lua
+++ b/test/sql-tap/null.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(45)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/numcast.test.lua b/test/sql-tap/numcast.test.lua
index 3161e48fa..18c6adc9e 100755
--- a/test/sql-tap/numcast.test.lua
+++ b/test/sql-tap/numcast.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(31)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/offset1.test.lua b/test/sql-tap/offset1.test.lua
index 451694af2..194c3a735 100755
--- a/test/sql-tap/offset1.test.lua
+++ b/test/sql-tap/offset1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(22)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/orderby1.test.lua b/test/sql-tap/orderby1.test.lua
index 51e8d301f..cc65360c4 100755
--- a/test/sql-tap/orderby1.test.lua
+++ b/test/sql-tap/orderby1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(35)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(35)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "orderby1"
+local testprefix = "orderby1"
 -- MUST_WORK_TEST
 -- # Generate test data for a join.  Verify that the join gets the
 -- # correct answer.
diff --git a/test/sql-tap/orderby2.test.lua b/test/sql-tap/orderby2.test.lua
index 3cee73f25..03f5b3cee 100755
--- a/test/sql-tap/orderby2.test.lua
+++ b/test/sql-tap/orderby2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(9)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(9)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "orderby2"
+local testprefix = "orderby2"
 -- Generate test data for a join.  Verify that the join gets the
 -- correct answer.
 --
diff --git a/test/sql-tap/orderby3.test.lua b/test/sql-tap/orderby3.test.lua
index 48373849a..6cbccf2e7 100755
--- a/test/sql-tap/orderby3.test.lua
+++ b/test/sql-tap/orderby3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(15)
 
 --!./tcltestrunner.lua
@@ -20,7 +20,7 @@ test:plan(15)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "orderby3"
+local testprefix = "orderby3"
 -- Generate test data for a join.  Verify that the join gets the
 -- correct answer.
 --
diff --git a/test/sql-tap/orderby4.test.lua b/test/sql-tap/orderby4.test.lua
index 774a19246..87f011e0a 100755
--- a/test/sql-tap/orderby4.test.lua
+++ b/test/sql-tap/orderby4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(6)
 
 --!./tcltestrunner.lua
@@ -21,7 +21,7 @@ test:plan(6)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "orderby4"
+local testprefix = "orderby4"
 -- Generate test data for a join.  Verify that the join gets the
 -- correct answer.
 --
diff --git a/test/sql-tap/orderby5.test.lua b/test/sql-tap/orderby5.test.lua
index c7c09bc07..0a1b69cfd 100755
--- a/test/sql-tap/orderby5.test.lua
+++ b/test/sql-tap/orderby5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(10)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(10)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "orderby5"
+local testprefix = "orderby5"
 -- Generate test data for a join.  Verify that the join gets the
 -- correct answer.
 --
diff --git a/test/sql-tap/orderby6.test.lua b/test/sql-tap/orderby6.test.lua
index d909f3493..cc8879ae6 100755
--- a/test/sql-tap/orderby6.test.lua
+++ b/test/sql-tap/orderby6.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(34)
 
 --!./tcltestrunner.lua
@@ -26,7 +26,7 @@ test:plan(34)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "orderby6"
+local testprefix = "orderby6"
 -- Run all tests twice.  Once with a normal table and a second time
 -- with a WITHOUT ROWID table
 --
diff --git a/test/sql-tap/orderby8.test.lua b/test/sql-tap/orderby8.test.lua
index 52f125755..dc0101769 100755
--- a/test/sql-tap/orderby8.test.lua
+++ b/test/sql-tap/orderby8.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(203)
 
 --!./tcltestrunner.lua
@@ -22,7 +22,7 @@ test:plan(203)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "orderby8"
+local testprefix = "orderby8"
 
 local rs = ""
 test:do_test(
diff --git a/test/sql-tap/orderby9.test.lua b/test/sql-tap/orderby9.test.lua
index acafb2840..1fad72ddd 100755
--- a/test/sql-tap/orderby9.test.lua
+++ b/test/sql-tap/orderby9.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
@@ -22,7 +22,7 @@ test:plan(4)
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
 
-testprefix = "orderby9"
+local testprefix = "orderby9"
 test:do_execsql_test(
     "setup",
     [[
diff --git a/test/sql-tap/position.test.lua b/test/sql-tap/position.test.lua
index e0455abc9..506efe0f4 100755
--- a/test/sql-tap/position.test.lua
+++ b/test/sql-tap/position.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(80)
 
 test:do_test(
diff --git a/test/sql-tap/pragma.test.lua b/test/sql-tap/pragma.test.lua
index d6f8b544d..737cf821f 100755
--- a/test/sql-tap/pragma.test.lua
+++ b/test/sql-tap/pragma.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 
 test:plan(10)
 
diff --git a/test/sql-tap/printf2.test.lua b/test/sql-tap/printf2.test.lua
index be6564c6b..992b2bb1b 100755
--- a/test/sql-tap/printf2.test.lua
+++ b/test/sql-tap/printf2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(22)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/quote.test.lua b/test/sql-tap/quote.test.lua
index edca165fd..65cda3db9 100755
--- a/test/sql-tap/quote.test.lua
+++ b/test/sql-tap/quote.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(8)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/randexpr1.test.lua b/test/sql-tap/randexpr1.test.lua
index a045e18c0..38a4aad28 100755
--- a/test/sql-tap/randexpr1.test.lua
+++ b/test/sql-tap/randexpr1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2600)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/resolver01.test.lua b/test/sql-tap/resolver01.test.lua
index 315c892ac..66db0f004 100755
--- a/test/sql-tap/resolver01.test.lua
+++ b/test/sql-tap/resolver01.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(27)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/select1.test.lua b/test/sql-tap/select1.test.lua
index d8be38da6..0e7c5a318 100755
--- a/test/sql-tap/select1.test.lua
+++ b/test/sql-tap/select1.test.lua
@@ -1,8 +1,8 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(173)
 
-function set_full_column_names(value)
+local function set_full_column_names(value)
     box.space._session_settings:update('sql_full_column_names', {
         {'=', 2, value}
     })
@@ -219,7 +219,7 @@ test:do_execsql_test(
         -- </select1-1.13>
     })
 
-long = "This is a string that is too big to fit inside a NBFS buffer"
+local long = "This is a string that is too big to fit inside a NBFS buffer"
 test:do_execsql_test(
     "select1-2.0",
 string.format([[
@@ -1051,7 +1051,7 @@ test:do_test(
     function()
         set_full_column_names(true)
         local msg
-        v = pcall( function ()
+        local v = pcall( function ()
                 msg = test:execsql2 "SELECT test1.f1+F2 FROM test1 ORDER BY f2"
             end)
         v = v == true and {0} or {1}
@@ -1178,7 +1178,7 @@ test:do_execsql2_test(
 test:do_test(
     "select1-6.9.7",
     function()
-        x = test:execsql2 [[
+        local x = test:execsql2 [[
             SELECT * FROM test1 a, (select 5, 6) LIMIT 1
         ]]
         for i, tmp in ipairs(x) do
@@ -1197,7 +1197,7 @@ test:do_test(
 test:do_test(
     "select1-6.9.8",
     function()
-        x = test:execsql2 [[
+        local x = test:execsql2 [[
             SELECT * FROM test1 a, (select 5 AS x, 6 AS y) AS b LIMIT 1
         ]]
         for i, tmp in ipairs(x) do
diff --git a/test/sql-tap/select2.test.lua b/test/sql-tap/select2.test.lua
index 24fad2149..96b29937f 100755
--- a/test/sql-tap/select2.test.lua
+++ b/test/sql-tap/select2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(16)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/select3.test.lua b/test/sql-tap/select3.test.lua
index 0b0b9cc73..258ac8000 100755
--- a/test/sql-tap/select3.test.lua
+++ b/test/sql-tap/select3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(38)
 
 --!./tcltestrunner.lua
@@ -29,7 +29,7 @@ test:do_test("select3-1.0", function()
     START TRANSACTION;
   ]]
   for i = 1, 32-1 do -- in X(0, "X!for", [=[["set i 1","$i<32","incr i"]]=]) do
-     j = 0
+     local j = 0
      while bit.lshift(1, j) < i do
 	-- for _ in X(0, "X!for", [=[["set j 0","(1<<$j)<$i","incr j"]]=]) do
 	j = j + 1
diff --git a/test/sql-tap/select4.test.lua b/test/sql-tap/select4.test.lua
index f7a320438..abc95a24f 100755
--- a/test/sql-tap/select4.test.lua
+++ b/test/sql-tap/select4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(105)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/select5.test.lua b/test/sql-tap/select5.test.lua
index d34de3139..d531cbcf8 100755
--- a/test/sql-tap/select5.test.lua
+++ b/test/sql-tap/select5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(46)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/select6.test.lua b/test/sql-tap/select6.test.lua
index 380fd67c1..47c2ff5ef 100755
--- a/test/sql-tap/select6.test.lua
+++ b/test/sql-tap/select6.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(88)
 
 --!./tcltestrunner.lua
@@ -23,7 +23,7 @@ test:plan(88)
 -- Omit this whole file if the library is build without subquery support.
 
 
-testprefix = "select6"
+local testprefix = "select6"
 test:do_test(
     "select6-1.0",
     function()
@@ -905,7 +905,7 @@ test:do_execsql_test(
         CREATE TABLE k(o  INT primary key);
     ]])
 
-err = { 1, "SELECTs to the left and right of UNION ALL do not have the same number of result columns" }
+local err = { 1, "SELECTs to the left and right of UNION ALL do not have the same number of result columns" }
 test:do_execsql_test(
     10.2,
     [[
diff --git a/test/sql-tap/select7.test.lua b/test/sql-tap/select7.test.lua
index e1e43c557..67edc5db3 100755
--- a/test/sql-tap/select7.test.lua
+++ b/test/sql-tap/select7.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(18)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(18)
 -- $Id: select7.test,v 1.11 2007/09/12 17:01:45 danielk1977 Exp $
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "select7"
+local testprefix = "select7"
 -- A 3-way INTERSECT.  Ticket #875
 test:do_execsql_test(
     "select7-1.1",
@@ -171,7 +171,7 @@ test:do_catchsql_test(
 -- hardcoded define from src
 -- 30 is default value
 local SQL_MAX_COMPOUND_SELECT = 30
-sql = "SELECT 0"
+local sql = "SELECT 0"
 for i = 0, SQL_MAX_COMPOUND_SELECT + 1, 1 do
     sql = sql .. " UNION ALL SELECT "..i..""
 end
diff --git a/test/sql-tap/select8.test.lua b/test/sql-tap/select8.test.lua
index 9684299fb..c1bdd93a2 100755
--- a/test/sql-tap/select8.test.lua
+++ b/test/sql-tap/select8.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
@@ -37,7 +37,7 @@ local result = test:execsql [[
     GROUP BY LOWER(artist)      
 ]]
 
-function subrange(t, first, last)
+local function subrange(t, first, last)
     local sub = {}
     for i=first,last do
         sub[#sub + 1] = t[i]
diff --git a/test/sql-tap/select9.test.lua b/test/sql-tap/select9.test.lua
index 1ae16a658..4f7da84e2 100755
--- a/test/sql-tap/select9.test.lua
+++ b/test/sql-tap/select9.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(21157)
 -- it is bad idea to store 20k positive test results in git
 test.silent = true
@@ -47,11 +47,11 @@ test.silent = true
 --   pass to [do_test] for each individual LIMIT OFFSET test case.
 --
 
-function trim(s)
+local function trim(s)
     return s:match "^%s*(.-)%s*$"
 end
 
-function subrange(t, first, last)
+local function subrange(t, first, last)
     local sub = {}
     for i=first,last do
         sub[#sub + 1] = t[i]
diff --git a/test/sql-tap/selectA.test.lua b/test/sql-tap/selectA.test.lua
index 5cc69ef61..a608ab093 100755
--- a/test/sql-tap/selectA.test.lua
+++ b/test/sql-tap/selectA.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(194)
 
 --!./tcltestrunner.lua
@@ -25,7 +25,7 @@ test:plan(194)
 -- $Id: selectA.test,v 1.6 2008/08/21 14:24:29 drh Exp $
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "selectA"
+local testprefix = "selectA"
 
 
 test:do_execsql_test(
diff --git a/test/sql-tap/selectB.test.lua b/test/sql-tap/selectB.test.lua
index 56d4b9d1b..b56403ce5 100755
--- a/test/sql-tap/selectB.test.lua
+++ b/test/sql-tap/selectB.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(162)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/selectC.test.lua b/test/sql-tap/selectC.test.lua
index b0e751ac5..20a0203a6 100755
--- a/test/sql-tap/selectC.test.lua
+++ b/test/sql-tap/selectC.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(18)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/selectE.test.lua b/test/sql-tap/selectE.test.lua
index 32c3d6a06..fb1bc8794 100755
--- a/test/sql-tap/selectE.test.lua
+++ b/test/sql-tap/selectE.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(7)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/selectF.test.lua b/test/sql-tap/selectF.test.lua
index 4cc5af137..dbd9dfdad 100755
--- a/test/sql-tap/selectF.test.lua
+++ b/test/sql-tap/selectF.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 --!./tcltestrunner.lua
@@ -20,7 +20,7 @@ test:plan(2)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "selectF"
+local testprefix = "selectF"
 test:do_execsql_test(
     1,
     [[
diff --git a/test/sql-tap/selectG.test.lua b/test/sql-tap/selectG.test.lua
index 0ca066d1c..a9c7d9fb6 100755
--- a/test/sql-tap/selectG.test.lua
+++ b/test/sql-tap/selectG.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(1)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "selectG"
+local testprefix = "selectG"
 -- Do an INSERT with a VALUES clause that contains 100,000 entries.  Verify
 -- that this insert happens quickly (in less than 10 seconds).  Actually, the
 -- insert will normally happen in less than 0.5 seconds on a workstation, but
diff --git a/test/sql-tap/sort.test.lua b/test/sql-tap/sort.test.lua
index 18bfd443d..065f648b7 100755
--- a/test/sql-tap/sort.test.lua
+++ b/test/sql-tap/sort.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(60)
 
 --!./tcltestrunner.lua
@@ -794,7 +794,7 @@ box.internal.sql_create_function("cksum", cksum)
             "sort-14."..tn,
             function()
                 sql_test_control("sql_TESTCTRL_SORTER_MMAP", "db", mmap_limit)
-                prev = ""
+                local prev = ""
                 X(536, "X!cmd", [=[["db","eval"," SELECT * FROM t11 ORDER BY b ","\n         if {$b != [cksum $a]} {error \"checksum failed\"}\n         if {[string compare $b $prev] < 0} {error \"sort failed\"}\n         set prev $b\n       "]]=])
                 return X(541, "X!cmd", [=[["set","",""]]=])
             end, {
@@ -818,6 +818,7 @@ box.internal.sql_create_function("cksum", cksum)
         reset_db()
         sql_test_control("sql_TESTCTRL_SORTER_MMAP", "db", mmap_limit)
         test:execsql(string.format("PRAGMA temp_store = %s; PRAGMA threads = '%s'", tmpstore, nWorker))
+        local ten, one
         ten = string.rep("X", 10300)
         one = string.rep("y", 200)
         if softheaplimit then
diff --git a/test/sql-tap/sql-errors.test.lua b/test/sql-tap/sql-errors.test.lua
index 5ec94bfe3..469193a2b 100755
--- a/test/sql-tap/sql-errors.test.lua
+++ b/test/sql-tap/sql-errors.test.lua
@@ -1,15 +1,16 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(72)
 
 test:execsql([[
 	CREATE TABLE t0 (i INT PRIMARY KEY, a INT);
 	CREATE VIEW v0 AS SELECT * FROM t0;
 ]])
+local format, s0
 format = {}
 for i = 1, 2001 do format[i] = {name = 'A' .. i, type = 'unsigned'} end
 s0 = box.schema.space.create('S0', {format = format})
-i0 = s0:create_index('I0')
+s0:create_index('I0')
 
 test:do_catchsql_test(
 	"sql-errors-1.1",
@@ -21,7 +22,7 @@ test:do_catchsql_test(
 		-- </sql-errors-1.1>
 	})
 
-create_statement = 'CREATE TABLE t2 (i INT PRIMARY KEY'
+local create_statement = 'CREATE TABLE t2 (i INT PRIMARY KEY'
 for i = 1, 2001 do
 	create_statement = create_statement .. ', s' .. i .. ' INT'
 end
@@ -156,7 +157,7 @@ test:do_catchsql_test(
 		-- </sql-errors-1.14>
 	})
 
-select_statement = 'SELECT i FROM t0 WHERE i = 0'
+local select_statement = 'SELECT i FROM t0 WHERE i = 0'
 for i = 1, 200 do
 	select_statement = select_statement .. ' OR i = ' .. i
 end
@@ -337,7 +338,7 @@ test:do_catchsql_test(
 		-- </sql-errors-1.29>
 	})
 
-create_index_statement = 'CREATE INDEX i30 on t0(i'..string.rep(', i', 2000)..');'
+local create_index_statement = 'CREATE INDEX i30 on t0(i'..string.rep(', i', 2000)..');'
 
 test:do_catchsql_test(
 	"sql-errors-1.30",
@@ -348,7 +349,7 @@ test:do_catchsql_test(
 		-- </sql-errors-1.30>
 	})
 
-update_statement = 'UPDATE s0 SET a1 = a1 + 1'
+local update_statement = 'UPDATE s0 SET a1 = a1 + 1'
 for i = 2, 2001 do
 	update_statement = update_statement .. ', a' .. i .. ' = a' .. i .. ' + 1'
 end
diff --git a/test/sql-tap/start-transaction.test.lua b/test/sql-tap/start-transaction.test.lua
index 6d6b00b26..0ca6b632c 100755
--- a/test/sql-tap/start-transaction.test.lua
+++ b/test/sql-tap/start-transaction.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(21)
 
 -----------------------------------------------------------------
diff --git a/test/sql-tap/subquery.test.lua b/test/sql-tap/subquery.test.lua
index e0771825e..f57a22624 100755
--- a/test/sql-tap/subquery.test.lua
+++ b/test/sql-tap/subquery.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(69)
 
 --!./tcltestrunner.lua
@@ -643,7 +643,8 @@ test:do_execsql_test(
 -- for a matching column name did not cause an otherwise static subquery
 -- to become a dynamic (correlated) subquery.
 --
-callcnt = 0
+
+_G.callcnt = 0
 test:do_test(
     "subquery-5.1",
     function()
@@ -692,7 +693,7 @@ test:do_test(
 test:do_test(
     "subquery-6.1",
     function()
-        callcnt = 0
+        _G.callcnt = 0
         return test:execsql [[
             SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=y)
         ]]
@@ -711,7 +712,7 @@ test:do_test(
 test:do_test(
     "subquery-6.3",
     function()
-        callcnt = 0
+        _G.callcnt = 0
         return test:execsql [[
             SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=1)
         ]]
diff --git a/test/sql-tap/subquery2.test.lua b/test/sql-tap/subquery2.test.lua
index 9d0ce218c..5cd1afa86 100755
--- a/test/sql-tap/subquery2.test.lua
+++ b/test/sql-tap/subquery2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(11)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(11)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "subquery2"
+local testprefix = "subquery2"
 
 
 test:do_test(
diff --git a/test/sql-tap/subselect.test.lua b/test/sql-tap/subselect.test.lua
index 84c0b38b0..b6a20948d 100755
--- a/test/sql-tap/subselect.test.lua
+++ b/test/sql-tap/subselect.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(30)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/substr.test.lua b/test/sql-tap/substr.test.lua
index a9e656e6d..72224fd7b 100755
--- a/test/sql-tap/substr.test.lua
+++ b/test/sql-tap/substr.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(93)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua
index 1b4ec1173..590dbafbd 100755
--- a/test/sql-tap/table.test.lua
+++ b/test/sql-tap/table.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(79)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-02a8e81d44.test.lua b/test/sql-tap/tkt-02a8e81d44.test.lua
index b94f72e59..1ab0e175c 100755
--- a/test/sql-tap/tkt-02a8e81d44.test.lua
+++ b/test/sql-tap/tkt-02a8e81d44.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-31338dca7e.test.lua b/test/sql-tap/tkt-31338dca7e.test.lua
index 905ae6649..6f11b0eb5 100755
--- a/test/sql-tap/tkt-31338dca7e.test.lua
+++ b/test/sql-tap/tkt-31338dca7e.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(11)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-385a5b56b9.test.lua b/test/sql-tap/tkt-385a5b56b9.test.lua
index 653d68222..d10c3152e 100755
--- a/test/sql-tap/tkt-385a5b56b9.test.lua
+++ b/test/sql-tap/tkt-385a5b56b9.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(9)
 
 --!./tcltestrunner.lua
@@ -17,7 +17,7 @@ test:plan(9)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-385a5b56b9"
+local testprefix = "tkt-385a5b56b9"
 test:do_execsql_test(
     "1.0",
     [[
diff --git a/test/sql-tap/tkt-38cb5df375.test.lua b/test/sql-tap/tkt-38cb5df375.test.lua
index a7587ef3a..1539005b8 100755
--- a/test/sql-tap/tkt-38cb5df375.test.lua
+++ b/test/sql-tap/tkt-38cb5df375.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(293)
 
 --!./tcltestrunner.lua
@@ -321,7 +321,7 @@ for ii = 1, 9, 1 do
 
 end
 for ii = 1, 7, 1 do
-    jj = (7 - ii)
+    local jj = (7 - ii)
     test:do_execsql_test(
         "tkt-38cb5df375.51."..ii,
         [[
diff --git a/test/sql-tap/tkt-3998683a16.test.lua b/test/sql-tap/tkt-3998683a16.test.lua
index 9bc310358..44ce7087a 100755
--- a/test/sql-tap/tkt-3998683a16.test.lua
+++ b/test/sql-tap/tkt-3998683a16.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-3a77c9714e.test.lua b/test/sql-tap/tkt-3a77c9714e.test.lua
index 8068adcb4..82225ce89 100755
--- a/test/sql-tap/tkt-3a77c9714e.test.lua
+++ b/test/sql-tap/tkt-3a77c9714e.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
@@ -21,7 +21,7 @@ test:plan(4)
 -- ["source",[["testdir"],"\/tester.tcl"]]
 
 
-testprefix = "tkt-3a77c9714e"
+local testprefix = "tkt-3a77c9714e"
 test:do_execsql_test(
     1.1,
     [[
diff --git a/test/sql-tap/tkt-4a03edc4c8.test.lua b/test/sql-tap/tkt-4a03edc4c8.test.lua
index cb7a982dc..1bbaed30b 100755
--- a/test/sql-tap/tkt-4a03edc4c8.test.lua
+++ b/test/sql-tap/tkt-4a03edc4c8.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-4c86b126f2.test.lua b/test/sql-tap/tkt-4c86b126f2.test.lua
index 606a56add..51222cbdd 100755
--- a/test/sql-tap/tkt-4c86b126f2.test.lua
+++ b/test/sql-tap/tkt-4c86b126f2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-4dd95f6943.test.lua b/test/sql-tap/tkt-4dd95f6943.test.lua
index 21d6a18ff..c1d862a9d 100755
--- a/test/sql-tap/tkt-4dd95f6943.test.lua
+++ b/test/sql-tap/tkt-4dd95f6943.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(319)
 
 --!./tcltestrunner.lua
@@ -17,7 +17,7 @@ test:plan(319)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-4dd95f6943"
+local testprefix = "tkt-4dd95f6943"
 test:do_execsql_test(
     1.0,
     [[
diff --git a/test/sql-tap/tkt-4ef7e3cfca.test.lua b/test/sql-tap/tkt-4ef7e3cfca.test.lua
index ac8dd4bdd..9b02d42b7 100755
--- a/test/sql-tap/tkt-4ef7e3cfca.test.lua
+++ b/test/sql-tap/tkt-4ef7e3cfca.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(5)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(5)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-4ef7e3cfca"
+local testprefix = "tkt-4ef7e3cfca"
 
 test:do_catchsql_test(
     1.1,
diff --git a/test/sql-tap/tkt-54844eea3f.test.lua b/test/sql-tap/tkt-54844eea3f.test.lua
index 89d0d1218..042436c61 100755
--- a/test/sql-tap/tkt-54844eea3f.test.lua
+++ b/test/sql-tap/tkt-54844eea3f.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(3)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-54844eea3f"
+local testprefix = "tkt-54844eea3f"
 test:do_execsql_test(
     "1.0",
     [[
diff --git a/test/sql-tap/tkt-752e1646fc.test.lua b/test/sql-tap/tkt-752e1646fc.test.lua
index 9d198411a..a7c6978f8 100755
--- a/test/sql-tap/tkt-752e1646fc.test.lua
+++ b/test/sql-tap/tkt-752e1646fc.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-7a31705a7e6.test.lua b/test/sql-tap/tkt-7a31705a7e6.test.lua
index 48c235c2d..fdd360662 100755
--- a/test/sql-tap/tkt-7a31705a7e6.test.lua
+++ b/test/sql-tap/tkt-7a31705a7e6.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-7bbfb7d442.test.lua b/test/sql-tap/tkt-7bbfb7d442.test.lua
index bfddcd920..43537d229 100755
--- a/test/sql-tap/tkt-7bbfb7d442.test.lua
+++ b/test/sql-tap/tkt-7bbfb7d442.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(5)
 
 --!./tcltestrunner.lua
@@ -20,7 +20,7 @@ test:plan(5)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-7bbfb7d442"
+local testprefix = "tkt-7bbfb7d442"
 -- MUST_WORK_TEST
 if (1 > 0)
  then
diff --git a/test/sql-tap/tkt-80ba201079.test.lua b/test/sql-tap/tkt-80ba201079.test.lua
index 53678eef5..296bfe074 100755
--- a/test/sql-tap/tkt-80ba201079.test.lua
+++ b/test/sql-tap/tkt-80ba201079.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(11)
 
 --!./tcltestrunner.lua
@@ -22,7 +22,7 @@ test:plan(11)
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
 
-testprefix = "tkt-80ba201079"
+local testprefix = "tkt-80ba201079"
 test:do_test(
     "tkt-80ba2-100",
     function()
diff --git a/test/sql-tap/tkt-80e031a00f.test.lua b/test/sql-tap/tkt-80e031a00f.test.lua
index a0e6539e0..82769587b 100755
--- a/test/sql-tap/tkt-80e031a00f.test.lua
+++ b/test/sql-tap/tkt-80e031a00f.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(118)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-868145d012.test.lua b/test/sql-tap/tkt-868145d012.test.lua
index 61e925c64..5c6abb8a7 100755
--- a/test/sql-tap/tkt-868145d012.test.lua
+++ b/test/sql-tap/tkt-868145d012.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-8c63ff0ec.test.lua b/test/sql-tap/tkt-8c63ff0ec.test.lua
index 8e49db57d..776407ac2 100755
--- a/test/sql-tap/tkt-8c63ff0ec.test.lua
+++ b/test/sql-tap/tkt-8c63ff0ec.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
@@ -20,7 +20,7 @@ test:plan(3)
 -- 
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-8c63ff0ec"
+local testprefix = "tkt-8c63ff0ec"
 test:do_execsql_test(
     1.1,
     [[
diff --git a/test/sql-tap/tkt-91e2e8ba6f.test.lua b/test/sql-tap/tkt-91e2e8ba6f.test.lua
index b12b6e0f3..c6d9a26d8 100755
--- a/test/sql-tap/tkt-91e2e8ba6f.test.lua
+++ b/test/sql-tap/tkt-91e2e8ba6f.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(7)
 
 --!./tcltestrunner.lua
@@ -17,7 +17,7 @@ test:plan(7)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-91e2e8ba6f"
+local testprefix = "tkt-91e2e8ba6f"
 test:do_execsql_test(
     1.1,
     [[
diff --git a/test/sql-tap/tkt-9a8b09f8e6.test.lua b/test/sql-tap/tkt-9a8b09f8e6.test.lua
index ca3a5427a..8f305e444 100755
--- a/test/sql-tap/tkt-9a8b09f8e6.test.lua
+++ b/test/sql-tap/tkt-9a8b09f8e6.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(47)
 
 --!./tcltestrunner.lua
@@ -20,7 +20,7 @@ test:plan(47)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-9a8b09f8e6"
+local testprefix = "tkt-9a8b09f8e6"
 -- MUST_WORK_TEST
 if (0 > 0)
  then
diff --git a/test/sql-tap/tkt-a7b7803e.test.lua b/test/sql-tap/tkt-a7b7803e.test.lua
index 14f05ebfd..8fadf4519 100755
--- a/test/sql-tap/tkt-a7b7803e.test.lua
+++ b/test/sql-tap/tkt-a7b7803e.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(8)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-a8a0d2996a.test.lua b/test/sql-tap/tkt-a8a0d2996a.test.lua
index ddaeb60de..3b824106b 100755
--- a/test/sql-tap/tkt-a8a0d2996a.test.lua
+++ b/test/sql-tap/tkt-a8a0d2996a.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(12)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(12)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-a8a0d2996a"
+local testprefix = "tkt-a8a0d2996a"
 test:do_execsql_test(
     1.0,
     [[
diff --git a/test/sql-tap/tkt-b1d3a2e531.test.lua b/test/sql-tap/tkt-b1d3a2e531.test.lua
index 0cc7d7e59..f10f14a24 100755
--- a/test/sql-tap/tkt-b1d3a2e531.test.lua
+++ b/test/sql-tap/tkt-b1d3a2e531.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(11)
 
 --!./tcltestrunner.lua
@@ -22,7 +22,7 @@ test:plan(11)
 -- ["source",[["testdir"],"\/tester.tcl"]]
 
 
-testprefix = "tkt-b1d3a2e531"
+local testprefix = "tkt-b1d3a2e531"
 
 test:do_execsql_test(
     1.1,
diff --git a/test/sql-tap/tkt-b351d95f9.test.lua b/test/sql-tap/tkt-b351d95f9.test.lua
index 9bdf573b3..8ece3aedb 100755
--- a/test/sql-tap/tkt-b351d95f9.test.lua
+++ b/test/sql-tap/tkt-b351d95f9.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-b75a9ca6b0.test.lua b/test/sql-tap/tkt-b75a9ca6b0.test.lua
index dde6ab502..cc0374357 100755
--- a/test/sql-tap/tkt-b75a9ca6b0.test.lua
+++ b/test/sql-tap/tkt-b75a9ca6b0.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(20)
 
 --!./tcltestrunner.lua
@@ -23,7 +23,7 @@ test:plan(20)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-b75a9ca6b0"
+local testprefix = "tkt-b75a9ca6b0"
 test:do_execsql_test(
     1,
     [[
diff --git a/test/sql-tap/tkt-ba7cbfaedc.test.lua b/test/sql-tap/tkt-ba7cbfaedc.test.lua
index 2aad10f2d..b214e9f0e 100755
--- a/test/sql-tap/tkt-ba7cbfaedc.test.lua
+++ b/test/sql-tap/tkt-ba7cbfaedc.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(19)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(19)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-ba7cbfaedc"
+local testprefix = "tkt-ba7cbfaedc"
 test:do_execsql_test(
     1,
     [[
diff --git a/test/sql-tap/tkt-bd484a090c.test.lua b/test/sql-tap/tkt-bd484a090c.test.lua
index 0347fd426..50c76304c 100755
--- a/test/sql-tap/tkt-bd484a090c.test.lua
+++ b/test/sql-tap/tkt-bd484a090c.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 --test:plan(2)
 test:plan(0)
 
@@ -18,7 +18,7 @@ test:plan(0)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-bd484a090c"
+local testprefix = "tkt-bd484a090c"
 
 -- Disabled until #3694 is resolved.
 --
diff --git a/test/sql-tap/tkt-d635236375.test.lua b/test/sql-tap/tkt-d635236375.test.lua
index ef20cf7a0..1b3e94f82 100755
--- a/test/sql-tap/tkt-d635236375.test.lua
+++ b/test/sql-tap/tkt-d635236375.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(2)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "tkt-d635236375"
+local testprefix = "tkt-d635236375"
 test:do_execsql_test(
     1.0,
     [[
diff --git a/test/sql-tap/tkt-f973c7ac31.test.lua b/test/sql-tap/tkt-f973c7ac31.test.lua
index 381f29c65..b44203e54 100755
--- a/test/sql-tap/tkt-f973c7ac31.test.lua
+++ b/test/sql-tap/tkt-f973c7ac31.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(21)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt-fa7bf5ec.test.lua b/test/sql-tap/tkt-fa7bf5ec.test.lua
index 7152e028c..dbe168422 100755
--- a/test/sql-tap/tkt-fa7bf5ec.test.lua
+++ b/test/sql-tap/tkt-fa7bf5ec.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt1443.test.lua b/test/sql-tap/tkt1443.test.lua
index 35f9f3226..f0776285f 100755
--- a/test/sql-tap/tkt1443.test.lua
+++ b/test/sql-tap/tkt1443.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt1444.test.lua b/test/sql-tap/tkt1444.test.lua
index fb148bc5f..837edcfbe 100755
--- a/test/sql-tap/tkt1444.test.lua
+++ b/test/sql-tap/tkt1444.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt1449.test.lua b/test/sql-tap/tkt1449.test.lua
index 87403000f..3d402ba11 100755
--- a/test/sql-tap/tkt1449.test.lua
+++ b/test/sql-tap/tkt1449.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt1473.test.lua b/test/sql-tap/tkt1473.test.lua
index bc7991593..070ac43a9 100755
--- a/test/sql-tap/tkt1473.test.lua
+++ b/test/sql-tap/tkt1473.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(57)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt1501.test.lua b/test/sql-tap/tkt1501.test.lua
index c4fdfc436..4b3e5de6e 100755
--- a/test/sql-tap/tkt1501.test.lua
+++ b/test/sql-tap/tkt1501.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt1514.test.lua b/test/sql-tap/tkt1514.test.lua
index 685c916a8..6cfc9676b 100755
--- a/test/sql-tap/tkt1514.test.lua
+++ b/test/sql-tap/tkt1514.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt1537.test.lua b/test/sql-tap/tkt1537.test.lua
index a5a45601c..e333ce9fa 100755
--- a/test/sql-tap/tkt1537.test.lua
+++ b/test/sql-tap/tkt1537.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(15)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2141.test.lua b/test/sql-tap/tkt2141.test.lua
index c3cb19a59..f054d4502 100755
--- a/test/sql-tap/tkt2141.test.lua
+++ b/test/sql-tap/tkt2141.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2192.test.lua b/test/sql-tap/tkt2192.test.lua
index 52309ff2b..dabdfd141 100755
--- a/test/sql-tap/tkt2192.test.lua
+++ b/test/sql-tap/tkt2192.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 -- test:plan(6)
 test:plan(4)
 
diff --git a/test/sql-tap/tkt2339.test.lua b/test/sql-tap/tkt2339.test.lua
index 0f25303a7..3bd41784d 100755
--- a/test/sql-tap/tkt2339.test.lua
+++ b/test/sql-tap/tkt2339.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(9)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2391.test.lua b/test/sql-tap/tkt2391.test.lua
index b9703aab8..1320d6490 100755
--- a/test/sql-tap/tkt2391.test.lua
+++ b/test/sql-tap/tkt2391.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2640.test.lua b/test/sql-tap/tkt2640.test.lua
index 2f3af1d80..5198eb183 100755
--- a/test/sql-tap/tkt2640.test.lua
+++ b/test/sql-tap/tkt2640.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(6)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2767.test.lua b/test/sql-tap/tkt2767.test.lua
index 69338c190..c05b9b8ee 100755
--- a/test/sql-tap/tkt2767.test.lua
+++ b/test/sql-tap/tkt2767.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2822.test.lua b/test/sql-tap/tkt2822.test.lua
index 86674aeac..3f67a0a74 100755
--- a/test/sql-tap/tkt2822.test.lua
+++ b/test/sql-tap/tkt2822.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(30)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2832.test.lua b/test/sql-tap/tkt2832.test.lua
index 27b39b8b2..f5c7c10e7 100755
--- a/test/sql-tap/tkt2832.test.lua
+++ b/test/sql-tap/tkt2832.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(6)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2927.test.lua b/test/sql-tap/tkt2927.test.lua
index 64a9715e0..d51a228dd 100755
--- a/test/sql-tap/tkt2927.test.lua
+++ b/test/sql-tap/tkt2927.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(83)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt2942.test.lua b/test/sql-tap/tkt2942.test.lua
index f83d30c2b..d6137a75a 100755
--- a/test/sql-tap/tkt2942.test.lua
+++ b/test/sql-tap/tkt2942.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3201.test.lua b/test/sql-tap/tkt3201.test.lua
index 25862d77a..065b088af 100755
--- a/test/sql-tap/tkt3201.test.lua
+++ b/test/sql-tap/tkt3201.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(8)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3298.test.lua b/test/sql-tap/tkt3298.test.lua
index b95a56f3f..270e4f1ff 100755
--- a/test/sql-tap/tkt3298.test.lua
+++ b/test/sql-tap/tkt3298.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(6)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3334.test.lua b/test/sql-tap/tkt3334.test.lua
index 6d952ecb8..1ba19d22b 100755
--- a/test/sql-tap/tkt3334.test.lua
+++ b/test/sql-tap/tkt3334.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(11)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3346.test.lua b/test/sql-tap/tkt3346.test.lua
index 51823732a..d7c55cb3b 100755
--- a/test/sql-tap/tkt3346.test.lua
+++ b/test/sql-tap/tkt3346.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(5)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3357.test.lua b/test/sql-tap/tkt3357.test.lua
index b307673ac..645d63a73 100755
--- a/test/sql-tap/tkt3357.test.lua
+++ b/test/sql-tap/tkt3357.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3419.test.lua b/test/sql-tap/tkt3419.test.lua
index d95107dc6..f4ebc1697 100755
--- a/test/sql-tap/tkt3419.test.lua
+++ b/test/sql-tap/tkt3419.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(6)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3424.test.lua b/test/sql-tap/tkt3424.test.lua
index 2bbd226b3..5e19936c0 100755
--- a/test/sql-tap/tkt3424.test.lua
+++ b/test/sql-tap/tkt3424.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3442.test.lua b/test/sql-tap/tkt3442.test.lua
index 5b26122ef..5f9dc3b5a 100755
--- a/test/sql-tap/tkt3442.test.lua
+++ b/test/sql-tap/tkt3442.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3493.test.lua b/test/sql-tap/tkt3493.test.lua
index de77e61e9..78e465b00 100755
--- a/test/sql-tap/tkt3493.test.lua
+++ b/test/sql-tap/tkt3493.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(26)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3508.test.lua b/test/sql-tap/tkt3508.test.lua
index 643cf6f54..4f03e3e1b 100755
--- a/test/sql-tap/tkt3508.test.lua
+++ b/test/sql-tap/tkt3508.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3522.test.lua b/test/sql-tap/tkt3522.test.lua
index 1577a7d23..93f46a076 100755
--- a/test/sql-tap/tkt3522.test.lua
+++ b/test/sql-tap/tkt3522.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3527.test.lua b/test/sql-tap/tkt3527.test.lua
index 23d15e8bc..921a25baa 100755
--- a/test/sql-tap/tkt3527.test.lua
+++ b/test/sql-tap/tkt3527.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3541.test.lua b/test/sql-tap/tkt3541.test.lua
index 0d76e7744..32589cc7a 100755
--- a/test/sql-tap/tkt3541.test.lua
+++ b/test/sql-tap/tkt3541.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3554.test.lua b/test/sql-tap/tkt3554.test.lua
index 09307f2cf..c213f5808 100755
--- a/test/sql-tap/tkt3554.test.lua
+++ b/test/sql-tap/tkt3554.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3581.test.lua b/test/sql-tap/tkt3581.test.lua
index 455cda1f2..2e079d270 100755
--- a/test/sql-tap/tkt3581.test.lua
+++ b/test/sql-tap/tkt3581.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3731.test.lua b/test/sql-tap/tkt3731.test.lua
index 092e8bf93..3f0c9bf86 100755
--- a/test/sql-tap/tkt3731.test.lua
+++ b/test/sql-tap/tkt3731.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3773.test.lua b/test/sql-tap/tkt3773.test.lua
index 04b991755..ee0308ebe 100755
--- a/test/sql-tap/tkt3773.test.lua
+++ b/test/sql-tap/tkt3773.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3791.test.lua b/test/sql-tap/tkt3791.test.lua
index d39b6a2d5..33c50b0fb 100755
--- a/test/sql-tap/tkt3791.test.lua
+++ b/test/sql-tap/tkt3791.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 --test:plan(1)
 test:plan(0)
 
diff --git a/test/sql-tap/tkt3841.test.lua b/test/sql-tap/tkt3841.test.lua
index 56668f6a3..a62150023 100755
--- a/test/sql-tap/tkt3841.test.lua
+++ b/test/sql-tap/tkt3841.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3879.test.lua b/test/sql-tap/tkt3879.test.lua
index 55dffe906..6e2ba9498 100755
--- a/test/sql-tap/tkt3879.test.lua
+++ b/test/sql-tap/tkt3879.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(3)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3911.test.lua b/test/sql-tap/tkt3911.test.lua
index 64c43153a..678144f11 100755
--- a/test/sql-tap/tkt3911.test.lua
+++ b/test/sql-tap/tkt3911.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(5)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tkt3935.test.lua b/test/sql-tap/tkt3935.test.lua
index 5b458983a..7138e9e6a 100755
--- a/test/sql-tap/tkt3935.test.lua
+++ b/test/sql-tap/tkt3935.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(10)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/tokenize.test.lua b/test/sql-tap/tokenize.test.lua
index 2c0f7e368..8d19a507c 100755
--- a/test/sql-tap/tokenize.test.lua
+++ b/test/sql-tap/tokenize.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(16)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/transitive1.test.lua b/test/sql-tap/transitive1.test.lua
index 96895b4a7..af65dc518 100755
--- a/test/sql-tap/transitive1.test.lua
+++ b/test/sql-tap/transitive1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(26)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/trigger1.test.lua b/test/sql-tap/trigger1.test.lua
index 6fd5294b1..8224ef1ec 100755
--- a/test/sql-tap/trigger1.test.lua
+++ b/test/sql-tap/trigger1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(33)
 
 --!./tcltestrunner.lua
@@ -482,8 +482,7 @@ test:execsql [[
 -- trigger works.  Then drop the trigger.  Make sure the table is
 -- still there.
 --
-view_v1 = ""
-view_v1 = "view v1"
+local view_v1 = "view v1"
 
 
 -- do_test trigger1-6.1 {
diff --git a/test/sql-tap/trigger2.test.lua b/test/sql-tap/trigger2.test.lua
index 192b707d3..680cd07b8 100755
--- a/test/sql-tap/trigger2.test.lua
+++ b/test/sql-tap/trigger2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(26)
 
 --!./tcltestrunner.lua
@@ -61,6 +61,7 @@ test:plan(26)
 
 box.space._session_settings:update('sql_recursive_triggers', {{'=', 2, false}})
 -- 1.
+local ii, tbl_definitions
 ii = 0
 tbl_definitions = { "CREATE TABLE tbl (id INT PRIMARY KEY AUTOINCREMENT, a INTEGER UNIQUE, b INT );",
                     "CREATE TABLE tbl (id INT PRIMARY KEY AUTOINCREMENT, a INT UNIQUE, b INT );",
@@ -121,9 +122,9 @@ for _, tbl_defn in ipairs(tbl_definitions) do
     test:do_test(
         "trigger2-1."..ii..".1",
         function()
-            r = {}
+            local r = {}
             test:execsql [[ UPDATE tbl SET a = a * 10, b = b * 10; ]]
-            raw_result = test:execsql [[
+            local raw_result = test:execsql [[
                 SELECT * FROM rlog ORDER BY idx;
             ]]
             for k,v in pairs(raw_result) do table.insert(r, v) end
@@ -164,7 +165,7 @@ for _, tbl_defn in ipairs(tbl_definitions) do
     test:do_test(
         "trigger2-1."..ii..".2",
         function()
-            r = {}
+            local r = {}
             for _, v in ipairs(test:execsql [[
                 DELETE FROM tbl ;
                 SELECT * FROM rlog;
@@ -351,7 +352,7 @@ test:catchsql [[
 --   DROP TABLE log;
 -- }
 -- trigger2-3.2: WHEN clause
-when_triggers = { "t1 BEFORE INSERT ON tbl FOR EACH ROW WHEN new.a > 20" }
+local when_triggers = { "t1 BEFORE INSERT ON tbl FOR EACH ROW WHEN new.a > 20" }
 table.insert(when_triggers,"t2 BEFORE INSERT ON tbl FOR EACH ROW WHEN (SELECT count(*) FROM tbl) = 0")
 
 
diff --git a/test/sql-tap/trigger4.test.lua b/test/sql-tap/trigger4.test.lua
index 4f5406d4c..8b3ba6d00 100755
--- a/test/sql-tap/trigger4.test.lua
+++ b/test/sql-tap/trigger4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/trigger5.test.lua b/test/sql-tap/trigger5.test.lua
index 310e3591e..8336cdcf2 100755
--- a/test/sql-tap/trigger5.test.lua
+++ b/test/sql-tap/trigger5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/trigger7.test.lua b/test/sql-tap/trigger7.test.lua
index 50c01b906..393601ebe 100755
--- a/test/sql-tap/trigger7.test.lua
+++ b/test/sql-tap/trigger7.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(5)
 
 --!./tcltestrunner.lua
@@ -48,7 +48,7 @@ test:do_test(
               SELECT '___update_t1.y___';
             END;
         ]]
-        txt = test:execsql "EXPLAIN UPDATE t1 SET x=5"
+        local txt = test:execsql "EXPLAIN UPDATE t1 SET x=5"
         return arr_match(txt, "___update_t1.x___")
         -- return X(63, "X!cmd", [=[["string","match","*___update_t1.x___*",["txt"]]]=])
     end,
@@ -60,7 +60,7 @@ test:do_test(
 test:do_test(
     "trigger7-2.2",
     function()
-        txt = test:execsql "EXPLAIN UPDATE t1 SET x=5"
+        local txt = test:execsql "EXPLAIN UPDATE t1 SET x=5"
         return arr_match(txt, "___update_t1.y___")
         -- return X(67, "X!cmd", [=[["string","match","*___update_t1.y___*",["txt"]]]=])
     end,
@@ -72,7 +72,7 @@ test:do_test(
 test:do_test(
     "trigger7-2.3",
     function()
-        txt = test:execsql "EXPLAIN UPDATE t1 SET y=5"
+        local txt = test:execsql "EXPLAIN UPDATE t1 SET y=5"
         return arr_match(txt, "___update_t1.x___")
         -- return X(71, "X!cmd", [=[["string","match","*___update_t1.x___*",["txt"]]]=])
     end,
@@ -84,7 +84,7 @@ test:do_test(
 test:do_test(
     "trigger7-2.4",
     function()
-        txt = test:execsql "EXPLAIN UPDATE t1 SET y=5"
+        local txt = test:execsql "EXPLAIN UPDATE t1 SET y=5"
         return arr_match(txt, "___update_t1.y___")
         -- return X(75, "X!cmd", [=[["string","match","*___update_t1.y___*",["txt"]]]=])
     end,
diff --git a/test/sql-tap/trigger8.test.lua b/test/sql-tap/trigger8.test.lua
index 3c803d045..adb0c86ab 100755
--- a/test/sql-tap/trigger8.test.lua
+++ b/test/sql-tap/trigger8.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(1)
 
 --!./tcltestrunner.lua
@@ -28,7 +28,7 @@ test:plan(1)
 -- use 10000. But on symbian, which allows each application at most a 32MB
 -- heap, use 1000.
 --
-nStatement = 10000
+local nStatement = 10000
 
 test:do_test(
     "trigger8-1.1",
@@ -37,7 +37,7 @@ test:do_test(
             CREATE TABLE t1(x INT PRIMARY KEY);
             CREATE TABLE t2(y INT PRIMARY KEY);
         ]]
-        sql = string.format([[CREATE TRIGGER r%s AFTER INSERT ON t1
+        local sql = string.format([[CREATE TRIGGER r%s AFTER INSERT ON t1
         FOR EACH ROW BEGIN
 ]], nStatement)
         -- for _ in X(0, "X!for", [=[["set i 0","$i<$nStatement","incr i"]]=]) do
diff --git a/test/sql-tap/trigger9.test.lua b/test/sql-tap/trigger9.test.lua
index e39a31384..5c1f4cbb2 100755
--- a/test/sql-tap/trigger9.test.lua
+++ b/test/sql-tap/trigger9.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+_G.test = require("sqltester")
 test:plan(28)
 
 --!./tcltestrunner.lua
@@ -33,7 +33,7 @@ test:plan(28)
 -- ["source",[["testdir"],"\/tester.tcl"]]
 
 
-testprefix = "trigger9"
+local testprefix = "trigger9"
 
 local function has_rowdata(sql)
     local result = test:execsql('EXPLAIN '..sql)
diff --git a/test/sql-tap/triggerA.test.lua b/test/sql-tap/triggerA.test.lua
index fc8ecfe17..38a3dbea2 100755
--- a/test/sql-tap/triggerA.test.lua
+++ b/test/sql-tap/triggerA.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(17)
 
 --!./tcltestrunner.lua
@@ -36,12 +36,12 @@ test:do_test(
             CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT UNIQUE);
             CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER UNIQUE, c TEXT);
         ]]
-        i = 1
+        local i = 1
         local words = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"}
         for i, word in ipairs(words) do
         -- for _ in X(0, "X!foreach", [=[["word","one two three four five six seven eight nine ten"]]=]) do
             -- j = X(42, "X!cmd", [=[["expr","$i*100 + [string length $word]"]]=])
-            j = i * 100 + string.len(word)
+            local j = i * 100 + string.len(word)
             test:execsql(string.format([[
                 INSERT INTO t1 VALUES(%d,'%s');
                 INSERT INTO t2 VALUES(20-%d,%d,'%s');
diff --git a/test/sql-tap/triggerB.test.lua b/test/sql-tap/triggerB.test.lua
index 9dfe09c8e..55b3bc32f 100755
--- a/test/sql-tap/triggerB.test.lua
+++ b/test/sql-tap/triggerB.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(201)
 
 --!./tcltestrunner.lua
@@ -154,7 +154,7 @@ test:do_test(
         ]]
         -- for _ in X(0, "X!for", [=[["set i 0","$i<=65","incr i"]]=]) do
         for i=0,65 do    
-            sql = string.format([[
+            local sql = string.format([[
                     CREATE TRIGGER t3c%s AFTER UPDATE ON t3
                     FOR EACH ROW
                     WHEN old.c%s!=new.c%s
diff --git a/test/sql-tap/triggerC.test.lua b/test/sql-tap/triggerC.test.lua
index ef4d69d49..e95641938 100755
--- a/test/sql-tap/triggerC.test.lua
+++ b/test/sql-tap/triggerC.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(43)
 
 --!./tcltestrunner.lua
@@ -16,7 +16,7 @@ test:plan(43)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "triggerC"
+local testprefix = "triggerC"
 
 
 ---------------------------------------------------------------------------
@@ -866,7 +866,7 @@ test:do_catchsql_test(
 -- At one point, due to a bug allowing constant factoring within triggers,
 -- the following SQL would produce the wrong result.
 --
-SQL = [[
+local SQL = [[
   DROP TABLE IF EXISTS t1;
   DROP VIEW v2;
   DROP TABLE IF EXISTS t2;
diff --git a/test/sql-tap/triggerD.test.lua b/test/sql-tap/triggerD.test.lua
index d1b019330..bc433beee 100755
--- a/test/sql-tap/triggerD.test.lua
+++ b/test/sql-tap/triggerD.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(4)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/types.test.lua b/test/sql-tap/types.test.lua
index 2306433fa..91a89b887 100755
--- a/test/sql-tap/types.test.lua
+++ b/test/sql-tap/types.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
-NULL = require('msgpack').NULL
+local test = require("sqltester")
+local NULL = require('msgpack').NULL
 test:plan(14)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/types2.test.lua b/test/sql-tap/types2.test.lua
index 0640c8048..04ed3070d 100755
--- a/test/sql-tap/types2.test.lua
+++ b/test/sql-tap/types2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(398)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/unicode.test.lua b/test/sql-tap/unicode.test.lua
index 199073918..d916a8302 100755
--- a/test/sql-tap/unicode.test.lua
+++ b/test/sql-tap/unicode.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(23 * 3)
 
 -- 23 entities
diff --git a/test/sql-tap/unique.test.lua b/test/sql-tap/unique.test.lua
index 6b0a7e20d..e369c3283 100755
--- a/test/sql-tap/unique.test.lua
+++ b/test/sql-tap/unique.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(35)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/update.test.lua b/test/sql-tap/update.test.lua
index ac0389a7a..ac6ee8803 100755
--- a/test/sql-tap/update.test.lua
+++ b/test/sql-tap/update.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(111)
 
 --!./tcltestrunner.lua
@@ -47,7 +47,7 @@ test:do_test("update-3.1", function()
   test:execsql "CREATE TABLE test1(id  INT primary key, f1 int,f2 int)"
   -- for _ in X(0, "X!for", [=[["set i 1","$i<=10","incr i"]]=]) do
   for i = 1, 10 do    
-    sql = string.format("INSERT INTO test1 VALUES(%s,%s,%s)", i, i, bit.lshift(1, i)) -- X(0, "X!expr", [=[["<<",1,["i"]]]=]))
+    local sql = string.format("INSERT INTO test1 VALUES(%s,%s,%s)", i, i, bit.lshift(1, i)) -- X(0, "X!expr", [=[["<<",1,["i"]]]=]))
     test:execsql(sql)
   end
   return test:execsql "SELECT f1,f2 FROM test1 ORDER BY f1"
diff --git a/test/sql-tap/view.test.lua b/test/sql-tap/view.test.lua
index 60dfc927a..4d85d8bcb 100755
--- a/test/sql-tap/view.test.lua
+++ b/test/sql-tap/view.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(78)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua
index f267be8e6..3b7e36093 100755
--- a/test/sql-tap/where2.test.lua
+++ b/test/sql-tap/where2.test.lua
@@ -1,9 +1,9 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
-yaml = require("yaml")
-fio = require("fio")
+local test = require("sqltester")
+local yaml = require("yaml")
+local fio = require("fio")
 
-ffi = require("ffi")
+local ffi = require("ffi")
 test:plan(74)
 
 ffi.cdef[[
@@ -42,6 +42,7 @@ test:do_test(
             START TRANSACTION;
         ]]
         for i=1,100 do
+            local w, x, y, z
             w = i
             x = math.floor(math.log(i) / math.log(2))
             y = (((i * i) + (2 * i)) + 1)
@@ -213,6 +214,7 @@ test:do_test(
             CREATE TABLE x2(x INTEGER PRIMARY KEY);
             INSERT INTO x2 VALUES(1);
         ]]
+        local sql, out1, out2, out3
         sql = "SELECT * FROM x1, x2 WHERE x=1 ORDER BY random()"
         out1 = test:execsql(sql)
         out2 = test:execsql(sql)
@@ -508,8 +510,7 @@ test:do_test(
 
 -- Verify that OR clauses get translated into IN operators.
 --
-idx = ""
-idx = "*"
+local idx = "*"
 
 
 test:do_test(
@@ -590,7 +591,6 @@ test:do_test(
         -- </where2-6.5>
     })
 
-idx = ""
 idx = "I1ZYX"
 
 
@@ -957,6 +957,7 @@ test:do_test(
         test:execsql('CREATE TABLE tx(id int PRIMARY KEY, w int, x int, y int, z int);')
         -- for _ in X(0, "X!for", [=[["set i 1","$i<=100","incr i"]]=]) do
         for i=1,100 do
+            local w, x, y, z
             w = i
             x = math.floor(math.log(i) / math.log(2))
             y = (((i * i) + (2 * i)) + 1)
diff --git a/test/sql-tap/where3.test.lua b/test/sql-tap/where3.test.lua
index ae9e37f61..bc6e8108e 100755
--- a/test/sql-tap/where3.test.lua
+++ b/test/sql-tap/where3.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(83)
 
 --!./tcltestrunner.lua
@@ -118,6 +118,7 @@ test:do_test(
 --
 local function queryplan(sql)
     -- sql_sort_count = 0
+    local data, eqp
     data = test:execsql(sql)
     eqp = test:execsql("EXPLAIN QUERY PLAN "..sql)
     for i,v in ipairs(eqp) do
@@ -548,7 +549,7 @@ for cnt, predicate in ipairs(predicates) do
     test:do_test(
         "where3-6."..cnt..".1",
         function()
-            sql = "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
+            local sql = "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
             sql = sql .. " NATURAL JOIN t6z "
             sql = sql .. predicate
             return test:execsql(sql)
@@ -559,7 +560,7 @@ for cnt, predicate in ipairs(predicates) do
     test:do_test(
         "where3-6."..cnt..".2",
         function()
-            sql = "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
+            local sql = "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
             sql = sql .. " JOIN t6z USING(a) "
             sql = sql .. predicate
             return test:execsql(sql)
@@ -570,7 +571,7 @@ for cnt, predicate in ipairs(predicates) do
     test:do_test(
         "where3-6."..cnt..".3",
         function()
-            sql = "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
+            local sql = "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
             sql = sql .. " JOIN t6z USING(a) "
             sql = sql .. predicate
             return test:execsql(sql)
@@ -581,7 +582,7 @@ for cnt, predicate in ipairs(predicates) do
     test:do_test(
         "where3-6."..cnt..".4",
         function()
-            sql = "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
+            local sql = "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
             sql = sql .. " JOIN t6z USING(a) "
             sql = sql .. predicate
             return test:execsql(sql)
@@ -592,7 +593,7 @@ for cnt, predicate in ipairs(predicates) do
     test:do_test(
         "where3-6."..cnt..".5",
         function()
-            sql = "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
+            local sql = "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
             sql = sql .. " NATURAL JOIN t6z "
             sql = sql .. predicate
             return test:execsql(sql)
@@ -603,7 +604,7 @@ for cnt, predicate in ipairs(predicates) do
     test:do_test(
         "where3-6."..cnt..".6",
         function()
-            sql = "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
+            local sql = "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
             sql = sql .. " NATURAL JOIN t6z "
             sql = sql .. predicate
             return test:execsql(sql)
@@ -614,7 +615,7 @@ for cnt, predicate in ipairs(predicates) do
     test:do_test(
         "where3-6."..cnt..".7",
         function()
-            sql = "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
+            local sql = "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
             sql = sql .. " NATURAL JOIN t6z "
             sql = sql .. predicate
             return test:execsql(sql)
@@ -625,7 +626,7 @@ for cnt, predicate in ipairs(predicates) do
     test:do_test(
         "where3-6."..cnt..".8",
         function()
-            sql = "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
+            local sql = "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
             sql = sql .. " JOIN t6z USING(a) "
             sql = sql .. predicate
             return test:execsql(sql)
diff --git a/test/sql-tap/where4.test.lua b/test/sql-tap/where4.test.lua
index e38972666..65e7f9337 100755
--- a/test/sql-tap/where4.test.lua
+++ b/test/sql-tap/where4.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(8)
 
 --!./tcltestrunner.lua
@@ -23,7 +23,7 @@ test:plan(8)
 -- $Id: where4.test,v 1.6 2007/12/10 05:03:48 danielk1977 Exp $
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "where4"
+local testprefix = "where4"
 
 
 -- Build some test data
diff --git a/test/sql-tap/where5.test.lua b/test/sql-tap/where5.test.lua
index 3aefcaca5..4e778eba7 100755
--- a/test/sql-tap/where5.test.lua
+++ b/test/sql-tap/where5.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(50)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/where6.test.lua b/test/sql-tap/where6.test.lua
index 5fb79fa2a..f9de30dbc 100755
--- a/test/sql-tap/where6.test.lua
+++ b/test/sql-tap/where6.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(20)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/where7.test.lua b/test/sql-tap/where7.test.lua
index 70209545d..d3e7d91fe 100755
--- a/test/sql-tap/where7.test.lua
+++ b/test/sql-tap/where7.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(2023)
 
 --!./tcltestrunner.lua
@@ -229,7 +229,7 @@ test:do_test(
 test:do_test(
     "where7-1.20",
     function()
-        sql = "SELECT a FROM t1 WHERE a=11 OR b=11"
+        local sql = "SELECT a FROM t1 WHERE a=11 OR b=11"
         for i = 12, 100 do
             sql = sql .. string.format(" OR a=%s OR b=%s", i, i)
         end
@@ -244,7 +244,7 @@ test:do_test(
 test:do_test(
     "where7-1.21",
     function()
-        sql = "SELECT a FROM t1 WHERE b=11 OR c=11"
+        local sql = "SELECT a FROM t1 WHERE b=11 OR c=11"
         for i = 12, 100 do
             sql = sql .. string.format(" OR b=%s OR c=%s", i, i)
         end
@@ -259,7 +259,7 @@ test:do_test(
 test:do_test(
     "where7-1.22",
     function()
-        sql = "SELECT a FROM t1 WHERE (b=11 OR c=11"
+        local sql = "SELECT a FROM t1 WHERE (b=11 OR c=11"
         for i = 12, 100 do
             sql = sql .. string.format(" OR b=%s OR c=%s", i, i)
         end
@@ -274,7 +274,7 @@ test:do_test(
 test:do_test(
     "where7-1.23",
     function()
-        sql = "SELECT a FROM t1 WHERE (b=11 OR c=11"
+        local sql = "SELECT a FROM t1 WHERE (b=11 OR c=11"
         for i = 12, 100 do
             sql = sql .. string.format(" OR (b=%s AND d!=0) OR (c=%s AND d IS NOT NULL)", i, i)
         end
@@ -289,7 +289,7 @@ test:do_test(
 test:do_test(
     "where7-1.31",
     function()
-        sql = "SELECT a FROM t1 WHERE (a=11 AND b=11)"
+        local sql = "SELECT a FROM t1 WHERE (a=11 AND b=11)"
         for i = 12, 100 do
             sql = sql .. string.format(" OR (a=%s AND b=%s)", i, i)
         end
@@ -304,7 +304,7 @@ test:do_test(
 test:do_test(
     "where7-1.32",
     function()
-        sql = "SELECT a FROM t1 WHERE (b=11 AND c=11)"
+        local sql = "SELECT a FROM t1 WHERE (b=11 AND c=11)"
         for i = 12, 100 do
             sql = sql .. string.format(" OR (b=%s AND c=%s)", i, i)
         end
@@ -319,7 +319,7 @@ test:do_test(
 test:do_test(
     "where7-AST-depth-limit",
     function()
-        sql = "SELECT a FROM t1 WHERE a = 0"
+        local sql = "SELECT a FROM t1 WHERE a = 0"
         for i = 1, 199 do
             sql = sql .. string.format(" OR a = %s", i)
         end
diff --git a/test/sql-tap/whereA.test.lua b/test/sql-tap/whereA.test.lua
index a49d1c05c..968ceb2e9 100755
--- a/test/sql-tap/whereA.test.lua
+++ b/test/sql-tap/whereA.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(17)
 
 --!./tcltestrunner.lua
diff --git a/test/sql-tap/whereC.test.lua b/test/sql-tap/whereC.test.lua
index 58c049553..334d4cf29 100755
--- a/test/sql-tap/whereC.test.lua
+++ b/test/sql-tap/whereC.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 local yaml = require('yaml')
 test:plan(41)
 
@@ -17,7 +17,7 @@ test:plan(41)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "whereC"
+local testprefix = "whereC"
 test:do_execsql_test(
     1.0,
     [[
diff --git a/test/sql-tap/whereD.test.lua b/test/sql-tap/whereD.test.lua
index 14dc8d3bd..26221ec12 100755
--- a/test/sql-tap/whereD.test.lua
+++ b/test/sql-tap/whereD.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(36)
 
 --!./tcltestrunner.lua
@@ -19,7 +19,7 @@ test:plan(36)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "whereD"
+local testprefix = "whereD"
 test:do_execsql_test(
     1.1,
     [[
diff --git a/test/sql-tap/whereF.test.lua b/test/sql-tap/whereF.test.lua
index 3235df437..12aefc4a4 100755
--- a/test/sql-tap/whereF.test.lua
+++ b/test/sql-tap/whereF.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(13)
 
 --!./tcltestrunner.lua
@@ -48,7 +48,7 @@ test:plan(13)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "whereF"
+local testprefix = "whereF"
 test:do_execsql_test(
     1.0,
     [[
diff --git a/test/sql-tap/whereG.test.lua b/test/sql-tap/whereG.test.lua
index 590027023..2fbc6c5b3 100755
--- a/test/sql-tap/whereG.test.lua
+++ b/test/sql-tap/whereG.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(23)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(23)
 -- likelihood() functions.
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "whereG"
+local testprefix = "whereG"
 test:do_execsql_test(
     "whereG-1.0",
     [[
diff --git a/test/sql-tap/whereI.test.lua b/test/sql-tap/whereI.test.lua
index 3ae5b82f2..79c6bcfe5 100755
--- a/test/sql-tap/whereI.test.lua
+++ b/test/sql-tap/whereI.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(7)
 
 --!./tcltestrunner.lua
@@ -20,7 +20,7 @@ test:plan(7)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "whereI"
+local testprefix = "whereI"
 test:do_execsql_test(1.0, [[
     CREATE TABLE t1(a INT, b TEXT, c TEXT, PRIMARY KEY(a));
     INSERT INTO t1 VALUES(1, 'a', 'z');
diff --git a/test/sql-tap/whereK.test.lua b/test/sql-tap/whereK.test.lua
index 58e3146a7..0ca7fff0d 100755
--- a/test/sql-tap/whereK.test.lua
+++ b/test/sql-tap/whereK.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(10)
 
 --!./tcltestrunner.lua
@@ -23,7 +23,7 @@ test:plan(10)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "whereK"
+local testprefix = "whereK"
 test:do_execsql_test(1.1, [[
   CREATE TABLE t1(a INT ,b INT ,c INT , primary key (a,b,c));
   WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<99)
diff --git a/test/sql-tap/with1.test.lua b/test/sql-tap/with1.test.lua
index 75935108c..86dd4f83a 100755
--- a/test/sql-tap/with1.test.lua
+++ b/test/sql-tap/with1.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(64)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(64)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "with1"
+local testprefix = "with1"
 -- if X(0, "X!capable", [["!cte"]]) then
 --   test:finish_test()
 --  return 
@@ -623,7 +623,7 @@ test:do_execsql_test("8.2-soduko", [[
 -- Some tests that use LIMIT and OFFSET in the definition of recursive CTEs.
 --
 -- I = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }
-function limit_test(tn, iLimit, iOffset)
+local function limit_test(tn, iLimit, iOffset)
     local last = 20 - 1
     local result = {}
     -- if X(0, "X!expr01", [["$iOffset < 0"]]) then
diff --git a/test/sql-tap/with2.test.lua b/test/sql-tap/with2.test.lua
index 1aa39b32e..456ded363 100755
--- a/test/sql-tap/with2.test.lua
+++ b/test/sql-tap/with2.test.lua
@@ -1,5 +1,5 @@
 #!/usr/bin/env tarantool
-test = require("sqltester")
+local test = require("sqltester")
 test:plan(59)
 
 --!./tcltestrunner.lua
@@ -18,7 +18,7 @@ test:plan(59)
 --
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
-testprefix = "with2"
+local testprefix = "with2"
 
 test:do_execsql_test(
     1.0,
-- 
2.28.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH v3] luacheck: change global vars to local in sql-tap
  2020-12-14 18:10 [Tarantool-patches] [PATCH v3] luacheck: change global vars to local in sql-tap Artem Starshov
@ 2020-12-14 19:20 ` Alexander V. Tikhonov
  2020-12-16 12:03 ` Kirill Yukhin
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander V. Tikhonov @ 2020-12-14 19:20 UTC (permalink / raw)
  To: Artem Starshov; +Cc: tarantool-patches

Hi Artem, hanks for the patch, as I see no new degradation found in
gitlab-ci testing commit criteria pipeline [1], patch LGTM.
NIT: these changes may cause some checksums to change, but we'll see
it later and easy update.

[1] - https://gitlab.com/tarantool/tarantool/-/pipelines/229670639

On Mon, Dec 14, 2020 at 09:10:51PM +0300, Artem Starshov wrote:
> Fixed luacheck warning 111 (setting non-standard global variable)
> in test/sql-tap directory.
> Enabled this directory for checking W111 in
> config file(.luacheckrc).
> 
> Changed almost all variables in test/sql-tap from globals
> to locals. In any cases, where variables need to be global,
> added explicit _G. prefix (table of globals).
> 
> Fixes #5173
> Part-of #5464
> ---
> Changes in v3:
>     - inline "globals" suppressions changed to _G usage
>     - removed some unnecessary suppressions
>     - rebased to master and corrected newly appeared tests
> 
> See LGTM from AlexTu: https://lists.tarantool.org/pipermail/tarantool-patches/2020-December/021194.html
> Branch:https://github.com/tarantool/tarantool/tree/artemreyt/gh-5173-fix-luacheck-warnings-sql-tap
> Issue: https://github.com/tarantool/tarantool/issues/5173
> 
>  .luacheckrc                                   | 54 +++++++++++++++-
>  test/sql-tap/aggnested.test.lua               |  2 +-
>  test/sql-tap/alias.test.lua                   | 16 ++---
>  test/sql-tap/alter.test.lua                   | 14 ++---
>  test/sql-tap/alter2.test.lua                  |  2 +-
>  test/sql-tap/analyze1.test.lua                |  4 +-
>  test/sql-tap/analyze3.test.lua                |  4 +-
>  test/sql-tap/analyze4.test.lua                |  2 +-
>  test/sql-tap/analyze5.test.lua                | 16 +++--
>  test/sql-tap/analyze6.test.lua                |  4 +-
>  test/sql-tap/analyze7.test.lua                |  2 +-
>  test/sql-tap/analyze8.test.lua                |  5 +-
>  test/sql-tap/analyze9.test.lua                | 42 ++++++++-----
>  test/sql-tap/analyzeC.test.lua                |  4 +-
>  test/sql-tap/analyzeD.test.lua                |  4 +-
>  test/sql-tap/analyzeE.test.lua                |  4 +-
>  test/sql-tap/analyzeF.test.lua                | 18 +++---
>  test/sql-tap/atof1.test.lua                   |  2 +-
>  test/sql-tap/autoinc.test.lua                 |  2 +-
>  test/sql-tap/autoindex1.test.lua              |  4 +-
>  test/sql-tap/autoindex4.test.lua              |  2 +-
>  test/sql-tap/autoindex5.test.lua              |  2 +-
>  test/sql-tap/badutf1.test.lua                 |  2 +-
>  test/sql-tap/between.test.lua                 |  3 +-
>  test/sql-tap/bigrow1.test.lua                 |  2 +-
>  test/sql-tap/blob.test.lua                    | 18 ++++--
>  test/sql-tap/boundary1.test.lua               |  2 +-
>  test/sql-tap/boundary2.test.lua               |  2 +-
>  test/sql-tap/boundary3.test.lua               |  2 +-
>  test/sql-tap/cast.test.lua                    |  3 +-
>  test/sql-tap/check.test.lua                   |  4 +-
>  test/sql-tap/coalesce.test.lua                |  2 +-
>  test/sql-tap/collation.test.lua               |  2 +-
>  test/sql-tap/collation_unicode.test.lua       |  2 +-
>  test/sql-tap/colname.test.lua                 |  2 +-
>  test/sql-tap/contrib01.test.lua               |  2 +-
>  test/sql-tap/count.test.lua                   |  6 +-
>  test/sql-tap/cse.test.lua                     |  4 +-
>  test/sql-tap/date.test.lua                    |  2 +-
>  test/sql-tap/debug_mode_only.test.lua         |  2 +-
>  test/sql-tap/default.test.lua                 |  2 +-
>  test/sql-tap/delete1.test.lua                 |  7 ++-
>  test/sql-tap/delete3.test.lua                 |  2 +-
>  test/sql-tap/delete4.test.lua                 |  4 +-
>  test/sql-tap/distinct.test.lua                |  2 +-
>  test/sql-tap/distinctagg.test.lua             |  2 +-
>  test/sql-tap/drop_all.test.lua                |  2 +-
>  test/sql-tap/e_delete.test.lua                |  2 +-
>  test/sql-tap/e_expr.test.lua                  | 15 ++---
>  test/sql-tap/e_select1.test.lua               |  7 ++-
>  test/sql-tap/eqp.test.lua                     |  2 +-
>  test/sql-tap/explain.test.lua                 |  6 +-
>  test/sql-tap/fkey1.test.lua                   |  2 +-
>  test/sql-tap/fkey2.test.lua                   |  2 +-
>  test/sql-tap/fkey3.test.lua                   |  2 +-
>  test/sql-tap/fkey4.test.lua                   |  2 +-
>  test/sql-tap/func.test.lua                    | 23 +++----
>  test/sql-tap/func2.test.lua                   | 62 +++++++++----------
>  test/sql-tap/func3.test.lua                   |  4 +-
>  test/sql-tap/func5.test.lua                   |  4 +-
>  ...2360-omit-truncate-in-transaction.test.lua |  2 +-
>  test/sql-tap/gh-2549-many-columns.test.lua    |  6 +-
>  test/sql-tap/gh-2723-concurrency.test.lua     |  4 +-
>  .../gh-2884-forbid-rowid-syntax.test.lua      |  2 +-
>  test/sql-tap/gh-2996-indexed-by.test.lua      |  4 +-
>  .../gh-3083-ephemeral-unref-tuples.test.lua   |  2 +-
>  ...gh-3251-string-pattern-comparison.test.lua |  2 +-
>  test/sql-tap/gh-3297-ephemeral-rowid.test.lua |  2 +-
>  .../gh-3307-xfer-optimization-issue.test.lua  |  2 +-
>  .../gh-3332-tuple-format-leak.test.lua        |  2 +-
>  test/sql-tap/gh-3350-skip-scan.test.lua       |  2 +-
>  .../sql-tap/gh-4659-block-hash-index.test.lua |  6 +-
>  ...-4766-wrong-cast-from-blob-to-int.test.lua |  4 +-
>  .../gh-5231-box-execute-writes-in-ro.test.lua |  2 +-
>  .../gh2127-indentifier-max-length.test.lua    |  2 +-
>  .../sql-tap/gh2130-index-refer-table.test.lua |  2 +-
>  test/sql-tap/gh2140-trans.test.lua            |  4 +-
>  test/sql-tap/gh2168-temp-tables.test.lua      |  2 +-
>  .../gh2250-trigger-chain-limit.test.lua       | 14 ++---
>  test/sql-tap/gh2259-in-stmt-trans.test.lua    |  2 +-
>  .../gh2548-select-compound-limit.test.lua     | 14 ++---
>  test/sql-tap/hexlit.test.lua                  |  2 +-
>  test/sql-tap/icu.test.lua                     |  2 +-
>  test/sql-tap/identifier-characters.test.lua   |  4 +-
>  test/sql-tap/identifier_case.test.lua         |  2 +-
>  test/sql-tap/in1.test.lua                     |  2 +-
>  test/sql-tap/in2.test.lua                     |  4 +-
>  test/sql-tap/in3.test.lua                     |  4 +-
>  test/sql-tap/in4.test.lua                     |  2 +-
>  test/sql-tap/in5.test.lua                     |  4 +-
>  test/sql-tap/index1.test.lua                  |  7 ++-
>  test/sql-tap/index2.test.lua                  |  2 +-
>  test/sql-tap/index3.test.lua                  |  2 +-
>  test/sql-tap/index4.test.lua                  |  4 +-
>  test/sql-tap/index6.test.lua                  |  2 +-
>  test/sql-tap/index7.test.lua                  |  8 +--
>  test/sql-tap/insert1.test.lua                 |  8 +--
>  test/sql-tap/insert3.test.lua                 |  2 +-
>  test/sql-tap/intpkey.test.lua                 |  4 +-
>  test/sql-tap/join.test.lua                    |  6 +-
>  test/sql-tap/join2.test.lua                   |  2 +-
>  test/sql-tap/join3.test.lua                   | 10 +--
>  test/sql-tap/join4.test.lua                   |  2 +-
>  test/sql-tap/join5.test.lua                   |  2 +-
>  test/sql-tap/join6.test.lua                   |  2 +-
>  test/sql-tap/keyword1.test.lua                |  4 +-
>  test/sql-tap/like2.test.lua                   |  2 +-
>  test/sql-tap/like3.test.lua                   |  2 +-
>  test/sql-tap/limit.test.lua                   |  6 +-
>  test/sql-tap/lua-tables.test.lua              | 12 ++--
>  test/sql-tap/lua/sqltester.lua                |  6 +-
>  test/sql-tap/lua_sql.test.lua                 |  8 +--
>  test/sql-tap/minmax2.test.lua                 | 36 ++++++-----
>  test/sql-tap/minmax3.test.lua                 |  2 +-
>  test/sql-tap/minmax4.test.lua                 |  2 +-
>  test/sql-tap/misc1.test.lua                   |  6 +-
>  test/sql-tap/misc3.test.lua                   |  2 +-
>  test/sql-tap/misc5.test.lua                   |  3 +-
>  test/sql-tap/null.test.lua                    |  2 +-
>  test/sql-tap/numcast.test.lua                 |  2 +-
>  test/sql-tap/offset1.test.lua                 |  2 +-
>  test/sql-tap/orderby1.test.lua                |  4 +-
>  test/sql-tap/orderby2.test.lua                |  4 +-
>  test/sql-tap/orderby3.test.lua                |  4 +-
>  test/sql-tap/orderby4.test.lua                |  4 +-
>  test/sql-tap/orderby5.test.lua                |  4 +-
>  test/sql-tap/orderby6.test.lua                |  4 +-
>  test/sql-tap/orderby8.test.lua                |  4 +-
>  test/sql-tap/orderby9.test.lua                |  4 +-
>  test/sql-tap/position.test.lua                |  2 +-
>  test/sql-tap/pragma.test.lua                  |  2 +-
>  test/sql-tap/printf2.test.lua                 |  2 +-
>  test/sql-tap/quote.test.lua                   |  2 +-
>  test/sql-tap/randexpr1.test.lua               |  2 +-
>  test/sql-tap/resolver01.test.lua              |  2 +-
>  test/sql-tap/select1.test.lua                 | 12 ++--
>  test/sql-tap/select2.test.lua                 |  2 +-
>  test/sql-tap/select3.test.lua                 |  4 +-
>  test/sql-tap/select4.test.lua                 |  2 +-
>  test/sql-tap/select5.test.lua                 |  2 +-
>  test/sql-tap/select6.test.lua                 |  6 +-
>  test/sql-tap/select7.test.lua                 |  6 +-
>  test/sql-tap/select8.test.lua                 |  4 +-
>  test/sql-tap/select9.test.lua                 |  6 +-
>  test/sql-tap/selectA.test.lua                 |  4 +-
>  test/sql-tap/selectB.test.lua                 |  2 +-
>  test/sql-tap/selectC.test.lua                 |  2 +-
>  test/sql-tap/selectE.test.lua                 |  2 +-
>  test/sql-tap/selectF.test.lua                 |  4 +-
>  test/sql-tap/selectG.test.lua                 |  4 +-
>  test/sql-tap/sort.test.lua                    |  5 +-
>  test/sql-tap/sql-errors.test.lua              | 13 ++--
>  test/sql-tap/start-transaction.test.lua       |  2 +-
>  test/sql-tap/subquery.test.lua                |  9 +--
>  test/sql-tap/subquery2.test.lua               |  4 +-
>  test/sql-tap/subselect.test.lua               |  2 +-
>  test/sql-tap/substr.test.lua                  |  2 +-
>  test/sql-tap/table.test.lua                   |  2 +-
>  test/sql-tap/tkt-02a8e81d44.test.lua          |  2 +-
>  test/sql-tap/tkt-31338dca7e.test.lua          |  2 +-
>  test/sql-tap/tkt-385a5b56b9.test.lua          |  4 +-
>  test/sql-tap/tkt-38cb5df375.test.lua          |  4 +-
>  test/sql-tap/tkt-3998683a16.test.lua          |  2 +-
>  test/sql-tap/tkt-3a77c9714e.test.lua          |  4 +-
>  test/sql-tap/tkt-4a03edc4c8.test.lua          |  2 +-
>  test/sql-tap/tkt-4c86b126f2.test.lua          |  2 +-
>  test/sql-tap/tkt-4dd95f6943.test.lua          |  4 +-
>  test/sql-tap/tkt-4ef7e3cfca.test.lua          |  4 +-
>  test/sql-tap/tkt-54844eea3f.test.lua          |  4 +-
>  test/sql-tap/tkt-752e1646fc.test.lua          |  2 +-
>  test/sql-tap/tkt-7a31705a7e6.test.lua         |  2 +-
>  test/sql-tap/tkt-7bbfb7d442.test.lua          |  4 +-
>  test/sql-tap/tkt-80ba201079.test.lua          |  4 +-
>  test/sql-tap/tkt-80e031a00f.test.lua          |  2 +-
>  test/sql-tap/tkt-868145d012.test.lua          |  2 +-
>  test/sql-tap/tkt-8c63ff0ec.test.lua           |  4 +-
>  test/sql-tap/tkt-91e2e8ba6f.test.lua          |  4 +-
>  test/sql-tap/tkt-9a8b09f8e6.test.lua          |  4 +-
>  test/sql-tap/tkt-a7b7803e.test.lua            |  2 +-
>  test/sql-tap/tkt-a8a0d2996a.test.lua          |  4 +-
>  test/sql-tap/tkt-b1d3a2e531.test.lua          |  4 +-
>  test/sql-tap/tkt-b351d95f9.test.lua           |  2 +-
>  test/sql-tap/tkt-b75a9ca6b0.test.lua          |  4 +-
>  test/sql-tap/tkt-ba7cbfaedc.test.lua          |  4 +-
>  test/sql-tap/tkt-bd484a090c.test.lua          |  4 +-
>  test/sql-tap/tkt-d635236375.test.lua          |  4 +-
>  test/sql-tap/tkt-f973c7ac31.test.lua          |  2 +-
>  test/sql-tap/tkt-fa7bf5ec.test.lua            |  2 +-
>  test/sql-tap/tkt1443.test.lua                 |  2 +-
>  test/sql-tap/tkt1444.test.lua                 |  2 +-
>  test/sql-tap/tkt1449.test.lua                 |  2 +-
>  test/sql-tap/tkt1473.test.lua                 |  2 +-
>  test/sql-tap/tkt1501.test.lua                 |  2 +-
>  test/sql-tap/tkt1514.test.lua                 |  2 +-
>  test/sql-tap/tkt1537.test.lua                 |  2 +-
>  test/sql-tap/tkt2141.test.lua                 |  2 +-
>  test/sql-tap/tkt2192.test.lua                 |  2 +-
>  test/sql-tap/tkt2339.test.lua                 |  2 +-
>  test/sql-tap/tkt2391.test.lua                 |  2 +-
>  test/sql-tap/tkt2640.test.lua                 |  2 +-
>  test/sql-tap/tkt2767.test.lua                 |  2 +-
>  test/sql-tap/tkt2822.test.lua                 |  2 +-
>  test/sql-tap/tkt2832.test.lua                 |  2 +-
>  test/sql-tap/tkt2927.test.lua                 |  2 +-
>  test/sql-tap/tkt2942.test.lua                 |  2 +-
>  test/sql-tap/tkt3201.test.lua                 |  2 +-
>  test/sql-tap/tkt3298.test.lua                 |  2 +-
>  test/sql-tap/tkt3334.test.lua                 |  2 +-
>  test/sql-tap/tkt3346.test.lua                 |  2 +-
>  test/sql-tap/tkt3357.test.lua                 |  2 +-
>  test/sql-tap/tkt3419.test.lua                 |  2 +-
>  test/sql-tap/tkt3424.test.lua                 |  2 +-
>  test/sql-tap/tkt3442.test.lua                 |  2 +-
>  test/sql-tap/tkt3493.test.lua                 |  2 +-
>  test/sql-tap/tkt3508.test.lua                 |  2 +-
>  test/sql-tap/tkt3522.test.lua                 |  2 +-
>  test/sql-tap/tkt3527.test.lua                 |  2 +-
>  test/sql-tap/tkt3541.test.lua                 |  2 +-
>  test/sql-tap/tkt3554.test.lua                 |  2 +-
>  test/sql-tap/tkt3581.test.lua                 |  2 +-
>  test/sql-tap/tkt3731.test.lua                 |  2 +-
>  test/sql-tap/tkt3773.test.lua                 |  2 +-
>  test/sql-tap/tkt3791.test.lua                 |  2 +-
>  test/sql-tap/tkt3841.test.lua                 |  2 +-
>  test/sql-tap/tkt3879.test.lua                 |  2 +-
>  test/sql-tap/tkt3911.test.lua                 |  2 +-
>  test/sql-tap/tkt3935.test.lua                 |  2 +-
>  test/sql-tap/tokenize.test.lua                |  2 +-
>  test/sql-tap/transitive1.test.lua             |  2 +-
>  test/sql-tap/trigger1.test.lua                |  5 +-
>  test/sql-tap/trigger2.test.lua                | 11 ++--
>  test/sql-tap/trigger4.test.lua                |  2 +-
>  test/sql-tap/trigger5.test.lua                |  2 +-
>  test/sql-tap/trigger7.test.lua                | 10 +--
>  test/sql-tap/trigger8.test.lua                |  6 +-
>  test/sql-tap/trigger9.test.lua                |  4 +-
>  test/sql-tap/triggerA.test.lua                |  6 +-
>  test/sql-tap/triggerB.test.lua                |  4 +-
>  test/sql-tap/triggerC.test.lua                |  6 +-
>  test/sql-tap/triggerD.test.lua                |  2 +-
>  test/sql-tap/types.test.lua                   |  4 +-
>  test/sql-tap/types2.test.lua                  |  2 +-
>  test/sql-tap/unicode.test.lua                 |  2 +-
>  test/sql-tap/unique.test.lua                  |  2 +-
>  test/sql-tap/update.test.lua                  |  4 +-
>  test/sql-tap/view.test.lua                    |  2 +-
>  test/sql-tap/where2.test.lua                  | 15 ++---
>  test/sql-tap/where3.test.lua                  | 19 +++---
>  test/sql-tap/where4.test.lua                  |  4 +-
>  test/sql-tap/where5.test.lua                  |  2 +-
>  test/sql-tap/where6.test.lua                  |  2 +-
>  test/sql-tap/where7.test.lua                  | 16 ++---
>  test/sql-tap/whereA.test.lua                  |  2 +-
>  test/sql-tap/whereC.test.lua                  |  4 +-
>  test/sql-tap/whereD.test.lua                  |  4 +-
>  test/sql-tap/whereF.test.lua                  |  4 +-
>  test/sql-tap/whereG.test.lua                  |  4 +-
>  test/sql-tap/whereI.test.lua                  |  4 +-
>  test/sql-tap/whereK.test.lua                  |  4 +-
>  test/sql-tap/with1.test.lua                   |  6 +-
>  test/sql-tap/with2.test.lua                   |  4 +-
>  261 files changed, 633 insertions(+), 549 deletions(-)
> 
> diff --git a/.luacheckrc b/.luacheckrc
> index 6fe34c2e1..29db9eeeb 100644
> --- a/.luacheckrc
> +++ b/.luacheckrc
> @@ -30,12 +30,64 @@ exclude_files = {
>      "build/**/*.lua",
>      -- Third-party source code.
>      "test-run/**/*.lua",
> -    "test/**/*.lua",
> +    "test/app/**/*.lua",
> +    "test/app-tap/**/*.lua",
> +    "test/box/**/*.lua",
> +    "test/box-py/**/*.lua",
> +    "test/box-tap/**/*.lua",
> +    "test/engine/**/*.lua",
> +    "test/engine_long/**/*.lua",
> +    "test/long_run-py/**/*.lua",
> +    "test/luajit-tap/**/*.lua",
> +    "test/replication/**/*.lua",
> +    "test/replication-py/**/*.lua",
> +    "test/sql/**/*.lua",
> +    "test/swim/**/*.lua",
> +    "test/var/**/*.lua",
> +    "test/vinyl/**/*.lua",
> +    "test/wal_off/**/*.lua",
> +    "test/xlog/**/*.lua",
> +    "test/xlog-py/**/*.lua",
>      "third_party/**/*.lua",
>      ".rocks/**/*.lua",
>      ".git/**/*.lua",
>  }
>  
> +files["test/sql-tap/**/*.lua"] = {
> +    ignore = {
> +        -- Accessing an undefined global variable.
> +        "113",
> +        -- Unused local variable.
> +        "211",
> +        -- Unused argument.
> +        "212",
> +        -- Unused loop variable.
> +        "213",
> +        -- Local variable is set but never accessed.
> +        "231",
> +        -- "Value assigned to a local variable is unused."
> +        "311",
> +        -- Unreachable code.
> +        "511",
> +        -- Loop can be executed at most once.
> +        "512",
> +        -- An empty if branch.
> +        "542",
> +        -- A line consists of nothing but whitespace.
> +        "611",
> +        -- A line contains trailing whitespace.
> +        "612",
> +        -- Trailing whitespace in a string.
> +        "613",
> +        -- Trailing whitespace in a comment.
> +        "614",
> +        -- Inconsistent indentation (SPACE followed by TAB).
> +        "621",
> +        -- Line is too long.
> +        "631"
> +    }
> +}
> +
>  files["src/lua/help.lua"] = {
>      -- Globals defined for interactive mode.
>      globals = {"help", "tutorial"},
> diff --git a/test/sql-tap/aggnested.test.lua b/test/sql-tap/aggnested.test.lua
> index 67a9ba891..8a79e0df2 100755
> --- a/test/sql-tap/aggnested.test.lua
> +++ b/test/sql-tap/aggnested.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(7)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/alias.test.lua b/test/sql-tap/alias.test.lua
> index 75391b305..27a611d19 100755
> --- a/test/sql-tap/alias.test.lua
> +++ b/test/sql-tap/alias.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(9)
>  
>  --!./tcltestrunner.lua
> @@ -24,7 +24,7 @@ test:plan(9)
>  -- A procedure to return a sequence of increasing integers.
>  --
>  
> -counter = 0
> +_G.counter = 0
>  
>  -- Function is declared as deterministic deliberately.
>  -- Otherwise it would be called as much as it occurs in a query.
> @@ -54,7 +54,7 @@ test:do_test(
>  test:do_test(
>      "alias-1.2",
>      function()
> -        counter = 0
> +        _G.counter = 0
>          return test:execsql([[
>              SELECT x, sequence() AS y FROM t1 WHERE y> 0 order by x desc
>          ]])
> @@ -67,7 +67,7 @@ test:do_test(
>  test:do_test(
>      "alias-1.3",
>      function()
> -        counter = 0
> +        _G.counter = 0
>          return test:execsql([[
>              SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y<99  order by x desc
>          ]])
> @@ -80,7 +80,7 @@ test:do_test(
>  test:do_test(
>      "alias-1.4",
>      function()
> -        counter = 0
> +        _G.counter = 0
>          return test:execsql([[
>              SELECT x, sequence() AS y FROM t1 WHERE y>0 AND y<99 AND y!=55  order by x desc
>          ]])
> @@ -108,7 +108,7 @@ test:do_test(
>  test:do_test(
>      "alias-1.6",
>      function()
> -        counter = 0
> +        _G.counter = 0
>          return test:execsql([[
>              SELECT x, sequence() AS y FROM t1 WHERE y BETWEEN 0 AND 99 order by x desc
>          ]])
> @@ -121,7 +121,7 @@ test:do_test(
>  test:do_test(
>      "alias-1.7",
>      function()
> -        counter = 0
> +        _G.counter = 0
>          return test:execsql([[
>              SELECT x, sequence() AS y FROM t1 WHERE y BETWEEN 0 AND 99 order by x desc
>          ]])
> @@ -147,7 +147,7 @@ test:do_test(
>  test:do_test(
>      "alias-1.9",
>      function()
> -        counter = 0
> +        _G.counter = 0
>          return test:execsql([[
>              SELECT x, sequence() AS y FROM t1 ORDER BY -y
>          ]])
> diff --git a/test/sql-tap/alter.test.lua b/test/sql-tap/alter.test.lua
> index 615b9d8a6..2fece6649 100755
> --- a/test/sql-tap/alter.test.lua
> +++ b/test/sql-tap/alter.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(50)
>  
>  test:do_execsql_test(
> @@ -90,11 +90,11 @@ test:do_catchsql_test(
>  test:do_test(
>      "alter-2.3.prepare",
>      function()
> -        format = {}
> +        local format = {}
>          format[1] = { name = 'id', type = 'integer'}
>          format[2] = { name = 'f2', type = 'number'}
> -        s = box.schema.create_space('t', {format = format})
> -        i = s:create_index('i', {parts= {1, 'integer'}})
> +        local s = box.schema.create_space('t', {format = format})
> +        s:create_index('i', {parts= {1, 'integer'}})
>  
>          s:replace{1, 4}
>          s:replace{2, 2}
> @@ -520,10 +520,10 @@ test:do_catchsql_test(
>  test:do_test(
>      "alter-8.1.0",
>      function()
> -        format = {}
> +        local format = {}
>          format[1] = { name = 'id', type = 'scalar'}
>          format[2] = { name = 'f2', type = 'scalar'}
> -        s = box.schema.create_space('T', {format = format})
> +        box.schema.create_space('T', {format = format})
>      end,
>      {})
>  
> @@ -560,7 +560,7 @@ test:do_catchsql_test(
>  test:do_test(
>      "alter-8.3.2",
>      function()
> -        i = box.space.T.index[1]
> +        local i = box.space.T.index[1]
>          return i.id
>      end, 1)
>  
> diff --git a/test/sql-tap/alter2.test.lua b/test/sql-tap/alter2.test.lua
> index 759acc9c3..b4e8b8810 100755
> --- a/test/sql-tap/alter2.test.lua
> +++ b/test/sql-tap/alter2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(26)
>  
>  -- This suite is aimed to test ALTER TABLE ADD CONSTRAINT statement.
> diff --git a/test/sql-tap/analyze1.test.lua b/test/sql-tap/analyze1.test.lua
> index f274cee16..18770a086 100755
> --- a/test/sql-tap/analyze1.test.lua
> +++ b/test/sql-tap/analyze1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(38)
>  
>  --!./tcltestrunner.lua
> @@ -384,7 +384,7 @@ test:do_execsql_test(
>          -- </analyze-5.0>
>      })
>  
> -stat = "_sql_stat4"
> +local stat = "_sql_stat4"
>  
>  test:do_execsql_test(
>      "analyze-5.1",
> diff --git a/test/sql-tap/analyze3.test.lua b/test/sql-tap/analyze3.test.lua
> index dcbea1da5..c36cfc83b 100755
> --- a/test/sql-tap/analyze3.test.lua
> +++ b/test/sql-tap/analyze3.test.lua
> @@ -1,8 +1,8 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(37)
>  
> -testprefix = "analyze3"
> +local testprefix = "analyze3"
>  
>  --!./tcltestrunner.lua
>  -- 2009 August 06
> diff --git a/test/sql-tap/analyze4.test.lua b/test/sql-tap/analyze4.test.lua
> index 7d7498faf..8327b78c7 100755
> --- a/test/sql-tap/analyze4.test.lua
> +++ b/test/sql-tap/analyze4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/analyze5.test.lua b/test/sql-tap/analyze5.test.lua
> index 45e76492a..1d6665ad0 100755
> --- a/test/sql-tap/analyze5.test.lua
> +++ b/test/sql-tap/analyze5.test.lua
> @@ -1,8 +1,8 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(88)
>  
> -json = require("json")
> +local json = require("json")
>  
>  --!./tcltestrunner.lua
>  -- 2011 January 19
> @@ -21,13 +21,13 @@ json = require("json")
>  -- with many repeated values and only a few distinct values.
>  --
>  
> -testprefix = "analyze5"
> +local testprefix = "analyze5"
>  local function eqp(sql)
>      return test:execsql("EXPLAIN QUERY PLAN"..sql)
>  end
>  
>  local function alpha(blob)
> -    ret = ""
> +    local ret = ""
>      for _, c in ipairs(X(37, "X!cmd", [=[["split",["blob"],""]]=])) do
>          if X(39, "X!cmd", [=[["string","is","alpha",["c"]]]=])
>   then
> @@ -64,13 +64,14 @@ test:do_test(
>          -- test:execsql("CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, t INT ,u INT ,v TEXT COLLATE nocase,w INT ,x INT ,y INT ,z INT )")
>          test:execsql("CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, t TEXT ,u TEXT ,v TEXT ,w TEXT ,x TEXT ,y TEXT ,z NUMBER)")
>          for i=0,999 do -- _ in X(0, "X!for", [=[["set i 0","$i < 1000","incr i"]]=]) do
> +            local y
>              if  ((i >= 25) and (i <= 50)) then
>                  y = 1
>              else
>                  y = 0
>              end
>  
> -            z = 0
> +            local z = 0
>              if i >= 400 then
>                  z = 1
>              end
> @@ -81,6 +82,7 @@ test:do_test(
>                  z = z + 1
>              end
>              
> +            local x, w, t, u
>              x = z
>              w = z
>              t = (z + 0.5)
> @@ -99,7 +101,7 @@ test:do_test(
>              -- if X(65, "X!cmd", [=[["expr","$i%2"]]=]) then
>              --    v = u
>              -- end
> -            v = 'NULL'
> +            local v = 'NULL'
>              test:execsql("INSERT INTO t1 (t,u,v,w,x,y,z) VALUES('"..t.."','"..u.."','"..v.."','"..w.."','"..x.."','"..y.."','"..z.."')")
>          end
>          test:execsql([[
> @@ -252,6 +254,7 @@ for i, v in pairs({
>      test:do_test(
>          "analyze5-1."..i.."b",
>          function()
> +            local w2, a1, a2, res
>              w2 = v[1]:gsub('y', '+y'):gsub('z', '+z')
>              a1 = test:execsql("SELECT id FROM t1 NOT INDEXED WHERE "..w2.." ORDER BY +id")
>              a2 = test:execsql("SELECT id FROM t1 WHERE "..v[1].." ORDER BY +id")
> @@ -298,6 +301,7 @@ for i, v in pairs({
>      test:do_test(
>          "analyze5-1."..i.."b",
>          function()
> +            local a1, a2, res
>              a1 = test:execsql("SELECT id FROM t1 NOT INDEXED WHERE "..v.." ORDER BY +id")
>              a2 = test:execsql("SELECT id FROM t1 WHERE "..v.." ORDER BY +id")
>              if (test.is_deeply_regex(a1, a1))
> diff --git a/test/sql-tap/analyze6.test.lua b/test/sql-tap/analyze6.test.lua
> index 1ba084e35..5ec40d22b 100755
> --- a/test/sql-tap/analyze6.test.lua
> +++ b/test/sql-tap/analyze6.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(13)
>  
>  --!./tcltestrunner.lua
> @@ -21,7 +21,7 @@ test:plan(13)
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
>  
> -testprefix = "analyze6"
> +local testprefix = "analyze6"
>  
>  test:do_test(
>      "analyze6-1.0",
> diff --git a/test/sql-tap/analyze7.test.lua b/test/sql-tap/analyze7.test.lua
> index 22bad4e17..203a0c3f9 100755
> --- a/test/sql-tap/analyze7.test.lua
> +++ b/test/sql-tap/analyze7.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(14)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/analyze8.test.lua b/test/sql-tap/analyze8.test.lua
> index 92ac993c5..5c80a7b2f 100755
> --- a/test/sql-tap/analyze8.test.lua
> +++ b/test/sql-tap/analyze8.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(15)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(15)
>  -- in this file is testing the capabilities of sql_stat3.
>  --
>  
> -testprefix = "analyze8"
> +local testprefix = "analyze8"
>  
>  -- Scenario:
>  --
> @@ -39,6 +39,7 @@ test:do_test(
>              CREATE INDEX t1c ON t1(c);
>          ]])
>          for i=0, 1000 do
> +            local a, b, c
>              if (i % 2 == 0)
>              then
>                  a = i
> diff --git a/test/sql-tap/analyze9.test.lua b/test/sql-tap/analyze9.test.lua
> index 02eb49f69..1d7c8b632 100755
> --- a/test/sql-tap/analyze9.test.lua
> +++ b/test/sql-tap/analyze9.test.lua
> @@ -1,8 +1,8 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(121)
>  
> -testprefix = "analyze9"
> +local testprefix = "analyze9"
>  
>  --!./tcltestrunner.lua
>  -- 2013 August 3
> @@ -46,8 +46,8 @@ test:do_execsql_test(
>          -- </1.1>
>      })
>  
> -msgpack_decode_sample = function(txt)
> -    msgpack = require('msgpack')
> +local function msgpack_decode_sample(txt)
> +    local msgpack = require('msgpack')
>      local i = 1
>      local decoded_str = ''
>      while msgpack.decode(txt)[i] ~= nil do
> @@ -63,6 +63,7 @@ msgpack_decode_sample = function(txt)
>      end
>      return decoded_str
>  end
> +_G.msgpack_decode_sample = msgpack_decode_sample
>  
>  box.internal.sql_create_function("msgpack_decode_sample", "TEXT", msgpack_decode_sample)
>  
> @@ -134,14 +135,15 @@ test:do_test(
>      })
>  
>  -- Analogue of function from tcl
> -lindex = function(str, pos)
> +local function lindex(str, pos)
>      return string.sub(str, pos+1, pos+1)
>  end
> +_G.lindex = lindex
>  
>  box.internal.sql_create_function("lindex", "TEXT", lindex)
>  
>  -- Analogue of function from tcl
> -lrange = function(str, first, last)
> +local function lrange(str, first, last)
>      local res_tokens = ""
>      local i = 1
>      for token in string.gmatch(str, "[^%s]+") do
> @@ -156,24 +158,27 @@ lrange = function(str, first, last)
>      end
>      return res_tokens
>  end
> +_G.lrange = lrange
>  
>  box.internal.sql_create_function("lrange", "TEXT", lrange)
>  
> -generate_tens = function(n)
> -    tens = {}
> +local function generate_tens(n)
> +    local tens = {}
>      for i = 1, n do
>          tens[i] = 10
>      end
>      return tens
>  end
> +_G.generate_tens = generate_tens
>  
> -generate_tens_str = function(n)
> -    tens = {}
> +local function generate_tens_str(n)
> +    local tens = {}
>      for i = 1, n do
>          tens[i] = "10"
>      end
>      return tens
>  end
> +_G.generate_tens_str = generate_tens_str
>  
>  -- Each value of "a" occurs exactly 10 times in the table.
>  --
> @@ -236,7 +241,7 @@ test:do_execsql_test(
>          CREATE INDEX i1 ON t1(c, b, a);
>      ]])
>  
> -insert_filler_rows_n = function(iStart, nCopy, nVal)
> +local function insert_filler_rows_n(iStart, nCopy, nVal)
>      for i = 0, nVal-1 do
>          local iVal = iStart+i
>          for j = 0, nCopy-1 do
> @@ -244,6 +249,7 @@ insert_filler_rows_n = function(iStart, nCopy, nVal)
>          end
>      end
>  end
> +_G.insert_filler_rows_n = insert_filler_rows_n
>  
>  box.internal.sql_create_function("insert_filler_rows_n", "INT", insert_filler_rows_n)
>  
> @@ -718,7 +724,7 @@ test:do_test(
>              else
>                  a = "\"DEF\""
>              end
> -            b = i % 5
> +            local b = i % 5
>              test:execsql(string.format("INSERT INTO t4 VALUES(null, '%s', '%s')", a, b))
>          test:execsql("ANALYZE")
>          end
> @@ -769,7 +775,7 @@ test:do_test(
>              else
>                  a = "\"DEF\""
>              end
> -            b = i % 5
> +            local b = i % 5
>              test:execsql(string.format("INSERT INTO t4 VALUES(null, '%s', '%s')", a, b))
>          test:execsql("ANALYZE")
>          end
> @@ -830,7 +836,7 @@ test:do_test(
>              else
>                  a = "\"DEF\""
>              end
> -            b = i % 5
> +            local b = i % 5
>              test:execsql(string.format("INSERT INTO t4 VALUES(null, 'abcdef', '%s', '%s')", a, b))
>          test:execsql("ANALYZE")
>          end
> @@ -881,7 +887,7 @@ test:do_test(
>              else
>                  a = "\"DEF\""
>              end
> -            b = i % 5
> +            local b = i % 5
>              test:execsql(string.format("INSERT INTO t4 VALUES(null, 'abcdef', '%s', '%s')", a, b))
>          test:execsql("ANALYZE")
>          end
> @@ -1246,9 +1252,10 @@ test:do_test(
>  
>  ---------------------------------------------------------------------------
>  
> -r = function()
> +local function r()
>      return math.random(1, 15)
>  end
> +_G.r = r
>  
>  box.internal.sql_create_function("r", "NUM", r)
>  
> @@ -1376,7 +1383,7 @@ test:do_execsql_test(
>      })
>  
>  
> -int_to_char = function(i)
> +local function int_to_char(i)
>      local ret = ""
>      local char = "abcdefghij"
>      local divs = {1000, 100, 10, 1}
> @@ -1385,6 +1392,7 @@ int_to_char = function(i)
>      end
>      return ret
>  end
> +_G.int_to_char = int_to_char
>  
>  box.internal.sql_create_function("int_to_char", "TEXT", int_to_char)
>  
> diff --git a/test/sql-tap/analyzeC.test.lua b/test/sql-tap/analyzeC.test.lua
> index 16d6233de..baae809a6 100755
> --- a/test/sql-tap/analyzeC.test.lua
> +++ b/test/sql-tap/analyzeC.test.lua
> @@ -1,8 +1,8 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(20)
>  
> -testprefix = "analyzeC"
> +local testprefix = "analyzeC"
>  
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/analyzeD.test.lua b/test/sql-tap/analyzeD.test.lua
> index 1f00e80e0..579cb350a 100755
> --- a/test/sql-tap/analyzeD.test.lua
> +++ b/test/sql-tap/analyzeD.test.lua
> @@ -1,8 +1,8 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(15)
>  
> -testprefix = "analyzeD"
> +local testprefix = "analyzeD"
>  
>  --!./tcltestrunner.lua
>  -- 2005 July 22
> diff --git a/test/sql-tap/analyzeE.test.lua b/test/sql-tap/analyzeE.test.lua
> index c0a33ad86..2da0c885f 100755
> --- a/test/sql-tap/analyzeE.test.lua
> +++ b/test/sql-tap/analyzeE.test.lua
> @@ -1,8 +1,8 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(48)
>  
> -testprefix = "analyzeE"
> +local testprefix = "analyzeE"
>  
>  --!./tcltestrunner.lua
>  -- 2014-10-08
> diff --git a/test/sql-tap/analyzeF.test.lua b/test/sql-tap/analyzeF.test.lua
> index 8f6fb5c97..e56437902 100755
> --- a/test/sql-tap/analyzeF.test.lua
> +++ b/test/sql-tap/analyzeF.test.lua
> @@ -1,8 +1,8 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(18)
>  
> -testprefix = "analyzeF"
> +local testprefix = "analyzeF"
>  
>  --!./tcltestrunner.lua
>  -- 2015-03-12
> @@ -43,10 +43,10 @@ test:do_execsql_test(
>  -- without the sql_DETERMINISTIC flag set.
>  --
>  
> -where_clauses_x = {"x = 4 AND y = 19", "x = '4' AND y = '19'", 
> +local where_clauses_x = {"x = 4 AND y = 19", "x = '4' AND y = '19'",
>  	"x = substr('145', 2, 1) AND y = substr('5195', 2, 2)"}
>  
> -where_clauses_y = {"x = 19 AND y = 4", "x = '19' AND y = '4'", 
> +local where_clauses_y = {"x = 19 AND y = 4", "x = '19' AND y = '4'",
>  	"x = substr('5195', 2, 2) AND y = substr('145', 2, 1)",
>  	"x = substr('5195', 2, 2+0) AND y = substr('145', 2, 1+0)",
>  	"x = substr('145', 2, 1+0) AND y = substr('5195', 2, 2+0)",
> @@ -56,7 +56,7 @@ where_clauses_y = {"x = 19 AND y = 4", "x = '19' AND y = '4'",
>  
>  
>  for test_number, where in ipairs(where_clauses_x) do
> -    res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1X (X=?)"}
> +    local res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1X (X=?)"}
>      test:do_eqp_test(
>          "1.1."..test_number,
>          "SELECT * FROM t1 WHERE "..where.."", {
> @@ -67,7 +67,7 @@ end
>  
>  
>  for test_number, where in ipairs(where_clauses_y) do
> -    res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1Y (Y=?)"}
> +    local res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1Y (Y=?)"}
>      test:do_eqp_test(
>          "1.2."..test_number,
>          "SELECT * FROM t1 WHERE "..where.."", {
> @@ -113,11 +113,11 @@ box.internal.sql_create_function("det4", "NUM", det4)
>  
>  box.internal.sql_create_function("det19", "NUM", det19)
>  
> -where_clause_x = {"x = det4() AND y = det19()"}
> +where_clauses_x = {"x = det4() AND y = det19()"}
>  where_clauses_y = {"x = det19() AND y = det4()"}
>  
>  for test_number, where in ipairs(where_clauses_y) do
> -    res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1Y (Y=?)"}
> +    local res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1Y (Y=?)"}
>      test:do_eqp_test(
>          "3.1."..test_number,
>          "SELECT * FROM t1 WHERE "..where.."", {
> @@ -126,7 +126,7 @@ for test_number, where in ipairs(where_clauses_y) do
>  end
>  
>  for test_number, where in ipairs(where_clauses_x) do
> -    res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1X (X=?)"}
> +    local res = {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX T1X (X=?)"}
>      test:do_eqp_test(
>          "3.2."..test_number,
>          "SELECT * FROM t1 WHERE "..where.."", {
> diff --git a/test/sql-tap/atof1.test.lua b/test/sql-tap/atof1.test.lua
> index fe045427d..78aca6557 100755
> --- a/test/sql-tap/atof1.test.lua
> +++ b/test/sql-tap/atof1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(9999)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/autoinc.test.lua b/test/sql-tap/autoinc.test.lua
> index 07442b60a..0ea1961fd 100755
> --- a/test/sql-tap/autoinc.test.lua
> +++ b/test/sql-tap/autoinc.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(57)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/autoindex1.test.lua b/test/sql-tap/autoindex1.test.lua
> index 94b824331..99d44a2bc 100755
> --- a/test/sql-tap/autoindex1.test.lua
> +++ b/test/sql-tap/autoindex1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(8)
>  
>  --
> @@ -36,7 +36,7 @@ test:do_eqp_test(
>          {1,0,0,"SEARCH TABLE T2 USING EPHEMERAL INDEX (C=?) (~20 rows)"}
>      })
>  
> -result = test:execsql([[SELECT b, (SELECT d FROM t2 WHERE c = a) FROM t1;]])
> +local result = test:execsql([[SELECT b, (SELECT d FROM t2 WHERE c = a) FROM t1;]])
>  
>  test:do_eqp_test(
>      "autoindex-1.2", [[
> diff --git a/test/sql-tap/autoindex4.test.lua b/test/sql-tap/autoindex4.test.lua
> index e22f49c67..c2ca723b8 100755
> --- a/test/sql-tap/autoindex4.test.lua
> +++ b/test/sql-tap/autoindex4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(8)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/autoindex5.test.lua b/test/sql-tap/autoindex5.test.lua
> index b1fddf37f..a7c7bb9a7 100755
> --- a/test/sql-tap/autoindex5.test.lua
> +++ b/test/sql-tap/autoindex5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/badutf1.test.lua b/test/sql-tap/badutf1.test.lua
> index 9079dfe25..654629bf7 100755
> --- a/test/sql-tap/badutf1.test.lua
> +++ b/test/sql-tap/badutf1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(23)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/between.test.lua b/test/sql-tap/between.test.lua
> index 60d9ae1d6..550976b86 100755
> --- a/test/sql-tap/between.test.lua
> +++ b/test/sql-tap/between.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(11)
>  
>  --!./tcltestrunner.lua
> @@ -29,6 +29,7 @@ test:do_test(
>              CREATE TABLE t1(w int primary key, x int, y int, z int);
>          ]])
>          for i = 1, 100, 1 do
> +            local w, x, y, z
>              w = i
>              x = math.floor((math.log(i)/math.log(2)))
>              y = (((i * i) + (2 * i)) + 1)
> diff --git a/test/sql-tap/bigrow1.test.lua b/test/sql-tap/bigrow1.test.lua
> index e712cd52b..6e4c21959 100755
> --- a/test/sql-tap/bigrow1.test.lua
> +++ b/test/sql-tap/bigrow1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(60)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/blob.test.lua b/test/sql-tap/blob.test.lua
> index d4845bbd4..e9c513988 100755
> --- a/test/sql-tap/blob.test.lua
> +++ b/test/sql-tap/blob.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(20)
>  
>  --!./tcltestrunner.lua
> @@ -33,35 +33,35 @@ end
>  test:do_test(
>      "blob-1.0",
>      function()
> -        blob = test:execsql "SELECT X'01020304';"
> +        local blob = test:execsql "SELECT X'01020304';"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "01020304")
>  
>  test:do_test(
>      "blob-1.1",
>      function()
> -        blob = test:execsql "SELECT x'ABCDEF';"
> +        local blob = test:execsql "SELECT x'ABCDEF';"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "ABCDEF")
>  
>  test:do_test(
>      "blob-1.2",
>      function()
> -        blob = test:execsql "SELECT x'';"
> +        local blob = test:execsql "SELECT x'';"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "blob-1.3",
>      function()
> -        blob = test:execsql "SELECT x'abcdEF12';"
> +        local blob = test:execsql "SELECT x'abcdEF12';"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "ABCDEF12")
>  
>  test:do_test(
>      "blob-1.3.2",
>      function()
> -        blob = test:execsql "SELECT x'0123456789abcdefABCDEF';"
> +        local blob = test:execsql "SELECT x'0123456789abcdefABCDEF';"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "0123456789ABCDEFABCDEF")
>  
> @@ -174,6 +174,7 @@ test:do_test(
>              INSERT INTO t1 VALUES(X'123456', x'7890ab');
>              INSERT INTO t1 VALUES(X'CDEF12', x'345678');
>          ]]
> +        local blobs, blobs2
>          blobs = test:execsql "SELECT * FROM t1"
>          blobs2 = {  }
>          for _, b in ipairs(blobs) do
> @@ -193,6 +194,7 @@ test:do_test(
>          test:execsql [[
>              CREATE INDEX i1 ON t1(a);
>          ]]
> +        local blobs, blobs2
>          blobs = test:execsql "SELECT * FROM t1"
>          blobs2 = {  }
>          for _, b in ipairs(blobs) do
> @@ -208,6 +210,7 @@ test:do_test(
>  test:do_test(
>      "blob-2.2",
>      function()
> +        local blobs, blobs2
>          blobs = test:execsql "SELECT * FROM t1 where a = X'123456'"
>          blobs2 = {  }
>          for _, b in ipairs(blobs) do
> @@ -223,6 +226,7 @@ test:do_test(
>  test:do_test(
>      "blob-2.3",
>      function()
> +        local blobs, blobs2
>          blobs = test:execsql "SELECT * FROM t1 where a = X'CDEF12'"
>          blobs2 = {  }
>          for _, b in ipairs(blobs) do
> @@ -238,6 +242,7 @@ test:do_test(
>  test:do_test(
>      "blob-2.4",
>      function()
> +        local blobs, blobs2
>          blobs = test:execsql "SELECT * FROM t1 where a = X'CD12'"
>          blobs2 = {  }
>          for _, b in ipairs(blobs) do
> @@ -269,6 +274,7 @@ if (0 > 0)
>      test:do_test(
>          "blob-3.2",
>          function()
> +            local blobs, blobs2
>              blobs = test:execsql "SELECT * FROM t1"
>              blobs2 = {  }
>              for _, b in ipairs(blobs) do
> diff --git a/test/sql-tap/boundary1.test.lua b/test/sql-tap/boundary1.test.lua
> index ffd667c15..da093cd81 100755
> --- a/test/sql-tap/boundary1.test.lua
> +++ b/test/sql-tap/boundary1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1511)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/boundary2.test.lua b/test/sql-tap/boundary2.test.lua
> index 0fa07e6cd..0574a4ea8 100755
> --- a/test/sql-tap/boundary2.test.lua
> +++ b/test/sql-tap/boundary2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3021)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/boundary3.test.lua b/test/sql-tap/boundary3.test.lua
> index 2f42b9bfb..f5643f4ab 100755
> --- a/test/sql-tap/boundary3.test.lua
> +++ b/test/sql-tap/boundary3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1896)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/cast.test.lua b/test/sql-tap/cast.test.lua
> index fb0790d04..4d7c92cfc 100755
> --- a/test/sql-tap/cast.test.lua
> +++ b/test/sql-tap/cast.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(79)
>  
>  --!./tcltestrunner.lua
> @@ -789,6 +789,7 @@ if 0 > 0 then
>  test:do_test(
>      "cast-3.32.1",
>      function()
> +        local blob, DB, STMT
>          blob = 1234567890
>          DB = sql_connection_pointer("db")
>          STMT = sql_prepare(DB, "SELECT CAST(? AS NUMBER)", -1, "TAIL")
> diff --git a/test/sql-tap/check.test.lua b/test/sql-tap/check.test.lua
> index 3dc28cf0d..cd9f24796 100755
> --- a/test/sql-tap/check.test.lua
> +++ b/test/sql-tap/check.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(61)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(61)
>  -- $Id: check.test,v 1.13 2009/06/05 17:09:12 drh Exp $
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "check"
> +local testprefix = "check"
>  -- Only run these tests if the build includes support for CHECK constraints
>  
>  
> diff --git a/test/sql-tap/coalesce.test.lua b/test/sql-tap/coalesce.test.lua
> index 5501e6992..366e8667a 100755
> --- a/test/sql-tap/coalesce.test.lua
> +++ b/test/sql-tap/coalesce.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(9)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/collation.test.lua b/test/sql-tap/collation.test.lua
> index f7099b222..d8e727f12 100755
> --- a/test/sql-tap/collation.test.lua
> +++ b/test/sql-tap/collation.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(192)
>  
>  local prefix = "collation-"
> diff --git a/test/sql-tap/collation_unicode.test.lua b/test/sql-tap/collation_unicode.test.lua
> index b6b189d98..7b4d777f0 100755
> --- a/test/sql-tap/collation_unicode.test.lua
> +++ b/test/sql-tap/collation_unicode.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(28 * 4)
>  
>  local prefix = "unicode-collation-"
> diff --git a/test/sql-tap/colname.test.lua b/test/sql-tap/colname.test.lua
> index 3901feea9..191396bcc 100755
> --- a/test/sql-tap/colname.test.lua
> +++ b/test/sql-tap/colname.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(79)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/contrib01.test.lua b/test/sql-tap/contrib01.test.lua
> index 67dc2bdfa..74c5af54c 100755
> --- a/test/sql-tap/contrib01.test.lua
> +++ b/test/sql-tap/contrib01.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/count.test.lua b/test/sql-tap/count.test.lua
> index 08c225bc5..9f4d759b5 100755
> --- a/test/sql-tap/count.test.lua
> +++ b/test/sql-tap/count.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(30)
>  
>  --!./tcltestrunner.lua
> @@ -33,7 +33,7 @@ test:plan(30)
>  --      SELECT count(*) FROM sql_master;
>  --   }
>  -- } {0}
> -iTest = 0
> +local iTest = 0
>  local queries = {
>      "/* no-op */",
>      "CREATE INDEX i1 ON t1(a);"
> @@ -105,7 +105,7 @@ for _, zIndex in ipairs(queries) do
>          })
>  
>  end
> -json = require("json")
> +local json = require("json")
>  local function uses_op_count(sql)
>      if test:lsearch(test:execsql("EXPLAIN "..sql), "Count")>0 then
>          return 1
> diff --git a/test/sql-tap/cse.test.lua b/test/sql-tap/cse.test.lua
> index 341b6de01..e09f955a0 100755
> --- a/test/sql-tap/cse.test.lua
> +++ b/test/sql-tap/cse.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(118)
>  
>  --!./tcltestrunner.lua
> @@ -252,7 +252,7 @@ for i = 1, 99, 1 do
>          table.insert(answer,j)
>          table.insert(answer,r)
>      end
> -    sql = "SELECT "..table.concat(colset, ",").." FROM t2"
> +    local sql = "SELECT "..table.concat(colset, ",").." FROM t2"
>      test:do_test(
>          "cse-2.2."..i,
>          function()
> diff --git a/test/sql-tap/date.test.lua b/test/sql-tap/date.test.lua
> index 87fc80db0..b414b5397 100755
> --- a/test/sql-tap/date.test.lua
> +++ b/test/sql-tap/date.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  -- test:plan(1279)
>  test:plan(0)
>  
> diff --git a/test/sql-tap/debug_mode_only.test.lua b/test/sql-tap/debug_mode_only.test.lua
> index 2b3f6a1a0..71fd43a17 100755
> --- a/test/sql-tap/debug_mode_only.test.lua
> +++ b/test/sql-tap/debug_mode_only.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
>  -- This file contains testcases which can only be valudated in debug mode.
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(30)
>  
>  local ffi = require("ffi")
> diff --git a/test/sql-tap/default.test.lua b/test/sql-tap/default.test.lua
> index f1def2b10..1832e3af7 100755
> --- a/test/sql-tap/default.test.lua
> +++ b/test/sql-tap/default.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(15)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/delete1.test.lua b/test/sql-tap/delete1.test.lua
> index bfed3ba9d..f1658695f 100755
> --- a/test/sql-tap/delete1.test.lua
> +++ b/test/sql-tap/delete1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(10)
>  
>  --!./tcltestrunner.lua
> @@ -132,11 +132,12 @@ test:do_test(
>      })
>  
>  -- Tests for data dictionary integration.
> -format = {}
> +local format = {}
>  format[1] = {name = 'id', type = 'scalar'}
>  format[2] = {name = 'f', type = 'scalar'}
> +local s
>  s = box.schema.create_space('t', {format = format})
> -i = s:create_index('i', {parts = {1, 'scalar'}})
> +s:create_index('i', {parts = {1, 'scalar'}})
>  
>  test:do_test(
>      "delete1-6.0",
> diff --git a/test/sql-tap/delete3.test.lua b/test/sql-tap/delete3.test.lua
> index b5968ae96..e9d1f5a21 100755
> --- a/test/sql-tap/delete3.test.lua
> +++ b/test/sql-tap/delete3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/delete4.test.lua b/test/sql-tap/delete4.test.lua
> index 7c0eec15e..43585e603 100755
> --- a/test/sql-tap/delete4.test.lua
> +++ b/test/sql-tap/delete4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(14)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(14)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "delete4"
> +local testprefix = "delete4"
>  test:do_execsql_test(
>      1.1,
>      [[
> diff --git a/test/sql-tap/distinct.test.lua b/test/sql-tap/distinct.test.lua
> index ae35a0db5..02fe8a426 100755
> --- a/test/sql-tap/distinct.test.lua
> +++ b/test/sql-tap/distinct.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(56)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/distinctagg.test.lua b/test/sql-tap/distinctagg.test.lua
> index 5454bf0ed..9b1346f7d 100755
> --- a/test/sql-tap/distinctagg.test.lua
> +++ b/test/sql-tap/distinctagg.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(6)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/drop_all.test.lua b/test/sql-tap/drop_all.test.lua
> index b08daf87c..a03ce598f 100755
> --- a/test/sql-tap/drop_all.test.lua
> +++ b/test/sql-tap/drop_all.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  local prefix = "drop_all-"
>  
> diff --git a/test/sql-tap/e_delete.test.lua b/test/sql-tap/e_delete.test.lua
> index a0c944327..d1cf2a79f 100755
> --- a/test/sql-tap/e_delete.test.lua
> +++ b/test/sql-tap/e_delete.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(18)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/e_expr.test.lua b/test/sql-tap/e_expr.test.lua
> index 7ee7a2d98..f5b58cb79 100755
> --- a/test/sql-tap/e_expr.test.lua
> +++ b/test/sql-tap/e_expr.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(10641)
>  
>  --!./tcltestrunner.lua
> @@ -1078,18 +1078,18 @@ test:do_execsql_test(
>  -- MUST_WORK_TEST prepared statements
>  if (0>0) then
>      local function parameter_test(tn, sql, params, result)
> -        stmt = sql_prepare_v2("db", sql, -1)
> +        local stmt = sql_prepare_v2("db", sql, -1)
>          for _ in X(0, "X!foreach", [=[["number name",["params"]]]=]) do
> -            nm = sql_bind_parameter_name(stmt, number)
> +            local nm = sql_bind_parameter_name(stmt, number)
>              X(480, "X!cmd", [=[["do_test",[["tn"],".name.",["number"]],[["list","set","",["nm"]]],["name"]]]=])
>              sql_bind_int(stmt, number, ((-1) * number))
>          end
>          sql_step(stmt)
> -        res = {  }
> +        local res = {  }
>          for _ in X(0, "X!for", [=[["set i 0","$i < [sql_column_count $stmt]","incr i"]]=]) do
>              table.insert(res,sql_column_text(stmt, i))
>          end
> -        rc = sql_finalize(stmt)
> +        local rc = sql_finalize(stmt)
>          X(491, "X!cmd", [=[["do_test",[["tn"],".rc"],[["list","set","",["rc"]]],"sql_OK"]]=])
>          X(492, "X!cmd", [=[["do_test",[["tn"],".res"],[["list","set","",["res"]]],["result"]]]=])
>      end
> @@ -1126,7 +1126,7 @@ if (0>0) then
>      test:do_test(
>          "e_expr-11.7.1",
>          function()
> -            stmt = sql_prepare_v2("db", " SELECT ?, :a, @b, ?d ", -1)
> +            local stmt = sql_prepare_v2("db", " SELECT ?, :a, @b, ?d ", -1)
>              sql_step(stmt)
>              return { sql_column_type(stmt, 0), sql_column_type(stmt, 1), sql_column_type(stmt, 2), sql_column_type(stmt, 3) }
>          end, {
> @@ -2119,7 +2119,7 @@ test:do_execsql_test(
>  -- calling the application-defined SQL functions like(Y,X) or like(Y,X,Z).
>  --
>  local likeargs = {}
> -function likefunc(...)
> +local function likefunc(...)
>      local args = {...}
>      for i, v in ipairs(args) do
>          table.insert(likeargs, v)
> @@ -2489,6 +2489,7 @@ test:do_execsql_test(
>          -- </e_expr-20.2>
>      })
>  
> +local a, b, c
>  a = 0
>  b = 0
>  c = 0
> diff --git a/test/sql-tap/e_select1.test.lua b/test/sql-tap/e_select1.test.lua
> index 578620fca..2a189582d 100755
> --- a/test/sql-tap/e_select1.test.lua
> +++ b/test/sql-tap/e_select1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(509)
>  
>  --!./tcltestrunner.lua
> @@ -835,7 +835,7 @@ end
>  -- MUST_WORK_TEST prepared statement
>  if 0>0 then
>  for _ in X(0, "X!foreach", [=[["tn select nCol","\n  1   \"SELECT a,b,c FROM z1\" 3\n  2   \"SELECT a,b,c FROM z1 NATURAL JOIN z3\"  3\n  3   \"SELECT z1.a,z1.b,z1.c FROM z1 NATURAL JOIN z3\" 3\n  4   \"SELECT z3.a,z3.b FROM z1 NATURAL JOIN z3\" 2\n  5   \"SELECT z1.a,z1.b,z1.c, z3.a,z3.b FROM z1 NATURAL JOIN z3\" 5\n  6   \"SELECT 1, 2, z1.a,z1.b,z1.c FROM z1\" 5\n  7   \"SELECT a, a,b,c, b, c FROM z1\" 6\n"]]=]) do
> -    stmt = sql_prepare_v2("db", select, -1, "DUMMY")
> +    local stmt = sql_prepare_v2("db", select, -1, "DUMMY")
>      test:do_sql_column_count_test(
>          "e_select-4.3."..tn,
>          stmt, {
> @@ -963,13 +963,14 @@ test:do_select_tests(
>  if 0>0 then
>  for _ in X(0, "X!foreach", [=[["tn select","\n  8.1  \"SELECT count(*) FROM a1\"\n  8.2  \"SELECT count(*) FROM a1 WHERE 0\"\n  8.3  \"SELECT count(*) FROM a1 WHERE 1\"\n  8.4  \"SELECT max(a1.one)+min(two), a1.one, two, * FROM a1, a2 WHERE 1\"\n  8.5  \"SELECT max(a1.one)+min(two), a1.one, two, * FROM a1, a2 WHERE 0\"\n"]]=]) do
>      -- Set $nRow to the number of rows returned by $select:
> +    local stmt, nRow
>      stmt = sql_prepare_v2("db", select, -1, "DUMMY")
>      nRow = 0
>      while X(979, "X!cmd", [=[["expr","\"sql_ROW\" == [sql_step $::stmt]"]]=])
>   do
>          nRow = nRow + 1
>      end
> -    rc = sql_finalize(stmt)
> +    local rc = sql_finalize(stmt)
>      -- Test that $nRow==1 and that statement execution was successful
>      -- (rc==sql_OK).
>      X(983, "X!cmd", [=[["do_test",["e_select-4.",["tn"]],[["list","list",["rc"],["nRow"]]],"sql_OK 1"]]=])
> diff --git a/test/sql-tap/eqp.test.lua b/test/sql-tap/eqp.test.lua
> index 83ef947bb..6519fc4e9 100755
> --- a/test/sql-tap/eqp.test.lua
> +++ b/test/sql-tap/eqp.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(70)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/explain.test.lua b/test/sql-tap/explain.test.lua
> index 9b8d8404a..117bda29d 100755
> --- a/test/sql-tap/explain.test.lua
> +++ b/test/sql-tap/explain.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  -- gh-3231: make sure that there is no redundant OP_Goto at the
> @@ -21,7 +21,7 @@ test:do_execsql_test(
>  test:do_test(
>      "explain-1.1",
>      function()
> -        opcodes = test:execsql("EXPLAIN SELECT * FROM t1;")
> +        local opcodes = test:execsql("EXPLAIN SELECT * FROM t1;")
>          return opcodes[1]
>      end,
>          -- <explain-1.1>
> @@ -32,7 +32,7 @@ test:do_test(
>  test:do_test(
>      "explain-1.2",
>      function()
> -        opcodes = test:execsql("EXPLAIN SELECT a + 1 FROM t1 WHERE id = 4 OR id = 5;")
> +        local opcodes = test:execsql("EXPLAIN SELECT a + 1 FROM t1 WHERE id = 4 OR id = 5;")
>          return opcodes[1]
>      end,
>          -- <explain-1.2>
> diff --git a/test/sql-tap/fkey1.test.lua b/test/sql-tap/fkey1.test.lua
> index d6ef473aa..960a0df84 100755
> --- a/test/sql-tap/fkey1.test.lua
> +++ b/test/sql-tap/fkey1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(25)
>  
>  -- This file implements regression tests for foreign keys.
> diff --git a/test/sql-tap/fkey2.test.lua b/test/sql-tap/fkey2.test.lua
> index bd3e0c78c..df9807ddc 100755
> --- a/test/sql-tap/fkey2.test.lua
> +++ b/test/sql-tap/fkey2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(116)
>  
>  -- This file implements regression tests for foreign keys.
> diff --git a/test/sql-tap/fkey3.test.lua b/test/sql-tap/fkey3.test.lua
> index 900ac321c..47958cf9c 100755
> --- a/test/sql-tap/fkey3.test.lua
> +++ b/test/sql-tap/fkey3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(25)
>  
>  -- This file implements regression tests for foreign keys.
> diff --git a/test/sql-tap/fkey4.test.lua b/test/sql-tap/fkey4.test.lua
> index 397e8b895..d4963f876 100755
> --- a/test/sql-tap/fkey4.test.lua
> +++ b/test/sql-tap/fkey4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(17)
>  
>  -- This file implements regression tests for foreign keys.
> diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua
> index 3c088920f..d14eef421 100755
> --- a/test/sql-tap/func.test.lua
> +++ b/test/sql-tap/func.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(14694)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(14694)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "func"
> +local testprefix = "func"
>  -- Create a table to work with.
>  --
>  test:do_test(
> @@ -1048,7 +1048,7 @@ test:do_execsql_test(
>  --
>  -- MUST_WORK_TEST testfunc not implemented
>  if 0 > 0 then
> -DB = sql_connection_pointer("db")
> +local DB = sql_connection_pointer("db")
>  X(525, "X!cmd", [=[["sql_register_test_function",["::DB"],"testfunc"]]=])
>  test:do_catchsql_test(
>      "func-10.1",
> @@ -1300,6 +1300,7 @@ test:do_execsql_test(
>  test:do_test(
>      "func-13.7",
>      function()
> +        local DB, sql, STMT, res
>          DB = sql_connection_pointer("db")
>          sql = "SELECT test_auxdata( ? , a ) FROM t4;"
>          STMT = sql_prepare(DB, sql, -1, "TAIL")
> @@ -1348,7 +1349,7 @@ test:do_execsql_test(
>          -- </13.8.3>
>      })
>  
> -V = "one"
> +local V = "one"
>  test:do_execsql_test(
>      "13.8.4",
>      [[
> @@ -1454,7 +1455,7 @@ test:do_test(
>          test:execsql([[
>              CREATE TABLE tbl2(id integer primary key, a INT, b INT);
>          ]])
> -        STMT = sql_prepare(DB, "INSERT INTO tbl2 VALUES(1, ?, ?)", -1, "TAIL")
> +        local STMT = sql_prepare(DB, "INSERT INTO tbl2 VALUES(1, ?, ?)", -1, "TAIL")
>          sql_bind_blob(STMT, 1, "abc", 3)
>          sql_step(STMT)
>          sql_finalize(STMT)
> @@ -2341,9 +2342,9 @@ if 0>0 then
>  for i = 1, sql_LIMIT_FUNCTION_ARG, 1 do
>      midargs = midargs .. ",'/"..i.."'"
>      midres = midres .. "/"..i
> -    result = digest.md5_hex(string.format("this%sprogram%sis%sfree%ssoftware%s",
> +    local result = digest.md5_hex(string.format("this%sprogram%sis%sfree%ssoftware%s",
>            midres,midres,midres,midres,midres))
> -    sql = "SELECT md5sum(t1"..midargs..") FROM tbl1"
> +    local sql = "SELECT md5sum(t1"..midargs..") FROM tbl1"
>      test:do_test(
>          "func-24.7."..i,
>          function()
> @@ -2468,7 +2469,7 @@ test:do_test(
>  test:do_test(
>      "func-26.2",
>      function()
> -        a = ""
> +        local a = ""
>          for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG","incr i"]]=]) do
>              table.insert(a,i)
>          end
> @@ -2484,7 +2485,7 @@ test:do_test(
>  test:do_test(
>      "func-26.3",
>      function()
> -        a = ""
> +        local a = ""
>          for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG+1","incr i"]]=]) do
>              table.insert(a,i)
>          end
> @@ -2500,7 +2501,7 @@ test:do_test(
>  test:do_test(
>      "func-26.4",
>      function()
> -        a = ""
> +        local a = ""
>          for _ in X(0, "X!for", [=[["set i 1","$i<=$::sql_MAX_FUNCTION_ARG-1","incr i"]]=]) do
>              table.insert(a,i)
>          end
> @@ -2952,7 +2953,7 @@ test:do_catchsql_test(
>          -- </func-76.4>
>      })
>  
> -ffi = require('ffi')
> +_G.ffi = require('ffi')
>  box.schema.func.create('TOSTRING', {language = 'Lua', is_deterministic = true,
>                                      body = 'function(a) return a end',
>                                      param_list = {'any'}, returns = 'string',
> diff --git a/test/sql-tap/func2.test.lua b/test/sql-tap/func2.test.lua
> index c9bd3665f..95b8a1f5f 100755
> --- a/test/sql-tap/func2.test.lua
> +++ b/test/sql-tap/func2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(130)
>  
>  --!./tcltestrunner.lua
> @@ -1027,7 +1027,7 @@ end
>  test:do_test(
>      "func2-3.1.1",
>      function()
> -        blob = test:execsql "SELECT x'1234'"
> +        local blob = test:execsql "SELECT x'1234'"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "1234")
>  
> @@ -1065,203 +1065,203 @@ test:do_catchsql_test(
>  test:do_test(
>      "func2-3.2.0",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 0, 0)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 0, 0)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.2.1",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 0, 1)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 0, 1)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.2.2",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 0, 2)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 0, 2)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "12")
>  
>  test:do_test(
>      "func2-3.2.3",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 0, 3)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 0, 3)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "1234")
>  
>  test:do_test(
>      "func2-3.3.0",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 0)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 0)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.3.1",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 1)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 1)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "12")
>  
>  test:do_test(
>      "func2-3.3.2",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 2)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 2)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "1234")
>  
>  test:do_test(
>      "func2-3.3.3",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 3)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 3)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "1234")
>  
>  test:do_test(
>      "func2-3.4.0",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 0)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 0)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.4.1",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 1)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 1)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "34")
>  
>  test:do_test(
>      "func2-3.4.2",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 2)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 2)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "34")
>  
>  test:do_test(
>      "func2-3.4.3",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 3)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 3)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "34")
>  
>  test:do_test(
>      "func2-3.5.0",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 0)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 0)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.5.1",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 1)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 1)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "12")
>  
>  test:do_test(
>      "func2-3.5.2",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 2)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 2)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "1234")
>  
>  test:do_test(
>      "func2-3.5.3",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 3)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 3)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "1234")
>  
>  test:do_test(
>      "func2-3.6.0",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -1, 0)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, 0)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.6.1",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -1, -1)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, -1)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "12")
>  
>  test:do_test(
>      "func2-3.6.2",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -1, -2)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, -2)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "12")
>  
>  test:do_test(
>      "func2-3.6.3",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -1, -3)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -1, -3)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "12")
>  
>  test:do_test(
>      "func2-3.7.0",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -2, 0)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, 0)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.7.1",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -2, -1)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, -1)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.7.2",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', -2, -2)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', -2, -2)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.8.0",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 1, 0)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, 0)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.8.1",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 1, -1)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, -1)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.8.2",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 1, -2)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 1, -2)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.9.0",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 2, 0)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 2, 0)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "")
>  
>  test:do_test(
>      "func2-3.9.1",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 2, -1)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 2, -1)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "12")
>  
>  test:do_test(
>      "func2-3.9.2",
>      function()
> -        blob = test:execsql "SELECT SUBSTR(x'1234', 2, -2)"
> +        local blob = test:execsql "SELECT SUBSTR(x'1234', 2, -2)"
>          return bin_to_hex(test.lindex(blob, 0))
>      end, "12")
>  
> diff --git a/test/sql-tap/func3.test.lua b/test/sql-tap/func3.test.lua
> index 95d96965e..7f1d8d33c 100755
> --- a/test/sql-tap/func3.test.lua
> +++ b/test/sql-tap/func3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(35)
>  
>  --!./tcltestrunner.lua
> @@ -288,7 +288,7 @@ test:do_test(
>  --
>  -- gh-3929: sql: ANSI aliases for LENGTH().
>  --
> -suits = {}
> +local suits = {}
>  suits[1] = {str = '123456789', len = 9}
>  suits[2] = {str = '\x80', len = 1}
>  suits[3] = {str = '\x61\x62\x63', len = 3}
> diff --git a/test/sql-tap/func5.test.lua b/test/sql-tap/func5.test.lua
> index 8329e1735..c991e9163 100755
> --- a/test/sql-tap/func5.test.lua
> +++ b/test/sql-tap/func5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(22)
>  
>  --!./tcltestrunner.lua
> @@ -69,7 +69,7 @@ test:do_execsql_test(
>          -- </func5-2.1>
>      })
>  
> -global_counter = 0
> +_G.global_counter = 0
>  
>  box.schema.func.create('COUNTER1', {language = 'Lua', is_deterministic = false,
>                         param_list = {'any'}, returns = 'integer',
> diff --git a/test/sql-tap/gh-2360-omit-truncate-in-transaction.test.lua b/test/sql-tap/gh-2360-omit-truncate-in-transaction.test.lua
> index aa2989bdc..27d9bd42e 100755
> --- a/test/sql-tap/gh-2360-omit-truncate-in-transaction.test.lua
> +++ b/test/sql-tap/gh-2360-omit-truncate-in-transaction.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
>  
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  test:do_execsql_test(
> diff --git a/test/sql-tap/gh-2549-many-columns.test.lua b/test/sql-tap/gh-2549-many-columns.test.lua
> index ed8c9d9b2..ec994d58b 100755
> --- a/test/sql-tap/gh-2549-many-columns.test.lua
> +++ b/test/sql-tap/gh-2549-many-columns.test.lua
> @@ -1,9 +1,10 @@
>  #!/usr/bin/env tarantool
>  -- The maximum number of columns in sql is 2000. This test checks it.
>  
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
> +local success_column_count, fail_column_count
>  success_column_count = 2000
>  fail_column_count = 2001
>  
> @@ -11,7 +12,7 @@ test:execsql("DROP TABLE IF EXISTS t1")
>  test:execsql("DROP TABLE IF EXISts t2")
>  
>  local function form_create_statement(name, column_count)
> -	create_statement = 'CREATE TABLE ' .. name .. '('
> +	local create_statement = 'CREATE TABLE ' .. name .. '('
>  	for i = 1,column_count do
>  		if i > 1 then create_statement = create_statement .. ',' end
>  		create_statement = create_statement .. 's' .. i .. ' INT'
> @@ -21,6 +22,7 @@ local function form_create_statement(name, column_count)
>  	return create_statement
>  end
>  
> +local success_statement, fail_statement
>  success_statement = form_create_statement("t1", success_column_count)
>  fail_statement = form_create_statement("t2", fail_column_count)
>  
> diff --git a/test/sql-tap/gh-2723-concurrency.test.lua b/test/sql-tap/gh-2723-concurrency.test.lua
> index 842142d2d..aa9be0130 100755
> --- a/test/sql-tap/gh-2723-concurrency.test.lua
> +++ b/test/sql-tap/gh-2723-concurrency.test.lua
> @@ -1,12 +1,12 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  local fiber = require("fiber")
>  local N = 20
>  
>  -- this test uses ddl which is not working concurrently
>  -- see issue #2741
> -ch = fiber.channel(N)
> +local ch = fiber.channel(N)
>  for id = 1, N do
>      fiber.create(
>          function ()
> diff --git a/test/sql-tap/gh-2884-forbid-rowid-syntax.test.lua b/test/sql-tap/gh-2884-forbid-rowid-syntax.test.lua
> index c628510c2..74356703a 100755
> --- a/test/sql-tap/gh-2884-forbid-rowid-syntax.test.lua
> +++ b/test/sql-tap/gh-2884-forbid-rowid-syntax.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  local ok = pcall(test.execsql, test, [[
> diff --git a/test/sql-tap/gh-2996-indexed-by.test.lua b/test/sql-tap/gh-2996-indexed-by.test.lua
> index 4c5a4d053..ed820ee1b 100755
> --- a/test/sql-tap/gh-2996-indexed-by.test.lua
> +++ b/test/sql-tap/gh-2996-indexed-by.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(13)
>  
>  -- gh-2996 - INDEXED BY clause wasn't working.
> @@ -12,7 +12,7 @@ test:execsql [[
>      CREATE INDEX t1ix1 on t1(b);
>  ]]
>  
> -sample_size = 1000
> +local sample_size = 1000
>  local query = "INSERT INTO t1 VALUES "
>  
>  for i = 1, sample_size do
> diff --git a/test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua b/test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua
> index 3807ba665..0b7c3ca32 100755
> --- a/test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua
> +++ b/test/sql-tap/gh-3083-ephemeral-unref-tuples.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
>  
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  test:do_test(
> diff --git a/test/sql-tap/gh-3251-string-pattern-comparison.test.lua b/test/sql-tap/gh-3251-string-pattern-comparison.test.lua
> index 641469211..483ab326d 100755
> --- a/test/sql-tap/gh-3251-string-pattern-comparison.test.lua
> +++ b/test/sql-tap/gh-3251-string-pattern-comparison.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(162)
>  
>  local prefix = "like-test-"
> diff --git a/test/sql-tap/gh-3297-ephemeral-rowid.test.lua b/test/sql-tap/gh-3297-ephemeral-rowid.test.lua
> index dd2b07cc5..5497f87f4 100755
> --- a/test/sql-tap/gh-3297-ephemeral-rowid.test.lua
> +++ b/test/sql-tap/gh-3297-ephemeral-rowid.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  -- Check that OP_NextIdEphemeral generates unique ids.
> diff --git a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
> index bb8a4989e..5b9df5c09 100755
> --- a/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
> +++ b/test/sql-tap/gh-3307-xfer-optimization-issue.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(39)
>  
>  local function do_xfer_test(test, test_func, test_name, func, exp, opts)
> diff --git a/test/sql-tap/gh-3332-tuple-format-leak.test.lua b/test/sql-tap/gh-3332-tuple-format-leak.test.lua
> index 84e67b7ef..5e286ed0d 100755
> --- a/test/sql-tap/gh-3332-tuple-format-leak.test.lua
> +++ b/test/sql-tap/gh-3332-tuple-format-leak.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  test:do_test(
> diff --git a/test/sql-tap/gh-3350-skip-scan.test.lua b/test/sql-tap/gh-3350-skip-scan.test.lua
> index 4cecfe081..f4f9500fd 100755
> --- a/test/sql-tap/gh-3350-skip-scan.test.lua
> +++ b/test/sql-tap/gh-3350-skip-scan.test.lua
> @@ -2,7 +2,7 @@
>  
>  -- gh-3350, gh-2859
>  
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  local function lindex(str, pos)
> diff --git a/test/sql-tap/gh-4659-block-hash-index.test.lua b/test/sql-tap/gh-4659-block-hash-index.test.lua
> index f0f3cb983..c02d3eb7a 100755
> --- a/test/sql-tap/gh-4659-block-hash-index.test.lua
> +++ b/test/sql-tap/gh-4659-block-hash-index.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  -- gh-4782 - Raise an error in case space features HASH index.
> @@ -8,13 +8,13 @@ test:plan(4)
>  -- This is actually a stub until we are unable to employ
>  -- HASH index while planning a query.
>  
> -f = {
> +local f = {
>      {'1', 'unsigned'},
>      {'2', 'string'},
>      {'3', 'array'}
>  }
>  
> -s = box.schema.create_space("T1", {format = f})
> +local s = box.schema.create_space("T1", {format = f})
>  s:create_index('PK', {type = 'hash', parts = {'1'}})
>  
>  test:do_catchsql_test(
> diff --git a/test/sql-tap/gh-4766-wrong-cast-from-blob-to-int.test.lua b/test/sql-tap/gh-4766-wrong-cast-from-blob-to-int.test.lua
> index 929870d27..da8c2dcd6 100755
> --- a/test/sql-tap/gh-4766-wrong-cast-from-blob-to-int.test.lua
> +++ b/test/sql-tap/gh-4766-wrong-cast-from-blob-to-int.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --
> @@ -21,7 +21,7 @@ test:do_execsql_test(
>  -- Make sure that BLOB longer than 12287 bytes cannot be cast to
>  -- INTEGER.
>  --
> -long_str = string.rep('0', 12284)
> +local long_str = string.rep('0', 12284)
>  test:do_execsql_test(
>      "gh-4766-2",
>      "SELECT CAST('" .. long_str .. "123'" .. " AS INTEGER);", {
> diff --git a/test/sql-tap/gh-5231-box-execute-writes-in-ro.test.lua b/test/sql-tap/gh-5231-box-execute-writes-in-ro.test.lua
> index 05c23c2f8..5fbef707b 100755
> --- a/test/sql-tap/gh-5231-box-execute-writes-in-ro.test.lua
> +++ b/test/sql-tap/gh-5231-box-execute-writes-in-ro.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
>  
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(9)
>  
>  local expected_err = "Can't modify data because this instance is in read-only mode."
> diff --git a/test/sql-tap/gh2127-indentifier-max-length.test.lua b/test/sql-tap/gh2127-indentifier-max-length.test.lua
> index 46efffeed..112689327 100755
> --- a/test/sql-tap/gh2127-indentifier-max-length.test.lua
> +++ b/test/sql-tap/gh2127-indentifier-max-length.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  
>  test:plan(4)
>  
> diff --git a/test/sql-tap/gh2130-index-refer-table.test.lua b/test/sql-tap/gh2130-index-refer-table.test.lua
> index 2ced0fa07..40d2a47e5 100755
> --- a/test/sql-tap/gh2130-index-refer-table.test.lua
> +++ b/test/sql-tap/gh2130-index-refer-table.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(5)
>  
>  test:execsql " DROP TABLE IF EXISTS t1 "
> diff --git a/test/sql-tap/gh2140-trans.test.lua b/test/sql-tap/gh2140-trans.test.lua
> index 3843c97be..eeab34c17 100755
> --- a/test/sql-tap/gh2140-trans.test.lua
> +++ b/test/sql-tap/gh2140-trans.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(10)
>  
>  box.execute("DROP TABLE IF EXISTS t1")
> @@ -29,7 +29,7 @@ test:do_execsql_test('rollback1_check',
>  
>  for _, verb in ipairs({'ROLLBACK', 'ABORT'}) do
>      box.execute('DELETE FROM t2')
> -    answer = "/Duplicate key exists in unique index 'unique_unnamed_T1_2' in space 'T1'/"
> +    local answer = "/Duplicate key exists in unique index 'unique_unnamed_T1_2' in space 'T1'/"
>      test:do_catchsql_test('insert1_'..verb,
>                            [[START TRANSACTION;
>                              INSERT INTO t2 VALUES (20, 2, 2);
> diff --git a/test/sql-tap/gh2168-temp-tables.test.lua b/test/sql-tap/gh2168-temp-tables.test.lua
> index 37db002a4..02b6b30b5 100755
> --- a/test/sql-tap/gh2168-temp-tables.test.lua
> +++ b/test/sql-tap/gh2168-temp-tables.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  test:do_catchsql_test(
> diff --git a/test/sql-tap/gh2250-trigger-chain-limit.test.lua b/test/sql-tap/gh2250-trigger-chain-limit.test.lua
> index 0a8a6c58d..d3e90539a 100755
> --- a/test/sql-tap/gh2250-trigger-chain-limit.test.lua
> +++ b/test/sql-tap/gh2250-trigger-chain-limit.test.lua
> @@ -1,18 +1,18 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(8)
>  
>  for _, table_count in ipairs({30, 31}) do
>      -- Clean up, create tables, add entries
>      for i = 1,table_count do
>          -- First table for uniform triggers check
> -        drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';'
> +        local drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';'
>          box.execute(drop_string)
>  
> -        create_string = 'CREATE TABLE t' .. i .. ' (s1 INT UNIQUE, s2 INT, s3 INT PRIMARY KEY);'
> +        local create_string = 'CREATE TABLE t' .. i .. ' (s1 INT UNIQUE, s2 INT, s3 INT PRIMARY KEY);'
>          box.execute(create_string)
>  
> -        insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ', 0);'
> +        local insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ', 0);'
>          box.execute(insert_string)
>  
>          -- Second table for triggers mixture check
> @@ -28,7 +28,7 @@ for _, table_count in ipairs({30, 31}) do
>  
>      -- And ON DELETE|UPDATE|INSERT triggers
>      for i = 1,table_count-1 do
> -        create_string = 'CREATE TRIGGER td' .. i
> +        local create_string = 'CREATE TRIGGER td' .. i
>          create_string = create_string .. ' BEFORE DELETE ON t' .. i
>              .. ' FOR EACH ROW '
>          create_string = create_string .. ' BEGIN DELETE FROM t' .. i+1
> @@ -73,8 +73,8 @@ for _, table_count in ipairs({30, 31}) do
>          box.execute(create_string)
>      end
>  
> -    function check(sql)
> -        msg = ''
> +    local function check(sql)
> +        local msg = ''
>          local _, msg = pcall(function () test:execsql(sql) end)
>          msg = tostring(msg)
>          test:do_test(sql,
> diff --git a/test/sql-tap/gh2259-in-stmt-trans.test.lua b/test/sql-tap/gh2259-in-stmt-trans.test.lua
> index 6bd055074..10eaaaaa0 100755
> --- a/test/sql-tap/gh2259-in-stmt-trans.test.lua
> +++ b/test/sql-tap/gh2259-in-stmt-trans.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(20)
>  
>  box.execute("DROP TABLE IF EXISTS t1")
> diff --git a/test/sql-tap/gh2548-select-compound-limit.test.lua b/test/sql-tap/gh2548-select-compound-limit.test.lua
> index 76769d6ae..7ddf5b9f6 100755
> --- a/test/sql-tap/gh2548-select-compound-limit.test.lua
> +++ b/test/sql-tap/gh2548-select-compound-limit.test.lua
> @@ -1,29 +1,29 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(9)
>  
>  -- box.cfg{wal_mode='none'}
>  
> -table_count = 31
> +local table_count = 31
>  
> -select_string_last = ''
> +local select_string_last = ''
>  
>  for _, term in ipairs({'UNION', 'UNION ALL', 'INTERSECT', 'EXCEPT'}) do
> -    select_string = ''
> +    local select_string = ''
>      test:do_test("Positive COMPOUND "..term,
>                   function()
>                       for i = 1,table_count do
> -                         drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';\n'
> +                         local drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';\n'
>                           test:execsql(drop_string)
>                       end
>  
>                       for i = 1,table_count do
> -                         create_string = 'CREATE TABLE t' .. i .. ' (s1 int primary key, s2 int);\n'
> +                         local create_string = 'CREATE TABLE t' .. i .. ' (s1 int primary key, s2 int);\n'
>                           test:execsql(create_string)
>                       end
>  
>                       for i = 1,table_count do
> -                         insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ');\n'
> +                         local insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ');\n'
>                           test:execsql(insert_string)
>                       end
>  
> diff --git a/test/sql-tap/hexlit.test.lua b/test/sql-tap/hexlit.test.lua
> index 220aa9117..a3cbeaa07 100755
> --- a/test/sql-tap/hexlit.test.lua
> +++ b/test/sql-tap/hexlit.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(128)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/icu.test.lua b/test/sql-tap/icu.test.lua
> index ad37feba3..4e25ba7c5 100755
> --- a/test/sql-tap/icu.test.lua
> +++ b/test/sql-tap/icu.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(0)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/identifier-characters.test.lua b/test/sql-tap/identifier-characters.test.lua
> index 27ed2f889..7b257921d 100755
> --- a/test/sql-tap/identifier-characters.test.lua
> +++ b/test/sql-tap/identifier-characters.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> -identifier = require("identifier")
> +local test = require("sqltester")
> +local identifier = require("identifier")
>  test:plan(9)
>  
>  local test_prefix = "identifier_char-"
> diff --git a/test/sql-tap/identifier_case.test.lua b/test/sql-tap/identifier_case.test.lua
> index 2a00626fc..84b6078fd 100755
> --- a/test/sql-tap/identifier_case.test.lua
> +++ b/test/sql-tap/identifier_case.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(73)
>  
>  local test_prefix = "identifier_case-"
> diff --git a/test/sql-tap/in1.test.lua b/test/sql-tap/in1.test.lua
> index 570cc1779..e889844dc 100755
> --- a/test/sql-tap/in1.test.lua
> +++ b/test/sql-tap/in1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(80)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/in2.test.lua b/test/sql-tap/in2.test.lua
> index 5782eab0c..dcdf4b0ed 100755
> --- a/test/sql-tap/in2.test.lua
> +++ b/test/sql-tap/in2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1999)
>  
>  --!./tcltestrunner.lua
> @@ -29,7 +29,7 @@ test:do_execsql_test(
>          -- </in2-1>
>      })
>  
> -N = 2000
> +local N = 2000
>  -- MUST_WORK_TEST
>  test:do_test(
>      "in2-2",
> diff --git a/test/sql-tap/in3.test.lua b/test/sql-tap/in3.test.lua
> index a6d842962..7358f0a20 100755
> --- a/test/sql-tap/in3.test.lua
> +++ b/test/sql-tap/in3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(28)
>  
>  --!./tcltestrunner.lua
> @@ -27,7 +27,7 @@ test:plan(28)
>  -- implementation of the sql statement passed as a an argument.
>  --
>  local function nEphemeral(sql)
> -    nEph = 0
> +    local nEph = 0
>      for _, op in ipairs(test:execsql("EXPLAIN "..sql.."")) do
>          if (op == "OpenTEphemeral")
>   then
> diff --git a/test/sql-tap/in4.test.lua b/test/sql-tap/in4.test.lua
> index 5c01ccdab..7374f926e 100755
> --- a/test/sql-tap/in4.test.lua
> +++ b/test/sql-tap/in4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(52)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/in5.test.lua b/test/sql-tap/in5.test.lua
> index b4e6f8dae..a4972fc10 100755
> --- a/test/sql-tap/in5.test.lua
> +++ b/test/sql-tap/in5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(22)
>  
>  --!./tcltestrunner.lua
> @@ -16,7 +16,7 @@ test:plan(22)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "in5"
> +local testprefix = "in5"
>  test:do_execsql_test(
>      "in5-1.1",
>      [[
> diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua
> index ce66b7c1e..ea25727a4 100755
> --- a/test/sql-tap/index1.test.lua
> +++ b/test/sql-tap/index1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(73)
>  
>  --!./tcltestrunner.lua
> @@ -585,7 +585,7 @@ test:do_test(
>          for i = 1, 50, 1 do
>              test:execsql(string.format("INSERT INTO t3 VALUES('x%sx',%s,0.%s)", i, i, i))
>          end
> -        sql_search_count = 0
> +        local sql_search_count = 0
>          return X(381, "X!cmd", [=[["concat",[["execsql","SELECT c FROM t3 WHERE b==10"]],["sql_search_count"]]]=])
>      end, {
>          -- <index-11.1>
> @@ -1011,10 +1011,11 @@ end
>  test:do_test(
>      "index-22.1.0",
>      function()
> +        local format
>          format = {}
>          format[1] = { name = 'id', type = 'scalar'}
>          format[2] = { name = 'f2', type = 'scalar'}
> -        s = box.schema.create_space('T', {format = format})
> +        box.schema.create_space('T', {format = format})
>      end,
>      {})
>  
> diff --git a/test/sql-tap/index2.test.lua b/test/sql-tap/index2.test.lua
> index 5c0b4c1ee..04bbe8b10 100755
> --- a/test/sql-tap/index2.test.lua
> +++ b/test/sql-tap/index2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(7)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/index3.test.lua b/test/sql-tap/index3.test.lua
> index 6eb532411..909a184da 100755
> --- a/test/sql-tap/index3.test.lua
> +++ b/test/sql-tap/index3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/index4.test.lua b/test/sql-tap/index4.test.lua
> index 37c0569eb..4ea713a58 100755
> --- a/test/sql-tap/index4.test.lua
> +++ b/test/sql-tap/index4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(7)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(7)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "index4"
> +local testprefix = "index4"
>  test:do_execsql_test(
>      1.1,
>      [[
> diff --git a/test/sql-tap/index6.test.lua b/test/sql-tap/index6.test.lua
> index 15ae49245..501478ff5 100755
> --- a/test/sql-tap/index6.test.lua
> +++ b/test/sql-tap/index6.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(14)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/index7.test.lua b/test/sql-tap/index7.test.lua
> index c98f17218..de3589725 100755
> --- a/test/sql-tap/index7.test.lua
> +++ b/test/sql-tap/index7.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(12)
>  
>  --!./tcltestrunner.lua
> @@ -20,12 +20,6 @@ test:plan(12)
>  -- ["source",[["testdir"],"\/tester.tcl"]]
>  
>  
> --- Capture the output of a pragma in a TEMP table.
> ---
> -local function capture_pragma(db, tabname, sql)
> -    once = 1
> -end
> -
>  -- load_static_extension db wholenumber;
>  -- do_test index7-1.1 {
>  --   # Able to parse and manage partial indices
> diff --git a/test/sql-tap/insert1.test.lua b/test/sql-tap/insert1.test.lua
> index d28baf11a..75dbe92b0 100755
> --- a/test/sql-tap/insert1.test.lua
> +++ b/test/sql-tap/insert1.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> -yaml = require('yaml')
> +local test = require("sqltester")
> +local yaml = require('yaml')
>  test:plan(28)
>  
>  --!./tcltestrunner.lua
> @@ -307,7 +307,7 @@ test:do_execsql_test("insert-4.7", [[
>    -- if X(0, "X!capable", [["explain"]]) then
>      test:do_test("insert-5.3", function()
>        -- verify that a temporary table is used to copy t4 to t4
> -      x = test:execsql [[
> +      local x = test:execsql [[
>          EXPLAIN INSERT INTO t4 SELECT x+2 FROM t4;
>        ]]
>        return {test:lsearch(x, 'OpenTEphemeral') > 0} -- X(264, "X!cmd", [=[["expr","[lsearch $x OpenEphemeral]>0"]]=])
> @@ -342,7 +342,7 @@ test:do_execsql_test("insert-4.7", [[
>    -- if X(0, "X!capable", [["explain"]]) then
>      test:do_test("insert-5.7", function()
>        -- verify that no temporary table is used to copy test1 to t4
> -      x = test:execsql [[
> +      local x = test:execsql [[
>          EXPLAIN INSERT INTO t4 SELECT one FROM test1;
>        ]]
>        return {test:lsearch(x, 'OpenTemp') > 0} -- X(298, "X!cmd", [=[["expr","[lsearch $x OpenTemp]>0"]]=])
> diff --git a/test/sql-tap/insert3.test.lua b/test/sql-tap/insert3.test.lua
> index b92bc508e..6e1c2b0e0 100755
> --- a/test/sql-tap/insert3.test.lua
> +++ b/test/sql-tap/insert3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(18)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/intpkey.test.lua b/test/sql-tap/intpkey.test.lua
> index 684a24114..32baf6baf 100755
> --- a/test/sql-tap/intpkey.test.lua
> +++ b/test/sql-tap/intpkey.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(31)
>  
>  --!./tcltestrunner.lua
> @@ -371,7 +371,7 @@ test:do_execsql_test(
>  -- Do an SQL statement.  Append the search count to the end of the result.
>  --
>  local function count(sql)
> -    sql_search_count = 0
> +    local sql_search_count = 0
>      local r = test:execsql(sql)
>      table.insert(r, sql_search_count)
>      return r
> diff --git a/test/sql-tap/join.test.lua b/test/sql-tap/join.test.lua
> index 840b780a3..1fc968307 100755
> --- a/test/sql-tap/join.test.lua
> +++ b/test/sql-tap/join.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> -NULL = require('msgpack').NULL
> +local test = require("sqltester")
> +local NULL = require('msgpack').NULL
>  test:plan(92)
>  
>  --!./tcltestrunner.lua
> @@ -1059,7 +1059,7 @@ test:do_execsql_test(
>      ]])
>  
>  local function jointest(tn, nTbl, res)
> -    sql = "SELECT 1 FROM "..string.rep("t14,", (nTbl - 1)).." t14;"
> +    local sql = "SELECT 1 FROM "..string.rep("t14,", (nTbl - 1)).." t14;"
>      test:do_catchsql_test(tn, sql, res)
>      -- X(685, "X!cmd", [=[["uplevel",[["list","do_catchsql_test",["tn"],["sql"],["res"]]]]]=])
>  end
> diff --git a/test/sql-tap/join2.test.lua b/test/sql-tap/join2.test.lua
> index c61ffd84f..d5747ea9c 100755
> --- a/test/sql-tap/join2.test.lua
> +++ b/test/sql-tap/join2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(7)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/join3.test.lua b/test/sql-tap/join3.test.lua
> index 876b3121a..4aa8c94a3 100755
> --- a/test/sql-tap/join3.test.lua
> +++ b/test/sql-tap/join3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(129)
>  
>  --!./tcltestrunner.lua
> @@ -36,7 +36,7 @@ for N=1, bitmask_size do
>          function()
>              test:execsql("CREATE TABLE t"..N.."(x INT primary key);")
>              test:execsql(string.format("INSERT INTO t%s VALUES(%s)", N, N))
> -            sql = "SELECT * FROM t1"
> +            local sql = "SELECT * FROM t1"
>              -- for _ in X(0, "X!for", [=[["set i 2","$i<=$N","incr i"]]=]) do
>              for i=2,N do
>                  sql = sql .. ", t"..i..""
> @@ -56,12 +56,12 @@ for N=1, bitmask_size do
>      test:do_test(
>          "join3-2."..N,
>          function()
> -            sql = "SELECT * FROM t1"
> +            local sql = "SELECT * FROM t1"
>              --for _ in X(0, "X!for", [=[["set i 2","$i<=$N","incr i"]]=]) do
>              for i=2, N do
>                  sql = sql .. ", t"..i..""
>              end
> -            sep = "WHERE"
> +            local sep = "WHERE"
>              --for _ in X(0, "X!for", [=[["set i 1","$i<$N","incr i"]]=]) do
>              for i=1, N - 1 do
>                  sql = sql .. string.format(" %s t%s.x==t%s.x+1", sep, (i + 1), i)
> @@ -78,7 +78,7 @@ end
>  test:do_test(
>      "join3-3.1",
>      function()
> -        sql = "SELECT * FROM t1 AS t0, t1"
> +        local sql = "SELECT * FROM t1 AS t0, t1"
>          for i=2, bitmask_size do
>              sql = sql .. ", t"..i..""
>          end
> diff --git a/test/sql-tap/join4.test.lua b/test/sql-tap/join4.test.lua
> index 7c0e912f1..da64c006c 100755
> --- a/test/sql-tap/join4.test.lua
> +++ b/test/sql-tap/join4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(8)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/join5.test.lua b/test/sql-tap/join5.test.lua
> index c18be5230..8dd0b1eda 100755
> --- a/test/sql-tap/join5.test.lua
> +++ b/test/sql-tap/join5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(22)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/join6.test.lua b/test/sql-tap/join6.test.lua
> index f6342a6d9..9ccb8673c 100755
> --- a/test/sql-tap/join6.test.lua
> +++ b/test/sql-tap/join6.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(14)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/keyword1.test.lua b/test/sql-tap/keyword1.test.lua
> index e39b22087..4e5fc5fd8 100755
> --- a/test/sql-tap/keyword1.test.lua
> +++ b/test/sql-tap/keyword1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(184)
>  
>  --!./tcltestrunner.lua
> @@ -239,7 +239,7 @@ for _, kw in ipairs(kwlist) do
>  end
>  
>  for _, kw in ipairs(bannedkws) do
> -    query = 'CREATE TABLE '..kw..'(a INT PRIMARY KEY);'
> +    local query = 'CREATE TABLE '..kw..'(a INT PRIMARY KEY);'
>      if kw == 'end' or kw == 'match' or kw == 'release' or kw == 'rename' or
>         kw == 'replace' or kw == 'binary' or kw == 'character' or
>         kw == 'smallint' then
> diff --git a/test/sql-tap/like2.test.lua b/test/sql-tap/like2.test.lua
> index 45341f851..70917d1e5 100755
> --- a/test/sql-tap/like2.test.lua
> +++ b/test/sql-tap/like2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(282)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/like3.test.lua b/test/sql-tap/like3.test.lua
> index e7c25dba6..68e2b5642 100755
> --- a/test/sql-tap/like3.test.lua
> +++ b/test/sql-tap/like3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(7)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/limit.test.lua b/test/sql-tap/limit.test.lua
> index a7d1451f7..4871e43db 100755
> --- a/test/sql-tap/limit.test.lua
> +++ b/test/sql-tap/limit.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(113)
>  
>  --!./tcltestrunner.lua
> @@ -28,7 +28,7 @@ test:execsql [[
>  ]]
>  for i=1,32 do
>      --for _ in X(0, "X!for", [=[["set i 1","$i<=32","incr i"]]=]) do
> -    j = 0
> +    local j = 0
>      while bit.lshift(1, j) < i do
>      -- for _ in X(0, "X!for", [=[["set j 0","(1<<$j)<$i","incr j"]]=]) do
>          j = j + 1
> @@ -694,7 +694,7 @@ test:do_catchsql_test(
>  test:do_test(
>      "limit-10.1",
>      function()
> -        limit = 10
> +        local limit = 10
>          return test:execsql [[
>              SELECT x FROM t1 LIMIT 10;
>          ]]
> diff --git a/test/sql-tap/lua-tables.test.lua b/test/sql-tap/lua-tables.test.lua
> index 07e0f6a1e..fa10d886d 100755
> --- a/test/sql-tap/lua-tables.test.lua
> +++ b/test/sql-tap/lua-tables.test.lua
> @@ -1,22 +1,23 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(14)
>  
>  test:do_test(
>      "lua-tables-prepare-1",
>      function()
> +        local format, s
>          format = {}
>          format[1] = { name = 'id', type = 'scalar'}
>          format[2] = { name = 'f2', type = 'scalar'}
>          s = box.schema.create_space('t', {format = format})
> -        i = s:create_index('i', {parts={1, 'scalar'}})
> +        s:create_index('i', {parts={1, 'scalar'}})
>  
>          s:replace{1, 4}
>          s:replace{2, 2}
>          s:replace{3, 3}
>          s:replace{4, 3}
>  
> -        s1 = box.schema.create_space('t1')
> +        local s1 = box.schema.create_space('t1')
>          s1:create_index('i', {parts={1, 'scalar'}})
>          s1:replace{1, 1}
>      end,
> @@ -52,6 +53,7 @@ test:do_catchsql_test(
>  test:do_test(
>      "lua-tables-prepare-6",
>      function()
> +        local format, s
>          format = {{name = "CODE", type = "integer"},
>              {name = "NAME", type = "scalar"}}
>          s = box.schema.create_space("ELEMENT", {format = format})
> @@ -130,7 +132,7 @@ test:do_execsql_test(
>  test:do_test(
>      "lua-tables-prepare-10",
>      function()
> -        sp = box.schema.space.create("TEST", {
> +        local sp = box.schema.space.create("TEST", {
>              engine = 'memtx',
>              format = {
>                  { name = 'ID', type = 'unsigned' },
> @@ -165,7 +167,7 @@ test:do_eqp_test(
>  test:do_test(
>      "no-format-create-index-prep",
>      function()
> -        s = box.schema.create_space('T')
> +        box.schema.create_space('T')
>      end, {})
>  
>  test:do_catchsql_test(
> diff --git a/test/sql-tap/lua/sqltester.lua b/test/sql-tap/lua/sqltester.lua
> index 9b0218e63..169d2f271 100644
> --- a/test/sql-tap/lua/sqltester.lua
> +++ b/test/sql-tap/lua/sqltester.lua
> @@ -177,7 +177,7 @@ end
>  test.execsql = execsql
>  
>  local function catchsql(self, sql, expect)
> -    r = {pcall(execsql, self, sql) }
> +    local r = {pcall(execsql, self, sql) }
>      if r[1] == true then
>          r[1] = 0
>      else
> @@ -256,7 +256,7 @@ end
>  test.sortsql = sortsql
>  
>  local function catchsql2(self, sql)
> -    r = {pcall(execsql2, self, sql) }
> +    local r = {pcall(execsql2, self, sql) }
>      -- 0 means ok
>      -- 1 means not ok
>      r[1] = r[1] == true and 0 or 1
> @@ -271,7 +271,7 @@ test.catchsql2 = catchsql2
>  -- 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)
> +    local tr = execsql(self, "EXPLAIN "..sql)
>      for i=1,8 do
>          table.remove(tr,1)
>      end
> diff --git a/test/sql-tap/lua_sql.test.lua b/test/sql-tap/lua_sql.test.lua
> index 31c563f3a..b22f195ca 100755
> --- a/test/sql-tap/lua_sql.test.lua
> +++ b/test/sql-tap/lua_sql.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> -NULL = require('msgpack').NULL
> +local test = require("sqltester")
> +local NULL = require('msgpack').NULL
>  test:plan(24)
>  
>  test:do_test(
> @@ -51,7 +51,7 @@ for _, val in ipairs({
>          {result})
>  end
>  
> -from_sql_to_lua = {
> +_G.from_sql_to_lua = {
>      [1] = {1, 1},
>      [2] = {"1", 1},
>      [3] = {"1.5", 1.5},
> @@ -82,7 +82,7 @@ for i = 1, #from_sql_to_lua, 1 do
>          {1})
>  end
>  
> -from_lua_to_sql = {
> +_G.from_lua_to_sql = {
>      [1] = {1, 1},
>      [2] = {"1.5", 1.5},
>      [3] = {"'1'", "1"},
> diff --git a/test/sql-tap/minmax2.test.lua b/test/sql-tap/minmax2.test.lua
> index 707d1c4da..f3d608aab 100755
> --- a/test/sql-tap/minmax2.test.lua
> +++ b/test/sql-tap/minmax2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(49)
>  
>  --!./tcltestrunner.lua
> @@ -56,10 +56,12 @@ test:do_execsql_test(
>          -- </minmax2-1.0>
>      })
>  
> +_G.sql_search_count = 0
> +
>  test:do_test(
>      "minmax2-1.1",
>      function()
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql "SELECT min(x) FROM t1"
>      end, {
>          -- <minmax2-1.1>
> @@ -76,7 +78,7 @@ test:do_test(
>  test:do_test(
>      "minmax2-1.3",
>      function()
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql "SELECT max(x) FROM t1"
>      end, {
>          -- <minmax2-1.3>
> @@ -94,7 +96,7 @@ test:do_test(
>      "minmax2-1.5",
>      function()
>          test:execsql "CREATE INDEX t1i1 ON t1(x DESC)"
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql "SELECT min(x) FROM t1"
>      end, {
>          -- <minmax2-1.5>
> @@ -105,13 +107,13 @@ test:do_test(
>  test:do_test(
>      "minmax2-1.6",
>      function()
> -        return box.stat.sql().sql_search_count - sql_search_count
> +        return box.stat.sql().sql_search_count - _G.sql_search_count
>      end, 1)
>  
>  test:do_test(
>      "minmax2-1.7",
>      function()
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql "SELECT max(x) FROM t1"
>      end, {
>          -- <minmax2-1.7>
> @@ -122,13 +124,13 @@ test:do_test(
>  test:do_test(
>      "minmax2-1.8",
>      function()
> -        return box.stat.sql().sql_search_count - sql_search_count
> +        return box.stat.sql().sql_search_count - _G.sql_search_count
>      end, 0)
>  
>  test:do_test(
>      "minmax2-1.9",
>      function()
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql "SELECT max(y) FROM t1"
>      end, {
>          -- <minmax2-1.9>
> @@ -139,7 +141,7 @@ test:do_test(
>  test:do_test(
>      "minmax2-1.10",
>      function()
> -        return box.stat.sql().sql_search_count - sql_search_count
> +        return box.stat.sql().sql_search_count - _G.sql_search_count
>      end, 19)
>  
>  test:do_test(
> @@ -149,7 +151,7 @@ test:do_test(
>              CREATE TABLE t2(a INTEGER PRIMARY KEY, b INT );
>              INSERT INTO t2 SELECT x, y FROM t1;
>          ]]
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql "SELECT min(a) FROM t2"
>      end, {
>          -- <minmax2-2.0>
> @@ -160,13 +162,13 @@ test:do_test(
>  test:do_test(
>      "minmax2-2.1",
>      function()
> -        return box.stat.sql().sql_search_count - sql_search_count
> +        return box.stat.sql().sql_search_count - _G.sql_search_count
>      end, 0)
>  
>  test:do_test(
>      "minmax2-2.2",
>      function()
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql "SELECT max(a) FROM t2"
>      end, {
>          -- <minmax2-2.2>
> @@ -177,7 +179,7 @@ test:do_test(
>  test:do_test(
>      "minmax2-2.3",
>      function()
> -        return box.stat.sql().sql_search_count - sql_search_count
> +        return box.stat.sql().sql_search_count - _G.sql_search_count
>      end, 0)
>  
>  test:do_test(
> @@ -186,7 +188,7 @@ test:do_test(
>          test:execsql "INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)"
>  
>  
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql "SELECT max(a) FROM t2"
>      end, {
>          -- <minmax2-3.0>
> @@ -197,7 +199,7 @@ test:do_test(
>  test:do_test(
>      "minmax2-3.1",
>      function()
> -        return box.stat.sql().sql_search_count - sql_search_count
> +        return box.stat.sql().sql_search_count - _G.sql_search_count
>      end, 0)
>  
>  test:do_test(
> @@ -206,7 +208,7 @@ test:do_test(
>          test:execsql "INSERT INTO t2 VALUES((SELECT max(a) FROM t2)+1,999)"
>  
>  
> -        sql_search_count = box.stat.sql().sql_search_count
> +        _G.sql_search_count = box.stat.sql().sql_search_count
>          return test:execsql " SELECT b FROM t2 WHERE a=(SELECT max(a) FROM t2) "
>  
>  
> @@ -220,7 +222,7 @@ test:do_test(
>  test:do_test(
>      "minmax2-3.3",
>      function()
> -        return box.stat.sql().sql_search_count - sql_search_count
> +        return box.stat.sql().sql_search_count - _G.sql_search_count
>      end, 1)
>  
>  test:do_execsql_test(
> diff --git a/test/sql-tap/minmax3.test.lua b/test/sql-tap/minmax3.test.lua
> index f1d9efc5a..90f4f6020 100755
> --- a/test/sql-tap/minmax3.test.lua
> +++ b/test/sql-tap/minmax3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(47)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/minmax4.test.lua b/test/sql-tap/minmax4.test.lua
> index b600c9bfe..1674a7753 100755
> --- a/test/sql-tap/minmax4.test.lua
> +++ b/test/sql-tap/minmax4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(21)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/misc1.test.lua b/test/sql-tap/misc1.test.lua
> index c0136d04c..c9b9cd7a8 100755
> --- a/test/sql-tap/misc1.test.lua
> +++ b/test/sql-tap/misc1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(59)
>  
>  --!./tcltestrunner.lua
> @@ -583,7 +583,7 @@ if (0 > 0) then
>              test:execsql("START TRANSACTION")
>              test:execsql("UPDATE t1 SET a=0 WHERE 0")
>              sql("db2", "test.db")
> -            rc = X(371, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
> +            local rc = X(371, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
>              return table.insert(rc,msg) or rc
>              -- v2 result: {1 {database is locked}}
>          end, {
> @@ -596,7 +596,7 @@ if (0 > 0) then
>          "misc1-11.2",
>          function()
>              test:execsql("COMMIT")
> -            rc = X(377, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
> +            local rc = X(377, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
>              db2("close")
>              return table.insert(rc,msg) or rc
>          end, {
> diff --git a/test/sql-tap/misc3.test.lua b/test/sql-tap/misc3.test.lua
> index d0e45e872..f27e83745 100755
> --- a/test/sql-tap/misc3.test.lua
> +++ b/test/sql-tap/misc3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  local json = require("json")
>  test:plan(34)
>  
> diff --git a/test/sql-tap/misc5.test.lua b/test/sql-tap/misc5.test.lua
> index 2725e6782..357c36ff6 100755
> --- a/test/sql-tap/misc5.test.lua
> +++ b/test/sql-tap/misc5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(31)
>  
>  --!./tcltestrunner.lua
> @@ -289,6 +289,7 @@ test:do_test(
>      "misc5-7.1",
>      function()
>          test:execsql "CREATE TABLE t1(x  INT primary key)"
> +        local sql, tail
>          sql = "INSERT INTO t1 VALUES("
>          tail = ""
>          for i = 0, 199, 1 do
> diff --git a/test/sql-tap/null.test.lua b/test/sql-tap/null.test.lua
> index 93589754c..a1f33f5ad 100755
> --- a/test/sql-tap/null.test.lua
> +++ b/test/sql-tap/null.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(45)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/numcast.test.lua b/test/sql-tap/numcast.test.lua
> index 3161e48fa..18c6adc9e 100755
> --- a/test/sql-tap/numcast.test.lua
> +++ b/test/sql-tap/numcast.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(31)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/offset1.test.lua b/test/sql-tap/offset1.test.lua
> index 451694af2..194c3a735 100755
> --- a/test/sql-tap/offset1.test.lua
> +++ b/test/sql-tap/offset1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(22)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/orderby1.test.lua b/test/sql-tap/orderby1.test.lua
> index 51e8d301f..cc65360c4 100755
> --- a/test/sql-tap/orderby1.test.lua
> +++ b/test/sql-tap/orderby1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(35)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(35)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "orderby1"
> +local testprefix = "orderby1"
>  -- MUST_WORK_TEST
>  -- # Generate test data for a join.  Verify that the join gets the
>  -- # correct answer.
> diff --git a/test/sql-tap/orderby2.test.lua b/test/sql-tap/orderby2.test.lua
> index 3cee73f25..03f5b3cee 100755
> --- a/test/sql-tap/orderby2.test.lua
> +++ b/test/sql-tap/orderby2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(9)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(9)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "orderby2"
> +local testprefix = "orderby2"
>  -- Generate test data for a join.  Verify that the join gets the
>  -- correct answer.
>  --
> diff --git a/test/sql-tap/orderby3.test.lua b/test/sql-tap/orderby3.test.lua
> index 48373849a..6cbccf2e7 100755
> --- a/test/sql-tap/orderby3.test.lua
> +++ b/test/sql-tap/orderby3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(15)
>  
>  --!./tcltestrunner.lua
> @@ -20,7 +20,7 @@ test:plan(15)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "orderby3"
> +local testprefix = "orderby3"
>  -- Generate test data for a join.  Verify that the join gets the
>  -- correct answer.
>  --
> diff --git a/test/sql-tap/orderby4.test.lua b/test/sql-tap/orderby4.test.lua
> index 774a19246..87f011e0a 100755
> --- a/test/sql-tap/orderby4.test.lua
> +++ b/test/sql-tap/orderby4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(6)
>  
>  --!./tcltestrunner.lua
> @@ -21,7 +21,7 @@ test:plan(6)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "orderby4"
> +local testprefix = "orderby4"
>  -- Generate test data for a join.  Verify that the join gets the
>  -- correct answer.
>  --
> diff --git a/test/sql-tap/orderby5.test.lua b/test/sql-tap/orderby5.test.lua
> index c7c09bc07..0a1b69cfd 100755
> --- a/test/sql-tap/orderby5.test.lua
> +++ b/test/sql-tap/orderby5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(10)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(10)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "orderby5"
> +local testprefix = "orderby5"
>  -- Generate test data for a join.  Verify that the join gets the
>  -- correct answer.
>  --
> diff --git a/test/sql-tap/orderby6.test.lua b/test/sql-tap/orderby6.test.lua
> index d909f3493..cc8879ae6 100755
> --- a/test/sql-tap/orderby6.test.lua
> +++ b/test/sql-tap/orderby6.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(34)
>  
>  --!./tcltestrunner.lua
> @@ -26,7 +26,7 @@ test:plan(34)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "orderby6"
> +local testprefix = "orderby6"
>  -- Run all tests twice.  Once with a normal table and a second time
>  -- with a WITHOUT ROWID table
>  --
> diff --git a/test/sql-tap/orderby8.test.lua b/test/sql-tap/orderby8.test.lua
> index 52f125755..dc0101769 100755
> --- a/test/sql-tap/orderby8.test.lua
> +++ b/test/sql-tap/orderby8.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(203)
>  
>  --!./tcltestrunner.lua
> @@ -22,7 +22,7 @@ test:plan(203)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "orderby8"
> +local testprefix = "orderby8"
>  
>  local rs = ""
>  test:do_test(
> diff --git a/test/sql-tap/orderby9.test.lua b/test/sql-tap/orderby9.test.lua
> index acafb2840..1fad72ddd 100755
> --- a/test/sql-tap/orderby9.test.lua
> +++ b/test/sql-tap/orderby9.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> @@ -22,7 +22,7 @@ test:plan(4)
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
>  
> -testprefix = "orderby9"
> +local testprefix = "orderby9"
>  test:do_execsql_test(
>      "setup",
>      [[
> diff --git a/test/sql-tap/position.test.lua b/test/sql-tap/position.test.lua
> index e0455abc9..506efe0f4 100755
> --- a/test/sql-tap/position.test.lua
> +++ b/test/sql-tap/position.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(80)
>  
>  test:do_test(
> diff --git a/test/sql-tap/pragma.test.lua b/test/sql-tap/pragma.test.lua
> index d6f8b544d..737cf821f 100755
> --- a/test/sql-tap/pragma.test.lua
> +++ b/test/sql-tap/pragma.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  
>  test:plan(10)
>  
> diff --git a/test/sql-tap/printf2.test.lua b/test/sql-tap/printf2.test.lua
> index be6564c6b..992b2bb1b 100755
> --- a/test/sql-tap/printf2.test.lua
> +++ b/test/sql-tap/printf2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(22)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/quote.test.lua b/test/sql-tap/quote.test.lua
> index edca165fd..65cda3db9 100755
> --- a/test/sql-tap/quote.test.lua
> +++ b/test/sql-tap/quote.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(8)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/randexpr1.test.lua b/test/sql-tap/randexpr1.test.lua
> index a045e18c0..38a4aad28 100755
> --- a/test/sql-tap/randexpr1.test.lua
> +++ b/test/sql-tap/randexpr1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2600)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/resolver01.test.lua b/test/sql-tap/resolver01.test.lua
> index 315c892ac..66db0f004 100755
> --- a/test/sql-tap/resolver01.test.lua
> +++ b/test/sql-tap/resolver01.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(27)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/select1.test.lua b/test/sql-tap/select1.test.lua
> index d8be38da6..0e7c5a318 100755
> --- a/test/sql-tap/select1.test.lua
> +++ b/test/sql-tap/select1.test.lua
> @@ -1,8 +1,8 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(173)
>  
> -function set_full_column_names(value)
> +local function set_full_column_names(value)
>      box.space._session_settings:update('sql_full_column_names', {
>          {'=', 2, value}
>      })
> @@ -219,7 +219,7 @@ test:do_execsql_test(
>          -- </select1-1.13>
>      })
>  
> -long = "This is a string that is too big to fit inside a NBFS buffer"
> +local long = "This is a string that is too big to fit inside a NBFS buffer"
>  test:do_execsql_test(
>      "select1-2.0",
>  string.format([[
> @@ -1051,7 +1051,7 @@ test:do_test(
>      function()
>          set_full_column_names(true)
>          local msg
> -        v = pcall( function ()
> +        local v = pcall( function ()
>                  msg = test:execsql2 "SELECT test1.f1+F2 FROM test1 ORDER BY f2"
>              end)
>          v = v == true and {0} or {1}
> @@ -1178,7 +1178,7 @@ test:do_execsql2_test(
>  test:do_test(
>      "select1-6.9.7",
>      function()
> -        x = test:execsql2 [[
> +        local x = test:execsql2 [[
>              SELECT * FROM test1 a, (select 5, 6) LIMIT 1
>          ]]
>          for i, tmp in ipairs(x) do
> @@ -1197,7 +1197,7 @@ test:do_test(
>  test:do_test(
>      "select1-6.9.8",
>      function()
> -        x = test:execsql2 [[
> +        local x = test:execsql2 [[
>              SELECT * FROM test1 a, (select 5 AS x, 6 AS y) AS b LIMIT 1
>          ]]
>          for i, tmp in ipairs(x) do
> diff --git a/test/sql-tap/select2.test.lua b/test/sql-tap/select2.test.lua
> index 24fad2149..96b29937f 100755
> --- a/test/sql-tap/select2.test.lua
> +++ b/test/sql-tap/select2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(16)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/select3.test.lua b/test/sql-tap/select3.test.lua
> index 0b0b9cc73..258ac8000 100755
> --- a/test/sql-tap/select3.test.lua
> +++ b/test/sql-tap/select3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(38)
>  
>  --!./tcltestrunner.lua
> @@ -29,7 +29,7 @@ test:do_test("select3-1.0", function()
>      START TRANSACTION;
>    ]]
>    for i = 1, 32-1 do -- in X(0, "X!for", [=[["set i 1","$i<32","incr i"]]=]) do
> -     j = 0
> +     local j = 0
>       while bit.lshift(1, j) < i do
>  	-- for _ in X(0, "X!for", [=[["set j 0","(1<<$j)<$i","incr j"]]=]) do
>  	j = j + 1
> diff --git a/test/sql-tap/select4.test.lua b/test/sql-tap/select4.test.lua
> index f7a320438..abc95a24f 100755
> --- a/test/sql-tap/select4.test.lua
> +++ b/test/sql-tap/select4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(105)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/select5.test.lua b/test/sql-tap/select5.test.lua
> index d34de3139..d531cbcf8 100755
> --- a/test/sql-tap/select5.test.lua
> +++ b/test/sql-tap/select5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(46)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/select6.test.lua b/test/sql-tap/select6.test.lua
> index 380fd67c1..47c2ff5ef 100755
> --- a/test/sql-tap/select6.test.lua
> +++ b/test/sql-tap/select6.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(88)
>  
>  --!./tcltestrunner.lua
> @@ -23,7 +23,7 @@ test:plan(88)
>  -- Omit this whole file if the library is build without subquery support.
>  
>  
> -testprefix = "select6"
> +local testprefix = "select6"
>  test:do_test(
>      "select6-1.0",
>      function()
> @@ -905,7 +905,7 @@ test:do_execsql_test(
>          CREATE TABLE k(o  INT primary key);
>      ]])
>  
> -err = { 1, "SELECTs to the left and right of UNION ALL do not have the same number of result columns" }
> +local err = { 1, "SELECTs to the left and right of UNION ALL do not have the same number of result columns" }
>  test:do_execsql_test(
>      10.2,
>      [[
> diff --git a/test/sql-tap/select7.test.lua b/test/sql-tap/select7.test.lua
> index e1e43c557..67edc5db3 100755
> --- a/test/sql-tap/select7.test.lua
> +++ b/test/sql-tap/select7.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(18)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(18)
>  -- $Id: select7.test,v 1.11 2007/09/12 17:01:45 danielk1977 Exp $
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "select7"
> +local testprefix = "select7"
>  -- A 3-way INTERSECT.  Ticket #875
>  test:do_execsql_test(
>      "select7-1.1",
> @@ -171,7 +171,7 @@ test:do_catchsql_test(
>  -- hardcoded define from src
>  -- 30 is default value
>  local SQL_MAX_COMPOUND_SELECT = 30
> -sql = "SELECT 0"
> +local sql = "SELECT 0"
>  for i = 0, SQL_MAX_COMPOUND_SELECT + 1, 1 do
>      sql = sql .. " UNION ALL SELECT "..i..""
>  end
> diff --git a/test/sql-tap/select8.test.lua b/test/sql-tap/select8.test.lua
> index 9684299fb..c1bdd93a2 100755
> --- a/test/sql-tap/select8.test.lua
> +++ b/test/sql-tap/select8.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> @@ -37,7 +37,7 @@ local result = test:execsql [[
>      GROUP BY LOWER(artist)      
>  ]]
>  
> -function subrange(t, first, last)
> +local function subrange(t, first, last)
>      local sub = {}
>      for i=first,last do
>          sub[#sub + 1] = t[i]
> diff --git a/test/sql-tap/select9.test.lua b/test/sql-tap/select9.test.lua
> index 1ae16a658..4f7da84e2 100755
> --- a/test/sql-tap/select9.test.lua
> +++ b/test/sql-tap/select9.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(21157)
>  -- it is bad idea to store 20k positive test results in git
>  test.silent = true
> @@ -47,11 +47,11 @@ test.silent = true
>  --   pass to [do_test] for each individual LIMIT OFFSET test case.
>  --
>  
> -function trim(s)
> +local function trim(s)
>      return s:match "^%s*(.-)%s*$"
>  end
>  
> -function subrange(t, first, last)
> +local function subrange(t, first, last)
>      local sub = {}
>      for i=first,last do
>          sub[#sub + 1] = t[i]
> diff --git a/test/sql-tap/selectA.test.lua b/test/sql-tap/selectA.test.lua
> index 5cc69ef61..a608ab093 100755
> --- a/test/sql-tap/selectA.test.lua
> +++ b/test/sql-tap/selectA.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(194)
>  
>  --!./tcltestrunner.lua
> @@ -25,7 +25,7 @@ test:plan(194)
>  -- $Id: selectA.test,v 1.6 2008/08/21 14:24:29 drh Exp $
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "selectA"
> +local testprefix = "selectA"
>  
>  
>  test:do_execsql_test(
> diff --git a/test/sql-tap/selectB.test.lua b/test/sql-tap/selectB.test.lua
> index 56d4b9d1b..b56403ce5 100755
> --- a/test/sql-tap/selectB.test.lua
> +++ b/test/sql-tap/selectB.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(162)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/selectC.test.lua b/test/sql-tap/selectC.test.lua
> index b0e751ac5..20a0203a6 100755
> --- a/test/sql-tap/selectC.test.lua
> +++ b/test/sql-tap/selectC.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(18)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/selectE.test.lua b/test/sql-tap/selectE.test.lua
> index 32c3d6a06..fb1bc8794 100755
> --- a/test/sql-tap/selectE.test.lua
> +++ b/test/sql-tap/selectE.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(7)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/selectF.test.lua b/test/sql-tap/selectF.test.lua
> index 4cc5af137..dbd9dfdad 100755
> --- a/test/sql-tap/selectF.test.lua
> +++ b/test/sql-tap/selectF.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  --!./tcltestrunner.lua
> @@ -20,7 +20,7 @@ test:plan(2)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "selectF"
> +local testprefix = "selectF"
>  test:do_execsql_test(
>      1,
>      [[
> diff --git a/test/sql-tap/selectG.test.lua b/test/sql-tap/selectG.test.lua
> index 0ca066d1c..a9c7d9fb6 100755
> --- a/test/sql-tap/selectG.test.lua
> +++ b/test/sql-tap/selectG.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(1)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "selectG"
> +local testprefix = "selectG"
>  -- Do an INSERT with a VALUES clause that contains 100,000 entries.  Verify
>  -- that this insert happens quickly (in less than 10 seconds).  Actually, the
>  -- insert will normally happen in less than 0.5 seconds on a workstation, but
> diff --git a/test/sql-tap/sort.test.lua b/test/sql-tap/sort.test.lua
> index 18bfd443d..065f648b7 100755
> --- a/test/sql-tap/sort.test.lua
> +++ b/test/sql-tap/sort.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(60)
>  
>  --!./tcltestrunner.lua
> @@ -794,7 +794,7 @@ box.internal.sql_create_function("cksum", cksum)
>              "sort-14."..tn,
>              function()
>                  sql_test_control("sql_TESTCTRL_SORTER_MMAP", "db", mmap_limit)
> -                prev = ""
> +                local prev = ""
>                  X(536, "X!cmd", [=[["db","eval"," SELECT * FROM t11 ORDER BY b ","\n         if {$b != [cksum $a]} {error \"checksum failed\"}\n         if {[string compare $b $prev] < 0} {error \"sort failed\"}\n         set prev $b\n       "]]=])
>                  return X(541, "X!cmd", [=[["set","",""]]=])
>              end, {
> @@ -818,6 +818,7 @@ box.internal.sql_create_function("cksum", cksum)
>          reset_db()
>          sql_test_control("sql_TESTCTRL_SORTER_MMAP", "db", mmap_limit)
>          test:execsql(string.format("PRAGMA temp_store = %s; PRAGMA threads = '%s'", tmpstore, nWorker))
> +        local ten, one
>          ten = string.rep("X", 10300)
>          one = string.rep("y", 200)
>          if softheaplimit then
> diff --git a/test/sql-tap/sql-errors.test.lua b/test/sql-tap/sql-errors.test.lua
> index 5ec94bfe3..469193a2b 100755
> --- a/test/sql-tap/sql-errors.test.lua
> +++ b/test/sql-tap/sql-errors.test.lua
> @@ -1,15 +1,16 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(72)
>  
>  test:execsql([[
>  	CREATE TABLE t0 (i INT PRIMARY KEY, a INT);
>  	CREATE VIEW v0 AS SELECT * FROM t0;
>  ]])
> +local format, s0
>  format = {}
>  for i = 1, 2001 do format[i] = {name = 'A' .. i, type = 'unsigned'} end
>  s0 = box.schema.space.create('S0', {format = format})
> -i0 = s0:create_index('I0')
> +s0:create_index('I0')
>  
>  test:do_catchsql_test(
>  	"sql-errors-1.1",
> @@ -21,7 +22,7 @@ test:do_catchsql_test(
>  		-- </sql-errors-1.1>
>  	})
>  
> -create_statement = 'CREATE TABLE t2 (i INT PRIMARY KEY'
> +local create_statement = 'CREATE TABLE t2 (i INT PRIMARY KEY'
>  for i = 1, 2001 do
>  	create_statement = create_statement .. ', s' .. i .. ' INT'
>  end
> @@ -156,7 +157,7 @@ test:do_catchsql_test(
>  		-- </sql-errors-1.14>
>  	})
>  
> -select_statement = 'SELECT i FROM t0 WHERE i = 0'
> +local select_statement = 'SELECT i FROM t0 WHERE i = 0'
>  for i = 1, 200 do
>  	select_statement = select_statement .. ' OR i = ' .. i
>  end
> @@ -337,7 +338,7 @@ test:do_catchsql_test(
>  		-- </sql-errors-1.29>
>  	})
>  
> -create_index_statement = 'CREATE INDEX i30 on t0(i'..string.rep(', i', 2000)..');'
> +local create_index_statement = 'CREATE INDEX i30 on t0(i'..string.rep(', i', 2000)..');'
>  
>  test:do_catchsql_test(
>  	"sql-errors-1.30",
> @@ -348,7 +349,7 @@ test:do_catchsql_test(
>  		-- </sql-errors-1.30>
>  	})
>  
> -update_statement = 'UPDATE s0 SET a1 = a1 + 1'
> +local update_statement = 'UPDATE s0 SET a1 = a1 + 1'
>  for i = 2, 2001 do
>  	update_statement = update_statement .. ', a' .. i .. ' = a' .. i .. ' + 1'
>  end
> diff --git a/test/sql-tap/start-transaction.test.lua b/test/sql-tap/start-transaction.test.lua
> index 6d6b00b26..0ca6b632c 100755
> --- a/test/sql-tap/start-transaction.test.lua
> +++ b/test/sql-tap/start-transaction.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(21)
>  
>  -----------------------------------------------------------------
> diff --git a/test/sql-tap/subquery.test.lua b/test/sql-tap/subquery.test.lua
> index e0771825e..f57a22624 100755
> --- a/test/sql-tap/subquery.test.lua
> +++ b/test/sql-tap/subquery.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(69)
>  
>  --!./tcltestrunner.lua
> @@ -643,7 +643,8 @@ test:do_execsql_test(
>  -- for a matching column name did not cause an otherwise static subquery
>  -- to become a dynamic (correlated) subquery.
>  --
> -callcnt = 0
> +
> +_G.callcnt = 0
>  test:do_test(
>      "subquery-5.1",
>      function()
> @@ -692,7 +693,7 @@ test:do_test(
>  test:do_test(
>      "subquery-6.1",
>      function()
> -        callcnt = 0
> +        _G.callcnt = 0
>          return test:execsql [[
>              SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=y)
>          ]]
> @@ -711,7 +712,7 @@ test:do_test(
>  test:do_test(
>      "subquery-6.3",
>      function()
> -        callcnt = 0
> +        _G.callcnt = 0
>          return test:execsql [[
>              SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=1)
>          ]]
> diff --git a/test/sql-tap/subquery2.test.lua b/test/sql-tap/subquery2.test.lua
> index 9d0ce218c..5cd1afa86 100755
> --- a/test/sql-tap/subquery2.test.lua
> +++ b/test/sql-tap/subquery2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(11)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(11)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "subquery2"
> +local testprefix = "subquery2"
>  
>  
>  test:do_test(
> diff --git a/test/sql-tap/subselect.test.lua b/test/sql-tap/subselect.test.lua
> index 84c0b38b0..b6a20948d 100755
> --- a/test/sql-tap/subselect.test.lua
> +++ b/test/sql-tap/subselect.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(30)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/substr.test.lua b/test/sql-tap/substr.test.lua
> index a9e656e6d..72224fd7b 100755
> --- a/test/sql-tap/substr.test.lua
> +++ b/test/sql-tap/substr.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(93)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua
> index 1b4ec1173..590dbafbd 100755
> --- a/test/sql-tap/table.test.lua
> +++ b/test/sql-tap/table.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(79)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-02a8e81d44.test.lua b/test/sql-tap/tkt-02a8e81d44.test.lua
> index b94f72e59..1ab0e175c 100755
> --- a/test/sql-tap/tkt-02a8e81d44.test.lua
> +++ b/test/sql-tap/tkt-02a8e81d44.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-31338dca7e.test.lua b/test/sql-tap/tkt-31338dca7e.test.lua
> index 905ae6649..6f11b0eb5 100755
> --- a/test/sql-tap/tkt-31338dca7e.test.lua
> +++ b/test/sql-tap/tkt-31338dca7e.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(11)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-385a5b56b9.test.lua b/test/sql-tap/tkt-385a5b56b9.test.lua
> index 653d68222..d10c3152e 100755
> --- a/test/sql-tap/tkt-385a5b56b9.test.lua
> +++ b/test/sql-tap/tkt-385a5b56b9.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(9)
>  
>  --!./tcltestrunner.lua
> @@ -17,7 +17,7 @@ test:plan(9)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-385a5b56b9"
> +local testprefix = "tkt-385a5b56b9"
>  test:do_execsql_test(
>      "1.0",
>      [[
> diff --git a/test/sql-tap/tkt-38cb5df375.test.lua b/test/sql-tap/tkt-38cb5df375.test.lua
> index a7587ef3a..1539005b8 100755
> --- a/test/sql-tap/tkt-38cb5df375.test.lua
> +++ b/test/sql-tap/tkt-38cb5df375.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(293)
>  
>  --!./tcltestrunner.lua
> @@ -321,7 +321,7 @@ for ii = 1, 9, 1 do
>  
>  end
>  for ii = 1, 7, 1 do
> -    jj = (7 - ii)
> +    local jj = (7 - ii)
>      test:do_execsql_test(
>          "tkt-38cb5df375.51."..ii,
>          [[
> diff --git a/test/sql-tap/tkt-3998683a16.test.lua b/test/sql-tap/tkt-3998683a16.test.lua
> index 9bc310358..44ce7087a 100755
> --- a/test/sql-tap/tkt-3998683a16.test.lua
> +++ b/test/sql-tap/tkt-3998683a16.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-3a77c9714e.test.lua b/test/sql-tap/tkt-3a77c9714e.test.lua
> index 8068adcb4..82225ce89 100755
> --- a/test/sql-tap/tkt-3a77c9714e.test.lua
> +++ b/test/sql-tap/tkt-3a77c9714e.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> @@ -21,7 +21,7 @@ test:plan(4)
>  -- ["source",[["testdir"],"\/tester.tcl"]]
>  
>  
> -testprefix = "tkt-3a77c9714e"
> +local testprefix = "tkt-3a77c9714e"
>  test:do_execsql_test(
>      1.1,
>      [[
> diff --git a/test/sql-tap/tkt-4a03edc4c8.test.lua b/test/sql-tap/tkt-4a03edc4c8.test.lua
> index cb7a982dc..1bbaed30b 100755
> --- a/test/sql-tap/tkt-4a03edc4c8.test.lua
> +++ b/test/sql-tap/tkt-4a03edc4c8.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-4c86b126f2.test.lua b/test/sql-tap/tkt-4c86b126f2.test.lua
> index 606a56add..51222cbdd 100755
> --- a/test/sql-tap/tkt-4c86b126f2.test.lua
> +++ b/test/sql-tap/tkt-4c86b126f2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-4dd95f6943.test.lua b/test/sql-tap/tkt-4dd95f6943.test.lua
> index 21d6a18ff..c1d862a9d 100755
> --- a/test/sql-tap/tkt-4dd95f6943.test.lua
> +++ b/test/sql-tap/tkt-4dd95f6943.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(319)
>  
>  --!./tcltestrunner.lua
> @@ -17,7 +17,7 @@ test:plan(319)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-4dd95f6943"
> +local testprefix = "tkt-4dd95f6943"
>  test:do_execsql_test(
>      1.0,
>      [[
> diff --git a/test/sql-tap/tkt-4ef7e3cfca.test.lua b/test/sql-tap/tkt-4ef7e3cfca.test.lua
> index ac8dd4bdd..9b02d42b7 100755
> --- a/test/sql-tap/tkt-4ef7e3cfca.test.lua
> +++ b/test/sql-tap/tkt-4ef7e3cfca.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(5)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(5)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-4ef7e3cfca"
> +local testprefix = "tkt-4ef7e3cfca"
>  
>  test:do_catchsql_test(
>      1.1,
> diff --git a/test/sql-tap/tkt-54844eea3f.test.lua b/test/sql-tap/tkt-54844eea3f.test.lua
> index 89d0d1218..042436c61 100755
> --- a/test/sql-tap/tkt-54844eea3f.test.lua
> +++ b/test/sql-tap/tkt-54844eea3f.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(3)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-54844eea3f"
> +local testprefix = "tkt-54844eea3f"
>  test:do_execsql_test(
>      "1.0",
>      [[
> diff --git a/test/sql-tap/tkt-752e1646fc.test.lua b/test/sql-tap/tkt-752e1646fc.test.lua
> index 9d198411a..a7c6978f8 100755
> --- a/test/sql-tap/tkt-752e1646fc.test.lua
> +++ b/test/sql-tap/tkt-752e1646fc.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-7a31705a7e6.test.lua b/test/sql-tap/tkt-7a31705a7e6.test.lua
> index 48c235c2d..fdd360662 100755
> --- a/test/sql-tap/tkt-7a31705a7e6.test.lua
> +++ b/test/sql-tap/tkt-7a31705a7e6.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-7bbfb7d442.test.lua b/test/sql-tap/tkt-7bbfb7d442.test.lua
> index bfddcd920..43537d229 100755
> --- a/test/sql-tap/tkt-7bbfb7d442.test.lua
> +++ b/test/sql-tap/tkt-7bbfb7d442.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(5)
>  
>  --!./tcltestrunner.lua
> @@ -20,7 +20,7 @@ test:plan(5)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-7bbfb7d442"
> +local testprefix = "tkt-7bbfb7d442"
>  -- MUST_WORK_TEST
>  if (1 > 0)
>   then
> diff --git a/test/sql-tap/tkt-80ba201079.test.lua b/test/sql-tap/tkt-80ba201079.test.lua
> index 53678eef5..296bfe074 100755
> --- a/test/sql-tap/tkt-80ba201079.test.lua
> +++ b/test/sql-tap/tkt-80ba201079.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(11)
>  
>  --!./tcltestrunner.lua
> @@ -22,7 +22,7 @@ test:plan(11)
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
>  
> -testprefix = "tkt-80ba201079"
> +local testprefix = "tkt-80ba201079"
>  test:do_test(
>      "tkt-80ba2-100",
>      function()
> diff --git a/test/sql-tap/tkt-80e031a00f.test.lua b/test/sql-tap/tkt-80e031a00f.test.lua
> index a0e6539e0..82769587b 100755
> --- a/test/sql-tap/tkt-80e031a00f.test.lua
> +++ b/test/sql-tap/tkt-80e031a00f.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(118)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-868145d012.test.lua b/test/sql-tap/tkt-868145d012.test.lua
> index 61e925c64..5c6abb8a7 100755
> --- a/test/sql-tap/tkt-868145d012.test.lua
> +++ b/test/sql-tap/tkt-868145d012.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-8c63ff0ec.test.lua b/test/sql-tap/tkt-8c63ff0ec.test.lua
> index 8e49db57d..776407ac2 100755
> --- a/test/sql-tap/tkt-8c63ff0ec.test.lua
> +++ b/test/sql-tap/tkt-8c63ff0ec.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> @@ -20,7 +20,7 @@ test:plan(3)
>  -- 
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-8c63ff0ec"
> +local testprefix = "tkt-8c63ff0ec"
>  test:do_execsql_test(
>      1.1,
>      [[
> diff --git a/test/sql-tap/tkt-91e2e8ba6f.test.lua b/test/sql-tap/tkt-91e2e8ba6f.test.lua
> index b12b6e0f3..c6d9a26d8 100755
> --- a/test/sql-tap/tkt-91e2e8ba6f.test.lua
> +++ b/test/sql-tap/tkt-91e2e8ba6f.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(7)
>  
>  --!./tcltestrunner.lua
> @@ -17,7 +17,7 @@ test:plan(7)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-91e2e8ba6f"
> +local testprefix = "tkt-91e2e8ba6f"
>  test:do_execsql_test(
>      1.1,
>      [[
> diff --git a/test/sql-tap/tkt-9a8b09f8e6.test.lua b/test/sql-tap/tkt-9a8b09f8e6.test.lua
> index ca3a5427a..8f305e444 100755
> --- a/test/sql-tap/tkt-9a8b09f8e6.test.lua
> +++ b/test/sql-tap/tkt-9a8b09f8e6.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(47)
>  
>  --!./tcltestrunner.lua
> @@ -20,7 +20,7 @@ test:plan(47)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-9a8b09f8e6"
> +local testprefix = "tkt-9a8b09f8e6"
>  -- MUST_WORK_TEST
>  if (0 > 0)
>   then
> diff --git a/test/sql-tap/tkt-a7b7803e.test.lua b/test/sql-tap/tkt-a7b7803e.test.lua
> index 14f05ebfd..8fadf4519 100755
> --- a/test/sql-tap/tkt-a7b7803e.test.lua
> +++ b/test/sql-tap/tkt-a7b7803e.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(8)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-a8a0d2996a.test.lua b/test/sql-tap/tkt-a8a0d2996a.test.lua
> index ddaeb60de..3b824106b 100755
> --- a/test/sql-tap/tkt-a8a0d2996a.test.lua
> +++ b/test/sql-tap/tkt-a8a0d2996a.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(12)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(12)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-a8a0d2996a"
> +local testprefix = "tkt-a8a0d2996a"
>  test:do_execsql_test(
>      1.0,
>      [[
> diff --git a/test/sql-tap/tkt-b1d3a2e531.test.lua b/test/sql-tap/tkt-b1d3a2e531.test.lua
> index 0cc7d7e59..f10f14a24 100755
> --- a/test/sql-tap/tkt-b1d3a2e531.test.lua
> +++ b/test/sql-tap/tkt-b1d3a2e531.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(11)
>  
>  --!./tcltestrunner.lua
> @@ -22,7 +22,7 @@ test:plan(11)
>  -- ["source",[["testdir"],"\/tester.tcl"]]
>  
>  
> -testprefix = "tkt-b1d3a2e531"
> +local testprefix = "tkt-b1d3a2e531"
>  
>  test:do_execsql_test(
>      1.1,
> diff --git a/test/sql-tap/tkt-b351d95f9.test.lua b/test/sql-tap/tkt-b351d95f9.test.lua
> index 9bdf573b3..8ece3aedb 100755
> --- a/test/sql-tap/tkt-b351d95f9.test.lua
> +++ b/test/sql-tap/tkt-b351d95f9.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-b75a9ca6b0.test.lua b/test/sql-tap/tkt-b75a9ca6b0.test.lua
> index dde6ab502..cc0374357 100755
> --- a/test/sql-tap/tkt-b75a9ca6b0.test.lua
> +++ b/test/sql-tap/tkt-b75a9ca6b0.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(20)
>  
>  --!./tcltestrunner.lua
> @@ -23,7 +23,7 @@ test:plan(20)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-b75a9ca6b0"
> +local testprefix = "tkt-b75a9ca6b0"
>  test:do_execsql_test(
>      1,
>      [[
> diff --git a/test/sql-tap/tkt-ba7cbfaedc.test.lua b/test/sql-tap/tkt-ba7cbfaedc.test.lua
> index 2aad10f2d..b214e9f0e 100755
> --- a/test/sql-tap/tkt-ba7cbfaedc.test.lua
> +++ b/test/sql-tap/tkt-ba7cbfaedc.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(19)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(19)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-ba7cbfaedc"
> +local testprefix = "tkt-ba7cbfaedc"
>  test:do_execsql_test(
>      1,
>      [[
> diff --git a/test/sql-tap/tkt-bd484a090c.test.lua b/test/sql-tap/tkt-bd484a090c.test.lua
> index 0347fd426..50c76304c 100755
> --- a/test/sql-tap/tkt-bd484a090c.test.lua
> +++ b/test/sql-tap/tkt-bd484a090c.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  --test:plan(2)
>  test:plan(0)
>  
> @@ -18,7 +18,7 @@ test:plan(0)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-bd484a090c"
> +local testprefix = "tkt-bd484a090c"
>  
>  -- Disabled until #3694 is resolved.
>  --
> diff --git a/test/sql-tap/tkt-d635236375.test.lua b/test/sql-tap/tkt-d635236375.test.lua
> index ef20cf7a0..1b3e94f82 100755
> --- a/test/sql-tap/tkt-d635236375.test.lua
> +++ b/test/sql-tap/tkt-d635236375.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(2)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "tkt-d635236375"
> +local testprefix = "tkt-d635236375"
>  test:do_execsql_test(
>      1.0,
>      [[
> diff --git a/test/sql-tap/tkt-f973c7ac31.test.lua b/test/sql-tap/tkt-f973c7ac31.test.lua
> index 381f29c65..b44203e54 100755
> --- a/test/sql-tap/tkt-f973c7ac31.test.lua
> +++ b/test/sql-tap/tkt-f973c7ac31.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(21)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt-fa7bf5ec.test.lua b/test/sql-tap/tkt-fa7bf5ec.test.lua
> index 7152e028c..dbe168422 100755
> --- a/test/sql-tap/tkt-fa7bf5ec.test.lua
> +++ b/test/sql-tap/tkt-fa7bf5ec.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt1443.test.lua b/test/sql-tap/tkt1443.test.lua
> index 35f9f3226..f0776285f 100755
> --- a/test/sql-tap/tkt1443.test.lua
> +++ b/test/sql-tap/tkt1443.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt1444.test.lua b/test/sql-tap/tkt1444.test.lua
> index fb148bc5f..837edcfbe 100755
> --- a/test/sql-tap/tkt1444.test.lua
> +++ b/test/sql-tap/tkt1444.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt1449.test.lua b/test/sql-tap/tkt1449.test.lua
> index 87403000f..3d402ba11 100755
> --- a/test/sql-tap/tkt1449.test.lua
> +++ b/test/sql-tap/tkt1449.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt1473.test.lua b/test/sql-tap/tkt1473.test.lua
> index bc7991593..070ac43a9 100755
> --- a/test/sql-tap/tkt1473.test.lua
> +++ b/test/sql-tap/tkt1473.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(57)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt1501.test.lua b/test/sql-tap/tkt1501.test.lua
> index c4fdfc436..4b3e5de6e 100755
> --- a/test/sql-tap/tkt1501.test.lua
> +++ b/test/sql-tap/tkt1501.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt1514.test.lua b/test/sql-tap/tkt1514.test.lua
> index 685c916a8..6cfc9676b 100755
> --- a/test/sql-tap/tkt1514.test.lua
> +++ b/test/sql-tap/tkt1514.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt1537.test.lua b/test/sql-tap/tkt1537.test.lua
> index a5a45601c..e333ce9fa 100755
> --- a/test/sql-tap/tkt1537.test.lua
> +++ b/test/sql-tap/tkt1537.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(15)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2141.test.lua b/test/sql-tap/tkt2141.test.lua
> index c3cb19a59..f054d4502 100755
> --- a/test/sql-tap/tkt2141.test.lua
> +++ b/test/sql-tap/tkt2141.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2192.test.lua b/test/sql-tap/tkt2192.test.lua
> index 52309ff2b..dabdfd141 100755
> --- a/test/sql-tap/tkt2192.test.lua
> +++ b/test/sql-tap/tkt2192.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  -- test:plan(6)
>  test:plan(4)
>  
> diff --git a/test/sql-tap/tkt2339.test.lua b/test/sql-tap/tkt2339.test.lua
> index 0f25303a7..3bd41784d 100755
> --- a/test/sql-tap/tkt2339.test.lua
> +++ b/test/sql-tap/tkt2339.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(9)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2391.test.lua b/test/sql-tap/tkt2391.test.lua
> index b9703aab8..1320d6490 100755
> --- a/test/sql-tap/tkt2391.test.lua
> +++ b/test/sql-tap/tkt2391.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2640.test.lua b/test/sql-tap/tkt2640.test.lua
> index 2f3af1d80..5198eb183 100755
> --- a/test/sql-tap/tkt2640.test.lua
> +++ b/test/sql-tap/tkt2640.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(6)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2767.test.lua b/test/sql-tap/tkt2767.test.lua
> index 69338c190..c05b9b8ee 100755
> --- a/test/sql-tap/tkt2767.test.lua
> +++ b/test/sql-tap/tkt2767.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2822.test.lua b/test/sql-tap/tkt2822.test.lua
> index 86674aeac..3f67a0a74 100755
> --- a/test/sql-tap/tkt2822.test.lua
> +++ b/test/sql-tap/tkt2822.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(30)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2832.test.lua b/test/sql-tap/tkt2832.test.lua
> index 27b39b8b2..f5c7c10e7 100755
> --- a/test/sql-tap/tkt2832.test.lua
> +++ b/test/sql-tap/tkt2832.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(6)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2927.test.lua b/test/sql-tap/tkt2927.test.lua
> index 64a9715e0..d51a228dd 100755
> --- a/test/sql-tap/tkt2927.test.lua
> +++ b/test/sql-tap/tkt2927.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(83)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt2942.test.lua b/test/sql-tap/tkt2942.test.lua
> index f83d30c2b..d6137a75a 100755
> --- a/test/sql-tap/tkt2942.test.lua
> +++ b/test/sql-tap/tkt2942.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3201.test.lua b/test/sql-tap/tkt3201.test.lua
> index 25862d77a..065b088af 100755
> --- a/test/sql-tap/tkt3201.test.lua
> +++ b/test/sql-tap/tkt3201.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(8)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3298.test.lua b/test/sql-tap/tkt3298.test.lua
> index b95a56f3f..270e4f1ff 100755
> --- a/test/sql-tap/tkt3298.test.lua
> +++ b/test/sql-tap/tkt3298.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(6)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3334.test.lua b/test/sql-tap/tkt3334.test.lua
> index 6d952ecb8..1ba19d22b 100755
> --- a/test/sql-tap/tkt3334.test.lua
> +++ b/test/sql-tap/tkt3334.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(11)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3346.test.lua b/test/sql-tap/tkt3346.test.lua
> index 51823732a..d7c55cb3b 100755
> --- a/test/sql-tap/tkt3346.test.lua
> +++ b/test/sql-tap/tkt3346.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(5)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3357.test.lua b/test/sql-tap/tkt3357.test.lua
> index b307673ac..645d63a73 100755
> --- a/test/sql-tap/tkt3357.test.lua
> +++ b/test/sql-tap/tkt3357.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3419.test.lua b/test/sql-tap/tkt3419.test.lua
> index d95107dc6..f4ebc1697 100755
> --- a/test/sql-tap/tkt3419.test.lua
> +++ b/test/sql-tap/tkt3419.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(6)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3424.test.lua b/test/sql-tap/tkt3424.test.lua
> index 2bbd226b3..5e19936c0 100755
> --- a/test/sql-tap/tkt3424.test.lua
> +++ b/test/sql-tap/tkt3424.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3442.test.lua b/test/sql-tap/tkt3442.test.lua
> index 5b26122ef..5f9dc3b5a 100755
> --- a/test/sql-tap/tkt3442.test.lua
> +++ b/test/sql-tap/tkt3442.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3493.test.lua b/test/sql-tap/tkt3493.test.lua
> index de77e61e9..78e465b00 100755
> --- a/test/sql-tap/tkt3493.test.lua
> +++ b/test/sql-tap/tkt3493.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(26)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3508.test.lua b/test/sql-tap/tkt3508.test.lua
> index 643cf6f54..4f03e3e1b 100755
> --- a/test/sql-tap/tkt3508.test.lua
> +++ b/test/sql-tap/tkt3508.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3522.test.lua b/test/sql-tap/tkt3522.test.lua
> index 1577a7d23..93f46a076 100755
> --- a/test/sql-tap/tkt3522.test.lua
> +++ b/test/sql-tap/tkt3522.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3527.test.lua b/test/sql-tap/tkt3527.test.lua
> index 23d15e8bc..921a25baa 100755
> --- a/test/sql-tap/tkt3527.test.lua
> +++ b/test/sql-tap/tkt3527.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3541.test.lua b/test/sql-tap/tkt3541.test.lua
> index 0d76e7744..32589cc7a 100755
> --- a/test/sql-tap/tkt3541.test.lua
> +++ b/test/sql-tap/tkt3541.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3554.test.lua b/test/sql-tap/tkt3554.test.lua
> index 09307f2cf..c213f5808 100755
> --- a/test/sql-tap/tkt3554.test.lua
> +++ b/test/sql-tap/tkt3554.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3581.test.lua b/test/sql-tap/tkt3581.test.lua
> index 455cda1f2..2e079d270 100755
> --- a/test/sql-tap/tkt3581.test.lua
> +++ b/test/sql-tap/tkt3581.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3731.test.lua b/test/sql-tap/tkt3731.test.lua
> index 092e8bf93..3f0c9bf86 100755
> --- a/test/sql-tap/tkt3731.test.lua
> +++ b/test/sql-tap/tkt3731.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3773.test.lua b/test/sql-tap/tkt3773.test.lua
> index 04b991755..ee0308ebe 100755
> --- a/test/sql-tap/tkt3773.test.lua
> +++ b/test/sql-tap/tkt3773.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3791.test.lua b/test/sql-tap/tkt3791.test.lua
> index d39b6a2d5..33c50b0fb 100755
> --- a/test/sql-tap/tkt3791.test.lua
> +++ b/test/sql-tap/tkt3791.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  --test:plan(1)
>  test:plan(0)
>  
> diff --git a/test/sql-tap/tkt3841.test.lua b/test/sql-tap/tkt3841.test.lua
> index 56668f6a3..a62150023 100755
> --- a/test/sql-tap/tkt3841.test.lua
> +++ b/test/sql-tap/tkt3841.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3879.test.lua b/test/sql-tap/tkt3879.test.lua
> index 55dffe906..6e2ba9498 100755
> --- a/test/sql-tap/tkt3879.test.lua
> +++ b/test/sql-tap/tkt3879.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(3)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3911.test.lua b/test/sql-tap/tkt3911.test.lua
> index 64c43153a..678144f11 100755
> --- a/test/sql-tap/tkt3911.test.lua
> +++ b/test/sql-tap/tkt3911.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(5)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tkt3935.test.lua b/test/sql-tap/tkt3935.test.lua
> index 5b458983a..7138e9e6a 100755
> --- a/test/sql-tap/tkt3935.test.lua
> +++ b/test/sql-tap/tkt3935.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(10)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/tokenize.test.lua b/test/sql-tap/tokenize.test.lua
> index 2c0f7e368..8d19a507c 100755
> --- a/test/sql-tap/tokenize.test.lua
> +++ b/test/sql-tap/tokenize.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(16)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/transitive1.test.lua b/test/sql-tap/transitive1.test.lua
> index 96895b4a7..af65dc518 100755
> --- a/test/sql-tap/transitive1.test.lua
> +++ b/test/sql-tap/transitive1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(26)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/trigger1.test.lua b/test/sql-tap/trigger1.test.lua
> index 6fd5294b1..8224ef1ec 100755
> --- a/test/sql-tap/trigger1.test.lua
> +++ b/test/sql-tap/trigger1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(33)
>  
>  --!./tcltestrunner.lua
> @@ -482,8 +482,7 @@ test:execsql [[
>  -- trigger works.  Then drop the trigger.  Make sure the table is
>  -- still there.
>  --
> -view_v1 = ""
> -view_v1 = "view v1"
> +local view_v1 = "view v1"
>  
>  
>  -- do_test trigger1-6.1 {
> diff --git a/test/sql-tap/trigger2.test.lua b/test/sql-tap/trigger2.test.lua
> index 192b707d3..680cd07b8 100755
> --- a/test/sql-tap/trigger2.test.lua
> +++ b/test/sql-tap/trigger2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(26)
>  
>  --!./tcltestrunner.lua
> @@ -61,6 +61,7 @@ test:plan(26)
>  
>  box.space._session_settings:update('sql_recursive_triggers', {{'=', 2, false}})
>  -- 1.
> +local ii, tbl_definitions
>  ii = 0
>  tbl_definitions = { "CREATE TABLE tbl (id INT PRIMARY KEY AUTOINCREMENT, a INTEGER UNIQUE, b INT );",
>                      "CREATE TABLE tbl (id INT PRIMARY KEY AUTOINCREMENT, a INT UNIQUE, b INT );",
> @@ -121,9 +122,9 @@ for _, tbl_defn in ipairs(tbl_definitions) do
>      test:do_test(
>          "trigger2-1."..ii..".1",
>          function()
> -            r = {}
> +            local r = {}
>              test:execsql [[ UPDATE tbl SET a = a * 10, b = b * 10; ]]
> -            raw_result = test:execsql [[
> +            local raw_result = test:execsql [[
>                  SELECT * FROM rlog ORDER BY idx;
>              ]]
>              for k,v in pairs(raw_result) do table.insert(r, v) end
> @@ -164,7 +165,7 @@ for _, tbl_defn in ipairs(tbl_definitions) do
>      test:do_test(
>          "trigger2-1."..ii..".2",
>          function()
> -            r = {}
> +            local r = {}
>              for _, v in ipairs(test:execsql [[
>                  DELETE FROM tbl ;
>                  SELECT * FROM rlog;
> @@ -351,7 +352,7 @@ test:catchsql [[
>  --   DROP TABLE log;
>  -- }
>  -- trigger2-3.2: WHEN clause
> -when_triggers = { "t1 BEFORE INSERT ON tbl FOR EACH ROW WHEN new.a > 20" }
> +local when_triggers = { "t1 BEFORE INSERT ON tbl FOR EACH ROW WHEN new.a > 20" }
>  table.insert(when_triggers,"t2 BEFORE INSERT ON tbl FOR EACH ROW WHEN (SELECT count(*) FROM tbl) = 0")
>  
>  
> diff --git a/test/sql-tap/trigger4.test.lua b/test/sql-tap/trigger4.test.lua
> index 4f5406d4c..8b3ba6d00 100755
> --- a/test/sql-tap/trigger4.test.lua
> +++ b/test/sql-tap/trigger4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/trigger5.test.lua b/test/sql-tap/trigger5.test.lua
> index 310e3591e..8336cdcf2 100755
> --- a/test/sql-tap/trigger5.test.lua
> +++ b/test/sql-tap/trigger5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/trigger7.test.lua b/test/sql-tap/trigger7.test.lua
> index 50c01b906..393601ebe 100755
> --- a/test/sql-tap/trigger7.test.lua
> +++ b/test/sql-tap/trigger7.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(5)
>  
>  --!./tcltestrunner.lua
> @@ -48,7 +48,7 @@ test:do_test(
>                SELECT '___update_t1.y___';
>              END;
>          ]]
> -        txt = test:execsql "EXPLAIN UPDATE t1 SET x=5"
> +        local txt = test:execsql "EXPLAIN UPDATE t1 SET x=5"
>          return arr_match(txt, "___update_t1.x___")
>          -- return X(63, "X!cmd", [=[["string","match","*___update_t1.x___*",["txt"]]]=])
>      end,
> @@ -60,7 +60,7 @@ test:do_test(
>  test:do_test(
>      "trigger7-2.2",
>      function()
> -        txt = test:execsql "EXPLAIN UPDATE t1 SET x=5"
> +        local txt = test:execsql "EXPLAIN UPDATE t1 SET x=5"
>          return arr_match(txt, "___update_t1.y___")
>          -- return X(67, "X!cmd", [=[["string","match","*___update_t1.y___*",["txt"]]]=])
>      end,
> @@ -72,7 +72,7 @@ test:do_test(
>  test:do_test(
>      "trigger7-2.3",
>      function()
> -        txt = test:execsql "EXPLAIN UPDATE t1 SET y=5"
> +        local txt = test:execsql "EXPLAIN UPDATE t1 SET y=5"
>          return arr_match(txt, "___update_t1.x___")
>          -- return X(71, "X!cmd", [=[["string","match","*___update_t1.x___*",["txt"]]]=])
>      end,
> @@ -84,7 +84,7 @@ test:do_test(
>  test:do_test(
>      "trigger7-2.4",
>      function()
> -        txt = test:execsql "EXPLAIN UPDATE t1 SET y=5"
> +        local txt = test:execsql "EXPLAIN UPDATE t1 SET y=5"
>          return arr_match(txt, "___update_t1.y___")
>          -- return X(75, "X!cmd", [=[["string","match","*___update_t1.y___*",["txt"]]]=])
>      end,
> diff --git a/test/sql-tap/trigger8.test.lua b/test/sql-tap/trigger8.test.lua
> index 3c803d045..adb0c86ab 100755
> --- a/test/sql-tap/trigger8.test.lua
> +++ b/test/sql-tap/trigger8.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(1)
>  
>  --!./tcltestrunner.lua
> @@ -28,7 +28,7 @@ test:plan(1)
>  -- use 10000. But on symbian, which allows each application at most a 32MB
>  -- heap, use 1000.
>  --
> -nStatement = 10000
> +local nStatement = 10000
>  
>  test:do_test(
>      "trigger8-1.1",
> @@ -37,7 +37,7 @@ test:do_test(
>              CREATE TABLE t1(x INT PRIMARY KEY);
>              CREATE TABLE t2(y INT PRIMARY KEY);
>          ]]
> -        sql = string.format([[CREATE TRIGGER r%s AFTER INSERT ON t1
> +        local sql = string.format([[CREATE TRIGGER r%s AFTER INSERT ON t1
>          FOR EACH ROW BEGIN
>  ]], nStatement)
>          -- for _ in X(0, "X!for", [=[["set i 0","$i<$nStatement","incr i"]]=]) do
> diff --git a/test/sql-tap/trigger9.test.lua b/test/sql-tap/trigger9.test.lua
> index e39a31384..5c1f4cbb2 100755
> --- a/test/sql-tap/trigger9.test.lua
> +++ b/test/sql-tap/trigger9.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +_G.test = require("sqltester")
>  test:plan(28)
>  
>  --!./tcltestrunner.lua
> @@ -33,7 +33,7 @@ test:plan(28)
>  -- ["source",[["testdir"],"\/tester.tcl"]]
>  
>  
> -testprefix = "trigger9"
> +local testprefix = "trigger9"
>  
>  local function has_rowdata(sql)
>      local result = test:execsql('EXPLAIN '..sql)
> diff --git a/test/sql-tap/triggerA.test.lua b/test/sql-tap/triggerA.test.lua
> index fc8ecfe17..38a3dbea2 100755
> --- a/test/sql-tap/triggerA.test.lua
> +++ b/test/sql-tap/triggerA.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(17)
>  
>  --!./tcltestrunner.lua
> @@ -36,12 +36,12 @@ test:do_test(
>              CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT UNIQUE);
>              CREATE TABLE t2(a INTEGER PRIMARY KEY, b INTEGER UNIQUE, c TEXT);
>          ]]
> -        i = 1
> +        local i = 1
>          local words = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"}
>          for i, word in ipairs(words) do
>          -- for _ in X(0, "X!foreach", [=[["word","one two three four five six seven eight nine ten"]]=]) do
>              -- j = X(42, "X!cmd", [=[["expr","$i*100 + [string length $word]"]]=])
> -            j = i * 100 + string.len(word)
> +            local j = i * 100 + string.len(word)
>              test:execsql(string.format([[
>                  INSERT INTO t1 VALUES(%d,'%s');
>                  INSERT INTO t2 VALUES(20-%d,%d,'%s');
> diff --git a/test/sql-tap/triggerB.test.lua b/test/sql-tap/triggerB.test.lua
> index 9dfe09c8e..55b3bc32f 100755
> --- a/test/sql-tap/triggerB.test.lua
> +++ b/test/sql-tap/triggerB.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(201)
>  
>  --!./tcltestrunner.lua
> @@ -154,7 +154,7 @@ test:do_test(
>          ]]
>          -- for _ in X(0, "X!for", [=[["set i 0","$i<=65","incr i"]]=]) do
>          for i=0,65 do    
> -            sql = string.format([[
> +            local sql = string.format([[
>                      CREATE TRIGGER t3c%s AFTER UPDATE ON t3
>                      FOR EACH ROW
>                      WHEN old.c%s!=new.c%s
> diff --git a/test/sql-tap/triggerC.test.lua b/test/sql-tap/triggerC.test.lua
> index ef4d69d49..e95641938 100755
> --- a/test/sql-tap/triggerC.test.lua
> +++ b/test/sql-tap/triggerC.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(43)
>  
>  --!./tcltestrunner.lua
> @@ -16,7 +16,7 @@ test:plan(43)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "triggerC"
> +local testprefix = "triggerC"
>  
>  
>  ---------------------------------------------------------------------------
> @@ -866,7 +866,7 @@ test:do_catchsql_test(
>  -- At one point, due to a bug allowing constant factoring within triggers,
>  -- the following SQL would produce the wrong result.
>  --
> -SQL = [[
> +local SQL = [[
>    DROP TABLE IF EXISTS t1;
>    DROP VIEW v2;
>    DROP TABLE IF EXISTS t2;
> diff --git a/test/sql-tap/triggerD.test.lua b/test/sql-tap/triggerD.test.lua
> index d1b019330..bc433beee 100755
> --- a/test/sql-tap/triggerD.test.lua
> +++ b/test/sql-tap/triggerD.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(4)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/types.test.lua b/test/sql-tap/types.test.lua
> index 2306433fa..91a89b887 100755
> --- a/test/sql-tap/types.test.lua
> +++ b/test/sql-tap/types.test.lua
> @@ -1,6 +1,6 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> -NULL = require('msgpack').NULL
> +local test = require("sqltester")
> +local NULL = require('msgpack').NULL
>  test:plan(14)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/types2.test.lua b/test/sql-tap/types2.test.lua
> index 0640c8048..04ed3070d 100755
> --- a/test/sql-tap/types2.test.lua
> +++ b/test/sql-tap/types2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(398)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/unicode.test.lua b/test/sql-tap/unicode.test.lua
> index 199073918..d916a8302 100755
> --- a/test/sql-tap/unicode.test.lua
> +++ b/test/sql-tap/unicode.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(23 * 3)
>  
>  -- 23 entities
> diff --git a/test/sql-tap/unique.test.lua b/test/sql-tap/unique.test.lua
> index 6b0a7e20d..e369c3283 100755
> --- a/test/sql-tap/unique.test.lua
> +++ b/test/sql-tap/unique.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(35)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/update.test.lua b/test/sql-tap/update.test.lua
> index ac0389a7a..ac6ee8803 100755
> --- a/test/sql-tap/update.test.lua
> +++ b/test/sql-tap/update.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(111)
>  
>  --!./tcltestrunner.lua
> @@ -47,7 +47,7 @@ test:do_test("update-3.1", function()
>    test:execsql "CREATE TABLE test1(id  INT primary key, f1 int,f2 int)"
>    -- for _ in X(0, "X!for", [=[["set i 1","$i<=10","incr i"]]=]) do
>    for i = 1, 10 do    
> -    sql = string.format("INSERT INTO test1 VALUES(%s,%s,%s)", i, i, bit.lshift(1, i)) -- X(0, "X!expr", [=[["<<",1,["i"]]]=]))
> +    local sql = string.format("INSERT INTO test1 VALUES(%s,%s,%s)", i, i, bit.lshift(1, i)) -- X(0, "X!expr", [=[["<<",1,["i"]]]=]))
>      test:execsql(sql)
>    end
>    return test:execsql "SELECT f1,f2 FROM test1 ORDER BY f1"
> diff --git a/test/sql-tap/view.test.lua b/test/sql-tap/view.test.lua
> index 60dfc927a..4d85d8bcb 100755
> --- a/test/sql-tap/view.test.lua
> +++ b/test/sql-tap/view.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(78)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua
> index f267be8e6..3b7e36093 100755
> --- a/test/sql-tap/where2.test.lua
> +++ b/test/sql-tap/where2.test.lua
> @@ -1,9 +1,9 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> -yaml = require("yaml")
> -fio = require("fio")
> +local test = require("sqltester")
> +local yaml = require("yaml")
> +local fio = require("fio")
>  
> -ffi = require("ffi")
> +local ffi = require("ffi")
>  test:plan(74)
>  
>  ffi.cdef[[
> @@ -42,6 +42,7 @@ test:do_test(
>              START TRANSACTION;
>          ]]
>          for i=1,100 do
> +            local w, x, y, z
>              w = i
>              x = math.floor(math.log(i) / math.log(2))
>              y = (((i * i) + (2 * i)) + 1)
> @@ -213,6 +214,7 @@ test:do_test(
>              CREATE TABLE x2(x INTEGER PRIMARY KEY);
>              INSERT INTO x2 VALUES(1);
>          ]]
> +        local sql, out1, out2, out3
>          sql = "SELECT * FROM x1, x2 WHERE x=1 ORDER BY random()"
>          out1 = test:execsql(sql)
>          out2 = test:execsql(sql)
> @@ -508,8 +510,7 @@ test:do_test(
>  
>  -- Verify that OR clauses get translated into IN operators.
>  --
> -idx = ""
> -idx = "*"
> +local idx = "*"
>  
>  
>  test:do_test(
> @@ -590,7 +591,6 @@ test:do_test(
>          -- </where2-6.5>
>      })
>  
> -idx = ""
>  idx = "I1ZYX"
>  
>  
> @@ -957,6 +957,7 @@ test:do_test(
>          test:execsql('CREATE TABLE tx(id int PRIMARY KEY, w int, x int, y int, z int);')
>          -- for _ in X(0, "X!for", [=[["set i 1","$i<=100","incr i"]]=]) do
>          for i=1,100 do
> +            local w, x, y, z
>              w = i
>              x = math.floor(math.log(i) / math.log(2))
>              y = (((i * i) + (2 * i)) + 1)
> diff --git a/test/sql-tap/where3.test.lua b/test/sql-tap/where3.test.lua
> index ae9e37f61..bc6e8108e 100755
> --- a/test/sql-tap/where3.test.lua
> +++ b/test/sql-tap/where3.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(83)
>  
>  --!./tcltestrunner.lua
> @@ -118,6 +118,7 @@ test:do_test(
>  --
>  local function queryplan(sql)
>      -- sql_sort_count = 0
> +    local data, eqp
>      data = test:execsql(sql)
>      eqp = test:execsql("EXPLAIN QUERY PLAN "..sql)
>      for i,v in ipairs(eqp) do
> @@ -548,7 +549,7 @@ for cnt, predicate in ipairs(predicates) do
>      test:do_test(
>          "where3-6."..cnt..".1",
>          function()
> -            sql = "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
> +            local sql = "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
>              sql = sql .. " NATURAL JOIN t6z "
>              sql = sql .. predicate
>              return test:execsql(sql)
> @@ -559,7 +560,7 @@ for cnt, predicate in ipairs(predicates) do
>      test:do_test(
>          "where3-6."..cnt..".2",
>          function()
> -            sql = "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
> +            local sql = "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
>              sql = sql .. " JOIN t6z USING(a) "
>              sql = sql .. predicate
>              return test:execsql(sql)
> @@ -570,7 +571,7 @@ for cnt, predicate in ipairs(predicates) do
>      test:do_test(
>          "where3-6."..cnt..".3",
>          function()
> -            sql = "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
> +            local sql = "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
>              sql = sql .. " JOIN t6z USING(a) "
>              sql = sql .. predicate
>              return test:execsql(sql)
> @@ -581,7 +582,7 @@ for cnt, predicate in ipairs(predicates) do
>      test:do_test(
>          "where3-6."..cnt..".4",
>          function()
> -            sql = "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
> +            local sql = "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
>              sql = sql .. " JOIN t6z USING(a) "
>              sql = sql .. predicate
>              return test:execsql(sql)
> @@ -592,7 +593,7 @@ for cnt, predicate in ipairs(predicates) do
>      test:do_test(
>          "where3-6."..cnt..".5",
>          function()
> -            sql = "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
> +            local sql = "SELECT * FROM t6w JOIN t6x USING(a) JOIN t6y USING(a)"
>              sql = sql .. " NATURAL JOIN t6z "
>              sql = sql .. predicate
>              return test:execsql(sql)
> @@ -603,7 +604,7 @@ for cnt, predicate in ipairs(predicates) do
>      test:do_test(
>          "where3-6."..cnt..".6",
>          function()
> -            sql = "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
> +            local sql = "SELECT * FROM t6w JOIN t6x USING(a) NATURAL JOIN t6y"
>              sql = sql .. " NATURAL JOIN t6z "
>              sql = sql .. predicate
>              return test:execsql(sql)
> @@ -614,7 +615,7 @@ for cnt, predicate in ipairs(predicates) do
>      test:do_test(
>          "where3-6."..cnt..".7",
>          function()
> -            sql = "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
> +            local sql = "SELECT * FROM t6w NATURAL JOIN t6x JOIN t6y USING(a)"
>              sql = sql .. " NATURAL JOIN t6z "
>              sql = sql .. predicate
>              return test:execsql(sql)
> @@ -625,7 +626,7 @@ for cnt, predicate in ipairs(predicates) do
>      test:do_test(
>          "where3-6."..cnt..".8",
>          function()
> -            sql = "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
> +            local sql = "SELECT * FROM t6w NATURAL JOIN t6x NATURAL JOIN t6y"
>              sql = sql .. " JOIN t6z USING(a) "
>              sql = sql .. predicate
>              return test:execsql(sql)
> diff --git a/test/sql-tap/where4.test.lua b/test/sql-tap/where4.test.lua
> index e38972666..65e7f9337 100755
> --- a/test/sql-tap/where4.test.lua
> +++ b/test/sql-tap/where4.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(8)
>  
>  --!./tcltestrunner.lua
> @@ -23,7 +23,7 @@ test:plan(8)
>  -- $Id: where4.test,v 1.6 2007/12/10 05:03:48 danielk1977 Exp $
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "where4"
> +local testprefix = "where4"
>  
>  
>  -- Build some test data
> diff --git a/test/sql-tap/where5.test.lua b/test/sql-tap/where5.test.lua
> index 3aefcaca5..4e778eba7 100755
> --- a/test/sql-tap/where5.test.lua
> +++ b/test/sql-tap/where5.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(50)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/where6.test.lua b/test/sql-tap/where6.test.lua
> index 5fb79fa2a..f9de30dbc 100755
> --- a/test/sql-tap/where6.test.lua
> +++ b/test/sql-tap/where6.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(20)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/where7.test.lua b/test/sql-tap/where7.test.lua
> index 70209545d..d3e7d91fe 100755
> --- a/test/sql-tap/where7.test.lua
> +++ b/test/sql-tap/where7.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(2023)
>  
>  --!./tcltestrunner.lua
> @@ -229,7 +229,7 @@ test:do_test(
>  test:do_test(
>      "where7-1.20",
>      function()
> -        sql = "SELECT a FROM t1 WHERE a=11 OR b=11"
> +        local sql = "SELECT a FROM t1 WHERE a=11 OR b=11"
>          for i = 12, 100 do
>              sql = sql .. string.format(" OR a=%s OR b=%s", i, i)
>          end
> @@ -244,7 +244,7 @@ test:do_test(
>  test:do_test(
>      "where7-1.21",
>      function()
> -        sql = "SELECT a FROM t1 WHERE b=11 OR c=11"
> +        local sql = "SELECT a FROM t1 WHERE b=11 OR c=11"
>          for i = 12, 100 do
>              sql = sql .. string.format(" OR b=%s OR c=%s", i, i)
>          end
> @@ -259,7 +259,7 @@ test:do_test(
>  test:do_test(
>      "where7-1.22",
>      function()
> -        sql = "SELECT a FROM t1 WHERE (b=11 OR c=11"
> +        local sql = "SELECT a FROM t1 WHERE (b=11 OR c=11"
>          for i = 12, 100 do
>              sql = sql .. string.format(" OR b=%s OR c=%s", i, i)
>          end
> @@ -274,7 +274,7 @@ test:do_test(
>  test:do_test(
>      "where7-1.23",
>      function()
> -        sql = "SELECT a FROM t1 WHERE (b=11 OR c=11"
> +        local sql = "SELECT a FROM t1 WHERE (b=11 OR c=11"
>          for i = 12, 100 do
>              sql = sql .. string.format(" OR (b=%s AND d!=0) OR (c=%s AND d IS NOT NULL)", i, i)
>          end
> @@ -289,7 +289,7 @@ test:do_test(
>  test:do_test(
>      "where7-1.31",
>      function()
> -        sql = "SELECT a FROM t1 WHERE (a=11 AND b=11)"
> +        local sql = "SELECT a FROM t1 WHERE (a=11 AND b=11)"
>          for i = 12, 100 do
>              sql = sql .. string.format(" OR (a=%s AND b=%s)", i, i)
>          end
> @@ -304,7 +304,7 @@ test:do_test(
>  test:do_test(
>      "where7-1.32",
>      function()
> -        sql = "SELECT a FROM t1 WHERE (b=11 AND c=11)"
> +        local sql = "SELECT a FROM t1 WHERE (b=11 AND c=11)"
>          for i = 12, 100 do
>              sql = sql .. string.format(" OR (b=%s AND c=%s)", i, i)
>          end
> @@ -319,7 +319,7 @@ test:do_test(
>  test:do_test(
>      "where7-AST-depth-limit",
>      function()
> -        sql = "SELECT a FROM t1 WHERE a = 0"
> +        local sql = "SELECT a FROM t1 WHERE a = 0"
>          for i = 1, 199 do
>              sql = sql .. string.format(" OR a = %s", i)
>          end
> diff --git a/test/sql-tap/whereA.test.lua b/test/sql-tap/whereA.test.lua
> index a49d1c05c..968ceb2e9 100755
> --- a/test/sql-tap/whereA.test.lua
> +++ b/test/sql-tap/whereA.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(17)
>  
>  --!./tcltestrunner.lua
> diff --git a/test/sql-tap/whereC.test.lua b/test/sql-tap/whereC.test.lua
> index 58c049553..334d4cf29 100755
> --- a/test/sql-tap/whereC.test.lua
> +++ b/test/sql-tap/whereC.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  local yaml = require('yaml')
>  test:plan(41)
>  
> @@ -17,7 +17,7 @@ test:plan(41)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "whereC"
> +local testprefix = "whereC"
>  test:do_execsql_test(
>      1.0,
>      [[
> diff --git a/test/sql-tap/whereD.test.lua b/test/sql-tap/whereD.test.lua
> index 14dc8d3bd..26221ec12 100755
> --- a/test/sql-tap/whereD.test.lua
> +++ b/test/sql-tap/whereD.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(36)
>  
>  --!./tcltestrunner.lua
> @@ -19,7 +19,7 @@ test:plan(36)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "whereD"
> +local testprefix = "whereD"
>  test:do_execsql_test(
>      1.1,
>      [[
> diff --git a/test/sql-tap/whereF.test.lua b/test/sql-tap/whereF.test.lua
> index 3235df437..12aefc4a4 100755
> --- a/test/sql-tap/whereF.test.lua
> +++ b/test/sql-tap/whereF.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(13)
>  
>  --!./tcltestrunner.lua
> @@ -48,7 +48,7 @@ test:plan(13)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "whereF"
> +local testprefix = "whereF"
>  test:do_execsql_test(
>      1.0,
>      [[
> diff --git a/test/sql-tap/whereG.test.lua b/test/sql-tap/whereG.test.lua
> index 590027023..2fbc6c5b3 100755
> --- a/test/sql-tap/whereG.test.lua
> +++ b/test/sql-tap/whereG.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(23)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(23)
>  -- likelihood() functions.
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "whereG"
> +local testprefix = "whereG"
>  test:do_execsql_test(
>      "whereG-1.0",
>      [[
> diff --git a/test/sql-tap/whereI.test.lua b/test/sql-tap/whereI.test.lua
> index 3ae5b82f2..79c6bcfe5 100755
> --- a/test/sql-tap/whereI.test.lua
> +++ b/test/sql-tap/whereI.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(7)
>  
>  --!./tcltestrunner.lua
> @@ -20,7 +20,7 @@ test:plan(7)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "whereI"
> +local testprefix = "whereI"
>  test:do_execsql_test(1.0, [[
>      CREATE TABLE t1(a INT, b TEXT, c TEXT, PRIMARY KEY(a));
>      INSERT INTO t1 VALUES(1, 'a', 'z');
> diff --git a/test/sql-tap/whereK.test.lua b/test/sql-tap/whereK.test.lua
> index 58e3146a7..0ca7fff0d 100755
> --- a/test/sql-tap/whereK.test.lua
> +++ b/test/sql-tap/whereK.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(10)
>  
>  --!./tcltestrunner.lua
> @@ -23,7 +23,7 @@ test:plan(10)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "whereK"
> +local testprefix = "whereK"
>  test:do_execsql_test(1.1, [[
>    CREATE TABLE t1(a INT ,b INT ,c INT , primary key (a,b,c));
>    WITH RECURSIVE c(x) AS (VALUES(0) UNION ALL SELECT x+1 FROM c WHERE x<99)
> diff --git a/test/sql-tap/with1.test.lua b/test/sql-tap/with1.test.lua
> index 75935108c..86dd4f83a 100755
> --- a/test/sql-tap/with1.test.lua
> +++ b/test/sql-tap/with1.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(64)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(64)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "with1"
> +local testprefix = "with1"
>  -- if X(0, "X!capable", [["!cte"]]) then
>  --   test:finish_test()
>  --  return 
> @@ -623,7 +623,7 @@ test:do_execsql_test("8.2-soduko", [[
>  -- Some tests that use LIMIT and OFFSET in the definition of recursive CTEs.
>  --
>  -- I = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 }
> -function limit_test(tn, iLimit, iOffset)
> +local function limit_test(tn, iLimit, iOffset)
>      local last = 20 - 1
>      local result = {}
>      -- if X(0, "X!expr01", [["$iOffset < 0"]]) then
> diff --git a/test/sql-tap/with2.test.lua b/test/sql-tap/with2.test.lua
> index 1aa39b32e..456ded363 100755
> --- a/test/sql-tap/with2.test.lua
> +++ b/test/sql-tap/with2.test.lua
> @@ -1,5 +1,5 @@
>  #!/usr/bin/env tarantool
> -test = require("sqltester")
> +local test = require("sqltester")
>  test:plan(59)
>  
>  --!./tcltestrunner.lua
> @@ -18,7 +18,7 @@ test:plan(59)
>  --
>  -- ["set","testdir",[["file","dirname",["argv0"]]]]
>  -- ["source",[["testdir"],"\/tester.tcl"]]
> -testprefix = "with2"
> +local testprefix = "with2"
>  
>  test:do_execsql_test(
>      1.0,
> -- 
> 2.28.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Tarantool-patches] [PATCH v3] luacheck: change global vars to local in sql-tap
  2020-12-14 18:10 [Tarantool-patches] [PATCH v3] luacheck: change global vars to local in sql-tap Artem Starshov
  2020-12-14 19:20 ` Alexander V. Tikhonov
@ 2020-12-16 12:03 ` Kirill Yukhin
  1 sibling, 0 replies; 3+ messages in thread
From: Kirill Yukhin @ 2020-12-16 12:03 UTC (permalink / raw)
  To: Artem Starshov; +Cc: tarantool-patches, Alexander Turenko

Hello,

On 14 Dec 21:10, Artem Starshov via Tarantool-patches wrote:
> Fixed luacheck warning 111 (setting non-standard global variable)
> in test/sql-tap directory.
> Enabled this directory for checking W111 in
> config file(.luacheckrc).
> 
> Changed almost all variables in test/sql-tap from globals
> to locals. In any cases, where variables need to be global,
> added explicit _G. prefix (table of globals).
> 
> Fixes #5173
> Part-of #5464
> ---
> Changes in v3:
>     - inline "globals" suppressions changed to _G usage
>     - removed some unnecessary suppressions
>     - rebased to master and corrected newly appeared tests
> 
> See LGTM from AlexTu: https://lists.tarantool.org/pipermail/tarantool-patches/2020-December/021194.html
> Branch:https://github.com/tarantool/tarantool/tree/artemreyt/gh-5173-fix-luacheck-warnings-sql-tap
> Issue: https://github.com/tarantool/tarantool/issues/5173

LGTM.
I've checked your patch into 2.5, 2.6 and master.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-16 12:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-14 18:10 [Tarantool-patches] [PATCH v3] luacheck: change global vars to local in sql-tap Artem Starshov
2020-12-14 19:20 ` Alexander V. Tikhonov
2020-12-16 12:03 ` Kirill Yukhin

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