Fixed a problem with some columns being shorter in views and triggering

errors when trying to get values. Temporary fix that needs discussion
This commit is contained in:
Celine Mercier
2016-05-20 18:45:29 +02:00
parent 3b59043ea8
commit e681ca646d
2 changed files with 27 additions and 26 deletions

View File

@ -1217,12 +1217,12 @@ int obi_enlarge_column(OBIDMS_column_p column)
} }
column->data = mmap(NULL, column->data = mmap(NULL,
new_data_size, new_data_size,
PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
MAP_SHARED, MAP_SHARED,
column_file_descriptor, column_file_descriptor,
header_size header_size
); );
if (column->data == MAP_FAILED) if (column->data == MAP_FAILED)
{ {
obi_set_errno(OBICOL_UNKNOWN_ERROR); obi_set_errno(OBICOL_UNKNOWN_ERROR);
@ -1282,29 +1282,29 @@ void obi_ini_to_NA_values(OBIDMS_column_p column,
} }
break; break;
case OBI_QUAL: for (i=start;i<end;i++)
{
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
}
break;
case OBI_STR: for (i=start;i<end;i++)
{
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
}
break;
case OBI_SEQ: for (i=start;i<end;i++)
{
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
}
break;
case OBI_IDX: for (i=start;i<end;i++) case OBI_IDX: for (i=start;i<end;i++)
{ {
*(((index_t*) (column->data)) + i) = OBIIdx_NA; *(((index_t*) (column->data)) + i) = OBIIdx_NA;
} }
break; break;
case OBI_QUAL: for (i=start;i<end;i++) // case not used since OBI_QUAL is only a returned_data_type
{
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
}
break;
case OBI_STR: for (i=start;i<end;i++) // case not used since OBI_QUAL is only a returned_data_type
{
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
}
break;
case OBI_SEQ: for (i=start;i<end;i++) // case not used since OBI_QUAL is only a returned_data_type
{
*(((index_t*) (column->data)) + i) = OBIIdx_NA;
}
break;
} }
} }
@ -1474,12 +1474,12 @@ int obi_column_prepare_to_set_value(OBIDMS_column_p column, index_t line_nb)
} }
int obi_column_prepare_to_get_value(OBIDMS_column_p column, index_t line_nb) int obi_column_prepare_to_get_value(OBIDMS_column_p column, index_t line_nb) // TODO problem with some columns in a view being empty or shorter and triggering an error because they've been truncated when the view was closed. Fixed with obiview.c in update_lines() for now
{ {
if ((line_nb+1) > ((column->header)->line_count)) if ((line_nb+1) > ((column->header)->line_count))
{ {
obi_set_errno(OBICOL_UNKNOWN_ERROR); obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError trying to get a value that is beyond the current number of lines used in the column"); obidebug(1, "\nError trying to get a value that is beyond the current number of lines of the column");
return -1; return -1;
} }
return 0; return 0;

View File

@ -299,6 +299,7 @@ int update_lines(Obiview_p view, index_t line_count)
// Enlarge the column // Enlarge the column
if (obi_enlarge_column((view->columns)[i]) < 0) if (obi_enlarge_column((view->columns)[i]) < 0)
return -1; return -1;
(((view->columns)[i])->header)->lines_used = line_count; // TODO Discuss, this means that columns are not truncated below the number of lines in the view. Maybe they should be to save place.
} }
} }