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 73FFF22B2E for ; Thu, 3 May 2018 14:49:36 -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 CB8scmtG0odO for ; Thu, 3 May 2018 14:49:36 -0400 (EDT) Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 2D0DD22B7E for ; Thu, 3 May 2018 14:49:36 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 4/4] sql: fix SAVEPOINT RELEASE statement Date: Thu, 3 May 2018 21:49:25 +0300 Message-Id: In-Reply-To: References: In-Reply-To: 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: v.shpilevoy@tarantool.org, Nikita Pettik Before this patch SAVEPOINT RELEASE statement always raised error, due to SQLite's obsolete code. Now it has been removed, and SAVEPOINT RELEASE works as desired. Closes #3379 --- src/box/sql/vdbe.c | 7 ----- test/sql/gh-3379-release-savepoints.result | 40 ++++++++++++++++++++++++++++ test/sql/gh-3379-release-savepoints.test.lua | 26 ++++++++++++++++++ 3 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 test/sql/gh-3379-release-savepoints.result create mode 100644 test/sql/gh-3379-release-savepoints.test.lua diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 6ea04901c..62f393de4 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -2901,13 +2901,6 @@ case OP_Savepoint: { if (!pSavepoint) { sqlite3VdbeError(p, "no such savepoint: %s", zName); rc = SQLITE_ERROR; - } else if (p1==SAVEPOINT_RELEASE) { - /* It is not possible to release (commit) a savepoint if there are - * active write statements. - */ - sqlite3VdbeError(p, "cannot release savepoint - " - "SQL statements in progress"); - rc = SQLITE_BUSY; } else { /* Determine whether or not this is a transaction savepoint. If so, diff --git a/test/sql/gh-3379-release-savepoints.result b/test/sql/gh-3379-release-savepoints.result new file mode 100644 index 000000000..5f5804b66 --- /dev/null +++ b/test/sql/gh-3379-release-savepoints.result @@ -0,0 +1,40 @@ +test_run = require('test_run').new() +--- +... +test_run:cmd("setopt delimiter ';'") +--- +- true +... +-- These tests check that release of SQL savepoints works as desired. +-- +-- box.cfg() +release_sv = function() + box.begin() + box.sql.execute('SAVEPOINT t1;') + box.sql.execute('RELEASE SAVEPOINT t1;') +end; +--- +... +release_sv(); +--- +... +box.commit(); +--- +... +release_sv_fail = function() + box.begin() + box.sql.execute('SAVEPOINT t1;') + box.sql.execute('SAVEPOINT t2;') + box.sql.execute('RELEASE SAVEPOINT t2;') + box.sql.execute('RELEASE SAVEPOINT t1;') + box.sql.execute('ROLLBACK TO t1;') +end; +--- +... +release_sv_fail(); +--- +- error: 'no such savepoint: T1' +... +box.commit(); +--- +... diff --git a/test/sql/gh-3379-release-savepoints.test.lua b/test/sql/gh-3379-release-savepoints.test.lua new file mode 100644 index 000000000..6b299045d --- /dev/null +++ b/test/sql/gh-3379-release-savepoints.test.lua @@ -0,0 +1,26 @@ +test_run = require('test_run').new() +test_run:cmd("setopt delimiter ';'") + +-- These tests check that release of SQL savepoints works as desired. +-- + +-- box.cfg() + +release_sv = function() + box.begin() + box.sql.execute('SAVEPOINT t1;') + box.sql.execute('RELEASE SAVEPOINT t1;') +end; +release_sv(); +box.commit(); + +release_sv_fail = function() + box.begin() + box.sql.execute('SAVEPOINT t1;') + box.sql.execute('SAVEPOINT t2;') + box.sql.execute('RELEASE SAVEPOINT t2;') + box.sql.execute('RELEASE SAVEPOINT t1;') + box.sql.execute('ROLLBACK TO t1;') +end; +release_sv_fail(); +box.commit(); -- 2.15.1