Skip to content

Commit 43d1ab8

Browse files
committed
box: store field def array in read view if field names are enabled
We need field names in the raw read view API (available in EE only). Currently, we decode the raw format data to create the field def array for a raw read view space but this looks ugly and complicates the code. Let's duplicate the field def array stored in the space def instead, as we used to before commit d8abfe3 ("box: use format data instead of field def array in space read view"). NO_DOC=internal NO_TEST=internal NO_CHANGELOG=internal
1 parent 96a7b91 commit 43d1ab8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/box/read_view.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ static void
7575
space_read_view_delete(struct space_read_view *space_rv)
7676
{
7777
assert(space_rv->format == NULL);
78+
if (space_rv->field_count > 0)
79+
field_def_array_delete(space_rv->fields, space_rv->field_count);
7880
free(space_rv->format_data);
7981
for (uint32_t i = 0; i <= space_rv->index_id_max; i++) {
8082
struct index_read_view *index_rv = space_rv->index_map[i];
@@ -107,6 +109,15 @@ space_read_view_new(struct space *space, const struct read_view_opts *opts)
107109

108110
space_rv->id = space_id(space);
109111
space_rv->group_id = space_group_id(space);
112+
if (opts->enable_field_names && space->def->field_count > 0) {
113+
space_rv->fields = field_def_array_dup(space->def->fields,
114+
space->def->field_count);
115+
assert(space_rv->fields != NULL);
116+
space_rv->field_count = space->def->field_count;
117+
} else {
118+
space_rv->fields = NULL;
119+
space_rv->field_count = 0;
120+
}
110121
if (opts->enable_field_names &&
111122
space->def->format_data != NULL) {
112123
space_rv->format_data = xmalloc(space->def->format_data_len);

src/box/read_view.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,17 @@ struct space_read_view {
3434
uint32_t id;
3535
/** Space name. */
3636
char *name;
37+
/**
38+
* Tuple field definition array used by this space. Allocated only if
39+
* read_view_opts::enable_field_names is set, otherwise set to NULL.
40+
*/
41+
struct field_def *fields;
42+
/** Number of entries in the fields array. */
43+
uint32_t field_count;
3744
/**
3845
* Tuple format data used by this space. Allocated only if
3946
* read_view_opts::enable_field_names is set, otherwise set to NULL.
40-
* Used for creation of space_read_view::format and
41-
* box_raw_read_view_space::fields.
47+
* Used for creation of space_read_view::format.
4248
*/
4349
char *format_data;
4450
/** Length of tuple format data. */

0 commit comments

Comments
 (0)