Fixed bug when cloning column with line selection

This commit is contained in:
Celine Mercier
2016-09-21 17:50:21 +02:00
parent e79507b629
commit 43f3c69a40

View File

@ -1057,7 +1057,7 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
{
line_size = obi_sizeof((new_column->header)->stored_data_type) * (new_column->header)->nb_elements_per_line;
// Copy each line at the right index to the new column
for (i=0; i<nb_lines; i++)
for (i=0; i<((line_selection->header)->lines_used); i++)
{
// Get the index in the line selection column
index = obi_column_get_index(line_selection, i);
@ -1135,6 +1135,14 @@ int obi_truncate_column(OBIDMS_column_p column) // TODO is it necessary to unmap
int column_file_descriptor;
char* column_file_name;
// Check if the column is read-only
if (!(column->writable))
{
obi_set_errno(OBICOL_UNKNOWN_ERROR);
obidebug(1, "\nError trying to truncate a read-only column");
return -1;
}
// Compute the new line count = the number of lines used rounded to the nearest greater multiple of page size greater than 0
multiple = ceil((double) (ONE_IF_ZERO((column->header)->lines_used) * (column->header)->nb_elements_per_line * obi_sizeof((column->header)->stored_data_type)) / (double) getpagesize());
new_line_count = floor((((int) multiple) * getpagesize()) / ((column->header)->nb_elements_per_line * obi_sizeof((column->header)->stored_data_type)));