Skip to content
Snippets Groups Projects
Commit 3dcc3fd6 authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Vladimir Davydov
Browse files

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
parent c842448e
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment