Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] sql: Remove 'BEGIN TRANSACTION'
@ 2018-07-05 10:42 N.Tatunov
  2018-07-05 11:48 ` [tarantool-patches] " Nikita Tatunov
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: N.Tatunov @ 2018-07-05 10:42 UTC (permalink / raw)
  To: tarantool-patches; +Cc: alexander.turenko, N.Tatunov

Patch is aimed on making our sql closer to ANSI sql.

With the patch applied only following commands can be used:
 - "START TRANSACTION" to begin transaction.
 - "COMMIT" to end transaction.
 - "ROLLBACK" to rollback transaction without savepoints.
 - "ROLLBACK TO .." to rollback transaction to savepoint.

Closes #2164
---

Issue: https://github.com/tarantool/tarantool/issues/2164
Branch: https://github.com/tarantool/tarantool/tree/N_Tatunov/gh-2164-remove-begin-transaction

 extra/mkkeywordhash.c                       |  4 ++--
 src/box/sql/expr.c                          |  6 ++++--
 src/box/sql/parse.y                         | 12 +++++-------
 test/sql-tap/analyze3.test.lua              | 10 +++++-----
 test/sql-tap/check.test.lua                 |  2 +-
 test/sql-tap/count.test.lua                 |  2 +-
 test/sql-tap/delete3.test.lua               |  2 +-
 test/sql-tap/fkey4.test.lua                 |  4 ++--
 test/sql-tap/gh-2931-savepoints.test.lua    |  2 +-
 test/sql-tap/gh2140-trans.test.lua          |  8 ++++----
 test/sql-tap/gh2964-abort.test.lua          |  2 +-
 test/sql-tap/icu.test.lua                   |  2 +-
 test/sql-tap/identifier-characters.test.lua |  2 +-
 test/sql-tap/in1.test.lua                   |  4 ++--
 test/sql-tap/in2.test.lua                   |  2 +-
 test/sql-tap/index1.test.lua                |  6 +++---
 test/sql-tap/index2.test.lua                |  2 +-
 test/sql-tap/index3.test.lua                |  2 +-
 test/sql-tap/index4.test.lua                | 10 +++++-----
 test/sql-tap/insert3.test.lua               |  4 ++--
 test/sql-tap/intpkey.test.lua               |  2 +-
 test/sql-tap/join.test.lua                  | 10 +++++-----
 test/sql-tap/join5.test.lua                 |  2 +-
 test/sql-tap/limit.test.lua                 |  8 ++++----
 test/sql-tap/minmax2.test.lua               |  2 +-
 test/sql-tap/minmax3.test.lua               |  2 +-
 test/sql-tap/misc1.test.lua                 | 14 +++++++-------
 test/sql-tap/misc3.test.lua                 | 14 +++++++-------
 test/sql-tap/misc5.test.lua                 |  4 ++--
 test/sql-tap/null.test.lua                  |  2 +-
 test/sql-tap/orderby1.test.lua              |  6 +++---
 test/sql-tap/select1.test.lua               |  2 +-
 test/sql-tap/select2.test.lua               |  4 ++--
 test/sql-tap/select3.test.lua               |  2 +-
 test/sql-tap/select4.test.lua               |  4 ++--
 test/sql-tap/select5.test.lua               |  2 +-
 test/sql-tap/select6.test.lua               |  4 ++--
 test/sql-tap/select9.test.lua               |  2 +-
 test/sql-tap/selectF.test.lua               |  2 +-
 test/sql-tap/sort.test.lua                  |  2 +-
 test/sql-tap/subquery.test.lua              |  2 +-
 test/sql-tap/subquery2.test.lua             |  2 +-
 test/sql-tap/table.test.lua                 |  4 ++--
 test/sql-tap/tkt-4a03edc4c8.test.lua        |  2 +-
 test/sql-tap/tkt-b1d3a2e531.test.lua        |  2 +-
 test/sql-tap/tkt1449.test.lua               |  2 +-
 test/sql-tap/tkt3493.test.lua               |  2 +-
 test/sql-tap/trigger1.test.lua              | 10 +++++-----
 test/sql-tap/trigger2.test.lua              |  4 ++--
 test/sql-tap/trigger9.test.lua              | 22 +++++++++++-----------
 test/sql-tap/triggerC.test.lua              | 18 +++++++++---------
 test/sql-tap/update.test.lua                |  4 ++--
 test/sql-tap/view.test.lua                  |  2 +-
 test/sql-tap/where2.test.lua                |  4 ++--
 test/sql-tap/where4.test.lua                |  2 +-
 test/sql/tokenizer.result                   |  4 ++--
 test/sql/tokenizer.test.lua                 |  2 +-
 test/sql/transitive-transactions.result     |  6 +++---
 test/sql/transitive-transactions.test.lua   |  6 +++---
 59 files changed, 139 insertions(+), 139 deletions(-)

diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index 990c419..1ec1538 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -120,7 +120,7 @@ static Keyword aKeywordTable[] = {
   { "ASC",                    "TK_ASC",         ALWAYS,           true  },
   { "AUTOINCREMENT",          "TK_AUTOINCR",    AUTOINCR,         false },
   { "BEFORE",                 "TK_BEFORE",      TRIGGER,          false },
-  { "BEGIN",                  "TK_BEGIN",       ALWAYS,           true  },
+  { "BEGIN",                  "TK_BEGIN",       TRIGGER,          true  },
   { "BETWEEN",                "TK_BETWEEN",     ALWAYS,           true  },
   { "BY",                     "TK_BY",          ALWAYS,           true  },
   { "CASCADE",                "TK_CASCADE",     FKEY,             false },
@@ -210,6 +210,7 @@ static Keyword aKeywordTable[] = {
   { "SAVEPOINT",              "TK_SAVEPOINT",   ALWAYS,           true  },
   { "SELECT",                 "TK_SELECT",      ALWAYS,           true  },
   { "SET",                    "TK_SET",         ALWAYS,           true  },
+  { "START",                  "TK_START",       ALWAYS,           true  },
   { "TABLE",                  "TK_TABLE",       ALWAYS,           true  },
   { "THEN",                   "TK_THEN",        ALWAYS,           true  },
   { "TO",                     "TK_TO",          ALWAYS,           true  },
@@ -274,7 +275,6 @@ static Keyword aKeywordTable[] = {
   { "SIGNAL",                 "TK_STANDARD",    RESERVED,         true  },
   { "SMALLINT",               "TK_ID",          RESERVED,         true  },
   { "SPECIFIC",               "TK_STANDARD",    RESERVED,         true  },
-  { "START",                  "TK_STANDARD",    RESERVED,         true  },
   { "SYSTEM",                 "TK_STANDARD",    RESERVED,         true  },
   { "SQL",                    "TK_STANDARD",    RESERVED,         true  },
   { "USER",                   "TK_STANDARD",    RESERVED,         true  },
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 3183e3d..42ab600 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -4835,11 +4835,13 @@ sqlite3ExprIfFalse(Parse * pParse, Expr * pExpr, int dest, int jumpIfNull)
 	 * Assert()s verify that the computation is correct.
 	 */
 
-	op = ((pExpr->op + (TK_ISNULL & 1)) ^ 1) - (TK_ISNULL & 1);
+	if (pExpr->op >= TK_NE && pExpr->op <= TK_GE)
+		op = ((pExpr->op + (TK_NE & 1)) ^ 1) - (TK_NE & 1);
+	if (pExpr->op == TK_ISNULL || pExpr->op == TK_NOTNULL)
+		op = ((pExpr->op + (TK_ISNULL & 1)) ^ 1) - (TK_ISNULL & 1);
 
 	/*
 	 * Verify correct alignment of TK_ and OP_ constants.
-	 * Tokens TK_ISNULL and TK_NE shoud have the same parity.
 	 */
 	assert(pExpr->op != TK_NE || op == OP_Eq);
 	assert(pExpr->op != TK_EQ || op == OP_Ne);
diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index b2940b7..e956dfc 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -147,13 +147,11 @@ cmdx ::= cmd.
 ///////////////////// Begin and end transactions. ////////////////////////////
 //
 
-cmd ::= BEGIN trans_opt.  {sql_transaction_begin(pParse);}
+cmd ::= START TRANSACTION trans_opt.  {sql_transaction_begin(pParse);}
 trans_opt ::= .
-trans_opt ::= TRANSACTION.
-trans_opt ::= TRANSACTION nm.
-cmd ::= COMMIT trans_opt.      {sql_transaction_commit(pParse);}
-cmd ::= END trans_opt.         {sql_transaction_commit(pParse);}
-cmd ::= ROLLBACK trans_opt.    {sql_transaction_rollback(pParse);}
+trans_opt ::= nm.
+cmd ::= COMMIT.      {sql_transaction_commit(pParse);}
+cmd ::= ROLLBACK.    {sql_transaction_rollback(pParse);}
 
 savepoint_opt ::= SAVEPOINT.
 savepoint_opt ::= .
@@ -163,7 +161,7 @@ cmd ::= SAVEPOINT nm(X). {
 cmd ::= RELEASE savepoint_opt nm(X). {
   sqlite3Savepoint(pParse, SAVEPOINT_RELEASE, &X);
 }
-cmd ::= ROLLBACK trans_opt TO savepoint_opt nm(X). {
+cmd ::= ROLLBACK TO savepoint_opt nm(X). {
   sqlite3Savepoint(pParse, SAVEPOINT_ROLLBACK, &X);
 }
 
diff --git a/test/sql-tap/analyze3.test.lua b/test/sql-tap/analyze3.test.lua
index 26f8793..5079962 100755
--- a/test/sql-tap/analyze3.test.lua
+++ b/test/sql-tap/analyze3.test.lua
@@ -84,7 +84,7 @@ test:do_test(
         test:execsql([[
             CREATE TABLE t1(id INT PRIMARY KEY, x INTEGER, y);
             CREATE INDEX i1 ON t1(x);
-            BEGIN;
+            START TRANSACTION;
         ]])
         for i=1,1000 do
             test:execsql(string.format(" INSERT INTO t1 VALUES(%s, %s+99, %s-1) ", i, i, i))
@@ -219,7 +219,7 @@ test:do_execsql_test(
     "analyze3-1.2.1",
     [[
         CREATE TABLE t2(id INTEGER PRIMARY KEY, x TEXT, y);
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t2 SELECT * FROM t1;
         COMMIT;
         CREATE INDEX i2 ON t2(x);
@@ -340,7 +340,7 @@ test:do_execsql_test(
     "analyze3-1.3.1",
     [[
         CREATE TABLE t3(id INTEGER PRIMARY KEY, y TEXT, x INTEGER);
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t3 SELECT id, y, x FROM t1;
         COMMIT;
         CREATE INDEX i3 ON t3(x);
@@ -465,7 +465,7 @@ test:do_test(
 --     function()
 --         test:execsql([[
 --             PRAGMA case_sensitive_like=off;
---             BEGIN;
+--             START TRANSACTION;
 --             CREATE TABLE t1(a, b TEXT COLLATE nocase);
 --             CREATE INDEX i1 ON t1(b);
 --         ]])
@@ -595,7 +595,7 @@ test:do_test(
     function()
         test:execsql(" DROP TABLE IF EXISTS t1 ")
         test:execsql(" CREATE TABLE t1(id INTEGER PRIMARY KEY, a, b, c) ")
-        test:execsql("BEGIN")
+        test:execsql("START TRANSACTION")
         for i=1,1000 do
             test:execsql(string.format("INSERT INTO t1 VALUES(%s, %s, 'x', %s)", i, ((i-1) / 100), ((i-1) / 10)))
         end
diff --git a/test/sql-tap/check.test.lua b/test/sql-tap/check.test.lua
index f0b745e..ff36552 100755
--- a/test/sql-tap/check.test.lua
+++ b/test/sql-tap/check.test.lua
@@ -637,7 +637,7 @@ test:do_execsql_test(
 test:do_catchsql_test(
     "check-6.7",
     [[
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t1 VALUES(1,30.0, 9);
         INSERT OR ROLLBACK INTO t1 VALUES(8,40.0, 10);
     ]], {
diff --git a/test/sql-tap/count.test.lua b/test/sql-tap/count.test.lua
index a3d00d1..45808de 100755
--- a/test/sql-tap/count.test.lua
+++ b/test/sql-tap/count.test.lua
@@ -93,7 +93,7 @@ for _, zIndex in ipairs(queries) do
     test:do_execsql_test(
         "count-1."..iTest..".5",
         [[
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO t1 SELECT a+4096, b FROM t1;          --  8192
             INSERT INTO t1 SELECT a+8192, b FROM t1;          -- 16384
             INSERT INTO t1 SELECT a+16384, b FROM t1;          -- 32768
diff --git a/test/sql-tap/delete3.test.lua b/test/sql-tap/delete3.test.lua
index 5dc012d..d4617ce 100755
--- a/test/sql-tap/delete3.test.lua
+++ b/test/sql-tap/delete3.test.lua
@@ -25,7 +25,7 @@ test:do_execsql_test(
     "delete3-1.1",
     [[
         CREATE TABLE t1(x integer primary key);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t1 VALUES(1);
         INSERT INTO t1 VALUES(2);
         INSERT INTO t1 SELECT x+2 FROM t1;
diff --git a/test/sql-tap/fkey4.test.lua b/test/sql-tap/fkey4.test.lua
index 9415b62..df3548f 100755
--- a/test/sql-tap/fkey4.test.lua
+++ b/test/sql-tap/fkey4.test.lua
@@ -222,11 +222,11 @@ test:do_execsql_test(
 test:do_catchsql_test(
     "fkey8-3.2",
     [[
-        BEGIN;
+        START TRANSACTION;
             INSERT INTO c2 VALUES(13, 13);
             INSERT OR REPLACE INTO c2 VALUES(13, 13);
             DELETE FROM c2;
-        END;
+        COMMIT;
     ]], {
         -- <fkey8-3.2>
         0
diff --git a/test/sql-tap/gh-2931-savepoints.test.lua b/test/sql-tap/gh-2931-savepoints.test.lua
index 9668d8f..a5bbc1e 100755
--- a/test/sql-tap/gh-2931-savepoints.test.lua
+++ b/test/sql-tap/gh-2931-savepoints.test.lua
@@ -27,7 +27,7 @@ local testcases = {
 		select * from t1 union all select * from t2;]],
 		{0,{1,1}} },
 	{"3",
-		[[begin;
+		[[START TRANSACTION;
 		savepoint s1_1;
 		savepoint s1_2;]],
 		{0} },
diff --git a/test/sql-tap/gh2140-trans.test.lua b/test/sql-tap/gh2140-trans.test.lua
index 5539ed2..d5f63b2 100755
--- a/test/sql-tap/gh2140-trans.test.lua
+++ b/test/sql-tap/gh2140-trans.test.lua
@@ -12,7 +12,7 @@ box.sql.execute("INSERT INTO t1 VALUES (1,1);")
 box.sql.execute("INSERT INTO t2 VALUES (1,1);")
 
 test:do_execsql_test('commit1_check',
-                     [[BEGIN;
+                     [[START TRANSACTION;
                          INSERT INTO t1 VALUES (2,2);
                        COMMIT;
 
@@ -20,7 +20,7 @@ test:do_execsql_test('commit1_check',
                      {1, 1, 2, 2})
 
 test:do_execsql_test('rollback1_check',
-                     [[BEGIN;
+                     [[START TRANSACTION;
                          INSERT INTO t1 VALUES (3,3);
                        ROLLBACK;
 
@@ -35,7 +35,7 @@ for _, verb in ipairs({'ROLLBACK', 'ABORT'}) do
 		answer = "Duplicate key exists in unique index 'sqlite_autoindex_T1_1' in space 'T1'"
 	end
         test:do_catchsql_test('insert1_'..verb,
-                              [[BEGIN;
+                              [[START TRANSACTION;
                                   INSERT INTO t2 VALUES (2, 2);
                                   INSERT OR ]]..verb..[[ INTO t1 VALUES (1,1);
                               ]],
@@ -52,7 +52,7 @@ for _, verb in ipairs({'ROLLBACK', 'ABORT'}) do
 
         box.sql.execute('DELETE FROM t2')
         test:do_catchsql_test('update1_'..verb,
-                       [[BEGIN;
+                       [[START TRANSACTION;
                            INSERT INTO t2 VALUES (2, 2);
                            UPDATE OR ]]..verb..[[ t1 SET s1 = 1 WHERE s1 = 2;
                          ]],
diff --git a/test/sql-tap/gh2964-abort.test.lua b/test/sql-tap/gh2964-abort.test.lua
index 193aabb..5267786 100755
--- a/test/sql-tap/gh2964-abort.test.lua
+++ b/test/sql-tap/gh2964-abort.test.lua
@@ -45,7 +45,7 @@ for _, val in ipairs(data) do
 
     test:do_catchsql_test(
         local_test_prefix.."1",
-        "begin;")
+        "START TRANSACTION;")
 
     test:do_catchsql_test(
         local_test_prefix.."2",
diff --git a/test/sql-tap/icu.test.lua b/test/sql-tap/icu.test.lua
index 1a6b01f..5b67e9f 100755
--- a/test/sql-tap/icu.test.lua
+++ b/test/sql-tap/icu.test.lua
@@ -32,7 +32,7 @@ if (0 > 0)
             name,
             function ()
                 return test:execsql(string.format([[
-                    BEGIN;
+                    START TRANSACTION;
                     UPDATE test1 SET %s;
                     SELECT %s FROM test1;
                     ROLLBACK;
diff --git a/test/sql-tap/identifier-characters.test.lua b/test/sql-tap/identifier-characters.test.lua
index 31b45c6..e5a0782 100755
--- a/test/sql-tap/identifier-characters.test.lua
+++ b/test/sql-tap/identifier-characters.test.lua
@@ -60,7 +60,7 @@ local testcases = {
 	end},
 	{"savepoint name",
 	function (id)
-		test:execsql("begin")
+		test:execsql("START TRANSACTION")
 		local ok, res = pcall(test.execsql, test, string.format("savepoint \"%s\"", id))
 		test:execsql("commit")
 		if ok == false then error(res) end
diff --git a/test/sql-tap/in1.test.lua b/test/sql-tap/in1.test.lua
index fb31eb2..bd6bd9c 100755
--- a/test/sql-tap/in1.test.lua
+++ b/test/sql-tap/in1.test.lua
@@ -26,7 +26,7 @@ test:do_test(
     function()
         test:execsql [[
             CREATE TABLE t1(a PRIMARY KEY, b);
-            BEGIN;
+            START TRANSACTION;
         ]]
         -- for _ in X(0, "X!for", [=[["set i 1","$i<=10","incr i"]]=]) do
         local j = 1
@@ -1073,7 +1073,7 @@ test:do_execsql_test(
 -- MUST_WORK_TEST
 -- do_test in-13.14 {
 --   execsql {
---     BEGIN TRANSACTION;
+--     START TRANSACTION;
 --     CREATE TABLE a(id INTEGER);
 --     INSERT INTO a VALUES(1);
 --     INSERT INTO a VALUES(2);
diff --git a/test/sql-tap/in2.test.lua b/test/sql-tap/in2.test.lua
index a53624e..239585e 100755
--- a/test/sql-tap/in2.test.lua
+++ b/test/sql-tap/in2.test.lua
@@ -43,7 +43,7 @@ test:do_test(
             table.insert(rows, string.format('INSERT INTO a VALUES(%d, 0x%x)', 4001 + i, i))
         end
 
-        test:execsql('BEGIN')
+        test:execsql('START TRANSACTION')
         for _, v in ipairs(rows) do
             test:execsql(v)
         end
diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua
index 4329381..9013a1d 100755
--- a/test/sql-tap/index1.test.lua
+++ b/test/sql-tap/index1.test.lua
@@ -1077,7 +1077,7 @@ test:do_execsql_test(
     test:do_catchsql_test(
         "index-19.2",
         [[
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO t7 VALUES(1);
         ]], {
             -- <index-19.2>
@@ -1088,7 +1088,7 @@ test:do_execsql_test(
     test:do_catchsql_test(
         "index-19.3",
         [[
-            BEGIN;
+            START TRANSACTION;
         ]], {
             -- <index-19.3>
             1, "Operation is not permitted when there is an active transaction "
@@ -1108,7 +1108,7 @@ test:do_execsql_test(
     test:do_catchsql_test(
         "index-19.5",
         [[
-            BEGIN;
+            START TRANSACTION;
             COMMIT;
         ]], {
             -- <index-19.5>
diff --git a/test/sql-tap/index2.test.lua b/test/sql-tap/index2.test.lua
index 8df6af3..f9176b8 100755
--- a/test/sql-tap/index2.test.lua
+++ b/test/sql-tap/index2.test.lua
@@ -66,7 +66,7 @@ test:do_execsql_test(
 test:do_test(
     "index2-1.4",
     function()
-        test:execsql("BEGIN")
+        test:execsql("START TRANSACTION")
         for j = 1, ROW_NUM, 1 do
             local sql_parts = {"INSERT INTO t1 VALUES(".. ((j * 10000) + 1)}
             for i = 2, COL_NUM+1, 1 do
diff --git a/test/sql-tap/index3.test.lua b/test/sql-tap/index3.test.lua
index 7f6baa6..944bbd3 100755
--- a/test/sql-tap/index3.test.lua
+++ b/test/sql-tap/index3.test.lua
@@ -38,7 +38,7 @@ test:do_execsql_test(
 -- MUST_WORK_TEST
 -- do_test index3-1.2 {
 --   catchsql {
---     BEGIN;
+--     START TRANSACTION;
 --     CREATE UNIQUE INDEX i1 ON t1(a);
 --   }
 -- } {1 {UNIQUE constraint failed: t1.a}}
diff --git a/test/sql-tap/index4.test.lua b/test/sql-tap/index4.test.lua
index 22e5066..69b7ebc 100755
--- a/test/sql-tap/index4.test.lua
+++ b/test/sql-tap/index4.test.lua
@@ -23,7 +23,7 @@ test:do_execsql_test(
     1.1,
     [[
           CREATE TABLE t1(x primary key);
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t1 VALUES(randomblob(102));
           INSERT INTO t1 SELECT randomblob(102) FROM t1;     --     2
           INSERT INTO t1 SELECT randomblob(102) FROM t1;     --     4
@@ -79,7 +79,7 @@ test:do_execsql_test(
     [[
           DROP TABLE t1;
           CREATE TABLE t1(x primary key);
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t1 VALUES('a');
           INSERT INTO t1 VALUES('b');
           INSERT INTO t1 VALUES('c');
@@ -105,7 +105,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     1.7,
     [[
-        --BEGIN;
+        --START TRANSACTION;
           DROP TABLE t1;
           CREATE TABLE t1(x primary key);
           INSERT INTO t1 VALUES('a');
@@ -124,7 +124,7 @@ if (1 > 0)
     test:do_execsql_test(
         1.8,
         [[
-            --BEGIN;
+            --START TRANSACTION;
               DROP TABLE t1;
               CREATE TABLE t1(x primary key);
             --COMMIT;
@@ -141,7 +141,7 @@ test:do_execsql_test(
     2.1,
     [[
           CREATE TABLE t2(id primary key, x);
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t2 VALUES(1, 14);
           INSERT INTO t2 VALUES(2, 35);
           INSERT INTO t2 VALUES(3, 15);
diff --git a/test/sql-tap/insert3.test.lua b/test/sql-tap/insert3.test.lua
index c0e9d95..62d64e0 100755
--- a/test/sql-tap/insert3.test.lua
+++ b/test/sql-tap/insert3.test.lua
@@ -275,7 +275,7 @@ test:drop_all_tables()
 --             test:execsql([[
 --                 CREATE TABLE t1(id INTEGER PRIMARY KEY AUTOINCREMENT, a, b, c);
 --                 CREATE INDEX i1 ON t1(a, b);
---                 BEGIN;
+--                 START TRANSACTION;
 --                 INSERT INTO t1 (a,b,c)VALUES(randstr(10,400),randstr(10,400),randstr(10,400));
 --             ]])
 --             r = "randstr(10,400)"
@@ -292,7 +292,7 @@ test:drop_all_tables()
 --     test:do_execsql_test(
 --         "insert3-4.2",
 --         [[
---             BEGIN;
+--             START TRANSACTION;
 --               UPDATE t1 SET a = randstr(10,10) WHERE (id%4)==0;
 --               DELETE FROM t1 WHERE id%2;
 --               INSERT INTO t1 SELECT randstr(10,400), randstr(10,400), c FROM t1;
diff --git a/test/sql-tap/intpkey.test.lua b/test/sql-tap/intpkey.test.lua
index ecff3c0..bd9febe 100755
--- a/test/sql-tap/intpkey.test.lua
+++ b/test/sql-tap/intpkey.test.lua
@@ -601,7 +601,7 @@ end
 test:do_execsql_test(
     "intpkey-6.1",
     [[
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t1 VALUES(20,'b-20','c-20');
         INSERT INTO t1 VALUES(21,'b-21','c-21');
         INSERT INTO t1 VALUES(22,'b-22','c-22');
diff --git a/test/sql-tap/join.test.lua b/test/sql-tap/join.test.lua
index 074a293..2a1c0df 100755
--- a/test/sql-tap/join.test.lua
+++ b/test/sql-tap/join.test.lua
@@ -646,7 +646,7 @@ test:do_catchsql_test(
 
 -- do_test join-4.1 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --     CREATE TABLE t5(a INTEGER PRIMARY KEY);
 --     CREATE TABLE t6(a INTEGER);
 --     INSERT INTO t6 VALUES(NULL);
@@ -711,12 +711,12 @@ test:do_execsql_test(
         create table centros (id integer primary key, centro);
         create table usuarios (id integer primary key, nombre, apellidos,
         idcentro integer);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO centros VALUES(1,'xxx');
         INSERT INTO usuarios VALUES(1,'a','aa',1);
         INSERT INTO usuarios VALUES(2,'b','bb',1);
         INSERT INTO usuarios VALUES(3,'c','cc',NULL);
-        END;
+        COMMIT;
         create index idcentro on usuarios (idcentro);
         select usuarios.id, usuarios.nombre, centros.centro from
         usuarios left outer join centros on usuarios.idcentro = centros.id;
@@ -764,7 +764,7 @@ test:do_execsql_test(
 -- ifcapable view {
 -- do_test join-8.1 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --     CREATE TABLE t9(a INTEGER PRIMARY KEY, b);
 --     INSERT INTO t9 VALUES(1,11);
 --     INSERT INTO t9 VALUES(2,22);
@@ -818,7 +818,7 @@ test:do_execsql_test(
     [[
         CREATE TABLE t12(a primary key,b);
         CREATE TABLE t13(b primary key,c);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t12 VALUES(1,11);
         INSERT INTO t12 VALUES(2,22);
         INSERT INTO t13 VALUES(22,222);
diff --git a/test/sql-tap/join5.test.lua b/test/sql-tap/join5.test.lua
index 744407d..93f44c5 100755
--- a/test/sql-tap/join5.test.lua
+++ b/test/sql-tap/join5.test.lua
@@ -27,7 +27,7 @@ test:do_execsql_test(
         CREATE TABLE t1(a integer primary key, b integer, c integer);
         CREATE TABLE t2(x integer primary key, y);
         CREATE TABLE t3(p integer primary key, q);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t3 VALUES(11,'t3-11');
         INSERT INTO t3 VALUES(12,'t3-12');
         INSERT INTO t2 VALUES(11,'t2-11');
diff --git a/test/sql-tap/limit.test.lua b/test/sql-tap/limit.test.lua
index 4e2af8f..2293107 100755
--- a/test/sql-tap/limit.test.lua
+++ b/test/sql-tap/limit.test.lua
@@ -24,7 +24,7 @@ test:plan(103)
 --
 test:execsql [[
     CREATE TABLE t1(id primary key, x int, y int);
-    BEGIN;
+    START TRANSACTION;
 ]]
 for i=1,32 do
     --for _ in X(0, "X!for", [=[["set i 1","$i<=32","incr i"]]=]) do
@@ -234,7 +234,7 @@ test:do_test(
     function()
         return test:execsql [[
             CREATE TABLE t3(x primary KEY);
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO t3 SELECT x FROM t1 ORDER BY x LIMIT 10 OFFSET 1;
             INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
             INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
@@ -246,7 +246,7 @@ test:do_test(
             INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
             INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
             INSERT INTO t3 SELECT x+(SELECT max(x) FROM t3) FROM t3;
-            END;
+            COMMIT;
             SELECT count(*) FROM t3;
         ]]
 
@@ -347,7 +347,7 @@ test:do_execsql_test(
     "limit-6.1",
     [[
         CREATE TABLE t6(a primary key);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t6 VALUES(1);
         INSERT INTO t6 VALUES(2);
         INSERT INTO t6 SELECT a+2 FROM t6;
diff --git a/test/sql-tap/minmax2.test.lua b/test/sql-tap/minmax2.test.lua
index ab56f1a..fbb002f 100755
--- a/test/sql-tap/minmax2.test.lua
+++ b/test/sql-tap/minmax2.test.lua
@@ -27,7 +27,7 @@ test:do_execsql_test(
     "minmax2-1.0",
     [[
         CREATE TABLE t1(id PRIMARY KEY, x, y);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t1 VALUES(1, 1,1);
         INSERT INTO t1 VALUES(2, 2,2);
         INSERT INTO t1 VALUES(3, 3,2);
diff --git a/test/sql-tap/minmax3.test.lua b/test/sql-tap/minmax3.test.lua
index 7d1e3a8..d44ddab 100755
--- a/test/sql-tap/minmax3.test.lua
+++ b/test/sql-tap/minmax3.test.lua
@@ -52,7 +52,7 @@ test:do_test(
         -- set_file_format 4
         -- sqlite3 db test.db
         return test:execsql [[
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO t1 VALUES(1, '1', 'I',   'one');
             INSERT INTO t1 VALUES(2, '2', 'IV',  'four');
             INSERT INTO t1 VALUES(3, '2', NULL,  'three');
diff --git a/test/sql-tap/misc1.test.lua b/test/sql-tap/misc1.test.lua
index 5e1dfd1..5224309 100755
--- a/test/sql-tap/misc1.test.lua
+++ b/test/sql-tap/misc1.test.lua
@@ -177,7 +177,7 @@ test:do_test(
     function()
         test:execsql([[
             CREATE TABLE agger(one text primary key, two text, three text, four text);
-            BEGIN TRANSACTION;
+            START TRANSACTION;
             INSERT INTO agger VALUES(1, 'one', 'hello', 'yes');
             INSERT INTO agger VALUES(2, 'two', 'howdy', 'no');
             INSERT INTO agger VALUES(3, 'thr', 'howareya', 'yes');
@@ -238,7 +238,7 @@ test:do_execsql_test(
     "misc1-4.1",
     [[
         CREATE TABLE t2(a primary key);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t2 VALUES('This is a long string to use up a lot of disk -');
         UPDATE t2 SET a=a||a||a||a;
         INSERT INTO t2 SELECT '1 - ' || a FROM t2;
@@ -567,7 +567,7 @@ if (0 > 0) then
     test:do_test(
         "misc1-11.1",
         function()
-            test:execsql("BEGIN")
+            test:execsql("START TRANSACTION")
             test:execsql("UPDATE t1 SET a=0 WHERE 0")
             sqlite3("db2", "test.db")
             rc = X(371, "X!cmd", [=[["catch","db2 eval {SELECT count(*) FROM t1}","msg"]]=])
@@ -940,7 +940,7 @@ if (0 > 0) then
     test:do_execsql_test(
         "misc1-17.1",
         [[
-            BEGIN;
+            START TRANSACTION;
             CREATE TABLE RealTable(TestID INTEGER PRIMARY KEY, TestString TEXT);
             CREATE TABLE TempTable(TestID INTEGER PRIMARY KEY, TestString TEXT);
             CREATE TRIGGER trigTest_1 AFTER UPDATE ON TempTable BEGIN
@@ -1065,7 +1065,7 @@ test:do_execsql_test(
 -- do_execsql_test misc1-23.1 {
 --   CREATE TABLE t1(x);
 --   UPDATE sqlite_master SET sql='CREATE table t(d CHECK(T(#0)';
---   BEGIN;
+--   START TRANSACTION;
 --   CREATE TABLE t2(y);
 --   ROLLBACK;
 --   DROP TABLE IF EXISTS t3;
@@ -1078,7 +1078,7 @@ test:do_execsql_test(
 -- do_catchsql_test misc1-23.2 {
 --   CREATE TABLE t1(x UNIQUE);
 --   UPDATE sqlite_master SET sql='CREATE TABLE IF not EXISTS t(c)';
---   BEGIN;
+--   START TRANSACTION;
 --   CREATE TABLE t2(x);
 --   ROLLBACK;
 --   DROP TABLE F;
@@ -1088,7 +1088,7 @@ test:do_execsql_test(
 -- do_catchsql_test misc1-23.3 {
 --   CREATE TABLE t1(x UNIQUE);
 --   UPDATE sqlite_master SET sql='CREATE table y(a TEXT, a TEXT)';
---   BEGIN;
+--   START TRANSACTION;
 --   CREATE TABLE t2(y);
 --   ROLLBACK;
 --   DROP TABLE IF EXISTS t;
diff --git a/test/sql-tap/misc3.test.lua b/test/sql-tap/misc3.test.lua
index 7029e56..92f8210 100755
--- a/test/sql-tap/misc3.test.lua
+++ b/test/sql-tap/misc3.test.lua
@@ -40,7 +40,7 @@ test:do_test(
             INSERT INTO t1 VALUES(2,'x');
             UPDATE t1 SET b=substr(b,1,500);
             CREATE TABLE t2(x PRIMARY KEY,y);
-            BEGIN;
+            START TRANSACTION;
         ]])
         test:catchsql("UPDATE t1 SET a=CASE a WHEN 2 THEN 1 ELSE a END, b='y';")
         return test:execsql([[
@@ -73,7 +73,7 @@ test:do_test(
             INSERT INTO t1 SELECT a+16, b FROM t1;
             INSERT INTO t1 SELECT a+32, b FROM t1;
             INSERT INTO t1 SELECT a+64, b FROM t1;
-            BEGIN;
+            START TRANSACTION;
         ]])
         test:catchsql("UPDATE t1 SET a=CASE a WHEN 128 THEN 127 ELSE a END, b='';")
         return test:execsql([[
@@ -408,13 +408,13 @@ test:do_execsql_test(
 
 
 
--- Ticket #626:  make sure EXPLAIN prevents BEGIN and COMMIT from working.
+-- Ticket #626:  make sure EXPLAIN prevents START TRANSACTION and COMMIT from working.
 --
 test:do_test(
     "misc3-6.1",
     function()
-        test:execsql("EXPLAIN BEGIN")
-        return test:catchsql("BEGIN")
+        test:execsql("EXPLAIN START TRANSACTION")
+        return test:catchsql("START TRANSACTION")
     end, {
         -- <misc3-6.1>
         0
@@ -435,7 +435,7 @@ test:do_test(
 test:do_test(
     "misc3-6.3",
     function()
-        test:execsql("BEGIN; EXPLAIN ROLLBACK")
+        test:execsql("START TRANSACTION; EXPLAIN ROLLBACK")
         return test:catchsql("ROLLBACK")
     end, {
         -- <misc3-6.3>
@@ -494,7 +494,7 @@ if (0 > 0) then
             CREATE TABLE y1(a primary key);
             CREATE TABLE y2(b primary key);
             CREATE TABLE y3(c primary key);
-            BEGIN;
+            START TRANSACTION;
             CREATE TRIGGER r1 AFTER DELETE ON y1 FOR EACH ROW BEGIN
               INSERT INTO y3(c) SELECT b FROM y2 ORDER BY b LIMIT 1;
             END;
diff --git a/test/sql-tap/misc5.test.lua b/test/sql-tap/misc5.test.lua
index 09deeff..eef7d1f 100755
--- a/test/sql-tap/misc5.test.lua
+++ b/test/sql-tap/misc5.test.lua
@@ -73,7 +73,7 @@ test:do_execsql_test(
     [[
         create table t2(x primary key);
         create table t2_temp(id primary key, x);
-        BEGIN;
+        START TRANSACTION;
         insert into t2_temp values(1, 1);
         insert into t2_temp select id+1,x*2 from t2_temp;
         insert into t2_temp select id+2,x*4 from t2_temp;
@@ -311,7 +311,7 @@ test:do_test(
 --   catchsql {
 --     CREATE TABLE t1(x UNIQUE);
 --     UPDATE sqlite_master SET sql='CREATE table t(o CHECK(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((;VALUES(o)';
---     BEGIN;
+--     START TRANSACTION;
 --     CREATE TABLE t2(y);
 --     ROLLBACK;
 --     DROP TABLE IF EXISTS D;
diff --git a/test/sql-tap/null.test.lua b/test/sql-tap/null.test.lua
index ee30961..65d5720 100755
--- a/test/sql-tap/null.test.lua
+++ b/test/sql-tap/null.test.lua
@@ -26,7 +26,7 @@ test:do_execsql_test(
     "null-1.0",
     [[
         create table t1(a primary key,b,c);
-        begin;
+        START TRANSACTION;
         insert into t1 values(1,0,0);
         insert into t1 values(2,0,1);
         insert into t1 values(3,1,0);
diff --git a/test/sql-tap/orderby1.test.lua b/test/sql-tap/orderby1.test.lua
index e216df2..30ccf83 100755
--- a/test/sql-tap/orderby1.test.lua
+++ b/test/sql-tap/orderby1.test.lua
@@ -40,7 +40,7 @@ test:do_test(
               name TEXT,
               UNIQUE(aid, tn)
             );
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO album VALUES(1, '1-one'), (2, '2-two'), (3, '3-three');
             INSERT INTO track VALUES
                 (1, 1, 1, 'one-a'),
@@ -276,7 +276,7 @@ test:do_test(
 -- #
 -- do_test 2.0 {
 --   db eval {
---     BEGIN;
+--     START TRANSACTION;
 --     DROP TABLE album;
 --     DROP TABLE track;
 --     CREATE TABLE album(
@@ -427,7 +427,7 @@ test:do_test(
               name TEXT,
               UNIQUE(aid ASC, tn DESC)
             );
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO album VALUES(1, '1-one'), (2, '2-two'), (3, '3-three');
             INSERT INTO track VALUES
                 (1, 1, 1, 'one-a'),
diff --git a/test/sql-tap/select1.test.lua b/test/sql-tap/select1.test.lua
index 2f55722..6cfce9a 100755
--- a/test/sql-tap/select1.test.lua
+++ b/test/sql-tap/select1.test.lua
@@ -1985,7 +1985,7 @@ test:do_test(
         test:execsql [[
             drop table if exists abc;
             create TABLE abc(a, b, c, PRIMARY KEY(a, b));
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO abc VALUES(1, 1, 1);
         ]]
         for i = 0,9,1 do
diff --git a/test/sql-tap/select2.test.lua b/test/sql-tap/select2.test.lua
index 48b85ad..bc33f62 100755
--- a/test/sql-tap/select2.test.lua
+++ b/test/sql-tap/select2.test.lua
@@ -23,7 +23,7 @@ test:plan(16)
 --
 test:execsql "DROP TABLE IF EXISTS tbl1"
 test:execsql "CREATE TABLE tbl1(id int, f1 int, f2 int, primary key(id))"
-test:execsql "BEGIN"
+test:execsql "START TRANSACTION"
 for i = 0, 30, 1 do
     test:execsql(string.format("INSERT INTO tbl1 VALUES(%s, %s,%s)", i, i%9, i%10))
 end
@@ -74,7 +74,7 @@ test:execsql "DROP TABLE if exists tbl2"
 test:do_test(
     "select2-2.0.2",
     function()
-        test:execsql "CREATE TABLE tbl2(f1 int primary key, f2 int, f3 int); BEGIN;"
+        test:execsql "CREATE TABLE tbl2(f1 int primary key, f2 int, f3 int); START TRANSACTION;"
         for i = 1, 30000, 1 do
             test:execsql( string.format("INSERT INTO tbl2 VALUES(%s,%s,%s)",i, i*2, i*3))
         end
diff --git a/test/sql-tap/select3.test.lua b/test/sql-tap/select3.test.lua
index 58ed7d5..d49bb87 100755
--- a/test/sql-tap/select3.test.lua
+++ b/test/sql-tap/select3.test.lua
@@ -26,7 +26,7 @@ test:do_test("select3-1.0", function()
   test:execsql [[
     DROP TABLE IF EXISTS t1;
     CREATE TABLE t1(n int primary key, log int);
-    BEGIN;
+    START TRANSACTION;
   ]]
   for i = 1, 32-1 do -- in X(0, "X!for", [=[["set i 1","$i<32","incr i"]]=]) do
      j = 0
diff --git a/test/sql-tap/select4.test.lua b/test/sql-tap/select4.test.lua
index 600bc5b..a3a7004 100755
--- a/test/sql-tap/select4.test.lua
+++ b/test/sql-tap/select4.test.lua
@@ -28,7 +28,7 @@ test:plan(103)
 test:execsql [[
     DROP TABLE IF EXISTS t1;
     CREATE TABLE t1(n int primary key, log int);
-    BEGIN;
+    START TRANSACTION;
 ]]
 local i, j
 for i = 1, 31, 1 do
@@ -760,7 +760,7 @@ test:do_test(
     function()
         test:execsql [[
             CREATE TABLE t3(a text primary key, b float, c text);
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO t3 VALUES(1, 1.1, '1.1');
             INSERT INTO t3 VALUES(2, 1.10, '1.10');
             INSERT INTO t3 VALUES(3, 1.10, '1.1');
diff --git a/test/sql-tap/select5.test.lua b/test/sql-tap/select5.test.lua
index 97cf3f9..7ca25ae 100755
--- a/test/sql-tap/select5.test.lua
+++ b/test/sql-tap/select5.test.lua
@@ -25,7 +25,7 @@ test:plan(32)
 test:execsql [[
     DROP TABLE IF EXISTS t1;
     CREATE TABLE t1(x int primary key, y int);
-    BEGIN;
+    START TRANSACTION;
 ]]
 local i, j
 for i = 1, 31, 1 do
diff --git a/test/sql-tap/select6.test.lua b/test/sql-tap/select6.test.lua
index 5f3edf3..306e43c 100755
--- a/test/sql-tap/select6.test.lua
+++ b/test/sql-tap/select6.test.lua
@@ -32,7 +32,7 @@ test:do_test(
         return test:execsql [[
             DROP TABLE IF EXISTS t1;
             CREATE TABLE t1 (x int PRIMARY KEY, y int);
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO t1 VALUES(1,1);
             INSERT INTO t1 VALUES(2,2);
             INSERT INTO t1 VALUES(3,2);
@@ -680,7 +680,7 @@ test:do_execsql_test(
         CREATE TABLE t3 (p primary key, q);
         DROP TABLE IF EXISTS t4;
         CREATE TABLE t4(q primary key, r);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO t3 VALUES(1,11);
         INSERT INTO t3 VALUES(2,22);
         INSERT INTO t4 VALUES(11,111);
diff --git a/test/sql-tap/select9.test.lua b/test/sql-tap/select9.test.lua
index e85308c..323304b 100755
--- a/test/sql-tap/select9.test.lua
+++ b/test/sql-tap/select9.test.lua
@@ -138,7 +138,7 @@ test:do_execsql_test(
         DROP TABLE IF EXISTS t2;
         CREATE TABLE t1(id primary key, a, b, c);
         CREATE TABLE t2(id primary key, d, e, f);
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t1 VALUES(0, 1,  'one',   'I');
           INSERT INTO t1 VALUES(1, 3,  NULL,    NULL);
           INSERT INTO t1 VALUES(2, 5,  'five',  'V');
diff --git a/test/sql-tap/selectF.test.lua b/test/sql-tap/selectF.test.lua
index 0222ee2..a28fe5d 100755
--- a/test/sql-tap/selectF.test.lua
+++ b/test/sql-tap/selectF.test.lua
@@ -26,7 +26,7 @@ test:do_execsql_test(
     [[
         CREATE TABLE t1(a primary key, b, c);
         CREATE TABLE t2(d primary key, e, f);
-        BEGIN TRANSACTION;
+        START TRANSACTION;
         INSERT INTO t1 VALUES(1,'one','I');
         INSERT INTO t2 VALUES(5,'ten','XX');
         INSERT INTO t2 VALUES(6,NULL,NULL);
diff --git a/test/sql-tap/sort.test.lua b/test/sql-tap/sort.test.lua
index edd0816..436af4b 100755
--- a/test/sql-tap/sort.test.lua
+++ b/test/sql-tap/sort.test.lua
@@ -831,7 +831,7 @@ test:do_execsql_test(
 test:do_test(
     "sort-13.1",
     function()
-        test:execsql("BEGIN;")
+        test:execsql("START TRANSACTION;")
         for i = 0, 100000 -1 , 1 do
             test:execsql( string.format("INSERT INTO t10 VALUES(%s +1, %s/10, %s%%10)",i, i, i))
         end
diff --git a/test/sql-tap/subquery.test.lua b/test/sql-tap/subquery.test.lua
index 119f602..fc6a13d 100755
--- a/test/sql-tap/subquery.test.lua
+++ b/test/sql-tap/subquery.test.lua
@@ -28,7 +28,7 @@ test:do_test(
         test:execsql [[
             CREATE TABLE t1(a PRIMARY KEY,b);
             CREATE TABLE t2(x PRIMARY KEY,y);
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO t1 VALUES(1,2);
             INSERT INTO t1 VALUES(3,4);
             INSERT INTO t1 VALUES(5,6);
diff --git a/test/sql-tap/subquery2.test.lua b/test/sql-tap/subquery2.test.lua
index 647a240..db3a317 100755
--- a/test/sql-tap/subquery2.test.lua
+++ b/test/sql-tap/subquery2.test.lua
@@ -29,7 +29,7 @@ test:do_test(
             CREATE TABLE t1(a PRIMARY KEY,b);
             CREATE TABLE t2(c PRIMARY KEY,d);
             CREATE TABLE t3(e PRIMARY KEY,f);
-            BEGIN;
+            START TRANSACTION;
             INSERT INTO t1 VALUES(1,2);
             INSERT INTO t1 VALUES(3,4);
             INSERT INTO t1 VALUES(5,6);
diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua
index 31330a5..ac10675 100755
--- a/test/sql-tap/table.test.lua
+++ b/test/sql-tap/table.test.lua
@@ -429,7 +429,7 @@ if (0 > 0)
                 CREATE TABLE t0(a,b);
                 CREATE INDEX t ON t0(a);
                 UPDATE sqlite_master SET sql='CREATE TABLE a.b(a UNIQUE';
-                --BEGIN;
+                --START TRANSACTION;
                 --CREATE TABLE t1(x);
                 --ROLLBACK;
                 DROP TABLE IF EXISTS t99;
@@ -1133,7 +1133,7 @@ test:do_test(
 -- #
 -- do_catchsql_test table-18.1 {
 --   DROP TABLE IF EXISTS t1;
---   BEGIN;
+--   START TRANSACTION;
 --   CREATE TABLE t1 AS SELECT zeroblob(2e20);
 -- } {1 {string or blob too big}}
 -- do_execsql_test table-18.2 {
diff --git a/test/sql-tap/tkt-4a03edc4c8.test.lua b/test/sql-tap/tkt-4a03edc4c8.test.lua
index d05271a..cbee2b4 100755
--- a/test/sql-tap/tkt-4a03edc4c8.test.lua
+++ b/test/sql-tap/tkt-4a03edc4c8.test.lua
@@ -32,7 +32,7 @@ test:do_test(
             INSERT INTO t1 VALUES(2, 2);
         ]]
         return test:catchsql [[
-            BEGIN;
+            START TRANSACTION;
               INSERT INTO t1 VALUES(1, 2);
             COMMIT;
         ]]
diff --git a/test/sql-tap/tkt-b1d3a2e531.test.lua b/test/sql-tap/tkt-b1d3a2e531.test.lua
index 5cfa2e1..d5f34cc 100755
--- a/test/sql-tap/tkt-b1d3a2e531.test.lua
+++ b/test/sql-tap/tkt-b1d3a2e531.test.lua
@@ -117,7 +117,7 @@ test:do_execsql_test(
 test:do_catchsql_test(
     3.2,
     [[
-        -- BEGIN;
+        -- START TRANSACTION;
           DELETE FROM pp2;
         -- COMMIT;
           DROP TABLE pp1;
diff --git a/test/sql-tap/tkt1449.test.lua b/test/sql-tap/tkt1449.test.lua
index 0318187..3bb931c 100755
--- a/test/sql-tap/tkt1449.test.lua
+++ b/test/sql-tap/tkt1449.test.lua
@@ -33,7 +33,7 @@ test:do_execsql_test(
     "tkt1449-1.1",
     [[
         -- Tarantool: DDL is prohibited inside a transaction so far
-        -- BEGIN;
+        -- START TRANSACTION;
         CREATE TABLE ACLS(ISSUEID text(50) not null, OBJECTID text(50) not null, PARTICIPANTID text(50) not null, PERMISSIONBITS int not null, constraint PK_ACLS primary key (ISSUEID, OBJECTID, PARTICIPANTID));
         CREATE TABLE ACTIONITEMSTATUSES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, FRIENDLYNAME text(100) not null, REVISION int not null, SHORTNAME text(30) not null, LONGNAME text(200) not null, ATTACHMENTHANDLING int not null, RESULT int not null, NOTIFYCREATOR text(1) null, NOTIFYASSIGNEE text(1) null, NOTIFYFYI text(1) null, NOTIFYCLOSURETEAM text(1) null, NOTIFYCOORDINATORS text(1) null, COMMENTREQUIRED text(1) not null, constraint PK_ACTIONITEMSTATUSES primary key (ISSUEID, OBJECTID));
         CREATE TABLE ACTIONITEMTYPES(CLASSID int null, SEQNO int not null, LASTMODONNODEID text(50) not null, PREVMODONNODEID text(50) null, ISSUEID text(50) not null, OBJECTID text(50) not null, REVISIONNUM int not null, CONTAINERID text(50) not null, AUTHORID text(50) not null, CREATIONDATE text(25) null, LASTMODIFIEDDATE text(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD text(300) null, LASTMODIFIEDBYID text(50) null, REVISION int not null, LABEL text(200) not null, INSTRUCTIONS text not null, EMAILINSTRUCTIONS text null, ALLOWEDSTATUSES text not null, INITIALSTATUS text(100) not null, COMMENTREQUIRED text(1) not null, ATTACHMENTHANDLING int not null, constraint PK_ACTIONITEMTYPES primary key (ISSUEID, OBJECTID));
diff --git a/test/sql-tap/tkt3493.test.lua b/test/sql-tap/tkt3493.test.lua
index 17eab05..85f3c08 100755
--- a/test/sql-tap/tkt3493.test.lua
+++ b/test/sql-tap/tkt3493.test.lua
@@ -26,7 +26,7 @@ test:do_execsql_test(
         CREATE TABLE A (id INTEGER PRIMARY KEY, val TEXT);
         CREATE TABLE B (id INTEGER PRIMARY KEY, val TEXT);
         CREATE TABLE A_B (B_id INTEGER NOT NULL PRIMARY KEY, A_id INTEGER);
-        BEGIN;
+        START TRANSACTION;
         INSERT INTO A VALUES(1,'123');
         INSERT INTO A VALUES(2,'456');
         INSERT INTO B VALUES(1,1);
diff --git a/test/sql-tap/trigger1.test.lua b/test/sql-tap/trigger1.test.lua
index 0707c8f..f5793e6 100755
--- a/test/sql-tap/trigger1.test.lua
+++ b/test/sql-tap/trigger1.test.lua
@@ -119,7 +119,7 @@ test:do_catchsql_test(
 
 -- do_test trigger1-1.3 {
 --     catchsql {
---         BEGIN;
+--         START TRANSACTION;
 --         CREATE TRIGGER tr2 INSERT ON t1 BEGIN
 --             SELECT * from sqlite_master; END;
 --         ROLLBACK;
@@ -137,7 +137,7 @@ test:do_catchsql_test(
 -- } {0 {}}
 -- do_test trigger1-1.5 {
 --     execsql {
---         BEGIN;
+--         START TRANSACTION;
 --         DROP TRIGGER tr2;
 --         ROLLBACK;
 --         DROP TRIGGER tr2;
@@ -677,7 +677,7 @@ test:do_execsql_test(
 --   } {main 1 2 3 temp 4 5 6 aux 7 8 9}
 --   do_test trigger1-10.5 {
 --     execsql {
---       BEGIN;
+--       START TRANSACTION;
 --       INSERT INTO main.t4 VALUES(1, 2, 3);
 --       INSERT INTO temp.t4 VALUES(4, 5, 6);
 --       INSERT INTO aux.t4  VALUES(7, 8, 9);
@@ -852,7 +852,7 @@ test:do_catchsql_test(
 test:do_catchsql_test(
     "trigger1-16.8",
     [[
-        BEGIN;
+        START TRANSACTION;
           CREATE TRIGGER tr168 INSERT ON tA BEGIN
             INSERT INTO t16 values(1);
           END;
@@ -867,7 +867,7 @@ test:execsql [[
 test:do_catchsql_test(
     "trigger1-16.9",
     [[
-        BEGIN;
+        START TRANSACTION;
           DROP TRIGGER t16err3;
    ]], {
         1, [[Space _trigger does not support multi-statement transactions]]
diff --git a/test/sql-tap/trigger2.test.lua b/test/sql-tap/trigger2.test.lua
index 578acf5..ecbe6f8 100755
--- a/test/sql-tap/trigger2.test.lua
+++ b/test/sql-tap/trigger2.test.lua
@@ -497,7 +497,7 @@ test:execsql [[
 --   }
 --   do_test trigger2-6.1a {
 --     execsql {
---       BEGIN;
+--       START TRANSACTION;
 --       INSERT INTO tbl values (1, 2, 3);
 --       SELECT * from tbl;
 --     }
@@ -549,7 +549,7 @@ test:execsql [[
 --   }
 --   do_test trigger2-6.2a {
 --     execsql {
---       BEGIN;
+--       START TRANSACTION;
 --       UPDATE tbl SET a = 1 WHERE a = 4;
 --       SELECT * from tbl;
 --     }
diff --git a/test/sql-tap/trigger9.test.lua b/test/sql-tap/trigger9.test.lua
index 840d184..3040958 100755
--- a/test/sql-tap/trigger9.test.lua
+++ b/test/sql-tap/trigger9.test.lua
@@ -69,7 +69,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN
           INSERT INTO t2 VALUES(old.x);
         END;
-        BEGIN;
+        START TRANSACTION;
           DELETE FROM t1;
           SELECT * FROM t2;
     ]], {
@@ -105,7 +105,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 BEFORE DELETE ON t1 BEGIN
           INSERT INTO t2 VALUES(old.x);
         END;
-        BEGIN;
+        START TRANSACTION;
           DELETE FROM t1;
           SELECT * FROM t2;
     ]], {
@@ -141,7 +141,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 BEFORE DELETE ON t1 WHEN old.x='1' BEGIN
           INSERT INTO t2 VALUES(old.x);
         END;
-        BEGIN;
+        START TRANSACTION;
           DELETE FROM t1;
           SELECT * FROM t2;
     ]], {
@@ -177,7 +177,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
           INSERT INTO t2 VALUES(old.x);
         END;
-        BEGIN;
+        START TRANSACTION;
           UPDATE t1 SET y = '';
           SELECT * FROM t2;
     ]], {
@@ -213,7 +213,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 BEFORE UPDATE ON t1 BEGIN
           INSERT INTO t2 VALUES(old.x);
         END;
-        BEGIN;
+        START TRANSACTION;
           UPDATE t1 SET y = '';
           SELECT * FROM t2;
     ]], {
@@ -249,7 +249,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 BEFORE UPDATE ON t1 WHEN old.x>='2' BEGIN
           INSERT INTO t2 VALUES(old.x);
         END;
-        BEGIN;
+        START TRANSACTION;
           UPDATE t1 SET y = '';
           SELECT * FROM t2;
     ]], {
@@ -299,7 +299,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
           INSERT INTO t2 VALUES(old.a);
         END;
-        BEGIN;
+        START TRANSACTION;
           UPDATE v1 SET b = 'hello';
           SELECT * FROM t2;
         ROLLBACK;
@@ -324,7 +324,7 @@ test:do_test(
             CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
               INSERT INTO t2 VALUES(old.a);
             END;
-            BEGIN;
+            START TRANSACTION;
               UPDATE v1 SET c = 'hello';
               SELECT * FROM t2;
             ROLLBACK;
@@ -344,7 +344,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
           INSERT INTO t2 VALUES(old.a);
         END;
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t3 VALUES(4, 3, 'three');
           UPDATE v1 SET b = 'hello';
           SELECT * FROM t2;
@@ -364,7 +364,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
           INSERT INTO t2 VALUES(old.a);
         END;
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t3 VALUES(5, 1, 'uno');
           UPDATE v1 SET b = 'hello';
           SELECT * FROM t2;
@@ -385,7 +385,7 @@ test:do_execsql_test(
         CREATE TRIGGER trig1 INSTEAD OF UPDATE ON v1 BEGIN
           INSERT INTO t2 VALUES(old.a);
         END;
-        BEGIN;
+        START TRANSACTION;
           INSERT INTO t3 VALUES(6, 1, 'zero');
           UPDATE v1 SET b = 'hello';
           SELECT * FROM t2;
diff --git a/test/sql-tap/triggerC.test.lua b/test/sql-tap/triggerC.test.lua
index e58072e..eb18336 100755
--- a/test/sql-tap/triggerC.test.lua
+++ b/test/sql-tap/triggerC.test.lua
@@ -633,7 +633,7 @@ test:do_execsql_test(
 -- } {
 --   do_test triggerC-5.1.$n {
 --     execsql "
---       BEGIN;
+--       START TRANSACTION;
 --         $dml ;
 --         SELECT * FROM t5g ORDER BY rowid;
 --         SELECT * FROM t5 ORDER BY rowid;
@@ -666,7 +666,7 @@ test:do_execsql_test(
 -- } {
 --   do_test triggerC-5.2.$n {
 --     execsql "
---       BEGIN;
+--       START TRANSACTION;
 --         $dml ;
 --         SELECT * FROM t5g ORDER BY rowid;
 --         SELECT * FROM t5 ORDER BY rowid;
@@ -696,7 +696,7 @@ test:do_execsql_test(
 -- } {
 --   do_test triggerC-5.3.$n {
 --     execsql "
---       BEGIN;
+--       START TRANSACTION;
 --         $dml ;
 --         SELECT * FROM t5g ORDER BY rowid;
 --         SELECT * FROM t5 ORDER BY rowid;
@@ -773,7 +773,7 @@ test:do_execsql_test(
 -- } {}
 -- do_test triggerC-7.2 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --       UPDATE t7 SET b=7 WHERE a = 5;
 --       SELECT * FROM t7;
 --       SELECT * FROM t8;
@@ -782,7 +782,7 @@ test:do_execsql_test(
 -- } {3 4 5 7 {after fired 3->3}}
 -- do_test triggerC-7.3 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --       UPDATE t7 SET b=7 WHERE a = 1;
 --       SELECT * FROM t7;
 --       SELECT * FROM t8;
@@ -800,7 +800,7 @@ test:do_execsql_test(
 -- } {}
 -- do_test triggerC-7.5 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --       UPDATE t7 SET b=7 WHERE a = 5;
 --       SELECT rowid, * FROM t7;
 --       SELECT * FROM t8;
@@ -809,7 +809,7 @@ test:do_execsql_test(
 -- } {2 3 4 3 5 7 8 1 2 {after fired 1->8} {after fired 3->3}}
 -- do_test triggerC-7.6 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --       UPDATE t7 SET b=7 WHERE a = 1;
 --       SELECT rowid, * FROM t7;
 --       SELECT * FROM t8;
@@ -830,7 +830,7 @@ test:do_execsql_test(
 -- } {}
 -- do_test triggerC-7.8 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --       DELETE FROM t7 WHERE a = 3;
 --       SELECT rowid, * FROM t7;
 --       SELECT * FROM t8;
@@ -839,7 +839,7 @@ test:do_execsql_test(
 -- } {3 5 6 8 1 2 {after fired 2}}
 -- do_test triggerC-7.9 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --       DELETE FROM t7 WHERE a = 1;
 --       SELECT rowid, * FROM t7;
 --       SELECT * FROM t8;
diff --git a/test/sql-tap/update.test.lua b/test/sql-tap/update.test.lua
index a4efe40..4a1b555 100755
--- a/test/sql-tap/update.test.lua
+++ b/test/sql-tap/update.test.lua
@@ -1011,7 +1011,7 @@ test:do_catchsql_test("update-10.10", [[
 -- #
 -- do_test update-13.1 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --     CREATE TABLE t2(id primary key, a);
 --     INSERT INTO t2 VALUES(1, 1);
 --     INSERT INTO t2 VALUES(2, 2);
@@ -1049,7 +1049,7 @@ test:do_catchsql_test("update-10.10", [[
 -- } {2048}
 -- do_test update-13.4 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --     INSERT INTO t2 SELECT id+2048,a+2048 FROM t2;
 --     INSERT INTO t2 SELECT id+4096,a+4096 FROM t2;
 --     INSERT INTO t2 SELECT id+8192,a+8192 FROM t2;
diff --git a/test/sql-tap/view.test.lua b/test/sql-tap/view.test.lua
index ac1a27d..4670019 100755
--- a/test/sql-tap/view.test.lua
+++ b/test/sql-tap/view.test.lua
@@ -53,7 +53,7 @@ if (0 > 0)
     test:do_execsql_test(
         "view-1.1",
         [[
-            BEGIN;
+            START TRANSACTION;
             CREATE VIEW IF NOT EXISTS v1 AS SELECT a,b FROM t1;
             SELECT * FROM v1 ORDER BY a;
         ]], {
diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua
index 67820df..e657996 100755
--- a/test/sql-tap/where2.test.lua
+++ b/test/sql-tap/where2.test.lua
@@ -39,7 +39,7 @@ test:do_test(
     function()
         test:execsql [[
             CREATE TABLE t1(w int PRIMARY KEY, x int, y int, z int);
-            BEGIN;
+            START TRANSACTION;
         ]]
         for i=1,100 do
             w = i
@@ -1214,7 +1214,7 @@ test:do_execsql_test(
         function()
             test:execsql [[
                 CREATE TABLE t10(id int PRIMARY KEY,a,b,c);
-                BEGIN;
+                START TRANSACTION;
                 INSERT INTO t10 VALUES(1, 1,1,1);
                 INSERT INTO t10 VALUES(2, 1,2,2);
                 INSERT INTO t10 VALUES(3, 1,3,3);
diff --git a/test/sql-tap/where4.test.lua b/test/sql-tap/where4.test.lua
index 5ed9e99..e027ed2 100755
--- a/test/sql-tap/where4.test.lua
+++ b/test/sql-tap/where4.test.lua
@@ -294,7 +294,7 @@ test:do_test(
 -- integrity_check {where4-99.0}
 -- do_test where4-7.1 {
 --   execsql {
---     BEGIN;
+--     START TRANSACTION;
 --     CREATE TABLE t8(a primary key, b, c, d);
 --     CREATE INDEX t8_i ON t8(a, b, c);
 --     CREATE TABLE t7(i primary key);
diff --git a/test/sql/tokenizer.result b/test/sql/tokenizer.result
index 9e50b87..7c0ca8f 100644
--- a/test/sql/tokenizer.result
+++ b/test/sql/tokenizer.result
@@ -102,9 +102,9 @@ sql_tokenizer.split_sql('select 1; -- test comment\n; select 2;')
 - - select 1;
   - ' select 2;'
 ...
-sql_tokenizer.split_sql("begin; insert into table values ('example kek--'); commit;")
+sql_tokenizer.split_sql("start transaction; insert into table values ('example kek--'); commit;")
 ---
-- - begin;
+- - start transaction;
   - ' insert into table values (''example kek--'');'
   - ' commit;'
 ...
diff --git a/test/sql/tokenizer.test.lua b/test/sql/tokenizer.test.lua
index 7a69d12..5c1cadc 100644
--- a/test/sql/tokenizer.test.lua
+++ b/test/sql/tokenizer.test.lua
@@ -32,7 +32,7 @@ test_run:cmd("setopt delimiter ''");
 
 sql_tokenizer.split_sql('select 1; -- test comment\n; select 2;')
 
-sql_tokenizer.split_sql("begin; insert into table values ('example kek--'); commit;")
+sql_tokenizer.split_sql("start transaction; insert into table values ('example kek--'); commit;")
 
 sql_tokenizer.split_sql("insert into quoted(a) value 'lalala'")
 
diff --git a/test/sql/transitive-transactions.result b/test/sql/transitive-transactions.result
index da618d2..a01b1d0 100644
--- a/test/sql/transitive-transactions.result
+++ b/test/sql/transitive-transactions.result
@@ -21,10 +21,10 @@ box.begin() box.sql.execute('COMMIT');
 box.begin() box.sql.execute('ROLLBACK');
 ---
 ...
-box.sql.execute('BEGIN;') box.commit();
+box.sql.execute('START TRANSACTION;') box.commit();
 ---
 ...
-box.sql.execute('BEGIN;') box.rollback();
+box.sql.execute('START TRANSACTION;') box.rollback();
 ---
 ...
 box.sql.execute('pragma foreign_keys = 1;');
@@ -52,7 +52,7 @@ box.space.CHILD:select();
 - []
 ...
 fk_violation_2 = function()
-    box.sql.execute('BEGIN;')
+    box.sql.execute('START TRANSACTION;')
     box.sql.execute('INSERT INTO child VALUES (1, 1);')
     box.commit()
 end;
diff --git a/test/sql/transitive-transactions.test.lua b/test/sql/transitive-transactions.test.lua
index f663bf6..1ac2b8d 100644
--- a/test/sql/transitive-transactions.test.lua
+++ b/test/sql/transitive-transactions.test.lua
@@ -10,8 +10,8 @@ test_run:cmd("setopt delimiter ';'")
 
 box.begin() box.sql.execute('COMMIT');
 box.begin() box.sql.execute('ROLLBACK');
-box.sql.execute('BEGIN;') box.commit();
-box.sql.execute('BEGIN;') box.rollback();
+box.sql.execute('START TRANSACTION;') box.commit();
+box.sql.execute('START TRANSACTION;') box.rollback();
 
 box.sql.execute('pragma foreign_keys = 1;');
 box.sql.execute('CREATE TABLE parent(id INT PRIMARY KEY, y INT UNIQUE);');
@@ -26,7 +26,7 @@ fk_violation_1();
 box.space.CHILD:select();
 
 fk_violation_2 = function()
-    box.sql.execute('BEGIN;')
+    box.sql.execute('START TRANSACTION;')
     box.sql.execute('INSERT INTO child VALUES (1, 1);')
     box.commit()
 end;
-- 
2.7.4

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

end of thread, other threads:[~2018-07-20 13:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-05 10:42 [tarantool-patches] [PATCH] sql: Remove 'BEGIN TRANSACTION' N.Tatunov
2018-07-05 11:48 ` [tarantool-patches] " Nikita Tatunov
2018-07-09 15:35 ` Alexander Turenko
2018-07-13  2:15 ` n.pettik
2018-07-16 12:22   ` Nikita Tatunov
2018-07-19  0:24     ` n.pettik
2018-07-19 11:48       ` Nikita Tatunov
2018-07-19 14:03         ` n.pettik
2018-07-19 15:44           ` Vladislav Shpilevoy
2018-07-19 18:08             ` Nikita Tatunov
2018-07-19 18:13               ` Vladislav Shpilevoy
2018-07-20 13:24 ` Kirill Yukhin

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