25 #include <sys/types.h> 55 int *instance_lock_timeout,
int *space_to_process,
OID * last_processed_oid,
121 if (
is_class (ref_oid, &ref_class_oid))
126 #if defined(CUBRID_DEBUG) 160 int return_value = 0;
169 return_value += error_code;
196 HEAP_ATTRVALUE *value =
NULL;
197 int force_count = 0, updated_n_attrs_id = 0;
203 if (upd_scancache ==
NULL || attr_info ==
NULL || oid ==
NULL)
229 atts_id = (
int *)
db_private_alloc (thread_p, attr_info->num_values * sizeof (
int));
235 for (i = 0, value = attr_info->values; i < attr_info->num_values; i++, value++)
240 value->state = HEAP_WRITTEN_ATTRVALUE;
241 atts_id[updated_n_attrs_id] = value->attrid;
242 updated_n_attrs_id++;
251 if ((updated_n_attrs_id > 0)
252 || (attr_info->read_classrepr !=
NULL && attr_info->last_classrepr !=
NULL 253 && attr_info->read_classrepr->id != attr_info->last_classrepr->id))
333 int *instance_lock_timeout,
int *space_to_process,
OID * last_processed_oid,
int *
total_objects,
336 int nobjects, nfetched,
i, j;
337 OID last_oid, prev_oid;
346 int ret =
NO_ERROR, object_processed;
349 int nfailed_instances = 0;
351 if (class_oid ==
NULL || hfid ==
NULL || space_to_process ==
NULL || *space_to_process <= 0
352 || *space_to_process > max_space_to_process || last_processed_oid ==
NULL || total_objects ==
NULL 353 || failed_objects ==
NULL || modified_objects ==
NULL || big_objects ==
NULL || *total_objects < 0
354 || *failed_objects < 0)
362 if (mvcc_snapshot ==
NULL)
384 COPY_OID (&last_oid, last_processed_oid);
385 COPY_OID (&prev_oid, last_processed_oid);
387 while (nobjects != nfetched)
391 &nfetched, &nfailed_instances, &last_oid, &fetch_area, mvcc_snapshot);
395 (*total_objects) += nfailed_instances;
396 (*failed_objects) += nfailed_instances;
398 if (fetch_area !=
NULL)
403 for (i = 0; i < mobjs->
num_objs; i++)
405 if (obj->
length > *space_to_process)
407 if (*space_to_process == max_space_to_process)
415 *space_to_process = 0;
416 COPY_OID (last_processed_oid, &prev_oid);
418 for (j = i; j < mobjs->
num_objs; j++)
433 *space_to_process -= obj->
length;
440 object_processed =
process_object (thread_p, &upd_scancache, &attr_info, &obj->
oid);
442 if (object_processed != 1)
446 if (object_processed == -1)
453 (*modified_objects)++;
484 COPY_OID (last_processed_oid, &last_oid);
517 int instance_lock_timeout,
int class_lock_timeout,
bool delete_old_repr,
519 int *modified_objects,
int *big_objects,
int *initial_last_repr_id)
522 int i, j, start_index = -1;
523 int max_space_to_process;
532 if (class_oids ==
NULL || n_classes <= 0 || space_to_process <= 0 || last_processed_class_oid ==
NULL 533 || last_processed_oid ==
NULL || total_objects ==
NULL || failed_objects ==
NULL || modified_objects ==
NULL 534 || big_objects ==
NULL || initial_last_repr_id ==
NULL)
539 for (start_index = 0; start_index < n_classes; start_index++)
541 if (
OID_EQ (class_oids + start_index, last_processed_class_oid))
547 if (start_index == n_classes)
552 for (i = 0; i < n_classes; i++)
554 total_objects[
i] = 0;
555 failed_objects[
i] = 0;
556 modified_objects[
i] = 0;
560 max_space_to_process = space_to_process;
561 for (i = start_index; i < n_classes; i++)
593 if (initial_last_repr_id[i] <= 0)
602 (thread_p, class_oids + i, &hfid, max_space_to_process, &instance_lock_timeout, &space_to_process,
603 last_processed_oid, total_objects + i, failed_objects + i, modified_objects + i,
607 for (j = start_index; j <=
i; j++)
610 failed_objects[j] = 0;
611 modified_objects[j] = 0;
619 if (delete_old_repr &&
OID_ISNULL (last_processed_oid) && failed_objects[i] == 0
629 for (j = start_index; j <=
i; j++)
632 failed_objects[j] = 0;
633 modified_objects[j] = 0;
648 if (space_to_process == 0)
656 if (i < n_classes - 1)
658 COPY_OID (last_processed_class_oid, class_oids + i + 1);
667 COPY_OID (last_processed_class_oid, class_oids + i);
696 int current_tran_index = -1;
726 int current_tran_index = -1;
755 int current_tran_index = -1;
static int process_value(THREAD_ENTRY *thread_p, DB_VALUE *value)
void heap_scancache_end_modify(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
int boot_heap_compact_pages(THREAD_ENTRY *thread_p, OID *class_oid)
#define COMPACTDB_INVALID_CLASS
DB_COLLECTION * db_get_set(const DB_VALUE *value)
MVCC_SNAPSHOT * logtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
int boot_compact_stop(THREAD_ENTRY *thread_p)
int heap_scancache_start_modify(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache, const HFID *hfid, const OID *class_oid, int op_type, MVCC_SNAPSHOT *mvcc_snapshot)
SCAN_CODE heap_get_visible_version(THREAD_ENTRY *thread_p, const OID *oid, OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, int ispeeking, int old_chn)
void locator_free_copy_area(LC_COPYAREA *copyarea)
#define LC_START_ONEOBJ_PTR_IN_COPYAREA(manyobjs_ptr)
void set_iterator_free(SET_ITERATOR *it)
#define csect_enter(a, b, c)
REPR_ID heap_get_class_repr_id(THREAD_ENTRY *thread_p, OID *class_oid)
#define ASSERT_ERROR_AND_SET(error_code)
#define OID_SET_NULL(oidp)
int set_iterator_next(SET_ITERATOR *it)
#define COMPACTDB_LOCKED_CLASS
int heap_scancache_end(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
static int desc_disk_to_attr_info(THREAD_ENTRY *thread_p, OID *oid, RECDES *recdes, HEAP_CACHE_ATTRINFO *attr_info)
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
static bool compact_started
SCAN_CODE locator_lock_and_get_object(THREAD_ENTRY *thread_p, const OID *oid, OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, LOCK lock, int ispeeking, int old_chn, NON_EXISTENT_HANDLING non_ex_handling_type)
#define LC_RECDES_TO_GET_ONEOBJ(copy_area_ptr, oneobj_ptr, recdes_ptr)
int heap_attrinfo_start(THREAD_ENTRY *thread_p, const OID *class_oid, int requested_num_attrs, const ATTR_ID *attrids, HEAP_CACHE_ATTRINFO *attr_info)
#define ER_QPROC_INVALID_PARAMETER
bool boot_can_compact(THREAD_ENTRY *thread_p)
#define OID_IS_ROOTOID(oidp)
int xlocator_lock_and_fetch_all(THREAD_ENTRY *thread_p, const HFID *hfid, LOCK *instance_lock, int *instance_lock_timeout, OID *class_oid, LOCK *class_lock, int *nobjects, int *nfetched, int *nfailed_instance_locks, OID *last_oid, LC_COPYAREA **fetch_area, MVCC_SNAPSHOT *mvcc_snapshot)
#define SINGLE_ROW_UPDATE
void lock_unlock_object(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, bool force)
static int process_set(THREAD_ENTRY *thread_p, DB_SET *set)
#define OID_EQ(oidp1, oidp2)
int heap_attrinfo_read_dbvalues(THREAD_ENTRY *thread_p, const OID *inst_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, HEAP_CACHE_ATTRINFO *attr_info)
int locator_attribute_info_force(THREAD_ENTRY *thread_p, const HFID *hfid, OID *oid, HEAP_CACHE_ATTRINFO *attr_info, ATTR_ID *att_id, int n_att_id, LC_COPYAREA_OPERATION operation, int op_type, HEAP_SCANCACHE *scan_cache, int *force_count, bool not_check_fk, REPL_INFO_TYPE repl_info, int pruning_type, PRUNING_CONTEXT *pcontext, FUNC_PRED_UNPACK_INFO *func_preds, MVCC_REEV_DATA *mvcc_reev_data, UPDATE_INPLACE_STYLE force_update_inplace, RECDES *rec_descriptor, bool need_locking)
int heap_attrinfo_clear_dbvalues(HEAP_CACHE_ATTRINFO *attr_info)
#define LC_NEXT_ONEOBJ_PTR_IN_COPYAREA(oneobj_ptr)
int catalog_drop_old_representations(THREAD_ENTRY *thread_p, OID *class_id_p)
static int failed_objects
#define db_private_free(thrd, ptr)
#define COMPACTDB_UNPROCESSED_CLASS
static int process_class(THREAD_ENTRY *thread_p, OID *class_oid, HFID *hfid, int max_space_to_process, int *instance_lock_timeout, int *space_to_process, OID *last_processed_oid, int *total_objects, int *failed_objects, int *modified_objects, int *big_objects)
#define db_private_alloc(thrd, size)
static bool is_class(OID *obj_oid, OID *class_oid)
#define LOG_FIND_THREAD_TRAN_INDEX(thrd)
#define HFID_IS_NULL(hfid)
OID * db_get_oid(const DB_VALUE *value)
static int process_object(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *upd_scancache, HEAP_CACHE_ATTRINFO *attr_info, OID *oid)
static int last_tran_index
MVCC_SNAPSHOT * mvcc_snapshot
int lock_object_wait_msecs(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, int cond_flag, int wait_msecs)
#define ER_HEAP_UNKNOWN_OBJECT
#define LC_MANYOBJS_PTR_IN_COPYAREA(copy_areaptr)
int boot_compact_start(THREAD_ENTRY *thread_p)
DB_VALUE * set_iterator_value(SET_ITERATOR *it)
#define DB_VALUE_TYPE(value)
char * msgcat_message(int cat_id, int set_id, int msg_id)
void heap_attrinfo_end(THREAD_ENTRY *thread_p, HEAP_CACHE_ATTRINFO *attr_info)
int heap_scancache_quick_start(HEAP_SCANCACHE *scan_cache)
#define ER_COMPACTDB_ALREADY_STARTED
int heap_get_class_info(THREAD_ENTRY *thread_p, const OID *class_oid, HFID *hfid_out, FILE_TYPE *ftype_out, char **classname_out)
#define COMPACTDB_REPR_DELETED
int heap_compact_pages(THREAD_ENTRY *thread_p, OID *class_oid)
int boot_compact_db(THREAD_ENTRY *thread_p, OID *class_oids, int n_classes, int space_to_process, int instance_lock_timeout, int class_lock_timeout, bool delete_old_repr, OID *last_processed_class_oid, OID *last_processed_oid, int *total_objects, int *failed_objects, int *modified_objects, int *big_objects, int *initial_last_repr_id)
SET_ITERATOR * set_iterate(DB_COLLECTION *set)
#define ER_MVCC_NOT_SATISFIED_REEVALUATION
#define MSGCAT_CATALOG_UTILS