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 F0D4E286BB for ; Mon, 11 Mar 2019 16:00:39 -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 LGv-tHG2Hn1z for ; Mon, 11 Mar 2019 16:00:39 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 9A0D723CE0 for ; Mon, 11 Mar 2019 16:00:39 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: [tarantool-patches] Re: [PATCH v2 4/9] box: fix on_replace_trigger_rollback routine From: "n.pettik" In-Reply-To: Date: Mon, 11 Mar 2019 23:00:37 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <9961E112-506A-4B99-A94B-1B2F7B2C442A@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: Kirill Shcherbatov This patch LGTM. Since it is barely related to check constraints, I suggest to consider it as independent. > 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(-) >=20 > 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(); >=20 > on_commit->data =3D old_trigger; > - on_rollback->data =3D new_trigger; > + on_rollback->data =3D > + old_tuple =3D=3D NULL ? new_trigger : = old_trigger; > new_trigger_guard.is_active =3D false; > } >=20 > 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 =3D box.space._trigger:get('T1T') > +--- > +... > +t_new =3D t:totable() > +--- > +... > +t_new[3]['sql'] =3D 'CREATE TRIGGER t1t INSERT ON t1 BEGIN INSERT = INTO t2 VALUES (2, 2); END;' > +--- > +... > +_ =3D box.space._trigger:replace(t, t_new) > +--- > +- error: Failed to write to disk > +... > +box.error.injection.set("ERRINJ_WAL_IO", false) > +--- > +- ok > +... > +_ =3D 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 =3D box.space._trigger:get('T1T') > +t_new =3D t:totable() > +t_new[3]['sql'] =3D 'CREATE TRIGGER t1t INSERT ON t1 BEGIN INSERT = INTO t2 VALUES (2, 2); END;' > +_ =3D box.space._trigger:replace(t, t_new) > +box.error.injection.set("ERRINJ_WAL_IO", false) > +_ =3D 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;") > --=20 > 2.19.2 >=20