Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: kyukhin@tarantool.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] [PATCH] sql: remove meaningless triggerE test
Date: Thu,  2 Aug 2018 14:29:18 +0300	[thread overview]
Message-ID: <20180802112918.90330-1-korablev@tarantool.org> (raw)

Originally, SQLite doesn't allow to use binding parameters in trigger's
body. triggerE test checks only this taboo. However, binding mechanism is
not properly implemented now, so this test seems to be useless and can
be removed.
---
Branch: https://github.com/tarantool/tarantool/tree/np/remove-useless-trigger-test
Issue: no corresponding issue

 test/sql-tap/triggerE.test.lua | 117 -----------------------------------------
 1 file changed, 117 deletions(-)
 delete mode 100755 test/sql-tap/triggerE.test.lua

diff --git a/test/sql-tap/triggerE.test.lua b/test/sql-tap/triggerE.test.lua
deleted file mode 100755
index 6119e8fcd..000000000
--- a/test/sql-tap/triggerE.test.lua
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env tarantool
-test = require("sqltester")
-test:plan(17)
-
---!./tcltestrunner.lua
--- 2009 December 29
---
--- The author disclaims copyright to this source code.  In place of
--- a legal notice', here is a blessing:
---
---    May you do good and not evil.
---    May you find forgiveness for yourself and forgive others.
---    May you share freely, never taking more than you give.
---
--------------------------------------------------------------------------
---
--- This file tests the effects of SQL variable references embedded in
--- triggers. If the user attempts to create such a trigger, it is an
--- error. However, if an existing trigger definition is read from
--- the sqlite_master table, the variable reference always evaluates
--- to NULL.
---
--- ["set","testdir",[["file","dirname",["argv0"]]]]
--- ["source",[["testdir"],"\/tester.tcl"]]
-
-
-testprefix = "triggerE"
-test:do_execsql_test(
-    1.0,
-    [[
-        CREATE TABLE t1(a PRIMARY KEY, b);
-        CREATE TABLE t2(c  PRIMARY KEY, d);
-        CREATE TABLE t3(e  PRIMARY KEY, f);
-    ]])
-
--- forcedelete test.db2
--- do_execsql_test 1.1 {
---   ATTACH 'test.db2' AS aux;
---   CREATE TABLE aux.t4(x);
---   INSERT INTO aux.t4 VALUES(5);
---
---   CREATE TRIGGER tr1 AFTER INSERT ON t1 WHEN new.a IN (SELECT x FROM aux.t4)
---   BEGIN
---     SELECT 1;
---   END;
--- }
--- do_execsql_test 1.2 { INSERT INTO t1 VALUES(1,1); }
--- do_execsql_test 1.3 { INSERT INTO t1 VALUES(5,5); }
----------------------------------------------------------------------------
--- Attempt to create various triggers that use bound variables.
---
-local errmsg = "trigger cannot use variables"
-for tn, defn in ipairs({
-        "AFTER INSERT ON t1 WHEN new.a = ? BEGIN SELECT 1; END; ",
-        "BEFORE DELETE ON t1 BEGIN SELECT ?; END; ",
-        "BEFORE DELETE ON t1 BEGIN SELECT * FROM (SELECT * FROM (SELECT ?)); END; ",
-        "BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 GROUP BY ?; END; ",
-        "BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 LIMIT ?; END; ",
-        "BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 ORDER BY ?; END; ",
-        "BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET c = ?; END; ",
-        "BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET c = 1 WHERE d = ?; END; "}) do
-
--- for _ in X(0, "X!foreach", [=[["tn defn","\n  1 { AFTER INSERT ON t1 WHEN new.a = ? BEGIN SELECT 1; END; }\n  2 { BEFORE DELETE ON t1 BEGIN SELECT ?; END; }\n  3 { BEFORE DELETE ON t1 BEGIN SELECT * FROM (SELECT * FROM (SELECT ?)); END; }\n  5 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 GROUP BY ?; END; }\n  6 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 LIMIT ?; END; }\n  7 { BEFORE DELETE ON t1 BEGIN SELECT * FROM t2 ORDER BY ?; END; }\n  8 { BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET c = ?; END; }\n  9 { BEFORE UPDATE ON t1 BEGIN UPDATE t2 SET c = 1 WHERE d = ?; END; }\n"]]=]) do
-    test:catchsql "drop trigger tr1"
-    test:do_catchsql_test(
-        "1.1."..tn,
-        "CREATE TRIGGER tr1 "..defn.."", {
-            1, errmsg
-        })
-
-    test:do_catchsql_test(
-        "1.2."..tn,
-        "CREATE TRIGGER tr1 "..defn.."", {
-            1, errmsg
-        })
-end
----------------------------------------------------------------------------
--- Test that variable references within trigger definitions loaded from
--- the sqlite_master table are automatically converted to NULL.
---
--- do_execsql_test 2.1 {
---   INSERT INTO sqlite_master VALUES('trigger', 'tr1', 't1', 0,
---     'CREATE TRIGGER tr1 AFTER INSERT ON t1 BEGIN
---         INSERT INTO t2 VALUES(?1, ?2);
---      END'
---   );
---   INSERT INTO sqlite_master VALUES('trigger', 'tr2', 't3', 0,
---     'CREATE TRIGGER tr2 AFTER INSERT ON t3 WHEN ?1 IS NULL BEGIN
---         UPDATE t2 SET c=d WHERE c IS ?2;
---      END'
---   );
--- }
--- db close
--- sqlite3 db test.db
--- do_execsql_test 2.2.1 {
---   INSERT INTO t1 VALUES(1, 2);
---   SELECT * FROM t2;
--- } {{} {}}
--- do_test 2.2.2 {
---   set one 3
---   execsql {
---     DELETE FROM t2;
---     INSERT INTO t1 VALUES($one, ?1);
---     SELECT * FROM t2;
---   }
--- } {{} {}}
--- do_execsql_test 2.2.3 { SELECT * FROM t1 } {1 2 3 3}
--- do_execsql_test 2.3 {
---   DELETE FROM t2;
---   INSERT INTO t2 VALUES('x', 'y');
---   INSERT INTO t2 VALUES(NULL, 'z');
---   INSERT INTO t3 VALUES(1, 2);
---   SELECT * FROM t3;
---   SELECT * FROM t2;
--- } {1 2 x y z z}
-test:finish_test()
-
-- 
2.15.1

             reply	other threads:[~2018-08-02 11:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-02 11:29 Nikita Pettik [this message]
2018-08-02 14:09 ` [tarantool-patches] " Kirill Yukhin

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20180802112918.90330-1-korablev@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH] sql: remove meaningless triggerE test' \
    /path/to/YOUR_REPLY

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

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

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