From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org, korablev@tarantool.org Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] [PATCH v2 4/9] box: fix on_replace_trigger_rollback routine Date: Wed, 30 Jan 2019 11:59:11 +0300 [thread overview] Message-ID: <a5fe539e828d5126697d7a98029064106ffa3076.1548838034.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1548838034.git.kshcherbatov@tarantool.org> The function on_replace_trigger_rollback in the case of a replace operation rollback was called with an incorrect argument, as a result of which the used memory was freed. --- src/box/alter.cc | 3 ++- test/sql/errinj.result | 24 ++++++++++++++++++++++++ test/sql/errinj.test.lua | 7 +++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index ab3dd2e22..eff3524cf 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -3591,7 +3591,8 @@ on_replace_dd_trigger(struct trigger * /* trigger */, void *event) diag_raise(); on_commit->data = old_trigger; - on_rollback->data = new_trigger; + on_rollback->data = + old_tuple == NULL ? new_trigger : old_trigger; new_trigger_guard.is_active = false; } diff --git a/test/sql/errinj.result b/test/sql/errinj.result index c423c8bc6..acce52e8a 100644 --- a/test/sql/errinj.result +++ b/test/sql/errinj.result @@ -205,6 +205,30 @@ box.error.injection.set("ERRINJ_WAL_IO", true) --- - ok ... +t = box.space._trigger:get('T1T') +--- +... +t_new = t:totable() +--- +... +t_new[3]['sql'] = 'CREATE TRIGGER t1t INSERT ON t1 BEGIN INSERT INTO t2 VALUES (2, 2); END;' +--- +... +_ = box.space._trigger:replace(t, t_new) +--- +- error: Failed to write to disk +... +box.error.injection.set("ERRINJ_WAL_IO", false) +--- +- ok +... +_ = box.space._trigger:replace(t, t_new) +--- +... +box.error.injection.set("ERRINJ_WAL_IO", true) +--- +- ok +... box.sql.execute("DROP TRIGGER t1t;") --- - error: Failed to write to disk diff --git a/test/sql/errinj.test.lua b/test/sql/errinj.test.lua index 8378c255c..fc19c859b 100644 --- a/test/sql/errinj.test.lua +++ b/test/sql/errinj.test.lua @@ -75,6 +75,13 @@ box.sql.execute("INSERT INTO t1 VALUES (3, 3);") box.sql.execute("SELECT * from t1"); box.sql.execute("SELECT * from t2"); box.error.injection.set("ERRINJ_WAL_IO", true) +t = box.space._trigger:get('T1T') +t_new = t:totable() +t_new[3]['sql'] = 'CREATE TRIGGER t1t INSERT ON t1 BEGIN INSERT INTO t2 VALUES (2, 2); END;' +_ = box.space._trigger:replace(t, t_new) +box.error.injection.set("ERRINJ_WAL_IO", false) +_ = box.space._trigger:replace(t, t_new) +box.error.injection.set("ERRINJ_WAL_IO", true) box.sql.execute("DROP TRIGGER t1t;") box.error.injection.set("ERRINJ_WAL_IO", false) box.sql.execute("DELETE FROM t1;") -- 2.19.2
next prev parent reply other threads:[~2019-01-30 8:59 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-01-30 8:59 [tarantool-patches] [PATCH v2 0/9] sql: Checks on server side Kirill Shcherbatov 2019-01-30 8:59 ` [tarantool-patches] [PATCH v2 1/9] box: fix upgrade script for _fk_constraint space Kirill Shcherbatov 2019-03-11 18:44 ` [tarantool-patches] " n.pettik 2019-03-13 11:36 ` Kirill Yukhin 2019-01-30 8:59 ` [tarantool-patches] [PATCH v2 2/9] box: fix _trigger and _ck_constraint access check Kirill Shcherbatov 2019-03-11 19:29 ` [tarantool-patches] " n.pettik 2019-03-22 9:29 ` Vladislav Shpilevoy 2019-03-26 10:59 ` Kirill Shcherbatov 2019-04-01 14:06 ` n.pettik 2019-03-13 11:38 ` Kirill Yukhin 2019-03-13 11:44 ` Kirill Yukhin 2019-01-30 8:59 ` [tarantool-patches] [PATCH v2 3/9] box: fix Tarantool upgrade from 2.1.0 to 2.1.1 Kirill Shcherbatov 2019-03-12 11:45 ` [tarantool-patches] " n.pettik 2019-03-20 15:12 ` n.pettik 2019-03-20 15:38 ` Kirill Shcherbatov 2019-03-21 15:23 ` n.pettik 2019-03-21 15:36 ` Vladislav Shpilevoy 2019-03-22 9:28 ` Vladislav Shpilevoy 2019-03-22 10:18 ` Kirill Shcherbatov 2019-03-22 10:21 ` Vladislav Shpilevoy 2019-03-26 9:52 ` Kirill Yukhin 2019-01-30 8:59 ` Kirill Shcherbatov [this message] 2019-03-11 20:00 ` [tarantool-patches] Re: [PATCH v2 4/9] box: fix on_replace_trigger_rollback routine n.pettik 2019-03-13 11:39 ` Kirill Yukhin 2019-01-30 8:59 ` [tarantool-patches] [PATCH v2 5/9] schema: add new system space for CHECK constraints Kirill Shcherbatov 2019-03-22 9:29 ` [tarantool-patches] " Vladislav Shpilevoy 2019-03-22 9:52 ` n.pettik 2019-03-26 10:59 ` Kirill Shcherbatov 2019-04-01 19:45 ` n.pettik 2019-04-16 13:51 ` Kirill Shcherbatov 2019-01-30 8:59 ` [tarantool-patches] [PATCH v2 6/9] sql: disallow use of TYPEOF in Check Kirill Shcherbatov 2019-03-26 10:59 ` [tarantool-patches] " Kirill Shcherbatov 2019-04-01 19:52 ` n.pettik 2019-01-30 8:59 ` [tarantool-patches] [PATCH v2 7/9] sql: refactor sqlite3_reset routine Kirill Shcherbatov 2019-03-26 10:59 ` [tarantool-patches] " Kirill Shcherbatov 2019-01-30 8:59 ` [tarantool-patches] [PATCH v2 8/9] box: exported sql_bind structure and API Kirill Shcherbatov 2019-03-26 10:59 ` [tarantool-patches] " Kirill Shcherbatov 2019-01-30 8:59 ` [tarantool-patches] [PATCH v2 9/9] sql: run check constraint tests on space alter Kirill Shcherbatov 2019-03-26 10:59 ` [tarantool-patches] " Kirill Shcherbatov 2019-04-02 14:14 ` n.pettik 2019-04-16 13:51 ` Kirill Shcherbatov
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=a5fe539e828d5126697d7a98029064106ffa3076.1548838034.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v2 4/9] box: fix on_replace_trigger_rollback routine' \ /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