diff --git a/src/obidmscolumn.c b/src/obidmscolumn.c index a7aa67e..3a8b689 100644 --- a/src/obidmscolumn.c +++ b/src/obidmscolumn.c @@ -549,7 +549,7 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms, index_t minimum_line_count; OBIType_t returned_data_type; OBIType_t stored_data_type; - char final_indexer_name[INDEXER_MAX_NAME]; + char* final_indexer_name; new_column = NULL; @@ -569,13 +569,35 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms, obidebug(1, "\nCan't create column because of invalid data type"); return NULL; } + + // Get the column directory structure associated to the column + column_directory = obi_column_directory(dms, column_name); + if (column_directory == NULL) + { + obi_set_errno(OBICOLDIR_UNKNOWN_ERROR); + obidebug(1, "\nError opening a column directory structure"); + return NULL; + } + + // Get the latest version number + version_number = obi_get_new_version_number(column_directory, true); + if (version_number < 0) + { + return NULL; + } + + // Build the indexer name if needed if (((data_type == OBI_STR) || (data_type == OBI_SEQ)) && (strcmp(indexer_name, "") == 0)) - { // TODO make function in obiblob_indexer.c and discuss the fact that it's here - strcpy(final_indexer_name, column_name); - strcat(final_indexer_name, "_indexer"); // TODO _version_indexer + { + final_indexer_name = obi_build_indexer_name(column_name, version_number); + if (final_indexer_name == NULL) + return NULL; } else + { + final_indexer_name = (char*) malloc((strlen(indexer_name)+1)*sizeof(char)); strcpy(final_indexer_name, indexer_name); + } returned_data_type = data_type; if ((data_type == OBI_STR) || (data_type == OBI_SEQ)) @@ -623,27 +645,11 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms, return NULL; } - // Get the column directory structure associated to the column - column_directory = obi_column_directory(dms, column_name); - if (column_directory == NULL) - { - obi_set_errno(OBICOLDIR_UNKNOWN_ERROR); - obidebug(1, "\nError opening a column directory structure"); - return NULL; - } - // Calculate the size needed header_size = obi_get_platform_header_size(); data_size = obi_array_sizeof(stored_data_type, nb_lines, nb_elements_per_line); file_size = header_size + data_size; - // Get the latest version number - version_number = obi_get_new_version_number(column_directory, true); - if (version_number < 0) - { - return NULL; - } - // Get the column file name column_file_name = build_column_file_name(column_name, version_number); if (column_file_name == NULL)