box: pass source tuple to `default_func` field option of `space:format`
Let's pass the source tuple received as the argument to DML to the `default_func` field option of `space:format` to give users more versatility and the opportunity to compute the field value using other fields from the source tuple. For the tuple argument, we create a tuple rather than pass a MsgPack object for consistency with our other box APIs, even though it is suboptimal in terms of performance. We create the tuple argument with the empty default format, however, in the future it is possible to create it with a `names_only=true` format so that the source tuple can have the space format's data dictionary. We create the tuple argument from the source tuple data, which implies the following: (i) fields may not adhere to the space format; (ii) nil fields are always nil (i.e., the `default` value and the `default_func` are not used). (i) is because we can only validate the tuple after we finish building it. (ii) is because trying to use the `default` value and the `default_func` would have field build ordering ambiguity and would hurt performance of field building. Closes #9825 @TarantoolBot document Title: Tuple argument of `default_func` field option of `space:format` Product: Tarantool Since: 3.2 Root documents: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/format/ The source tuple (i.e., the argument of DML) is now passed as a second argument to the `default_func` field option of `space:format`. See also tarantool/tarantool#9825 and [PRD](https://www.notion.so/tarantool/Pass-tuple-as-argument-to-field-s-default_func-8785637fb79f43e4b8ca729e75fc4582). Please note that the tuple argument is created from the source tuple data, which implies the following: (i) fields may not adhere to the space format; (ii) nil fields are always nil (i.e., the `default` value and the `default_func` are not used).
Showing
- changelogs/unreleased/gh-9825-space-format-default-func-tuple-arg.md 4 additions, 0 deletions...unreleased/gh-9825-space-format-default-func-tuple-arg.md
- src/box/field_default_func.c 7 additions, 2 deletionssrc/box/field_default_func.c
- src/box/field_default_func.h 6 additions, 4 deletionssrc/box/field_default_func.h
- src/box/sql/func.c 2 additions, 2 deletionssrc/box/sql/func.c
- src/box/tuple_format.c 12 additions, 2 deletionssrc/box/tuple_format.c
- src/box/tuple_format.h 13 additions, 0 deletionssrc/box/tuple_format.h
- test/engine-luatest/gh_9825_space_format_default_func_tuple_arg_test.lua 68 additions, 0 deletions...test/gh_9825_space_format_default_func_tuple_arg_test.lua
Loading
Please register or sign in to comment