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 3038D2AC16 for ; Wed, 14 Nov 2018 07:33:00 -0500 (EST) 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 TdWtcobIMMc6 for ; Wed, 14 Nov 2018 07:33:00 -0500 (EST) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 C17012CDE9 for ; Wed, 14 Nov 2018 07:32:59 -0500 (EST) Subject: [tarantool-patches] Re: [PATCH v2 4/4] sql: rename changes() to row_count() References: From: Vladislav Shpilevoy Message-ID: Date: Wed, 14 Nov 2018 15:32:56 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: Nikita Pettik , tarantool-patches@freelists.org Thanks for the patch! > diff --git a/test/sql/row-count.result b/test/sql/row-count.result > new file mode 100644 > index 000000000..7577d2795 > --- /dev/null > +++ b/test/sql/row-count.result > @@ -0,0 +1,157 @@ > +test_run = require('test_run').new() > +--- > +... > +engine = test_run:get_cfg('engine') > +--- > +... > +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') > +--- > +... > +-- Test cases concerning row count calculations. > +-- > +box.sql.execute("CREATE TABLE t1 (s1 CHAR(10) PRIMARY KEY);") > +--- > +... > +box.sql.execute("SELECT ROW_COUNT();") > +--- > +- - [1] > +... > +box.sql.execute("SELECT ROW_COUNT();") > +--- > +- - [0] 1. As I understand, ROW_COUNT() should return > 0 only in a not empty transaction. Here you got rowcount > 0 after DDL transaction is committed. Also, twice in a row called row_count() returning different values looks weird. 'rowcount' should be returned as a metavalue from a DDL/DML when box.sql.execute is removed. > diff --git a/test/sql/row-count.test.lua b/test/sql/row-count.test.lua > new file mode 100644 > index 000000000..38d3520c2 > --- /dev/null > +++ b/test/sql/row-count.test.lua > @@ -0,0 +1,54 @@ > +test_run = require('test_run').new() > +engine = test_run:get_cfg('engine') > +box.sql.execute('pragma sql_default_engine=\''..engine..'\'') > + > +-- Test cases concerning row count calculations. > +-- > +box.sql.execute("CREATE TABLE t1 (s1 CHAR(10) PRIMARY KEY);") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("CREATE TABLE t2 (s1 CHAR(10) PRIMARY KEY, s2 CHAR(10) REFERENCES t1 ON DELETE CASCADE);") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("CREATE TABLE t3 (i1 INT PRIMARY KEY, i2 INT);") > +box.sql.execute("INSERT INTO t3 VALUES (0, 0);") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("CREATE TRIGGER x AFTER DELETE ON t1 FOR EACH ROW BEGIN UPDATE t3 SET i1 = i1 + ROW_COUNT(); END;") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("INSERT INTO t1 VALUES ('a');") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("INSERT INTO t2 VALUES ('a','a');") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("INSERT INTO t1 VALUES ('b'), ('c'), ('d');") > +box.sql.execute("SELECT ROW_COUNT();") > +-- REPLACE is accounted for two operations: DELETE + INSERT. > +box.sql.execute("REPLACE INTO t2 VALUES('a', 'c');") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("DELETE FROM t1;") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3);") > +box.sql.execute("TRUNCATE TABLE t3;") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3);") > +box.sql.execute("UPDATE t3 SET i2 = 666;") > +box.sql.execute("SELECT ROW_COUNT();") > + > +-- All statements which are not accounted as DML should > +-- return 0 (zero) as a row count. > +-- > +box.sql.execute("START TRANSACTION;") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("COMMIT;") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("COMMIT;") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("ANALYZE;") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute("EXPLAIN QUERY PLAN INSERT INTO t1 VALUES ('b'), ('c'), ('d');") > +box.sql.execute("SELECT ROW_COUNT();") > +box.sql.execute('PRAGMA recursive_triggers') > + > +-- Clean-up. > +-- > +box.sql.execute("DROP TABLE t2;") > +box.sql.execute("DROP TABLE t3;") > +box.sql.execute("DROP TABLE t1;") > \ No newline at end of file 2. "No newline at end of file."