Close a set of records and free allocated memory, optionally inserting new records into the database. If action == DRMS_FREE_RECORD, then if a record being closed is the only reference to a SUMS storage unit slot, that slot is freed and marked for removal during SUMS garbage collection. During SUMS garbage collection, all data-segment files stored within this storage unit will be deleted. In this scenario, segment files written to SUMS during the current DRMS session are not preserved. If action == DRMS_INSERT_RECORD, then this function saves the keyword, link, and segment information in the appropriate database tables, and ensures that segment files written to SUMS during the current DRMS session are preserved. In order to succeed, no record contained in rs can be marked read-only.
Regardless of action, this function calls drms_free_records to deallo- cate the rs DRMS_RecordSet_t structure, the array of pointers to DRMS_Record_t structures contained within rs, and the actual DRMS_Record_t structures that these pointers reference. All these structures and pointers must have been previously allocated in heap memory (functions like drms_open_records ensure this is the case). The records are also removed from the record cache (env->record_cache).
Upon successful completion, the function returns 0. If an error occurs, the function returns an appropriate error code defined in drms_statuscodes.h. Typical errors are as follows. If action is nei- ther DRMS_FREE_RECORD nor DRMS_INSERT_RECORD, then DRMS_ERROR_INVALI- DACTION is returned. If action == DRMS_INSERT_RECORD and at least one record in rs is marked read-only, then DRMS_ERROR_COMMITREADONLY is returned.