[PATCH] lua: add type of operation to space trigger parameters

Vladimir Davydov vdavydov.dev at gmail.com
Mon Apr 8 13:17:23 MSK 2019


On Thu, Apr 04, 2019 at 08:49:45PM +0300, Serge Petrenko wrote:
> Add the type of operation which is being executed to before_replace and
> on_replace triggers.
> 
> Closes #4099
> 
> @TarantoolBot document
> Title: new parameter for space before_replace and on_replace triggers
> Now before_replace and on_replace triggers accept an additional
> parameter: the type of operation that is being executed.
> (INSERT/REPLACE/DELETE/UPDATE/UPSERT)
> For example, a trigger function may now look like this:
> ```
> function before_replace_trig(old, new, space_name, op_type)
>     if op_type == 'INSERT' then
> 	return old
>     else
> 	return new
>     end
> end
> ```
> And will restrict all INSERTs, but allow REPLACEs, UPSERTs, DELETEs and
> UPDATEs.
> ---
> https://github.com/tarantool/tarantool/issues/4099
> https://github.com/tarantool/tarantool/tree/sp/gh-4099-before-replace-op-type
> 
>  src/box/lua/space.cc             |  6 ++-
>  src/box/space.c                  | 10 +++++
>  test/box/before_replace.result   | 64 ++++++++++++++++++++++++++++++--
>  test/box/before_replace.test.lua | 27 +++++++++++++-
>  test/box/on_replace.result       | 54 +++++++++++++++++++++++++++
>  test/box/on_replace.test.lua     | 19 ++++++++++
>  6 files changed, 174 insertions(+), 6 deletions(-)

Pushed to master, 2.1, 1.10.



More information about the Tarantool-patches mailing list