From: Vladimir Davydov <vdavydov.dev@gmail.com> To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Cc: tarantool-patches@freelists.org Subject: Re: [PATCH 1/1] box: expose on_commit/rollback triggers for Lua Date: Fri, 17 Aug 2018 11:40:44 +0300 [thread overview] Message-ID: <20180817084044.bjroy7t2mirkyqn2@esperanza> (raw) In-Reply-To: <6aff0ac07499e8d43a0b8cd64edbe1c40a31cbff.1534441147.git.v.shpilevoy@tarantool.org> I haven't looked at the code yet, just skimmed over the commit message, but already have a couple of questions that I think should be clarified in the documentation request. On Thu, Aug 16, 2018 at 08:57:10PM +0300, Vladislav Shpilevoy wrote: > On commit/rollback triggers are already implemented > within Tarantool internals. The patch just exposes > them for Lua. Below the API is described, which > deserves an attention though. > > Closes #857 > > @TarantoolBot document > Title: Document box.on_commit/on_rollback triggers > On commit/rollback triggers can be set similar to > space:on_replace triggers: From before_replace/on_replace trigger you can issue DDL statements. What happens if you try to do the same from on_commit/on_rollback trigger? > > box.on_commit/rollback(new_trigger, old_trigger) > > A trigger can be set only inside an active > transaction. When a trigger is called, it takes 1 > parameter: an iterator over the transaction > statements. > > box.on_commit(function(iterator) > for i, old_tuple, new_tuple, space_id in iterator() do > -- Do something with tuples and space ... > end > end) OK, on_commit trigger takes committed tuples. What arguments does on_rollback trigger take? > > On each step the iterator returns 4 values: statement > number (grows from 1 to statement count), old tuple or > nil, new tuple or nil and space id. Old tuple is not > nil when the statement updated or deleted the existing > tuple. New tuple is not nil when the statement updated > or inserted the tuple. > > The iterator can not be used outside of the trigger. > Otherwise it throws an error. > > On_commit/rollback triggers shall not fail, otherwise > Tarantool exits with panic.
next prev parent reply other threads:[~2018-08-17 8:40 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-08-16 17:57 Vladislav Shpilevoy 2018-08-17 8:40 ` Vladimir Davydov [this message] 2018-08-17 14:45 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-17 11:21 ` Vladimir Davydov 2018-08-17 14:45 ` [tarantool-patches] " Vladislav Shpilevoy 2018-08-17 15:15 ` Vladimir Davydov 2018-08-17 15:42 ` [tarantool-patches] " Kirill Yukhin
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=20180817084044.bjroy7t2mirkyqn2@esperanza \ --to=vdavydov.dev@gmail.com \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [PATCH 1/1] box: expose on_commit/rollback triggers for Lua' \ /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