From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 936A543D67B for ; Mon, 14 Oct 2019 19:03:27 +0300 (MSK) From: Kirill Shcherbatov Date: Mon, 14 Oct 2019 19:03:17 +0300 Message-Id: <13b180b87580875ff26612193fe7992ac60a45c4.1571068485.git.kshcherbatov@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v1 2/9] box: rename struct trigger to lua_trigger List-Id: Tarantool development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@freelists.org, tarantool-patches@dev.tarantool.org, kostja.osipov@gmail.com, korablev@tarantool.org Renamed struct trigger to struct lua_trigger because the 'trigger' name is too general. Currently Tarantool has non-persistent AppServer Lua triggers represented with 'trigger' structure so as SQL-specific persistent trigger object named 'sql_trigger'. In scope of this patchset we going to significantly rework triggers subsystem and introduce a new base trigger class named 'trigger', so this name is be better to be released. Needed for #4343 --- src/box/alter.cc | 232 ++++++++++++++++++------------------ src/box/alter.h | 34 +++--- src/box/applier.cc | 28 ++--- src/box/applier.h | 2 +- src/box/ck_constraint.c | 2 +- src/box/ck_constraint.h | 4 +- src/box/error.cc | 2 +- src/box/iproto.cc | 4 +- src/box/lua/call.c | 4 +- src/box/lua/sequence.c | 4 +- src/box/lua/space.cc | 4 +- src/box/lua/tuple.c | 2 +- src/box/memtx_space.c | 8 +- src/box/recovery.cc | 2 +- src/box/relay.cc | 6 +- src/box/replication.cc | 8 +- src/box/replication.h | 4 +- src/box/schema.cc | 2 +- src/box/session.cc | 4 +- src/box/session.h | 4 +- src/box/space.c | 8 +- src/box/space.h | 2 +- src/box/txn.c | 8 +- src/box/txn.h | 14 +-- src/box/vinyl.c | 32 ++--- src/box/vy_lsm.c | 2 +- src/box/vy_scheduler.c | 4 +- src/box/vy_tx.c | 2 +- src/lib/core/cbus.c | 2 +- src/lib/core/fiber.c | 6 +- src/lib/core/trigger.cc | 6 +- src/lib/core/trigger.h | 20 ++-- src/lib/swim/swim.c | 2 +- src/lua/swim.c | 2 +- src/lua/trigger.c | 6 +- src/lua/trigger.h | 2 +- src/lua/utils.h | 2 +- src/main.cc | 4 +- test/unit/cbus.c | 6 +- test/unit/swim.c | 14 +-- test/unit/swim_test_utils.c | 6 +- 41 files changed, 255 insertions(+), 255 deletions(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index bb3686d6e..4bc2e6e6b 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -705,11 +705,11 @@ public: * A trigger installed on transaction commit/rollback events of * the transaction which initiated the alter. */ -static struct trigger * +static struct lua_trigger * txn_alter_trigger_new(trigger_f run, void *data) { - struct trigger *trigger = (struct trigger *) - region_calloc_object_xc(&in_txn()->region, struct trigger); + struct lua_trigger *trigger = (struct lua_trigger *) + region_calloc_object_xc(&in_txn()->region, struct lua_trigger); trigger->run = run; trigger->data = data; trigger->destroy = NULL; @@ -860,7 +860,7 @@ struct mh_i32_t *AlterSpaceLock::registry; * Replace the old space with a new one in the space cache. */ static void -alter_space_commit(struct trigger *trigger, void *event) +alter_space_commit(struct lua_trigger *trigger, void *event) { struct txn *txn = (struct txn *) event; struct alter_space *alter = (struct alter_space *) trigger->data; @@ -900,7 +900,7 @@ alter_space_commit(struct trigger *trigger, void *event) * alter_space_commit() failure (unlikely) */ static void -alter_space_rollback(struct trigger *trigger, void * /* event */) +alter_space_rollback(struct lua_trigger *trigger, void * /* event */) { struct alter_space *alter = (struct alter_space *) trigger->data; /* Rollback alter ops */ @@ -966,7 +966,7 @@ alter_space_do(struct txn_stmt *stmt, struct alter_space *alter) * free them in case of failure, because they are allocated on * the region. */ - struct trigger *on_commit, *on_rollback; + struct lua_trigger *on_commit, *on_rollback; on_commit = txn_alter_trigger_new(alter_space_commit, alter); on_rollback = txn_alter_trigger_new(alter_space_rollback, alter); @@ -1646,7 +1646,7 @@ MoveCkConstraints::rollback(struct alter_space *alter) * Delete the space. It is already removed from the space cache. */ static void -on_drop_space_commit(struct trigger *trigger, void *event) +on_drop_space_commit(struct lua_trigger *trigger, void *event) { (void) event; struct space *space = (struct space *)trigger->data; @@ -1659,7 +1659,7 @@ on_drop_space_commit(struct trigger *trigger, void *event) * reverted by the cascading rollback. */ static void -on_drop_space_rollback(struct trigger *trigger, void *event) +on_drop_space_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct space *space = (struct space *)trigger->data; @@ -1674,7 +1674,7 @@ on_drop_space_rollback(struct trigger *trigger, void *event) * rely on cascading rollback. */ static void -on_create_space_rollback(struct trigger *trigger, void *event) +on_create_space_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct space *space = (struct space *)trigger->data; @@ -1792,7 +1792,7 @@ update_view_references(struct Select *select, int update_value, * Its purpose is to release memory of SELECT. */ static void -on_create_view_commit(struct trigger *trigger, void *event) +on_create_view_commit(struct lua_trigger *trigger, void *event) { (void) event; struct Select *select = (struct Select *)trigger->data; @@ -1805,7 +1805,7 @@ on_create_view_commit(struct trigger *trigger, void *event) * releases memory for SELECT. */ static void -on_create_view_rollback(struct trigger *trigger, void *event) +on_create_view_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct Select *select = (struct Select *)trigger->data; @@ -1819,7 +1819,7 @@ on_create_view_rollback(struct trigger *trigger, void *event) * dependent spaces and release memory for SELECT. */ static void -on_drop_view_commit(struct trigger *trigger, void *event) +on_drop_view_commit(struct lua_trigger *trigger, void *event) { (void) event; struct Select *select = (struct Select *)trigger->data; @@ -1832,7 +1832,7 @@ on_drop_view_commit(struct trigger *trigger, void *event) * on_replace_dd_space trigger. */ static void -on_drop_view_rollback(struct trigger *trigger, void *event) +on_drop_view_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct Select *select = (struct Select *)trigger->data; @@ -1891,7 +1891,7 @@ on_drop_view_rollback(struct trigger *trigger, void *event) * clumsy, so it is simply not done. */ static void -on_replace_dd_space(struct trigger * /* trigger */, void *event) +on_replace_dd_space(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -1946,7 +1946,7 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event) * so it's safe to simply drop the space on * rollback. */ - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_create_space_rollback, space); txn_stmt_on_rollback(stmt, on_rollback); if (def->opts.is_view) { @@ -1969,11 +1969,11 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event) tnt_raise(ClientError, ER_NO_SUCH_SPACE, disappeared_space); } - struct trigger *on_commit_view = + struct lua_trigger *on_commit_view = txn_alter_trigger_new(on_create_view_commit, select); txn_stmt_on_commit(stmt, on_commit_view); - struct trigger *on_rollback_view = + struct lua_trigger *on_rollback_view = txn_alter_trigger_new(on_create_view_rollback, select); txn_stmt_on_rollback(stmt, on_rollback_view); @@ -2031,10 +2031,10 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event) * AlterSpaceOps are registered in case of space drop. */ ++schema_version; - struct trigger *on_commit = + struct lua_trigger *on_commit = txn_alter_trigger_new(on_drop_space_commit, old_space); txn_stmt_on_commit(stmt, on_commit); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_drop_space_rollback, old_space); txn_stmt_on_rollback(stmt, on_rollback); if (old_space->def->opts.is_view) { @@ -2046,11 +2046,11 @@ on_replace_dd_space(struct trigger * /* trigger */, void *event) auto select_guard = make_scoped_guard([=] { sql_select_delete(sql_get(), select); }); - struct trigger *on_commit_view = + struct lua_trigger *on_commit_view = txn_alter_trigger_new(on_drop_view_commit, select); txn_stmt_on_commit(stmt, on_commit_view); - struct trigger *on_rollback_view = + struct lua_trigger *on_rollback_view = txn_alter_trigger_new(on_drop_view_rollback, select); txn_stmt_on_rollback(stmt, on_rollback_view); @@ -2187,7 +2187,7 @@ index_is_used_by_fk_constraint(struct rlist *fk_list, uint32_t iid) * are modified. */ static void -on_replace_dd_index(struct trigger * /* trigger */, void *event) +on_replace_dd_index(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -2377,7 +2377,7 @@ on_replace_dd_index(struct trigger * /* trigger */, void *event) * rollback of all transactions following this one. */ static void -on_replace_dd_truncate(struct trigger * /* trigger */, void *event) +on_replace_dd_truncate(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -2584,7 +2584,7 @@ user_def_new_from_tuple(struct tuple *tuple) } static void -user_cache_remove_user(struct trigger *trigger, void * /* event */) +user_cache_remove_user(struct lua_trigger *trigger, void * /* event */) { struct tuple *tuple = (struct tuple *)trigger->data; uint32_t uid = tuple_field_u32_xc(tuple, BOX_USER_FIELD_ID); @@ -2592,7 +2592,7 @@ user_cache_remove_user(struct trigger *trigger, void * /* event */) } static void -user_cache_alter_user(struct trigger *trigger, void * /* event */) +user_cache_alter_user(struct lua_trigger *trigger, void * /* event */) { struct tuple *tuple = (struct tuple *)trigger->data; struct user_def *user = user_def_new_from_tuple(tuple); @@ -2606,7 +2606,7 @@ user_cache_alter_user(struct trigger *trigger, void * /* event */) * A trigger invoked on replace in the user table. */ static void -on_replace_dd_user(struct trigger * /* trigger */, void *event) +on_replace_dd_user(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -2623,7 +2623,7 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event) auto def_guard = make_scoped_guard([=] { free(user); }); (void) user_cache_replace(user); def_guard.is_active = false; - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(user_cache_remove_user, new_tuple); txn_stmt_on_rollback(stmt, on_rollback); } else if (new_tuple == NULL) { /* DELETE */ @@ -2645,7 +2645,7 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event) old_user->def->name, "the user has objects"); } user_cache_delete(uid); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(user_cache_alter_user, old_tuple); txn_stmt_on_rollback(stmt, on_rollback); } else { /* UPDATE, REPLACE */ @@ -2661,7 +2661,7 @@ on_replace_dd_user(struct trigger * /* trigger */, void *event) auto def_guard = make_scoped_guard([=] { free(user); }); user_cache_replace(user); def_guard.is_active = false; - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(user_cache_alter_user, old_tuple); txn_stmt_on_rollback(stmt, on_rollback); } @@ -2860,7 +2860,7 @@ func_def_new_from_tuple(struct tuple *tuple) } static void -on_create_func_rollback(struct trigger *trigger, void * /* event */) +on_create_func_rollback(struct lua_trigger *trigger, void * /* event */) { /* Remove the new function from the cache and delete it. */ struct func *func = (struct func *)trigger->data; @@ -2870,7 +2870,7 @@ on_create_func_rollback(struct trigger *trigger, void * /* event */) } static void -on_drop_func_commit(struct trigger *trigger, void * /* event */) +on_drop_func_commit(struct lua_trigger *trigger, void * /* event */) { /* Delete the old function. */ struct func *func = (struct func *)trigger->data; @@ -2878,7 +2878,7 @@ on_drop_func_commit(struct trigger *trigger, void * /* event */) } static void -on_drop_func_rollback(struct trigger *trigger, void * /* event */) +on_drop_func_rollback(struct lua_trigger *trigger, void * /* event */) { /* Insert the old function back into the cache. */ struct func *func = (struct func *)trigger->data; @@ -2891,7 +2891,7 @@ on_drop_func_rollback(struct trigger *trigger, void * /* event */) * functions on which there were defined any grants. */ static void -on_replace_dd_func(struct trigger * /* trigger */, void *event) +on_replace_dd_func(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -2906,7 +2906,7 @@ on_replace_dd_func(struct trigger * /* trigger */, void *event) auto def_guard = make_scoped_guard([=] { free(def); }); access_check_ddl(def->name, def->fid, def->uid, SC_FUNCTION, PRIV_C); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_create_func_rollback, NULL); struct func *func = func_new(def); if (func == NULL) @@ -2943,9 +2943,9 @@ on_replace_dd_func(struct trigger * /* trigger */, void *event) (unsigned) old_func->def->uid, "function is SQL built-in"); } - struct trigger *on_commit = + struct lua_trigger *on_commit = txn_alter_trigger_new(on_drop_func_commit, old_func); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_drop_func_rollback, old_func); func_cache_delete(old_func->def->fid); txn_stmt_on_commit(stmt, on_commit); @@ -3058,7 +3058,7 @@ coll_id_def_new_from_tuple(struct tuple *tuple, struct coll_id_def *def) /** Delete the new collation identifier. */ static void -on_create_collation_rollback(struct trigger *trigger, void *event) +on_create_collation_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct coll_id *coll_id = (struct coll_id *) trigger->data; @@ -3069,7 +3069,7 @@ on_create_collation_rollback(struct trigger *trigger, void *event) /** Free a deleted collation identifier on commit. */ static void -on_drop_collation_commit(struct trigger *trigger, void *event) +on_drop_collation_commit(struct lua_trigger *trigger, void *event) { (void) event; struct coll_id *coll_id = (struct coll_id *) trigger->data; @@ -3078,7 +3078,7 @@ on_drop_collation_commit(struct trigger *trigger, void *event) /** Put the collation identifier back on rollback. */ static void -on_drop_collation_rollback(struct trigger *trigger, void *event) +on_drop_collation_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct coll_id *coll_id = (struct coll_id *) trigger->data; @@ -3093,7 +3093,7 @@ on_drop_collation_rollback(struct trigger *trigger, void *event) * collations that a user defined. */ static void -on_replace_dd_collation(struct trigger * /* trigger */, void *event) +on_replace_dd_collation(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -3101,9 +3101,9 @@ on_replace_dd_collation(struct trigger * /* trigger */, void *event) struct tuple *new_tuple = stmt->new_tuple; if (new_tuple == NULL && old_tuple != NULL) { /* DELETE */ - struct trigger *on_commit = + struct lua_trigger *on_commit = txn_alter_trigger_new(on_drop_collation_commit, NULL); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_drop_collation_rollback, NULL); /* * TODO: Check that no index uses the collation @@ -3138,7 +3138,7 @@ on_replace_dd_collation(struct trigger * /* trigger */, void *event) txn_stmt_on_commit(stmt, on_commit); } else if (new_tuple != NULL && old_tuple == NULL) { /* INSERT */ - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_create_collation_rollback, NULL); struct coll_id_def new_def; coll_id_def_new_from_tuple(new_tuple, &new_def); @@ -3367,7 +3367,7 @@ grant_or_revoke(struct priv_def *priv) /** A trigger called on rollback of grant. */ static void -revoke_priv(struct trigger *trigger, void *event) +revoke_priv(struct lua_trigger *trigger, void *event) { (void) event; struct tuple *tuple = (struct tuple *)trigger->data; @@ -3379,7 +3379,7 @@ revoke_priv(struct trigger *trigger, void *event) /** A trigger called on rollback of revoke or modify. */ static void -modify_priv(struct trigger *trigger, void *event) +modify_priv(struct lua_trigger *trigger, void *event) { (void) event; struct tuple *tuple = (struct tuple *)trigger->data; @@ -3393,7 +3393,7 @@ modify_priv(struct trigger *trigger, void *event) * all granted privileges. */ static void -on_replace_dd_priv(struct trigger * /* trigger */, void *event) +on_replace_dd_priv(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -3405,7 +3405,7 @@ on_replace_dd_priv(struct trigger * /* trigger */, void *event) priv_def_create_from_tuple(&priv, new_tuple); priv_def_check(&priv, PRIV_GRANT); grant_or_revoke(&priv); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(revoke_priv, new_tuple); txn_stmt_on_rollback(stmt, on_rollback); } else if (new_tuple == NULL) { /* revoke */ @@ -3414,14 +3414,14 @@ on_replace_dd_priv(struct trigger * /* trigger */, void *event) priv_def_check(&priv, PRIV_REVOKE); priv.access = 0; grant_or_revoke(&priv); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(modify_priv, old_tuple); txn_stmt_on_rollback(stmt, on_rollback); } else { /* modify */ priv_def_create_from_tuple(&priv, new_tuple); priv_def_check(&priv, PRIV_GRANT); grant_or_revoke(&priv); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(modify_priv, old_tuple); txn_stmt_on_rollback(stmt, on_rollback); } @@ -3441,7 +3441,7 @@ on_replace_dd_priv(struct trigger * /* trigger */, void *event) * event, not in after-replace event. */ static void -on_replace_dd_schema(struct trigger * /* trigger */, void *event) +on_replace_dd_schema(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -3465,7 +3465,7 @@ on_replace_dd_schema(struct trigger * /* trigger */, void *event) * with it. */ static void -register_replica(struct trigger *trigger, void * /* event */) +register_replica(struct lua_trigger *trigger, void * /* event */) { struct tuple *new_tuple = (struct tuple *)trigger->data; @@ -3486,7 +3486,7 @@ register_replica(struct trigger *trigger, void * /* event */) } static void -unregister_replica(struct trigger *trigger, void * /* event */) +unregister_replica(struct lua_trigger *trigger, void * /* event */) { struct tuple *old_tuple = (struct tuple *)trigger->data; @@ -3517,7 +3517,7 @@ unregister_replica(struct trigger *trigger, void * /* event */) * set without first being reset (emptied). */ static void -on_replace_dd_cluster(struct trigger *trigger, void *event) +on_replace_dd_cluster(struct lua_trigger *trigger, void *event) { (void) trigger; struct txn *txn = (struct txn *) event; @@ -3550,7 +3550,7 @@ on_replace_dd_cluster(struct trigger *trigger, void *event) "updates of instance uuid"); } } else { - struct trigger *on_commit; + struct lua_trigger *on_commit; on_commit = txn_alter_trigger_new(register_replica, new_tuple); txn_stmt_on_commit(stmt, on_commit); @@ -3565,7 +3565,7 @@ on_replace_dd_cluster(struct trigger *trigger, void *event) tuple_field_u32_xc(old_tuple, BOX_CLUSTER_FIELD_ID); replica_check_id(replica_id); - struct trigger *on_commit; + struct lua_trigger *on_commit; on_commit = txn_alter_trigger_new(unregister_replica, old_tuple); txn_stmt_on_commit(stmt, on_commit); @@ -3618,7 +3618,7 @@ sequence_def_new_from_tuple(struct tuple *tuple, uint32_t errcode) } static void -on_create_sequence_rollback(struct trigger *trigger, void * /* event */) +on_create_sequence_rollback(struct lua_trigger *trigger, void * /* event */) { /* Remove the new sequence from the cache and delete it. */ struct sequence *seq = (struct sequence *)trigger->data; @@ -3628,7 +3628,7 @@ on_create_sequence_rollback(struct trigger *trigger, void * /* event */) } static void -on_drop_sequence_commit(struct trigger *trigger, void * /* event */) +on_drop_sequence_commit(struct lua_trigger *trigger, void * /* event */) { /* Delete the old sequence. */ struct sequence *seq = (struct sequence *)trigger->data; @@ -3636,7 +3636,7 @@ on_drop_sequence_commit(struct trigger *trigger, void * /* event */) } static void -on_drop_sequence_rollback(struct trigger *trigger, void * /* event */) +on_drop_sequence_rollback(struct lua_trigger *trigger, void * /* event */) { /* Insert the old sequence back into the cache. */ struct sequence *seq = (struct sequence *)trigger->data; @@ -3646,7 +3646,7 @@ on_drop_sequence_rollback(struct trigger *trigger, void * /* event */) static void -on_alter_sequence_commit(struct trigger *trigger, void * /* event */) +on_alter_sequence_commit(struct lua_trigger *trigger, void * /* event */) { /* Delete the old old sequence definition. */ struct sequence_def *def = (struct sequence_def *)trigger->data; @@ -3654,7 +3654,7 @@ on_alter_sequence_commit(struct trigger *trigger, void * /* event */) } static void -on_alter_sequence_rollback(struct trigger *trigger, void * /* event */) +on_alter_sequence_rollback(struct lua_trigger *trigger, void * /* event */) { /* Restore the old sequence definition. */ struct sequence_def *def = (struct sequence_def *)trigger->data; @@ -3670,7 +3670,7 @@ on_alter_sequence_rollback(struct trigger *trigger, void * /* event */) * Used to alter a sequence definition. */ static void -on_replace_dd_sequence(struct trigger * /* trigger */, void *event) +on_replace_dd_sequence(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -3686,7 +3686,7 @@ on_replace_dd_sequence(struct trigger * /* trigger */, void *event) ER_CREATE_SEQUENCE); access_check_ddl(new_def->name, new_def->id, new_def->uid, SC_SEQUENCE, PRIV_C); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_create_sequence_rollback, NULL); seq = sequence_new_xc(new_def); sequence_cache_insert(seq); @@ -3708,9 +3708,9 @@ on_replace_dd_sequence(struct trigger * /* trigger */, void *event) if (schema_find_grants("sequence", seq->def->id)) tnt_raise(ClientError, ER_DROP_SEQUENCE, seq->def->name, "the sequence has grants"); - struct trigger *on_commit = + struct lua_trigger *on_commit = txn_alter_trigger_new(on_drop_sequence_commit, seq); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_drop_sequence_rollback, seq); sequence_cache_delete(seq->def->id); txn_stmt_on_commit(stmt, on_commit); @@ -3722,9 +3722,9 @@ on_replace_dd_sequence(struct trigger * /* trigger */, void *event) assert(seq != NULL); access_check_ddl(seq->def->name, seq->def->id, seq->def->uid, SC_SEQUENCE, PRIV_A); - struct trigger *on_commit = + struct lua_trigger *on_commit = txn_alter_trigger_new(on_alter_sequence_commit, seq->def); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_alter_sequence_rollback, seq->def); seq->def = new_def; txn_stmt_on_commit(stmt, on_commit); @@ -3737,7 +3737,7 @@ on_replace_dd_sequence(struct trigger * /* trigger */, void *event) /** Restore the old sequence value on rollback. */ static void -on_drop_sequence_data_rollback(struct trigger *trigger, void * /* event */) +on_drop_sequence_data_rollback(struct lua_trigger *trigger, void * /* event */) { struct tuple *tuple = (struct tuple *)trigger->data; uint32_t id = tuple_field_u32_xc(tuple, BOX_SEQUENCE_DATA_FIELD_ID); @@ -3754,7 +3754,7 @@ on_drop_sequence_data_rollback(struct trigger *trigger, void * /* event */) * Used to update a sequence value. */ static void -on_replace_dd_sequence_data(struct trigger * /* trigger */, void *event) +on_replace_dd_sequence_data(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -3779,7 +3779,7 @@ on_replace_dd_sequence_data(struct trigger * /* trigger */, void *event) * we do want to restore the original sequence value * on rollback. */ - struct trigger *on_rollback = txn_alter_trigger_new( + struct lua_trigger *on_rollback = txn_alter_trigger_new( on_drop_sequence_data_rollback, old_tuple); txn_stmt_on_rollback(stmt, on_rollback); sequence_reset(seq); @@ -3826,7 +3826,7 @@ sequence_field_from_tuple(struct space *space, struct tuple *tuple, /** Attach a sequence to a space on rollback in _space_sequence. */ static void -set_space_sequence(struct trigger *trigger, void * /* event */) +set_space_sequence(struct lua_trigger *trigger, void * /* event */) { struct tuple *tuple = (struct tuple *)trigger->data; uint32_t space_id = tuple_field_u32_xc(tuple, @@ -3851,7 +3851,7 @@ set_space_sequence(struct trigger *trigger, void * /* event */) /** Detach a sequence from a space on rollback in _space_sequence. */ static void -clear_space_sequence(struct trigger *trigger, void * /* event */) +clear_space_sequence(struct lua_trigger *trigger, void * /* event */) { struct tuple *tuple = (struct tuple *)trigger->data; uint32_t space_id = tuple_field_u32_xc(tuple, @@ -3872,7 +3872,7 @@ clear_space_sequence(struct trigger *trigger, void * /* event */) * Used to update space <-> sequence mapping. */ static void -on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event) +on_replace_dd_space_sequence(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -3923,7 +3923,7 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event) space_name(space), "can not attach generated sequence"); } - struct trigger *on_rollback; + struct lua_trigger *on_rollback; if (stmt->old_tuple != NULL) on_rollback = txn_alter_trigger_new(set_space_sequence, stmt->old_tuple); @@ -3938,7 +3938,7 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event) sequence_path_guard.is_active = false; txn_stmt_on_rollback(stmt, on_rollback); } else { /* DELETE */ - struct trigger *on_rollback; + struct lua_trigger *on_rollback; on_rollback = txn_alter_trigger_new(set_space_sequence, stmt->old_tuple); assert(space->sequence == seq); @@ -3956,7 +3956,7 @@ on_replace_dd_space_sequence(struct trigger * /* trigger */, void *event) /** Delete the new trigger on rollback of an INSERT statement. */ static void -on_create_trigger_rollback(struct trigger *trigger, void * /* event */) +on_create_trigger_rollback(struct lua_trigger *trigger, void * /* event */) { struct sql_trigger *old_trigger = (struct sql_trigger *)trigger->data; struct sql_trigger *new_trigger; @@ -3971,7 +3971,7 @@ on_create_trigger_rollback(struct trigger *trigger, void * /* event */) /** Restore the old trigger on rollback of a DELETE statement. */ static void -on_drop_trigger_rollback(struct trigger *trigger, void * /* event */) +on_drop_trigger_rollback(struct lua_trigger *trigger, void * /* event */) { struct sql_trigger *old_trigger = (struct sql_trigger *)trigger->data; struct sql_trigger *new_trigger; @@ -3989,7 +3989,7 @@ on_drop_trigger_rollback(struct trigger *trigger, void * /* event */) * of a REPLACE statement. */ static void -on_replace_trigger_rollback(struct trigger *trigger, void * /* event */) +on_replace_trigger_rollback(struct lua_trigger *trigger, void * /* event */) { struct sql_trigger *old_trigger = (struct sql_trigger *)trigger->data; struct sql_trigger *new_trigger; @@ -4005,7 +4005,7 @@ on_replace_trigger_rollback(struct trigger *trigger, void * /* event */) * Drop useless old sql_trigger AST object if any. */ static void -on_replace_trigger_commit(struct trigger *trigger, void * /* event */) +on_replace_trigger_commit(struct lua_trigger *trigger, void * /* event */) { struct sql_trigger *old_trigger = (struct sql_trigger *)trigger->data; sql_trigger_delete(sql_get(), old_trigger); @@ -4016,15 +4016,15 @@ on_replace_trigger_commit(struct trigger *trigger, void * /* event */) * SQL triggers. */ static void -on_replace_dd_trigger(struct trigger * /* trigger */, void *event) +on_replace_dd_trigger(struct lua_trigger * /* trigger */, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); struct tuple *old_tuple = stmt->old_tuple; struct tuple *new_tuple = stmt->new_tuple; - struct trigger *on_rollback = txn_alter_trigger_new(NULL, NULL); - struct trigger *on_commit = + struct lua_trigger *on_rollback = txn_alter_trigger_new(NULL, NULL); + struct lua_trigger *on_commit = txn_alter_trigger_new(on_replace_trigger_commit, NULL); if (old_tuple != NULL && new_tuple == NULL) { @@ -4304,7 +4304,7 @@ space_reset_fk_constraint_mask(struct space *space) * release memory. */ static void -on_create_fk_constraint_rollback(struct trigger *trigger, void *event) +on_create_fk_constraint_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct fk_constraint *fk = (struct fk_constraint *)trigger->data; @@ -4317,7 +4317,7 @@ on_create_fk_constraint_rollback(struct trigger *trigger, void *event) /** Return old FK and release memory for the new one. */ static void -on_replace_fk_constraint_rollback(struct trigger *trigger, void *event) +on_replace_fk_constraint_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct fk_constraint *old_fk = (struct fk_constraint *)trigger->data; @@ -4335,7 +4335,7 @@ on_replace_fk_constraint_rollback(struct trigger *trigger, void *event) /** On rollback of drop simply return back FK to DD. */ static void -on_drop_fk_constraint_rollback(struct trigger *trigger, void *event) +on_drop_fk_constraint_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct fk_constraint *old_fk = (struct fk_constraint *)trigger->data; @@ -4355,7 +4355,7 @@ on_drop_fk_constraint_rollback(struct trigger *trigger, void *event) * so just release memory. */ static void -on_drop_or_replace_fk_constraint_commit(struct trigger *trigger, void *event) +on_drop_or_replace_fk_constraint_commit(struct lua_trigger *trigger, void *event) { (void) event; fk_constraint_delete((struct fk_constraint *) trigger->data); @@ -4398,7 +4398,7 @@ error: /** A trigger invoked on replace in the _fk_constraint space. */ static void -on_replace_dd_fk_constraint(struct trigger * /* trigger*/, void *event) +on_replace_dd_fk_constraint(struct lua_trigger * /* trigger*/, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -4510,7 +4510,7 @@ on_replace_dd_fk_constraint(struct trigger * /* trigger*/, void *event) fk, in_child_space); rlist_add_entry(&parent_space->parent_fk_constraint, fk, in_parent_space); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_create_fk_constraint_rollback, fk); txn_stmt_on_rollback(stmt, on_rollback); @@ -4528,11 +4528,11 @@ on_replace_dd_fk_constraint(struct trigger * /* trigger*/, void *event) in_child_space); rlist_add_entry(&parent_space->parent_fk_constraint, fk, in_parent_space); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_replace_fk_constraint_rollback, old_fk); txn_stmt_on_rollback(stmt, on_rollback); - struct trigger *on_commit = + struct lua_trigger *on_commit = txn_alter_trigger_new(on_drop_or_replace_fk_constraint_commit, old_fk); txn_stmt_on_commit(stmt, on_commit); @@ -4554,11 +4554,11 @@ on_replace_dd_fk_constraint(struct trigger * /* trigger*/, void *event) struct fk_constraint *old_fk= fk_constraint_remove(&child_space->child_fk_constraint, fk_def->name); - struct trigger *on_commit = + struct lua_trigger *on_commit = txn_alter_trigger_new(on_drop_or_replace_fk_constraint_commit, old_fk); txn_stmt_on_commit(stmt, on_commit); - struct trigger *on_rollback = + struct lua_trigger *on_rollback = txn_alter_trigger_new(on_drop_fk_constraint_rollback, old_fk); txn_stmt_on_rollback(stmt, on_rollback); @@ -4605,7 +4605,7 @@ ck_constraint_def_new_from_tuple(struct tuple *tuple) /** Rollback INSERT check constraint. */ static void -on_create_ck_constraint_rollback(struct trigger *trigger, void * /* event */) +on_create_ck_constraint_rollback(struct lua_trigger *trigger, void * /* event */) { struct ck_constraint *ck = (struct ck_constraint *)trigger->data; assert(ck != NULL); @@ -4620,7 +4620,7 @@ on_create_ck_constraint_rollback(struct trigger *trigger, void * /* event */) /** Commit DELETE check constraint. */ static void -on_drop_ck_constraint_commit(struct trigger *trigger, void * /* event */) +on_drop_ck_constraint_commit(struct lua_trigger *trigger, void * /* event */) { struct ck_constraint *ck = (struct ck_constraint *)trigger->data; assert(ck != NULL); @@ -4629,7 +4629,7 @@ on_drop_ck_constraint_commit(struct trigger *trigger, void * /* event */) /** Rollback DELETE check constraint. */ static void -on_drop_ck_constraint_rollback(struct trigger *trigger, void * /* event */) +on_drop_ck_constraint_rollback(struct lua_trigger *trigger, void * /* event */) { struct ck_constraint *ck = (struct ck_constraint *)trigger->data; assert(ck != NULL); @@ -4644,7 +4644,7 @@ on_drop_ck_constraint_rollback(struct trigger *trigger, void * /* event */) /** Commit REPLACE check constraint. */ static void -on_replace_ck_constraint_commit(struct trigger *trigger, void * /* event */) +on_replace_ck_constraint_commit(struct lua_trigger *trigger, void * /* event */) { struct ck_constraint *ck = (struct ck_constraint *)trigger->data; if (ck != NULL) @@ -4653,7 +4653,7 @@ on_replace_ck_constraint_commit(struct trigger *trigger, void * /* event */) /** Rollback REPLACE check constraint. */ static void -on_replace_ck_constraint_rollback(struct trigger *trigger, void * /* event */) +on_replace_ck_constraint_rollback(struct lua_trigger *trigger, void * /* event */) { struct ck_constraint *ck = (struct ck_constraint *)trigger->data; assert(ck != NULL); @@ -4670,7 +4670,7 @@ on_replace_ck_constraint_rollback(struct trigger *trigger, void * /* event */) /** A trigger invoked on replace in the _ck_constraint space. */ static void -on_replace_dd_ck_constraint(struct trigger * /* trigger*/, void *event) +on_replace_dd_ck_constraint(struct lua_trigger * /* trigger*/, void *event) { struct txn *txn = (struct txn *) event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -4680,8 +4680,8 @@ on_replace_dd_ck_constraint(struct trigger * /* trigger*/, void *event) tuple_field_u32_xc(old_tuple != NULL ? old_tuple : new_tuple, BOX_CK_CONSTRAINT_FIELD_SPACE_ID); struct space *space = space_cache_find_xc(space_id); - struct trigger *on_rollback = txn_alter_trigger_new(NULL, NULL); - struct trigger *on_commit = txn_alter_trigger_new(NULL, NULL); + struct lua_trigger *on_rollback = txn_alter_trigger_new(NULL, NULL); + struct lua_trigger *on_commit = txn_alter_trigger_new(NULL, NULL); if (new_tuple != NULL) { bool is_deferred = @@ -4758,7 +4758,7 @@ on_replace_dd_ck_constraint(struct trigger * /* trigger*/, void *event) /** A trigger invoked on replace in the _func_index space. */ static void -on_replace_dd_func_index(struct trigger *trigger, void *event) +on_replace_dd_func_index(struct lua_trigger *trigger, void *event) { (void) trigger; struct txn *txn = (struct txn *) event; @@ -4820,67 +4820,67 @@ on_replace_dd_func_index(struct trigger *trigger, void *event) scoped_guard.is_active = false; } -struct trigger alter_space_on_replace_space = { +struct lua_trigger alter_space_on_replace_space = { RLIST_LINK_INITIALIZER, on_replace_dd_space, NULL, NULL }; -struct trigger alter_space_on_replace_index = { +struct lua_trigger alter_space_on_replace_index = { RLIST_LINK_INITIALIZER, on_replace_dd_index, NULL, NULL }; -struct trigger on_replace_truncate = { +struct lua_trigger on_replace_truncate = { RLIST_LINK_INITIALIZER, on_replace_dd_truncate, NULL, NULL }; -struct trigger on_replace_schema = { +struct lua_trigger on_replace_schema = { RLIST_LINK_INITIALIZER, on_replace_dd_schema, NULL, NULL }; -struct trigger on_replace_user = { +struct lua_trigger on_replace_user = { RLIST_LINK_INITIALIZER, on_replace_dd_user, NULL, NULL }; -struct trigger on_replace_func = { +struct lua_trigger on_replace_func = { RLIST_LINK_INITIALIZER, on_replace_dd_func, NULL, NULL }; -struct trigger on_replace_collation = { +struct lua_trigger on_replace_collation = { RLIST_LINK_INITIALIZER, on_replace_dd_collation, NULL, NULL }; -struct trigger on_replace_priv = { +struct lua_trigger on_replace_priv = { RLIST_LINK_INITIALIZER, on_replace_dd_priv, NULL, NULL }; -struct trigger on_replace_cluster = { +struct lua_trigger on_replace_cluster = { RLIST_LINK_INITIALIZER, on_replace_dd_cluster, NULL, NULL }; -struct trigger on_replace_sequence = { +struct lua_trigger on_replace_sequence = { RLIST_LINK_INITIALIZER, on_replace_dd_sequence, NULL, NULL }; -struct trigger on_replace_sequence_data = { +struct lua_trigger on_replace_sequence_data = { RLIST_LINK_INITIALIZER, on_replace_dd_sequence_data, NULL, NULL }; -struct trigger on_replace_space_sequence = { +struct lua_trigger on_replace_space_sequence = { RLIST_LINK_INITIALIZER, on_replace_dd_space_sequence, NULL, NULL }; -struct trigger on_replace_trigger = { +struct lua_trigger on_replace_trigger = { RLIST_LINK_INITIALIZER, on_replace_dd_trigger, NULL, NULL }; -struct trigger on_replace_fk_constraint = { +struct lua_trigger on_replace_fk_constraint = { RLIST_LINK_INITIALIZER, on_replace_dd_fk_constraint, NULL, NULL }; -struct trigger on_replace_ck_constraint = { +struct lua_trigger on_replace_ck_constraint = { RLIST_LINK_INITIALIZER, on_replace_dd_ck_constraint, NULL, NULL }; -struct trigger on_replace_func_index = { +struct lua_trigger on_replace_func_index = { RLIST_LINK_INITIALIZER, on_replace_dd_func_index, NULL, NULL }; diff --git a/src/box/alter.h b/src/box/alter.h index 1bc837359..99d72cb96 100644 --- a/src/box/alter.h +++ b/src/box/alter.h @@ -30,23 +30,23 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include "trigger.h" +#include "lib/core/trigger.h" -extern struct trigger alter_space_on_replace_space; -extern struct trigger alter_space_on_replace_index; -extern struct trigger on_replace_truncate; -extern struct trigger on_replace_schema; -extern struct trigger on_replace_user; -extern struct trigger on_replace_func; -extern struct trigger on_replace_collation; -extern struct trigger on_replace_priv; -extern struct trigger on_replace_cluster; -extern struct trigger on_replace_sequence; -extern struct trigger on_replace_sequence_data; -extern struct trigger on_replace_space_sequence; -extern struct trigger on_replace_trigger; -extern struct trigger on_replace_fk_constraint; -extern struct trigger on_replace_ck_constraint; -extern struct trigger on_replace_func_index; +extern struct lua_trigger alter_space_on_replace_space; +extern struct lua_trigger alter_space_on_replace_index; +extern struct lua_trigger on_replace_truncate; +extern struct lua_trigger on_replace_schema; +extern struct lua_trigger on_replace_user; +extern struct lua_trigger on_replace_func; +extern struct lua_trigger on_replace_collation; +extern struct lua_trigger on_replace_priv; +extern struct lua_trigger on_replace_cluster; +extern struct lua_trigger on_replace_sequence; +extern struct lua_trigger on_replace_sequence_data; +extern struct lua_trigger on_replace_space_sequence; +extern struct lua_trigger on_replace_trigger; +extern struct lua_trigger on_replace_fk_constraint; +extern struct lua_trigger on_replace_ck_constraint; +extern struct lua_trigger on_replace_func_index; #endif /* INCLUDES_TARANTOOL_BOX_ALTER_H */ diff --git a/src/box/applier.cc b/src/box/applier.cc index 6239fcfd3..ba0fd5605 100644 --- a/src/box/applier.cc +++ b/src/box/applier.cc @@ -42,7 +42,7 @@ #include "replication.h" #include "iproto_constants.h" #include "version.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "xrow_io.h" #include "error.h" #include "session.h" @@ -612,7 +612,7 @@ applier_read_tx(struct applier *applier, struct stailq *rows) } static void -applier_txn_rollback_cb(struct trigger *trigger, void *event) +applier_txn_rollback_cb(struct lua_trigger *trigger, void *event) { (void) trigger; /* Setup shared applier diagnostic area. */ @@ -625,7 +625,7 @@ applier_txn_rollback_cb(struct trigger *trigger, void *event) } static void -applier_txn_commit_cb(struct trigger *trigger, void *event) +applier_txn_commit_cb(struct lua_trigger *trigger, void *event) { (void) trigger; /* Broadcast the commit event across all appliers. */ @@ -712,11 +712,11 @@ applier_apply_tx(struct stailq *rows) } /* We are ready to submit txn to wal. */ - struct trigger *on_rollback, *on_commit; - on_rollback = (struct trigger *)region_alloc(&txn->region, - sizeof(struct trigger)); - on_commit = (struct trigger *)region_alloc(&txn->region, - sizeof(struct trigger)); + struct lua_trigger *on_rollback, *on_commit; + on_rollback = (struct lua_trigger *)region_alloc(&txn->region, + sizeof(struct lua_trigger)); + on_commit = (struct lua_trigger *)region_alloc(&txn->region, + sizeof(struct lua_trigger)); if (on_rollback == NULL || on_commit == NULL) goto rollback; @@ -746,7 +746,7 @@ fail: * A trigger to update an applier state after a replication commit. */ static void -applier_on_commit(struct trigger *trigger, void *event) +applier_on_commit(struct lua_trigger *trigger, void *event) { (void) event; struct applier *applier = (struct applier *)trigger->data; @@ -757,7 +757,7 @@ applier_on_commit(struct trigger *trigger, void *event) * A trigger to update an applier state after a replication rollback. */ static void -applier_on_rollback(struct trigger *trigger, void *event) +applier_on_rollback(struct lua_trigger *trigger, void *event) { (void) event; struct applier *applier = (struct applier *)trigger->data; @@ -873,11 +873,11 @@ applier_subscribe(struct applier *applier) applier->lag = TIMEOUT_INFINITY; /* Register triggers to handle replication commits and rollbacks. */ - struct trigger on_commit; + struct lua_trigger on_commit; trigger_create(&on_commit, applier_on_commit, applier, NULL); trigger_add(&replicaset.applier.on_commit, &on_commit); - struct trigger on_rollback; + struct lua_trigger on_rollback; trigger_create(&on_rollback, applier_on_rollback, applier, NULL); trigger_add(&replicaset.applier.on_rollback, &on_rollback); @@ -1125,14 +1125,14 @@ applier_pause(struct applier *applier) } struct applier_on_state { - struct trigger base; + struct lua_trigger base; struct applier *applier; enum applier_state desired_state; struct fiber_cond wakeup; }; static void -applier_on_state_f(struct trigger *trigger, void *event) +applier_on_state_f(struct lua_trigger *trigger, void *event) { (void) event; struct applier_on_state *on_state = diff --git a/src/box/applier.h b/src/box/applier.h index b406e6aaf..ea812768d 100644 --- a/src/box/applier.h +++ b/src/box/applier.h @@ -38,7 +38,7 @@ #include #include "fiber_cond.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "trivia/util.h" #include "uuid/tt_uuid.h" #include "uri/uri.h" diff --git a/src/box/ck_constraint.c b/src/box/ck_constraint.c index 1cde27022..0df9301ba 100644 --- a/src/box/ck_constraint.c +++ b/src/box/ck_constraint.c @@ -176,7 +176,7 @@ ck_constraint_program_run(struct ck_constraint *ck_constraint, } void -ck_constraint_on_replace_trigger(struct trigger *trigger, void *event) +ck_constraint_on_replace_trigger(struct lua_trigger *trigger, void *event) { (void) trigger; struct txn *txn = (struct txn *) event; diff --git a/src/box/ck_constraint.h b/src/box/ck_constraint.h index f26f77a38..9050f6a31 100644 --- a/src/box/ck_constraint.h +++ b/src/box/ck_constraint.h @@ -42,7 +42,7 @@ struct space; struct space_def; struct sql_stmt; struct Expr; -struct trigger; +struct lua_trigger; /** Supported languages of ck constraint. */ enum ck_constraint_language { @@ -199,7 +199,7 @@ ck_constraint_delete(struct ck_constraint *ck_constraint); * The diag message is set. */ void -ck_constraint_on_replace_trigger(struct trigger *trigger, void *event); +ck_constraint_on_replace_trigger(struct lua_trigger *trigger, void *event); /** * Find check constraint object in space by given name and diff --git a/src/box/error.cc b/src/box/error.cc index 47dce3305..92aa2a727 100644 --- a/src/box/error.cc +++ b/src/box/error.cc @@ -33,7 +33,7 @@ #include "fiber.h" #include "rmean.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "vclock.h" #include "schema.h" diff --git a/src/box/iproto.cc b/src/box/iproto.cc index 8f899fed8..00f76dbf0 100644 --- a/src/box/iproto.cc +++ b/src/box/iproto.cc @@ -1506,7 +1506,7 @@ error: } static void -tx_process_call_on_yield(struct trigger *trigger, void *event) +tx_process_call_on_yield(struct lua_trigger *trigger, void *event) { (void)event; struct iproto_msg *msg = (struct iproto_msg *)trigger->data; @@ -1527,7 +1527,7 @@ tx_process_call(struct cmsg *m) * input on yield to avoid stalling other connections by * a long polling request. */ - struct trigger fiber_on_yield; + struct lua_trigger fiber_on_yield; trigger_create(&fiber_on_yield, tx_process_call_on_yield, msg, NULL); trigger_add(&fiber()->on_yield, &fiber_on_yield); diff --git a/src/box/lua/call.c b/src/box/lua/call.c index 631003c84..0a480458c 100644 --- a/src/box/lua/call.c +++ b/src/box/lua/call.c @@ -953,7 +953,7 @@ lbox_func_delete(struct lua_State *L, struct func *func) } static void -lbox_func_new_or_delete(struct trigger *trigger, void *event) +lbox_func_new_or_delete(struct lua_trigger *trigger, void *event) { struct lua_State *L = (struct lua_State *) trigger->data; struct func *func = (struct func *)event; @@ -965,7 +965,7 @@ lbox_func_new_or_delete(struct trigger *trigger, void *event) lbox_func_delete(L, func); } -static struct trigger on_alter_func_in_lua = { +static struct lua_trigger on_alter_func_in_lua = { RLIST_LINK_INITIALIZER, lbox_func_new_or_delete, NULL, NULL }; diff --git a/src/box/lua/sequence.c b/src/box/lua/sequence.c index bd9ec7589..4e3996ca9 100644 --- a/src/box/lua/sequence.c +++ b/src/box/lua/sequence.c @@ -158,7 +158,7 @@ lbox_sequence_delete(struct lua_State *L, struct sequence *seq) } static void -lbox_sequence_new_or_delete(struct trigger *trigger, void *event) +lbox_sequence_new_or_delete(struct lua_trigger *trigger, void *event) { struct lua_State *L = trigger->data; struct sequence *seq = event; @@ -180,7 +180,7 @@ box_lua_sequence_init(struct lua_State *L) luaL_register(L, "box.internal.sequence", sequence_internal_lib); lua_pop(L, 1); - static struct trigger on_alter_sequence_in_lua; + static struct lua_trigger on_alter_sequence_in_lua; trigger_create(&on_alter_sequence_in_lua, lbox_sequence_new_or_delete, L, NULL); trigger_add(&on_alter_sequence, &on_alter_sequence_in_lua); diff --git a/src/box/lua/space.cc b/src/box/lua/space.cc index d0a7e7815..060ef7feb 100644 --- a/src/box/lua/space.cc +++ b/src/box/lua/space.cc @@ -501,7 +501,7 @@ box_lua_space_delete(struct lua_State *L, uint32_t id) } static void -box_lua_space_new_or_delete(struct trigger *trigger, void *event) +box_lua_space_new_or_delete(struct lua_trigger *trigger, void *event) { struct lua_State *L = (struct lua_State *) trigger->data; struct space *space = (struct space *) event; @@ -513,7 +513,7 @@ box_lua_space_new_or_delete(struct trigger *trigger, void *event) } } -static struct trigger on_alter_space_in_lua = { +static struct lua_trigger on_alter_space_in_lua = { RLIST_LINK_INITIALIZER, box_lua_space_new_or_delete, NULL, NULL }; diff --git a/src/box/lua/tuple.c b/src/box/lua/tuple.c index 8b59466b9..5a37ca0f1 100644 --- a/src/box/lua/tuple.c +++ b/src/box/lua/tuple.c @@ -561,7 +561,7 @@ tuple_serializer_update_options(void) } static void -on_msgpack_serializer_update(struct trigger *trigger, void *event) +on_msgpack_serializer_update(struct lua_trigger *trigger, void *event) { (void) trigger; (void) event; diff --git a/src/box/memtx_space.c b/src/box/memtx_space.c index 487cfdadd..f3620c172 100644 --- a/src/box/memtx_space.c +++ b/src/box/memtx_space.c @@ -835,7 +835,7 @@ struct memtx_ddl_state { }; static void -memtx_check_on_replace(struct trigger *trigger, void *event) +memtx_check_on_replace(struct lua_trigger *trigger, void *event) { struct txn *txn = event; struct memtx_ddl_state *state = trigger->data; @@ -890,7 +890,7 @@ memtx_space_check_format(struct space *space, struct tuple_format *format) state.rc = 0; diag_create(&state.diag); - struct trigger on_replace; + struct lua_trigger on_replace; trigger_create(&on_replace, memtx_check_on_replace, &state, NULL); trigger_add(&space->on_replace, &on_replace); @@ -958,7 +958,7 @@ memtx_init_ephemeral_space(struct space *space) } static void -memtx_build_on_replace(struct trigger *trigger, void *event) +memtx_build_on_replace(struct lua_trigger *trigger, void *event) { struct txn *txn = event; struct memtx_ddl_state *state = trigger->data; @@ -1043,7 +1043,7 @@ memtx_space_build_index(struct space *src_space, struct index *new_index, state.rc = 0; diag_create(&state.diag); - struct trigger on_replace; + struct lua_trigger on_replace; trigger_create(&on_replace, memtx_build_on_replace, &state, NULL); trigger_add(&src_space->on_replace, &on_replace); diff --git a/src/box/recovery.cc b/src/box/recovery.cc index d122d618a..61960bb26 100644 --- a/src/box/recovery.cc +++ b/src/box/recovery.cc @@ -32,7 +32,7 @@ #include "small/rlist.h" #include "scoped_guard.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "fiber.h" #include "xlog.h" #include "xrow.h" diff --git a/src/box/relay.cc b/src/box/relay.cc index 74588cba7..b94a7691c 100644 --- a/src/box/relay.cc +++ b/src/box/relay.cc @@ -46,7 +46,7 @@ #include "iproto_constants.h" #include "recovery.h" #include "replication.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "vclock.h" #include "version.h" #include "xrow.h" @@ -412,7 +412,7 @@ tx_gc_advance(struct cmsg *msg) } static void -relay_on_close_log_f(struct trigger *trigger, void * /* event */) +relay_on_close_log_f(struct lua_trigger *trigger, void * /* event */) { static const struct cmsg_hop route[] = { {tx_gc_advance, NULL} @@ -569,7 +569,7 @@ relay_subscribe_f(va_list ap) &relay->relay_pipe, NULL, NULL, cbus_process); /* Setup garbage collection trigger. */ - struct trigger on_close_log = { + struct lua_trigger on_close_log = { RLIST_LINK_INITIALIZER, relay_on_close_log_f, relay, NULL }; trigger_add(&r->on_close_log, &on_close_log); diff --git a/src/box/replication.cc b/src/box/replication.cc index ee102a597..1a4d5f3d3 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -148,7 +148,7 @@ replica_is_orphan(struct replica *replica) } static void -replica_on_applier_state_f(struct trigger *trigger, void *event); +replica_on_applier_state_f(struct lua_trigger *trigger, void *event); static struct replica * replica_new(void) @@ -402,7 +402,7 @@ replica_on_applier_disconnect(struct replica *replica) } static void -replica_on_applier_state_f(struct trigger *trigger, void *event) +replica_on_applier_state_f(struct lua_trigger *trigger, void *event) { (void)event; struct replica *replica = container_of(trigger, @@ -571,12 +571,12 @@ struct replicaset_connect_state { }; struct applier_on_connect { - struct trigger base; + struct lua_trigger base; struct replicaset_connect_state *state; }; static void -applier_on_connect_f(struct trigger *trigger, void *event) +applier_on_connect_f(struct lua_trigger *trigger, void *event) { struct applier_on_connect *on_connect = container_of(trigger, struct applier_on_connect, base); diff --git a/src/box/replication.h b/src/box/replication.h index 19f283c7d..64104e79a 100644 --- a/src/box/replication.h +++ b/src/box/replication.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ #include "uuid/tt_uuid.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include #define RB_COMPACT 1 #include /* replicaset_t */ @@ -276,7 +276,7 @@ struct replica { /** * Trigger invoked when the applier changes its state. */ - struct trigger on_applier_state; + struct lua_trigger on_applier_state; /** * During initial connect or reconnect we require applier * to sync with the master before the replica can leave diff --git a/src/box/schema.cc b/src/box/schema.cc index 8d8aae448..3176555b2 100644 --- a/src/box/schema.cc +++ b/src/box/schema.cc @@ -264,7 +264,7 @@ static void sc_space_new(uint32_t id, const char *name, struct key_part_def *key_parts, uint32_t key_part_count, - struct trigger *replace_trigger) + struct lua_trigger *replace_trigger) { struct key_def *key_def = key_def_new(key_parts, key_part_count, false); if (key_def == NULL) diff --git a/src/box/session.cc b/src/box/session.cc index 59bf226dd..618cf48ad 100644 --- a/src/box/session.cc +++ b/src/box/session.cc @@ -32,7 +32,7 @@ #include "fiber.h" #include "memory.h" #include "assoc.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "user.h" #include "error.h" #include "tt_static.h" @@ -81,7 +81,7 @@ sid_max() } static void -session_on_stop(struct trigger *trigger, void * /* event */) +session_on_stop(struct lua_trigger *trigger, void * /* event */) { /* * Remove on_stop trigger from the fiber, otherwise the diff --git a/src/box/session.h b/src/box/session.h index 85a2d940b..2699f72ff 100644 --- a/src/box/session.h +++ b/src/box/session.h @@ -32,7 +32,7 @@ */ #include #include -#include "trigger.h" +#include "lib/core/trigger.h" #include "fiber.h" #include "user.h" #include "authentication.h" @@ -104,7 +104,7 @@ struct session { /** Session user id and global grants */ struct credentials credentials; /** Trigger for fiber on_stop to cleanup created on-demand session */ - struct trigger fiber_on_stop; + struct lua_trigger fiber_on_stop; }; struct session_vtab { diff --git a/src/box/space.c b/src/box/space.c index 042be042c..f8a184c4e 100644 --- a/src/box/space.c +++ b/src/box/space.c @@ -34,7 +34,7 @@ #include #include "bit/bit.h" #include "tuple_format.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "user.h" #include "session.h" #include "txn.h" @@ -590,8 +590,8 @@ space_add_ck_constraint(struct space *space, struct ck_constraint *ck) { rlist_add_entry(&space->ck_constraint, ck, link); if (space->ck_constraint_trigger == NULL) { - struct trigger *ck_trigger = - (struct trigger *) malloc(sizeof(*ck_trigger)); + struct lua_trigger *ck_trigger = + (struct lua_trigger *) malloc(sizeof(*ck_trigger)); if (ck_trigger == NULL) { diag_set(OutOfMemory, sizeof(*ck_trigger), "malloc", "ck_trigger"); @@ -610,7 +610,7 @@ space_remove_ck_constraint(struct space *space, struct ck_constraint *ck) { rlist_del_entry(ck, link); if (rlist_empty(&space->ck_constraint)) { - struct trigger *ck_trigger = space->ck_constraint_trigger; + struct lua_trigger *ck_trigger = space->ck_constraint_trigger; trigger_clear(ck_trigger); ck_trigger->destroy(ck_trigger); space->ck_constraint_trigger = NULL; diff --git a/src/box/space.h b/src/box/space.h index 7926aa65e..8064a046d 100644 --- a/src/box/space.h +++ b/src/box/space.h @@ -218,7 +218,7 @@ struct space { */ struct rlist ck_constraint; /** Trigger that performs ck constraint validation. */ - struct trigger *ck_constraint_trigger; + struct lua_trigger *ck_constraint_trigger; /** * Lists of foreign key constraints. In SQL terms child * space is the "from" table i.e. the table that contains diff --git a/src/box/txn.c b/src/box/txn.c index 38b1b595f..a8b580756 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -41,10 +41,10 @@ double too_long_threshold; static struct stailq txn_cache = {NULL, &txn_cache.first}; static void -txn_on_stop(struct trigger *trigger, void *event); +txn_on_stop(struct lua_trigger *trigger, void *event); static void -txn_on_yield(struct trigger *trigger, void *event); +txn_on_yield(struct lua_trigger *trigger, void *event); static void txn_run_rollback_triggers(struct txn *txn, struct rlist *triggers); @@ -840,7 +840,7 @@ txn_savepoint_release(struct txn_savepoint *svp) } static void -txn_on_stop(struct trigger *trigger, void *event) +txn_on_stop(struct lua_trigger *trigger, void *event) { (void) trigger; (void) event; @@ -865,7 +865,7 @@ txn_on_stop(struct trigger *trigger, void *event) * interactive transaction support in memtx. */ static void -txn_on_yield(struct trigger *trigger, void *event) +txn_on_yield(struct lua_trigger *trigger, void *event) { (void) trigger; (void) event; diff --git a/src/box/txn.h b/src/box/txn.h index da12feebf..016d6a68b 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -33,7 +33,7 @@ #include #include "salad/stailq.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "fiber.h" #include "space.h" @@ -205,12 +205,12 @@ struct txn { * Triggers on fiber yield to abort transaction for * for in-memory engine. */ - struct trigger fiber_on_yield; + struct lua_trigger fiber_on_yield; /** * Trigger on fiber stop, to rollback transaction * in case a fiber stops (all engines). */ - struct trigger fiber_on_stop; + struct lua_trigger fiber_on_stop; /** Commit and rollback triggers. */ struct rlist on_commit, on_rollback; /** @@ -309,14 +309,14 @@ txn_init_triggers(struct txn *txn) } static inline void -txn_on_commit(struct txn *txn, struct trigger *trigger) +txn_on_commit(struct txn *txn, struct lua_trigger *trigger) { txn_init_triggers(txn); trigger_add(&txn->on_commit, trigger); } static inline void -txn_on_rollback(struct txn *txn, struct trigger *trigger) +txn_on_rollback(struct txn *txn, struct lua_trigger *trigger) { txn_init_triggers(txn); trigger_add(&txn->on_rollback, trigger); @@ -338,14 +338,14 @@ txn_stmt_init_triggers(struct txn_stmt *stmt) } static inline void -txn_stmt_on_commit(struct txn_stmt *stmt, struct trigger *trigger) +txn_stmt_on_commit(struct txn_stmt *stmt, struct lua_trigger *trigger) { txn_stmt_init_triggers(stmt); trigger_add(&stmt->on_commit, trigger); } static inline void -txn_stmt_on_rollback(struct txn_stmt *stmt, struct trigger *trigger) +txn_stmt_on_rollback(struct txn_stmt *stmt, struct lua_trigger *trigger) { txn_stmt_init_triggers(stmt); trigger_add(&stmt->on_rollback, trigger); diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 23910795f..f01dc77ac 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -69,7 +69,7 @@ #include "xstream.h" #include "info/info.h" #include "column_mask.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "wal.h" /* wal_mode() */ /** @@ -163,7 +163,7 @@ struct vinyl_iterator { */ struct vy_tx tx_autocommit; /** Trigger invoked when tx ends to close the iterator. */ - struct trigger on_tx_destroy; + struct lua_trigger on_tx_destroy; }; struct vinyl_snapshot_iterator { @@ -176,7 +176,7 @@ static const struct engine_vtab vinyl_engine_vtab; static const struct space_vtab vinyl_space_vtab; static const struct index_vtab vinyl_index_vtab; -static struct trigger on_replace_vinyl_deferred_delete; +static struct lua_trigger on_replace_vinyl_deferred_delete; /** Extract vy_env from an engine object. */ static inline struct vy_env * @@ -1011,7 +1011,7 @@ struct vy_check_format_ctx { * tuples against a new format. */ static void -vy_check_format_on_replace(struct trigger *trigger, void *event) +vy_check_format_on_replace(struct lua_trigger *trigger, void *event) { struct txn *txn = event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -1071,7 +1071,7 @@ vinyl_space_check_format(struct space *space, struct tuple_format *format) /* See the comment in vinyl_space_build_index(). */ txn_can_yield(txn, true); - struct trigger on_replace; + struct lua_trigger on_replace; struct vy_check_format_ctx ctx; ctx.format = format; ctx.is_failed = false; @@ -3421,7 +3421,7 @@ fail: /* {{{ Cursor */ static void -vinyl_iterator_on_tx_destroy(struct trigger *trigger, void *event) +vinyl_iterator_on_tx_destroy(struct lua_trigger *trigger, void *event) { (void)event; struct vinyl_iterator *it = container_of(trigger, @@ -3792,7 +3792,7 @@ struct vy_build_ctx { * to the index that is currently being built. */ static void -vy_build_on_replace(struct trigger *trigger, void *event) +vy_build_on_replace(struct lua_trigger *trigger, void *event) { struct txn *txn = event; struct txn_stmt *stmt = txn_current_stmt(txn); @@ -4146,7 +4146,7 @@ vinyl_space_build_index(struct space *src_space, struct index *new_index, * may yield, we install an on_replace trigger to forward * DML requests issued during the build. */ - struct trigger on_replace; + struct lua_trigger on_replace; struct vy_build_ctx ctx; ctx.lsm = new_lsm; ctx.format = new_format; @@ -4248,7 +4248,7 @@ out: /* {{{ Deferred DELETE handling */ static void -vy_deferred_delete_on_commit(struct trigger *trigger, void *event) +vy_deferred_delete_on_commit(struct lua_trigger *trigger, void *event) { struct txn *txn = event; struct vy_mem *mem = trigger->data; @@ -4263,7 +4263,7 @@ vy_deferred_delete_on_commit(struct trigger *trigger, void *event) } static void -vy_deferred_delete_on_rollback(struct trigger *trigger, void *event) +vy_deferred_delete_on_rollback(struct lua_trigger *trigger, void *event) { (void)event; struct vy_mem *mem = trigger->data; @@ -4296,7 +4296,7 @@ vy_deferred_delete_on_rollback(struct trigger *trigger, void *event) * mistakenly skip both statements on recovery. */ static void -vy_deferred_delete_on_replace(struct trigger *trigger, void *event) +vy_deferred_delete_on_replace(struct lua_trigger *trigger, void *event) { (void)trigger; @@ -4410,19 +4410,19 @@ vy_deferred_delete_on_replace(struct trigger *trigger, void *event) * which will propagate the WAL row LSN to * the LSM tree. */ - struct trigger *on_commit = region_alloc(&txn->region, + struct lua_trigger *on_commit = region_alloc(&txn->region, sizeof(*on_commit)); if (on_commit == NULL) { diag_set(OutOfMemory, sizeof(*on_commit), - "region", "struct trigger"); + "region", "struct lua_trigger"); rc = -1; break; } - struct trigger *on_rollback = region_alloc(&txn->region, + struct lua_trigger *on_rollback = region_alloc(&txn->region, sizeof(*on_commit)); if (on_rollback == NULL) { diag_set(OutOfMemory, sizeof(*on_commit), - "region", "struct trigger"); + "region", "struct lua_trigger"); rc = -1; break; } @@ -4443,7 +4443,7 @@ vy_deferred_delete_on_replace(struct trigger *trigger, void *event) diag_raise(); } -static struct trigger on_replace_vinyl_deferred_delete = { +static struct lua_trigger on_replace_vinyl_deferred_delete = { RLIST_LINK_INITIALIZER, vy_deferred_delete_on_replace, NULL, NULL }; diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c index aa4bce9eb..c0f9c983c 100644 --- a/src/box/vy_lsm.c +++ b/src/box/vy_lsm.c @@ -45,7 +45,7 @@ #include "say.h" #include "schema.h" #include "tuple.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "vy_log.h" #include "vy_mem.h" #include "vy_range.h" diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c index ee361c31f..581b550a4 100644 --- a/src/box/vy_scheduler.c +++ b/src/box/vy_scheduler.c @@ -511,7 +511,7 @@ vy_scheduler_reset_stat(struct vy_scheduler *scheduler) } static void -vy_scheduler_on_delete_lsm(struct trigger *trigger, void *event) +vy_scheduler_on_delete_lsm(struct lua_trigger *trigger, void *event) { struct vy_lsm *lsm = event; struct vy_scheduler *scheduler = trigger->data; @@ -532,7 +532,7 @@ vy_scheduler_add_lsm(struct vy_scheduler *scheduler, struct vy_lsm *lsm) * Register a trigger that will remove this LSM tree from * the scheduler queues on destruction. */ - struct trigger *trigger = malloc(sizeof(*trigger)); + struct lua_trigger *trigger = malloc(sizeof(*trigger)); if (trigger == NULL) { diag_set(OutOfMemory, sizeof(*trigger), "malloc", "trigger"); return -1; diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c index d092e0cdb..a2dc0afbf 100644 --- a/src/box/vy_tx.c +++ b/src/box/vy_tx.c @@ -48,7 +48,7 @@ #include "schema.h" /* space_cache_version */ #include "session.h" #include "space.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "trivia/util.h" #include "tuple.h" #include "vy_cache.h" diff --git a/src/lib/core/cbus.c b/src/lib/core/cbus.c index b3b1280e7..b65693185 100644 --- a/src/lib/core/cbus.c +++ b/src/lib/core/cbus.c @@ -32,7 +32,7 @@ #include #include "fiber.h" -#include "trigger.h" +#include "lib/core/trigger.h" /** * Cord interconnect. diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c index b813c1739..2375ef42a 100644 --- a/src/lib/core/fiber.c +++ b/src/lib/core/fiber.c @@ -40,7 +40,7 @@ #include "assoc.h" #include "memory.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "third_party/valgrind/memcheck.h" @@ -1299,7 +1299,7 @@ cord_cojoin(struct cord *cord) } void -break_ev_loop_f(struct trigger *trigger, void *event) +break_ev_loop_f(struct lua_trigger *trigger, void *event) { (void) trigger; (void) event; @@ -1323,7 +1323,7 @@ cord_costart_thread_func(void *arg) if (f == NULL) return NULL; - struct trigger break_ev_loop = { + struct lua_trigger break_ev_loop = { RLIST_LINK_INITIALIZER, break_ev_loop_f, NULL, NULL }; /* diff --git a/src/lib/core/trigger.cc b/src/lib/core/trigger.cc index 4a43151e1..75c872569 100644 --- a/src/lib/core/trigger.cc +++ b/src/lib/core/trigger.cc @@ -29,14 +29,14 @@ * SUCH DAMAGE. */ -#include "trigger.h" +#include "lib/core/trigger.h" #include "exception.h" int trigger_run(struct rlist *list, void *event) { try { - struct trigger *trigger, *tmp; + struct lua_trigger *trigger, *tmp; rlist_foreach_entry_safe(trigger, list, link, tmp) trigger->run(trigger, event); } catch (Exception *e) { @@ -49,7 +49,7 @@ int trigger_run_reverse(struct rlist *list, void *event) { try { - struct trigger *trigger, *tmp; + struct lua_trigger *trigger, *tmp; rlist_foreach_entry_safe_reverse(trigger, list, link, tmp) trigger->run(trigger, event); } catch (Exception *e) { diff --git a/src/lib/core/trigger.h b/src/lib/core/trigger.h index 76fa6345d..8fe19498e 100644 --- a/src/lib/core/trigger.h +++ b/src/lib/core/trigger.h @@ -39,11 +39,11 @@ extern "C" { * Type of the callback which may be invoked * on an event. */ -struct trigger; -typedef void (*trigger_f)(struct trigger *trigger, void *event); -typedef void (*trigger_f0)(struct trigger *trigger); +struct lua_trigger; +typedef void (*trigger_f)(struct lua_trigger *trigger, void *event); +typedef void (*trigger_f0)(struct lua_trigger *trigger); -struct trigger +struct lua_trigger { struct rlist link; trigger_f run; @@ -60,7 +60,7 @@ struct trigger }; static inline void -trigger_create(struct trigger *trigger, trigger_f run, void *data, +trigger_create(struct lua_trigger *trigger, trigger_f run, void *data, trigger_f0 destroy) { rlist_create(&trigger->link); @@ -70,7 +70,7 @@ trigger_create(struct trigger *trigger, trigger_f run, void *data, } static inline void -trigger_add(struct rlist *list, struct trigger *trigger) +trigger_add(struct rlist *list, struct lua_trigger *trigger) { /* * New triggers are pushed to the beginning of the list. @@ -85,9 +85,9 @@ trigger_add(struct rlist *list, struct trigger *trigger) } static inline void -trigger_add_unique(struct rlist *list, struct trigger *trigger) +trigger_add_unique(struct rlist *list, struct lua_trigger *trigger) { - struct trigger *trg; + struct lua_trigger *trg; rlist_foreach_entry(trg, list, link) { if (trg->data == trigger->data && trg->run == trigger->run) return; @@ -96,7 +96,7 @@ trigger_add_unique(struct rlist *list, struct trigger *trigger) } static inline void -trigger_clear(struct trigger *trigger) +trigger_clear(struct lua_trigger *trigger) { rlist_del_entry(trigger, link); } @@ -105,7 +105,7 @@ trigger_clear(struct trigger *trigger) static inline void trigger_destroy(struct rlist *list) { - struct trigger *trigger, *tmp; + struct lua_trigger *trigger, *tmp; rlist_foreach_entry_safe(trigger, list, link, tmp) { trigger_clear(trigger); if (trigger->destroy) diff --git a/src/lib/swim/swim.c b/src/lib/swim/swim.c index 9a7b4ce85..752aff60e 100644 --- a/src/lib/swim/swim.c +++ b/src/lib/swim/swim.c @@ -37,7 +37,7 @@ #include "msgpuck.h" #include "assoc.h" #include "sio.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "errinj.h" #define HEAP_FORWARD_DECLARATION #include "salad/heap.h" diff --git a/src/lua/swim.c b/src/lua/swim.c index ae916bf78..59a2d2dc3 100644 --- a/src/lua/swim.c +++ b/src/lua/swim.c @@ -29,8 +29,8 @@ * SUCH DAMAGE. */ #include "swim/swim.h" -#include "trigger.h" #include "diag.h" +#include "lua/trigger.h" #include "lua/utils.h" static uint32_t ctid_swim_member_ptr; diff --git a/src/lua/trigger.c b/src/lua/trigger.c index 4803e85c5..7bfbb7a71 100644 --- a/src/lua/trigger.c +++ b/src/lua/trigger.c @@ -35,7 +35,7 @@ struct lbox_trigger { - struct trigger base; + struct lua_trigger base; /** A reference to Lua trigger function. */ int ref; /* @@ -53,7 +53,7 @@ struct lbox_trigger }; static void -lbox_trigger_destroy(struct trigger *ptr) +lbox_trigger_destroy(struct lua_trigger *ptr) { if (tarantool_L) { struct lbox_trigger *trigger = (struct lbox_trigger *) ptr; @@ -63,7 +63,7 @@ lbox_trigger_destroy(struct trigger *ptr) } static void -lbox_trigger_run(struct trigger *ptr, void *event) +lbox_trigger_run(struct lua_trigger *ptr, void *event) { struct lbox_trigger *trigger = (struct lbox_trigger *) ptr; /* diff --git a/src/lua/trigger.h b/src/lua/trigger.h index 1d1dcce35..09f4ecf9e 100644 --- a/src/lua/trigger.h +++ b/src/lua/trigger.h @@ -30,7 +30,7 @@ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ -#include +#include "lib/core/trigger.h" #if defined(__cplusplus) extern "C" { diff --git a/src/lua/utils.h b/src/lua/utils.h index f8c34545a..c87b117ef 100644 --- a/src/lua/utils.h +++ b/src/lua/utils.h @@ -261,7 +261,7 @@ struct luaL_serializer { * general serializer. For example, tuple serializer * subscribes on msgpack. */ - struct trigger update_trigger; + struct lua_trigger update_trigger; /** * List of triggers on update of this serializer. To push * updates down to dependent serializers. diff --git a/src/main.cc b/src/main.cc index 6ccb2a47f..898324d97 100644 --- a/src/main.cc +++ b/src/main.cc @@ -95,7 +95,7 @@ static struct fiber *on_shutdown_fiber = NULL; /** A flag restricting repeated execution of tarantool_exit(). */ static bool is_shutting_down = false; /** A trigger which will break the event loop on shutdown. */ -static struct trigger break_loop_trigger; +static struct lua_trigger break_loop_trigger; static int exit_code = 0; double @@ -684,7 +684,7 @@ print_help(const char *program) } static void -break_loop(struct trigger *, void *) +break_loop(struct lua_trigger *, void *) { ev_break(loop(), EVBREAK_ALL); } diff --git a/test/unit/cbus.c b/test/unit/cbus.c index be930ab8f..156ff8961 100644 --- a/test/unit/cbus.c +++ b/test/unit/cbus.c @@ -2,7 +2,7 @@ #include "fiber.h" #include "cbus.h" #include "unit.h" -#include "trigger.h" +#include "lib/core/trigger.h" /** * Test triggers on cpipe flush. Cpipe flush send all buffered @@ -31,7 +31,7 @@ struct cpipe pipe_to_main; * the direction from the main to the worker works in the same * way. */ -struct trigger on_flush_to_main; +struct lua_trigger on_flush_to_main; /** Common callbacks. {{{ ------------------------------------- */ @@ -44,7 +44,7 @@ do_nothing(struct cmsg *m) /** Callback called on each flush to the main thread. */ static void -flush_cb(struct trigger *t, void *e) +flush_cb(struct lua_trigger *t, void *e) { (void) t; (void) e; diff --git a/test/unit/swim.c b/test/unit/swim.c index 1371e7d26..40d08c58a 100644 --- a/test/unit/swim.c +++ b/test/unit/swim.c @@ -29,7 +29,7 @@ * SUCH DAMAGE. */ #include "swim_test_utils.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include /** @@ -828,7 +828,7 @@ struct trigger_ctx { }; static void -swim_on_member_event_save(struct trigger *t, void *event) +swim_on_member_event_save(struct lua_trigger *t, void *event) { struct trigger_ctx *c = (struct trigger_ctx *) t->data; ++c->counter; @@ -839,7 +839,7 @@ swim_on_member_event_save(struct trigger *t, void *event) } static void -swim_on_member_event_yield(struct trigger *t, void *event) +swim_on_member_event_yield(struct lua_trigger *t, void *event) { struct trigger_ctx *c = (struct trigger_ctx *) t->data; ++c->counter; @@ -849,7 +849,7 @@ swim_on_member_event_yield(struct trigger *t, void *event) } static void -swim_trigger_destroy_cb(struct trigger *t) +swim_trigger_destroy_cb(struct lua_trigger *t) { ((struct trigger_ctx *) t->data)->is_deleted = true; } @@ -872,7 +872,7 @@ swim_test_triggers(void) struct trigger_ctx tctx, tctx2; memset(&tctx, 0, sizeof(tctx)); memset(&tctx2, 0, sizeof(tctx2)); - struct trigger *t1 = (struct trigger *) malloc(sizeof(*t1)); + struct lua_trigger *t1 = (struct lua_trigger *) malloc(sizeof(*t1)); assert(t1 != NULL); trigger_create(t1, swim_on_member_event_save, (void *) &tctx, swim_trigger_destroy_cb); @@ -925,7 +925,7 @@ swim_test_triggers(void) * middle of an event processing. SWIM object should not * be deleted, until all the triggers are done. */ - struct trigger *t2 = (struct trigger *) malloc(sizeof(*t2)); + struct lua_trigger *t2 = (struct lua_trigger *) malloc(sizeof(*t2)); assert(t2 != NULL); tctx2.need_sleep = true; trigger_create(t2, swim_on_member_event_yield, (void *) &tctx2, NULL); @@ -1138,4 +1138,4 @@ main() { swim_run_test("swim.txt", main_f); return test_result; -} \ No newline at end of file +} diff --git a/test/unit/swim_test_utils.c b/test/unit/swim_test_utils.c index 7da82d93c..05fca6730 100644 --- a/test/unit/swim_test_utils.c +++ b/test/unit/swim_test_utils.c @@ -35,7 +35,7 @@ #include "uuid/tt_uuid.h" #include "trivia/util.h" #include "msgpuck.h" -#include "trigger.h" +#include "lib/core/trigger.h" #include "memory.h" #include "random.h" #include @@ -177,7 +177,7 @@ swim_cluster_id_to_uri(char *buffer, int id) * to yield. */ void -swim_test_event_cb(struct trigger *trigger, void *event) +swim_test_event_cb(struct lua_trigger *trigger, void *event) { (void) trigger; struct swim_on_member_event_ctx *ctx = @@ -195,7 +195,7 @@ swim_node_create(struct swim_node *n, int id) n->generation = 0; n->swim = swim_new(0); assert(n->swim != NULL); - struct trigger *t = (struct trigger *) malloc(sizeof(*t)); + struct lua_trigger *t = (struct lua_trigger *) malloc(sizeof(*t)); trigger_create(t, swim_test_event_cb, NULL, (trigger_f0) free); trigger_add(swim_trigger_list_on_member_event(n->swim), t); -- 2.23.0