From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 8618A2B03F for ; Sun, 30 Sep 2018 19:54:29 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7eyoaA-tixyt for ; Sun, 30 Sep 2018 19:54:29 -0400 (EDT) Received: from smtp38.i.mail.ru (smtp38.i.mail.ru [94.100.177.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 3AA2F2B036 for ; Sun, 30 Sep 2018 19:54:29 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH 2/2] sql: add test on changes/total_changes From: "n.pettik" In-Reply-To: Date: Mon, 1 Oct 2018 02:54:24 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <7BEF7461-8C36-472F-95D7-6E46CD99E956@tarantool.org> References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: Alex Khatskevich > On 27 Sep 2018, at 15:39, AKhatskevich = wrote: >=20 > Closes #2181 > --- > test/sql-tap/gh2181-changes-statistics.test.lua | 74 = +++++++++++++++++++++++++ > 1 file changed, 74 insertions(+) > create mode 100755 test/sql-tap/gh2181-changes-statistics.test.lua >=20 > diff --git a/test/sql-tap/gh2181-changes-statistics.test.lua = b/test/sql-tap/gh2181-changes-statistics.test.lua > new file mode 100755 > index 000000000..26eb95f28 > --- /dev/null > +++ b/test/sql-tap/gh2181-changes-statistics.test.lua > @@ -0,0 +1,74 @@ > +#!/usr/bin/env tarantool > +test =3D require("sqltester") > +test:plan(56) > + > +test:do_select_tests( > + "gh2181-changes-statistics", > + { > + {"0.1", "SELECT CHANGES()", {0}}, > + {"0.2", "SELECT TOTAL_CHANGES()", {0}}, > + {"1.0", "CREATE TABLE T1(A PRIMARY KEY)", {}}, > + {"1.1", "SELECT CHANGES()", {1}}, > + {"1.2", "SELECT TOTAL_CHANGES()", {1}}, > + {"2.0", "INSERT INTO T1 VALUES(1)", {}}, > + {"2.1", "SELECT CHANGES()", {1}}, > + {"2.2", "SELECT TOTAL_CHANGES()", {2}}, > + {"3.0", "INSERT INTO T1 VALUES(2)", {}}, > + {"3.1", "SELECT CHANGES()", {1}}, > + {"3.2", "SELECT TOTAL_CHANGES()", {3}}, > + {"4.0", "CREATE TABLE T2(A PRIMARY KEY)", {}}, > + {"4.1", "SELECT CHANGES()", {1}}, > + {"4.2", "SELECT TOTAL_CHANGES()", {4}}, > + {"5.0", "INSERT INTO T2 SELECT * FROM T1", {}}, > + {"5.1", "SELECT CHANGES()", {2}}, > + {"5.2", "SELECT TOTAL_CHANGES()", {6}}, > + {"6.0", [[ > + CREATE TRIGGER TRIG1 AFTER INSERT ON T1 FOR EACH = ROW BEGIN > + INSERT INTO T2 VALUES(NEW.A); > + END; > + ]],{}}, > + {"6.1", "SELECT CHANGES()", {1}}, > + {"6.2", "SELECT TOTAL_CHANGES()", {7}}, > + {"6.3", "INSERT INTO T1 VALUES(3)", {}}, > + -- 1 instead of 2; sqlite is the same. > + {"6.4", "SELECT CHANGES()", {1}}, > + {"6.5", "SELECT TOTAL_CHANGES()", {9}}, > + {"6.6", "DROP TRIGGER TRIG1"}, > + {"6.7", "SELECT CHANGES()", {1}}, > + {"6.8", "SELECT TOTAL_CHANGES()", {10}}, > + {"7.0", "DELETE FROM T1 WHERE A =3D 1", {}}, > + {"7.1", "SELECT CHANGES()", {1}}, > + {"7.2", "SELECT TOTAL_CHANGES()", {11}}, > + {"8.0", "UPDATE T1 SET A =3D 1 where A =3D 2", {}}, > + {"8.1", "SELECT CHANGES()", {1}}, > + {"8.2", "SELECT TOTAL_CHANGES()", {12}}, > + {"9.0", "SELECT COUNT(*) FROM T2", {3}}, > + {"9.1", "UPDATE T2 SET A =3D A + 3", {}}, > + -- Inserts to an ephemeral space are not counted. > + {"9.2", "SELECT CHANGES()", {3}}, > + {"9.3", "SELECT TOTAL_CHANGES()", {15}}, > + {"11.0", "DELETE FROM T1", {}}, > + {"11.1", "SELECT CHANGES()", {0}}, > + {"11.2", "SELECT TOTAL_CHANGES()", {15}}, > + {"12.0", "DELETE FROM T2 WHERE A < 100", {}}, > + {"12.1", "SELECT CHANGES()", {3}}, > + {"12.2", "SELECT TOTAL_CHANGES()", {18}}, > + -- Transactions/savepoints. > + {"13.0", "START TRANSACTION", {}}, > + {"13.1", "INSERT INTO T1 VALUES(11)", {}}, > + {"13.2", "SELECT CHANGES()", {1}}, > + {"13.3", "SELECT TOTAL_CHANGES()", {19}}, > + {"13.4", "SAVEPOINT S1", {}}, > + {"13.5", "INSERT INTO T1 VALUES(12)", {}}, > + {"13.6", "SELECT CHANGES()", {1}}, > + {"13.7", "SELECT TOTAL_CHANGES()", {20}}, > + {"13.8", "ROLLBACK TO SAVEPOINT S1", {}}, > + {"13.9", "SELECT CHANGES()", {1}}, > + {"13.10", "SELECT TOTAL_CHANGES()", {20}}, But why here TOTAL_CHANGES =3D=3D 20? At S1 savepoint we have TOTAL_CHANGES =3D=3D 19, so after rollback I guess it shouldn=E2=80=99t = change=E2=80=A6 Did I miss something?