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 19A6A2E2B9 for ; Sun, 9 Jun 2019 16:44:51 -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 C9mHIaTsM3wF for ; Sun, 9 Jun 2019 16:44:50 -0400 (EDT) Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [94.100.177.99]) (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 4E89C2E1B7 for ; Sun, 9 Jun 2019 16:44:50 -0400 (EDT) From: Georgy Kirichenko Subject: [tarantool-patches] [PATCH v3 02/14] ddl: synchronize privileges cache with actual data state. Date: Sun, 9 Jun 2019 23:44:31 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: Georgy Kirichenko We tend to synchronize cached data with the actual data changes: apply while on_replace and undo while on_rollback. --- src/box/alter.cc | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index ed9e55907..c4a1c52a9 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -2938,31 +2938,23 @@ grant_or_revoke(struct priv_def *priv) /** A trigger called on rollback of grant, or on commit of revoke. */ static void -revoke_priv(struct trigger * /* trigger */, void *event) +revoke_priv(struct trigger *trigger, void *event) { - struct txn *txn = (struct txn *) event; - struct txn_stmt *stmt = txn_last_stmt(txn); - struct tuple *tuple = (stmt->new_tuple ? - stmt->new_tuple : stmt->old_tuple); + (void) event; + struct tuple *tuple = (struct tuple *)trigger->data; struct priv_def priv; priv_def_create_from_tuple(&priv, tuple); - /* - * Access to the object has been removed altogether so - * there should be no grants at all. If only some grants - * were removed, modify_priv trigger would have been - * invoked. - */ priv.access = 0; grant_or_revoke(&priv); } /** A trigger called on rollback of grant, or on commit of revoke. */ static void -modify_priv(struct trigger * /* trigger */, void *event) +modify_priv(struct trigger *trigger, void *event) { - struct txn_stmt *stmt = txn_last_stmt((struct txn *) event); + (void) event; struct priv_def priv; - priv_def_create_from_tuple(&priv, stmt->new_tuple); + priv_def_create_from_tuple(&priv, (struct tuple *)trigger->data); grant_or_revoke(&priv); } @@ -2985,21 +2977,24 @@ on_replace_dd_priv(struct trigger * /* trigger */, void *event) priv_def_check(&priv, PRIV_GRANT); grant_or_revoke(&priv); struct trigger *on_rollback = - txn_alter_trigger_new(revoke_priv, NULL); + txn_alter_trigger_new(revoke_priv, new_tuple); txn_on_rollback(txn, on_rollback); } else if (new_tuple == NULL) { /* revoke */ assert(old_tuple); priv_def_create_from_tuple(&priv, old_tuple); priv_def_check(&priv, PRIV_REVOKE); - struct trigger *on_commit = - txn_alter_trigger_new(revoke_priv, NULL); - txn_on_commit(txn, on_commit); + priv.access = 0; + grant_or_revoke(&priv); + struct trigger *on_rollback = + txn_alter_trigger_new(modify_priv, old_tuple); + txn_on_rollback(txn, on_rollback); } else { /* modify */ priv_def_create_from_tuple(&priv, new_tuple); priv_def_check(&priv, PRIV_GRANT); - struct trigger *on_commit = - txn_alter_trigger_new(modify_priv, NULL); - txn_on_commit(txn, on_commit); + grant_or_revoke(&priv); + struct trigger *on_rollback = + txn_alter_trigger_new(modify_priv, old_tuple); + txn_on_rollback(txn, on_rollback); } } -- 2.21.0