Move default_value_expr from field_def to tuple_field
field_def, like any other _def struct, is supposed to be plain and simple - it should map data stored in the _space system spaces as is. Complex data structures produced from it, like field dictionary or compiled SQL expression should be stored in tuple_field. This simplifies reasoning about the lifetime of this structure: - If it's allocated on the region, as it is the case, when the structure is created from MsgPack data, it will live until the region is truncated. It doesn't need to be destroyed in this case. - If it's allocated on malloc (by a dup function), it should be explicitly deleted with a delete function. Why we are doing this now: to implement space upgrade, we'll need to add a new member to space_opts struct. The new member will be a struct that may store an array of field_def. The problem is space_opts created on the region from MsgPack data is never deleted (see alter.cc), which means that the expression stored in field_def could leak. Note: in order to avoid tuple -> sql dependency, we have to call sql_expr_compile and sql_expr_delete from tuple_format.c via a callback set by sql_init. NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
Showing
- src/box/alter.cc 0 additions, 21 deletionssrc/box/alter.cc
- src/box/field_def.c 0 additions, 1 deletionsrc/box/field_def.c
- src/box/field_def.h 0 additions, 2 deletionssrc/box/field_def.h
- src/box/space_def.c 11 additions, 68 deletionssrc/box/space_def.c
- src/box/space_def.h 1 addition, 16 deletionssrc/box/space_def.h
- src/box/sql.c 18 additions, 5 deletionssrc/box/sql.c
- src/box/sql/fk_constraint.c 4 additions, 1 deletionsrc/box/sql/fk_constraint.c
- src/box/sql/insert.c 9 additions, 5 deletionssrc/box/sql/insert.c
- src/box/tuple_format.c 12 additions, 0 deletionssrc/box/tuple_format.c
- src/box/tuple_format.h 21 additions, 0 deletionssrc/box/tuple_format.h
Loading
Please register or sign in to comment