206 std::atomic<int> &num_oids, std::atomic<int> &num_nulls);
211 bool has_keys ()
const;
235 int slot_id,
DB_VALUE * key,
bool * clear_key);
236 #if defined(CUBRID_DEBUG) 241 static int compare_driver (
const void *first,
const void *second,
void *arg);
246 #if defined(CUBRID_DEBUG) 247 static void list_print (
const BTREE_NODE * this_list);
253 bool * clear_key,
bool is_desc,
int *key_cnt,
478 root_header->num_nulls += null_delta;
479 root_header->num_oids += oid_delta;
480 root_header->num_keys += key_delta;
508 memcpy (rec->
data, root_header, fixed_size);
619 datap = (
char *) recdes->
data;
652 datap = (
char *) recdes->
data;
682 if (ovf_header ==
NULL)
719 char *pred_stream,
int pred_stream_size,
char *func_pred_stream,
int func_pred_stream_size,
720 int func_col_id,
int func_attr_index_start)
734 OID *notification_class_oid;
735 bool is_sysop_started =
false;
738 if (!btid || !hfids || !class_oids || !attr_ids || !key_type)
744 sort_args = &sort_args_info;
745 load_args = &load_args_info;
765 is_sysop_started =
true;
767 thread_p->push_resource_tracks ();
811 sort_args->
btid = &btid_int;
815 if (pred_stream && pred_stream_size > 0)
822 sort_args->
filter = filter_pred;
825 if (func_pred_stream && func_pred_stream_size > 0)
829 func_index_info.
col_id = func_col_id;
833 func_pred_stream_size, &func_unpack_info))
851 attr_offset = cur_class * sort_args->
n_attrs;
904 load_args->
btid = &btid_int;
938 btid_global_stats = *
btid;
958 "DEBUG_BTREE: load finished all. %d classes loaded, found %d nulls and %d oids, " 1026 #if !defined(NDEBUG) 1039 is_sysop_started =
false;
1046 if (
xbtree_add_index (thread_p, btid, key_type, &class_oids[0], attr_ids[0], unique_pk, sort_args->
n_oids,
1058 notification_class_oid = &class_oids[0];
1072 if (filter_pred !=
NULL)
1084 if (func_unpack_info)
1089 thread_p->pop_resource_tracks ();
1091 if (is_sysop_started)
1185 if (filter_pred !=
NULL)
1197 if (func_unpack_info)
1202 thread_p->pop_resource_tracks ();
1204 if (is_sysop_started)
1292 *header = load_args->
leaf.
hdr;
1349 nleaf_rec.
pnt = *pageid;
1452 char *temp_data =
NULL;
1464 int max_key_len, new_max;
1470 int last_key_offset, first_key_offset;
1471 bool clear_last_key =
false, clear_first_key =
false;
1480 root_header = &root_header_info;
1490 if (temp_data ==
NULL)
1501 assert (node_level == 2);
1589 assert (!
"setval error");
1612 max_key_len = MAX (new_max, max_key_len);
1614 assert (node_level == 2);
1651 assert (node_level == 2);
1666 next_pageptr =
NULL;
1700 assert (node_level == 2);
1735 if (cur_nleafpgptr ==
NULL)
1782 if (
btree_connect_page (thread_p, &first_key, max_key_len, &cur_nleafpgid, load_args, node_level) ==
NULL)
1877 #if defined (SERVER_MODE) 1901 if (next_pageptr ==
NULL)
1912 next_pageptr =
NULL;
1967 addr.
pgptr = page_ptr;
1993 || (header ==
NULL && node_level == -1));
2006 if (*page_new ==
NULL)
2036 assert (node_level == -1);
2095 if (new_leafpgptr ==
NULL)
2111 *header = new_leafhdr;
2125 *header = load_args->
leaf.
hdr;
2132 load_args->
leaf.
vpid = new_leafpgid;
2134 load_args->
leaf.
hdr = new_leafhdr;
2184 first_oid, &mvcc_info, load_args->
out_recdes);
2228 bool same_key =
true;
2240 int fixed_mvccid_size = 0;
2248 char *notify_vacuum_rv_data = notify_vacuum_rv_data_bufalign;
2250 int notify_vacuum_rv_data_length = 0;
2254 #if defined (SERVER_MODE) 2266 recdes = &sort_key_recdes;
2268 next_size =
sizeof (
char *);
2273 next = *(
char **) recdes->
data;
2317 #if defined(SERVER_MODE) 2330 #if defined(SERVER_MODE) 2340 COPY_OID (&original_oid, &this_oid);
2341 COPY_OID (&original_class_oid, &this_class_oid);
2342 original_mvcc_header = mvcc_header;
2349 "DEBUG_BTREE: load new object(%d, %d, %d) class(%d, %d, %d) and btid(%d, (%d, %d)) with " 2394 load_args->first_leafpgid = load_args->
leaf.
vpid;
2401 ret =
btree_first_oid (thread_p, &this_key, &this_class_oid, &this_oid, &mvcc_header, load_args);
2424 #if !defined (NDEBUG) 2448 same_key = (c ==
DB_EQ) ?
true :
false;
2477 OID first_oid, first_class_oid;
2483 &first_class_oid, &first_mvcc_info);
2492 &this_oid, &this_class_oid, &mvcc_info, &offset,
NULL,
NULL);
2505 #if !defined (NDEBUG) 2512 COPY_OID (&this_class_oid, &first_class_oid);
2544 if (new_ovfpgptr ==
NULL)
2553 if (ovf_header ==
NULL)
2565 load_args->
ovf.
vpid = new_ovfpgid;
2566 load_args->
ovf.
pgptr = new_ovfpgptr;
2567 new_ovfpgptr =
NULL;
2635 #if !defined (NDEBUG) 2713 ret =
btree_first_oid (thread_p, &this_key, &this_class_oid, &this_oid, &mvcc_header, load_args);
2734 #if !defined (NDEBUG) 2743 "DEBUG_BTREE: load added object(%d, %d, %d) " 2744 "class(%d, %d, %d) and btid(%d, (%d, %d)) with mvccinfo=%llu | %llu", this_oid.
volid,
2771 "DEBUG_BTREE: load notify vacuum object(%d, %d, %d) " 2772 "class(%d, %d, %d) and btid(%d, (%d, %d)) with mvccinfo=%llu | %llu",
2785 ¬ify_vacuum_rv_data, ¬ify_vacuum_rv_data_capacity,
2786 ¬ify_vacuum_rv_data_length);
2792 notify_vacuum_rv_data_length, notify_vacuum_rv_data);
2808 recdes->
data = next;
2818 if (notify_vacuum_rv_data !=
NULL && notify_vacuum_rv_data != notify_vacuum_rv_data_bufalign)
2841 if (notify_vacuum_rv_data !=
NULL && notify_vacuum_rv_data != notify_vacuum_rv_data_bufalign)
2850 #if defined(CUBRID_DEBUG) 2895 printf (
"Attribute: ");
2897 printf (
" Volid: %d", this_oid.
volid);
2898 printf (
" Pageid: %d", this_oid.
pageid);
2899 printf (
" Slotid: %d\n", this_oid.
slotid);
2931 bool includes_tde_class =
false;
2934 for (i = 0; i < sort_args->
n_classes; i++)
2942 includes_tde_class =
true;
2980 int *prefix_lengthp;
2991 prev_oid = sort_args->
cur_oid;
3007 bool save_cache_last_fix_page;
3021 attr_offset = cur_class * sort_args->
n_attrs;
3028 switch (scan_result)
3069 attr_offset = cur_class * sort_args->
n_attrs;
3072 &sort_args->
class_ids[cur_class], save_cache_last_fix_page,
false,
3132 snapshot_dirty_satisfied = mvcc_snapshot_dirty.
snapshot_fnc (thread_p, &mvcc_header, &mvcc_snapshot_dirty);
3147 else if (result !=
V_TRUE)
3177 prefix_lengthp =
NULL;
3187 if (dbvalue_ptr ==
NULL)
3200 if (dbvalue_ptr == &dbvalue || dbvalue_ptr->
need_clear ==
true)
3218 if (dbvalue_ptr == &dbvalue || dbvalue_ptr->
need_clear ==
true)
3225 "DEBUG_BTREE: load sort found null at oid(%d, %d, %d)" 3226 ", class_oid(%d, %d, %d), btid(%d, (%d, %d).", sort_args->
cur_oid.
volid,
3240 next_size =
sizeof (
char *);
3241 record_size = (next_size
3248 if (temp_recdes->
area_size < record_size)
3254 sort_args->
cur_oid = prev_oid;
3255 temp_recdes->
length = record_size;
3262 or_pad (&buf, next_size);
3320 "DEBUG_BTREE: load sort found oid(%d, %d, %d)" 3321 ", class_oid(%d, %d, %d), btid(%d, (%d, %d), mvcc_info=%llu | %llu.",
3343 if (dbvalue_ptr == &dbvalue || dbvalue_ptr->
need_clear ==
true)
3366 if (dbvalue_ptr == &dbvalue || dbvalue_ptr->
need_clear ==
true)
3384 char *mem1 = *(
char **) first;
3385 char *mem2 = *(
char **) second;
3398 mem1 +=
sizeof (
char *);
3399 mem2 +=
sizeof (
char *);
3437 char *bitptr1, *bitptr2;
3448 mem1 += bitmap_size;
3449 mem2 += bitmap_size;
3451 #if !defined(NDEBUG) 3452 for (i = 0, dom = key_type->
setdomain; dom; dom = dom->
next, i++);
3466 for (i = 0, dom = key_type->
setdomain; i < key_type->precision && dom; i++, dom = dom->
next)
3509 OR_BUF buf_val1, buf_val2;
3546 OID first_oid, second_oid;
3548 mem1 = *(
char **) first;
3549 mem2 = *(
char **) second;
3552 mem1 +=
sizeof (
char *);
3553 mem2 +=
sizeof (
char *);
3571 if (
OID_LT (&first_oid, &second_oid))
3604 if (new_node ==
NULL)
3609 new_node->
pageid = *pageid;
3621 next_node = next_node->
next;
3624 next_node->
next = new_node;
3649 *list = (*list)->
next;
3664 for (p = list; p !=
NULL; p = next)
3685 while (this_list !=
NULL)
3688 this_list = this_list->
next;
3694 #if defined(CUBRID_DEBUG) 3706 while (this_list !=
NULL)
3709 this_list = this_list->
next;
3721 btree_load_foo_debug (
void)
3723 (void) btree_dump_sort_output (
NULL,
NULL);
3744 fprintf (fp,
"\nNODE_TYPE: %s MAX_KEY_LEN: %4d PREV_PAGEID: {%4d , %4d} NEXT_PAGEID: {%4d , %4d} \n\n",
3760 #if !defined(NDEBUG) 3766 #if !defined(NDEBUG) 3804 bool clear_fk_key, clear_pk_key;
3805 int fk_node_key_cnt = -1, pk_node_key_cnt = -1;
3812 INT16 fk_slot_id = -1;
3813 bool found =
false, pk_has_slot_visible =
false, fk_has_visible =
false;
3814 char *val_print =
NULL;
3815 bool is_fk_scan_desc =
false;
3820 int classrepr_cacheindex = -1, part_count = -1, pos = -1;
3821 bool clear_pcontext =
false, has_partitions =
false;
3827 bool has_nulls =
false;
3848 if (classrepr ==
NULL)
3867 if (!is_fk_scan_desc)
3885 clear_pcontext =
true;
3894 part_count = pcontext.
count - 1;
3899 for (i = 0; i < part_count; i++)
3901 memcpy (&partitions[i].pcontext, &pcontext,
sizeof (
PRUNING_CONTEXT));
3902 memcpy (&partitions[i].bt_scan, &pk_bt_scan,
sizeof (
BTREE_SCAN));
3910 has_partitions =
true;
3916 &fk_key, &clear_fk_key, is_fk_scan_desc, &fk_node_key_cnt,
3917 &fk_node_header, &mvcc_snapshot_dirty);
3926 if (curr_fk_pageptr ==
NULL)
4007 BTID_COPY (&partitions[pos].btid, &pk_btid);
4013 old_page = pk_bt_scan.
C_page;
4017 pk_bt_scan = partitions[pos].
bt_scan;
4018 pk_node_key_cnt = partitions[pos].
key_cnt;
4019 pk_node_header = partitions[pos].
header;
4027 &pk_bt_scan.
C_page, &found);
4038 (val_print ? val_print :
"unknown value"));
4046 if (old_page !=
NULL)
4053 pk_bt_scan.
slot_id, &pk_has_slot_visible);
4059 if (!pk_has_slot_visible)
4064 (val_print ? val_print :
"unknown value"));
4074 if (old_page !=
NULL)
4086 &clear_pk_key,
false, &pk_node_key_cnt, &pk_node_header,
4087 &mvcc_snapshot_dirty);
4099 (val_print ? val_print :
"unknown value"));
4107 if (compare_ret ==
DB_EQ)
4112 else if (compare_ret ==
DB_LT)
4122 (val_print ? val_print :
"unknown value"));
4129 if (!found && pk_bt_scan.
slot_id > pk_node_key_cnt)
4131 old_page = pk_bt_scan.
C_page;
4139 partitions[pos].
key_cnt = pk_node_key_cnt;
4140 partitions[pos].
header = pk_node_header;
4155 for (i = 0; i < part_count; i++)
4157 if (partitions[i].bt_scan.C_page !=
NULL)
4164 if (old_page !=
NULL)
4169 if (curr_fk_pageptr !=
NULL)
4182 if (clear_pcontext ==
true)
4187 if (classrepr !=
NULL)
4211 int first_key_offset = 0;
4254 INT16 * slot_id,
DB_VALUE * key,
bool * clear_key,
bool is_desc,
int *key_cnt,
4261 bool is_slot_visible =
false;
4287 if (local_header ==
NULL)
4302 *slot_id = is_desc ? (*key_cnt + 1) : 0;
4308 *slot_id += (is_desc ? -1 : 1);
4311 if (*slot_id == 0 || *slot_id >= *key_cnt + 1)
4333 *slot_id = is_desc ? *key_cnt : 1;
4351 if (!is_slot_visible)
4366 *header = local_header;
4386 int slot_id,
bool * is_visible)
4390 int num_visible = 0;
4393 bool dummy_clear_key;
4395 *is_visible =
false;
4397 if (mvcc_snapshot ==
NULL)
4429 if (num_visible > 0)
4441 const char *
fk_name,
char *pred_stream,
int pred_stream_size,
char *func_pred_stream,
4442 int func_pred_stream_size,
int func_col_id,
int func_attr_index_start,
int ib_thread_count)
4450 bool is_sysop_started =
false;
4457 bool scan_cache_inited =
false;
4458 bool attr_info_inited =
false;
4463 bool old_check_intr;
4468 if (!btid || !hfids || !class_oids || !attr_ids || !key_type)
4477 #if !defined(NDEBUG) 4508 if (builder_snapshot ==
NULL)
4516 list_btid = (
BTID *) malloc (n_classes *
sizeof (
BTID));
4517 if (list_btid ==
NULL)
4526 for (cur_class = 0; cur_class <
n_classes; cur_class++)
4535 for (cur_class = 0; cur_class <
n_classes; cur_class++)
4543 if (pred_stream && pred_stream_size > 0)
4551 if (func_pred_stream && func_pred_stream_size > 0)
4555 func_index_info.
col_id = func_col_id;
4559 func_pred_stream_size, &func_unpack_info))
4565 attr_offset = cur_class *
n_attrs;
4568 if (
heap_scancache_start (thread_p, &scan_cache, &hfids[cur_class], &class_oids[cur_class],
true,
false,
4573 scan_cache_inited =
true;
4575 if (
heap_attrinfo_start (thread_p, &class_oids[cur_class], n_attrs, &attr_ids[attr_offset], &attr_info) !=
4580 attr_info_inited =
true;
4582 if (filter_pred !=
NULL)
4593 if (
heap_attrinfo_start (thread_p, &class_oids[cur_class], n_attrs, &attr_ids[attr_offset],
4625 ret =
online_index_builder (thread_p, &btid_int, &hfids[cur_class], &class_oids[cur_class], n_classes, attr_ids,
4626 n_attrs, func_index_info, filter_pred, attrs_prefix_length, &attr_info, &scan_cache,
4627 unique_pk, ib_thread_count, key_type);
4633 if (attr_info_inited)
4641 if (func_index_info.
expr)
4646 attr_info_inited =
false;
4649 if (scan_cache_inited)
4652 scan_cache_inited =
false;
4655 if (filter_pred !=
NULL)
4673 if (func_unpack_info !=
NULL)
4687 for (cur_class = 0; cur_class <
n_classes; cur_class++)
4698 #if defined (SERVER_MODE) 4717 #endif // SERVER_MODE 4736 for (cur_class = 0; cur_class <
n_classes; cur_class++)
4741 &class_oids[cur_class]);
4751 assert (scan_cache_inited ==
false && attr_info_inited ==
false);
4753 if (list_btid !=
NULL)
4763 if (builder_snapshot !=
NULL)
4771 if (attr_info_inited)
4779 if (func_index_info.
expr)
4784 attr_info_inited =
false;
4787 if (scan_cache_inited)
4790 scan_cache_inited =
false;
4793 if (filter_pred !=
NULL)
4810 if (func_unpack_info !=
NULL)
4815 if (list_btid !=
NULL)
4821 if (builder_snapshot !=
NULL)
4846 int *p_prefix_length;
4847 uint64_t tasks_started = 0;
4850 bool is_parallel = ib_thread_count > 0;
4851 std::atomic<int> num_keys = {0}, num_oids = {0}, num_nulls = {0};
4853 std::unique_ptr<index_builder_loader_task> load_task =
NULL;
4863 p_func_idx_info = func_idx_info.
expr ? &func_idx_info :
NULL;
4864 filter_eval_fnc = (filter_pred !=
NULL) ?
eval_fnc (thread_p, filter_pred->
pred, &single_node_type) :
NULL;
4878 load_context.
m_conn = thread_p->conn_entry;
4880 PERF_UTIME_TRACKER time_online_index = PERF_UTIME_TRACKER_INITIALIZER;
4882 PERF_UTIME_TRACKER_START (thread_p, &time_online_index);
4892 attr_offset = cur_class *
n_attrs;
4896 sc =
heap_next (thread_p, &hfids[cur_class], &class_oids[cur_class], &cur_oid, &cur_record, scancache,
COPY);
4902 else if (sc ==
S_END)
4919 eval_res = (*filter_eval_fnc) (thread_p, filter_pred->
pred,
NULL, &
cur_oid);
4925 else if (eval_res !=
V_TRUE)
4931 if (p_func_idx_info && p_func_idx_info->
expr)
4951 p_prefix_length =
NULL;
4952 if (attrs_prefix_length)
4954 p_prefix_length = &(attrs_prefix_length[0]);
4959 &cur_record, &dbvalue, aligned_midxkey_buf, p_func_idx_info, key_type);
4960 if (p_dbvalue ==
NULL)
4967 if (load_task ==
NULL)
4971 load_context, num_keys, num_oids, num_nulls));
4997 if (load_task !=
NULL && load_task->has_keys ())
5006 bool dummy_continue_checking =
true;
5070 std::atomic<int> &num_keys, std::atomic<int> &num_oids,
5071 std::atomic<int> &num_nulls)
5072 : m_load_context (load_context)
5073 , m_insert_list (load_context.m_key_type)
5074 , m_num_keys (num_keys)
5075 , m_num_oids (num_oids)
5076 , m_num_nulls (num_nulls)
5130 size_t key_count = 0;
5139 PERF_UTIME_TRACKER time_insert_task = PERF_UTIME_TRACKER_INITIALIZER;
5140 PERF_UTIME_TRACKER_START (&thread_ref, &time_insert_task);
5142 PERF_UTIME_TRACKER time_prepare_task = PERF_UTIME_TRACKER_INITIALIZER;
5143 PERF_UTIME_TRACKER_START (&thread_ref, &time_prepare_task);
5168 if (p_unique_stats !=
NULL)
int btree_change_root_header_delta(THREAD_ENTRY *thread_p, VFID *vfid, PAGE_PTR page_ptr, int null_delta, int oid_delta, int key_delta)
TP_DOMAIN * btree_generate_prefix_domain(BTID_INT *btid)
std::atomic< int > & m_num_nulls
int data_readval(struct or_buf *buf, DB_VALUE *value, const tp_domain *domain, int size, bool copy, char *copy_buf, int copy_buf_len) const
#define OR_BTID_ALIGNED_SIZE
#define OR_PUT_OID(ptr, oid)
FUNCTION_INDEX_INFO * func_index_info
void log_append_redo_data(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, LOG_DATA_ADDR *addr, int length, const void *data)
static int list_add(BTREE_NODE **list, VPID *pageid)
#define MVCC_IS_HEADER_DELID_VALID(rec_header_p)
#define MVCC_GET_INSID(header)
MVCC_SNAPSHOT * logtb_get_mvcc_snapshot(THREAD_ENTRY *thread_p)
int or_get_mvccid(OR_BUF *buf, MVCCID *mvccid)
int btree_create_file(THREAD_ENTRY *thread_p, const OID *class_oid, int attrid, BTID *btid)
#define BTID_AS_ARGS(btid)
void log_append_undoredo_data2(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VFID *vfid, PAGE_PTR pgptr, PGLENGTH offset, int undo_length, int redo_length, const void *undo_data, const void *redo_data)
size_t add_key(const DB_VALUE *key, const OID &oid)
static void btree_log_page(THREAD_ENTRY *thread_p, VFID *vfid, PAGE_PTR page_ptr)
BTREE_NODE_HEADER * btree_get_node_header(THREAD_ENTRY *thread_p, PAGE_PTR page_ptr)
static int btree_first_oid(THREAD_ENTRY *thread_p, DB_VALUE *this_key, OID *class_oid, OID *first_oid, MVCC_REC_HEADER *p_mvcc_rec_header, LOAD_ARGS *load_args)
void claim_system_worker()
#define OR_MULTI_ATT_IS_UNBOUND(bitptr, element)
int or_put_oid(OR_BUF *buf, const OID *oid)
static int online_index_builder(THREAD_ENTRY *thread_p, BTID_INT *btid_int, HFID *hfids, OID *class_oids, int n_classes, int *attrids, int n_attrs, FUNCTION_INDEX_INFO func_idx_info, PRED_EXPR_WITH_CONTEXT *filter_pred, int *attrs_prefix_length, HEAP_CACHE_ATTRINFO *attr_info, HEAP_SCANCACHE *scancache, int unique_pk, int ib_thread_count, TP_DOMAIN *key_type)
#define BTREE_GET_KEY_LEN_IN_PAGE(key_len)
static PAGE_PTR btree_proceed_leaf(THREAD_ENTRY *thread_p, LOAD_ARGS *load_args)
int data_writeval(struct or_buf *buf, const DB_VALUE *value) const
#define ER_NOT_NULL_DOES_NOT_ALLOW_NULL_VALUE
void btree_mvcc_info_from_heap_mvcc_header(MVCC_REC_HEADER *mvcc_header, BTREE_MVCC_INFO *mvcc_info)
int btree_write_record(THREAD_ENTRY *thread_p, BTID_INT *btid, void *node_rec, DB_VALUE *key, BTREE_NODE_TYPE node_type, int key_type, int key_len, bool during_loading, OID *class_oid, OID *oid, BTREE_MVCC_INFO *mvcc_info, RECDES *rec)
int or_put_domain(OR_BUF *buf, struct tp_domain *domain, int include_classoids, int is_null)
int spage_insert(THREAD_ENTRY *thread_p, PAGE_PTR page_p, RECDES *record_descriptor_p, PGSLOTID *out_slot_id_p)
int partition_load_pruning_context(THREAD_ENTRY *thread_p, const OID *class_oid, int pruning_type, PRUNING_CONTEXT *pinfo)
BTREE_ROOT_HEADER * btree_get_root_header(THREAD_ENTRY *thread_p, PAGE_PTR page_ptr)
const int LOG_SYSTEM_TRAN_INDEX
css_conn_entry * conn_entry
int SORT_PUT_FUNC(THREAD_ENTRY *thread_p, const RECDES *, void *)
struct tp_domain * setdomain
bool has_deadlock_priority
#define OR_BUF_INIT(buf, data, size)
#define BTREE_SET_CREATED_OVERFLOW_KEY_NOTIFICATION(THREAD, KEY, OID, C_OID, BTID, BTNM)
#define MVCC_IS_HEADER_INSID_NOT_ALL_VISIBLE(rec_header_p)
MVCCID oldest_visible_mvccid
void logpb_force_flush_pages(THREAD_ENTRY *thread_p)
void on_create(context_type &context) override
struct btree_node_header BTREE_NODE_HEADER
#define ASSERT_ERROR_AND_SET(error_code)
int or_get_oid(OR_BUF *buf, OID *oid)
bool logtb_set_tran_index_interrupt(THREAD_ENTRY *thread_p, int tran_index, bool set)
void thread_sleep(double millisec)
std::atomic< int > & m_num_oids
#define OR_MVCC_FLAG_VALID_INSID
TP_DOMAIN * nonleaf_key_type
BTID * xbtree_add_index(THREAD_ENTRY *thread_p, BTID *btid, TP_DOMAIN *key_type, OID *class_oid, int attr_id, int unique_pk, int num_oids, int num_nulls, int num_keys)
#define assert_release(e)
void on_retire(context_type &context) override
int lock_demote_class_lock(THREAD_ENTRY *thread_p, const OID *oid, LOCK lock, LOCK *ex_lock)
void pgbuf_set_dirty(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, bool free_page)
void scan_init_index_scan(INDX_SCAN_ID *isidp, struct btree_iscan_oid_list *oid_list, MVCC_SNAPSHOT *mvcc_snapshot)
#define BTREE_MAX_OIDLEN_INPAGE
BTREE_NODE_HEADER * header
static void list_clear(BTREE_NODE *list)
void log_append_undo_data2(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VFID *vfid, PAGE_PTR pgptr, PGLENGTH offset, int length, const void *data)
int or_mvcc_get_header(RECDES *record, MVCC_REC_HEADER *mvcc_header)
static int btree_save_last_leafrec(THREAD_ENTRY *thread_p, LOAD_ARGS *load_args)
int lock_object(THREAD_ENTRY *thread_p, const OID *oid, const OID *class_oid, LOCK lock, int cond_flag)
void log_sysop_start(THREAD_ENTRY *thread_p)
cubthread::manager * thread_get_manager(void)
#define OR_MVCC_FLAG_VALID_DELID
#define OR_ALIGNED_BUF(size)
static int btree_build_nleafs(THREAD_ENTRY *thread_p, LOAD_ARGS *load_args, int n_nulls, int n_oids, int n_keys)
#define OID_SET_NULL(oidp)
#define os_free_and_init(ptr)
#define OID_LT(oidp1, oidp2)
static int btree_load_new_page(THREAD_ENTRY *thread_p, const BTID *btid, BTREE_NODE_HEADER *header, int node_level, VPID *vpid_new, PAGE_PTR *page_new)
DB_LOGICAL(* PR_EVAL_FNC)(THREAD_ENTRY *thread_p, const PRED_EXPR *, val_descr *, OID *)
bool btree_multicol_key_is_null(DB_VALUE *key)
int btree_node_number_of_keys(THREAD_ENTRY *thread_p, PAGE_PTR page_ptr)
std::atomic< int > & m_num_keys
const int LOG_WORKER_POOL_INDEX_BUILDER
#define MVCC_CLEAR_FLAG_BITS(rec_header_p, flag)
void btree_init_temp_key_value(bool *clear_flag, DB_VALUE *key_value)
entry_workpool * create_worker_pool(std::size_t pool_size, std::size_t task_max_count, const char *name, entry_manager *context_manager, std::size_t core_count, bool debug_logging, bool pool_threads=false, wait_seconds wait_for_task_time=std::chrono::seconds(5))
static PAGE_PTR btree_connect_page(THREAD_ENTRY *thread_p, DB_VALUE *key, int max_key_len, VPID *pageid, LOAD_ARGS *load_args, int node_level)
MVCC_SATISFIES_SNAPSHOT_RESULT mvcc_satisfies_dirty(THREAD_ENTRY *thread_p, MVCC_REC_HEADER *rec_header, MVCC_SNAPSHOT *snapshot)
static bool btree_is_worker_pool_logging_true()
#define OR_MULTI_BOUND_BIT_BYTES(count)
#define BTREE_IS_UNIQUE(unique_pk)
#define PTR_ALIGN(addr, boundary)
PRED_EXPR_WITH_CONTEXT * filter
struct btree_overflow_header BTREE_OVERFLOW_HEADER
#define OID_AS_ARGS(oidp)
int btree_check_valid_record(THREAD_ENTRY *thread_p, BTID_INT *btid, RECDES *recp, BTREE_NODE_TYPE node_type, DB_VALUE *key)
#define er_log_debug(...)
static int btree_index_sort(THREAD_ENTRY *thread_p, SORT_ARGS *sort_args, SORT_PUT_FUNC *out_func, void *out_args)
DB_VALUE_COMPARE_RESULT btree_compare_key(DB_VALUE *key1, DB_VALUE *key2, TP_DOMAIN *key_domain, int do_coercion, int total_order, int *start_colp)
void execute(cubthread::entry &thread_ref)
int heap_scancache_end(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
void _er_log_debug(const char *file_name, const int line_no, const char *fmt,...)
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
#define BTREE_MAX_KEYLEN_INPAGE
index_builder_loader_task()=delete
SCAN_CODE spage_get_record(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id, RECDES *record_descriptor_p, int is_peeking)
int xlogtb_reset_wait_msecs(THREAD_ENTRY *thread_p, int wait_msecs)
void btree_rv_mvcc_save_increments(const BTID *btid, int key_delta, int oid_delta, int null_delta, RECDES *recdes)
#define VFID_ISNULL(vfid_ptr)
~index_builder_loader_task()
#define MVCCID_ALL_VISIBLE
#define pgbuf_unfix_and_init(thread_p, pgptr)
#define MVCC_SET_INSID(header, mvcc_id)
void vacuum_log_add_dropped_file(THREAD_ENTRY *thread_p, const VFID *vfid, const OID *class_oid, bool pospone_or_undo)
int btree_create_overflow_key_file(THREAD_ENTRY *thread_p, BTID_INT *btid)
int or_put_mvccid(OR_BUF *buf, MVCCID mvccid)
#define OR_ALIGNED_BUF_START(abuf)
int spage_update(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id, const RECDES *record_descriptor_p)
void log_append_redo_data2(THREAD_ENTRY *thread_p, LOG_RCVINDEX rcvindex, const VFID *vfid, PAGE_PTR pgptr, PGLENGTH offset, int length, const void *data)
int heap_scancache_start(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache, const HFID *hfid, const OID *class_oid, int cache_last_fix_page, int is_indexscan, MVCC_SNAPSHOT *mvcc_snapshot)
void switch_to_global_allocator_and_call(Func &&func, Args &&...args)
UINT64 prm_get_bigint_value(PARAM_ID prm_id)
int sort_listfile(THREAD_ENTRY *thread_p, INT16 volid, int est_inp_pg_cnt, SORT_GET_FUNC *get_fn, void *get_arg, SORT_PUT_FUNC *put_fn, void *put_arg, SORT_CMP_FUNC *cmp_fn, void *cmp_arg, SORT_DUP_OPTION option, int limit, bool includes_tde_class)
void partition_clear_pruning_context(PRUNING_CONTEXT *pinfo)
PAGE_TYPE pgbuf_get_page_ptype(THREAD_ENTRY *thread_p, PAGE_PTR pgptr)
int heap_get_class_tde_algorithm(THREAD_ENTRY *thread_p, const OID *class_oid, TDE_ALGORITHM *tde_algo)
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)
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
void btree_clear_mvcc_flags_from_oid(OID *oid)
int spage_max_space_for_new_record(THREAD_ENTRY *thread_p, PAGE_PTR page_p)
char * btree_pack_mvccinfo(char *ptr, BTREE_MVCC_INFO *mvcc_info)
#define BTREE_INIT_MVCC_HEADER(p_mvcc_rec_header)
BTID * xbtree_load_online_index(THREAD_ENTRY *thread_p, BTID *btid, const char *bt_name, TP_DOMAIN *key_type, OID *class_oids, int n_classes, int n_attrs, int *attr_ids, int *attrs_prefix_length, HFID *hfids, int unique_pk, int not_null_flag, OID *fk_refcls_oid, BTID *fk_refcls_pk_btid, const char *fk_name, char *pred_stream, int pred_stream_size, char *func_pred_stream, int func_pred_stream_size, int func_col_id, int func_attr_index_start, int ib_thread_count)
#define BTREE_MAX_OIDCOUNT_IN_SIZE(btid, size)
#define BTREE_MAX_OIDCOUNT_IN_LEAF_RECORD(btid)
void btree_leaf_record_change_overflow_link(THREAD_ENTRY *thread_p, BTID_INT *btid_int, RECDES *leaf_record, VPID *new_overflow_vpid, char **rv_undo_data_ptr, char **rv_redo_data_ptr)
int btree_online_index_list_dispatcher(THREAD_ENTRY *thread_p, BTID *btid, OID *class_oid, btree_insert_list *insert_list, int unique, BTREE_OP_PURPOSE purpose, LOG_LSA *undo_nxlsa)
void btree_mvcc_info_to_heap_mvcc_header(BTREE_MVCC_INFO *mvcc_info, MVCC_REC_HEADER *mvcc_header)
bool pgbuf_check_page_ptype(THREAD_ENTRY *thread_p, PAGE_PTR pgptr, PAGE_TYPE ptype)
static int compare_driver(const void *first, const void *second, void *arg)
int btree_rv_save_keyval_for_undo(BTID_INT *btid, DB_VALUE *key, OID *cls_oid, OID *oid, BTREE_MVCC_INFO *mvcc_info, BTREE_OP_PURPOSE purpose, char *preallocated_buffer, char **data, int *capacity, int *length)
int partition_prune_unique_btid(PRUNING_CONTEXT *pcontext, DB_VALUE *key, OID *class_oid, HFID *class_hfid, BTID *btid)
#define ER_OUT_OF_VIRTUAL_MEMORY
int btree_init_root_header(THREAD_ENTRY *thread_p, VFID *vfid, PAGE_PTR page_ptr, BTREE_ROOT_HEADER *root_header, TP_DOMAIN *key_type)
int btree_get_next_overflow_vpid(THREAD_ENTRY *thread_p, PAGE_PTR page_ptr, VPID *vpid)
#define SORT_RECORD_LENGTH(item_p)
#define OR_GET_OID(ptr, oid)
void btree_get_root_vpid_from_btid(THREAD_ENTRY *thread_p, BTID *btid, VPID *root_vpid)
bool css_is_shutdowning_server()
static int list_length(const BTREE_NODE *this_list)
batch_key_status add_key(const DB_VALUE *key, const OID &oid)
int or_put_byte(OR_BUF *buf, int num)
void btree_rv_nodehdr_dump(FILE *fp, int length, void *data)
int stx_map_stream_to_func_pred(THREAD_ENTRY *thread_p, func_pred **xasl, char *xasl_stream, int xasl_stream_size, XASL_UNPACK_INFO **xasl_unpack_info_ptr)
#define OID_EQ(oidp1, oidp2)
static int btree_get_value_from_leaf_slot(THREAD_ENTRY *thread_p, BTID_INT *btid_int, PAGE_PTR leaf_ptr, int slot_id, DB_VALUE *key, bool *clear_key)
#define heap_classrepr_free_and_init(class_repr, idxp)
const TP_DOMAIN * m_key_type
std::atomic< std::uint64_t > m_tasks_executed
int heap_attrinfo_read_dbvalues(THREAD_ENTRY *thread_p, const OID *inst_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, HEAP_CACHE_ATTRINFO *attr_info)
#define TP_DOMAIN_TYPE(dom)
unsigned has_partition_info
int btree_init_overflow_header(THREAD_ENTRY *thread_p, PAGE_PTR page_ptr, BTREE_OVERFLOW_HEADER *ovf_header)
int file_alloc(THREAD_ENTRY *thread_p, const VFID *vfid, FILE_INIT_PAGE_FUNC f_init, void *f_init_args, VPID *vpid_out, PAGE_PTR *page_out)
void btree_dump_key(FILE *fp, const DB_VALUE *key)
void btree_set_mvcc_flags_into_oid(MVCC_REC_HEADER *p_mvcc_header, OID *oid)
PGNSLOTS spage_number_of_records(PAGE_PTR page_p)
#define MVCC_IS_FLAG_SET(rec_header_p, flags)
int logtb_invalidate_snapshot_data(THREAD_ENTRY *thread_p)
#define BTREE_CURRENT_REV_LEVEL
DISK_ISVALID btree_verify_tree(THREAD_ENTRY *thread_p, const OID *class_oid_p, BTID_INT *btid_int, const char *btname)
DB_VALUE * heap_attrinfo_generate_key(THREAD_ENTRY *thread_p, int n_atts, int *att_ids, int *atts_prefix_length, HEAP_CACHE_ATTRINFO *attr_info, RECDES *recdes, DB_VALUE *db_valuep, char *buf, FUNCTION_INDEX_INFO *func_index_info, TP_DOMAIN *midxkey_domain)
static int btree_construct_leafs(THREAD_ENTRY *thread_p, const RECDES *in_recdes, void *arg)
int curr_rec_max_obj_count
#define BTID_SET_NULL(btid)
#define BTREE_OVERFLOW_KEY
int curr_non_del_obj_count
#define LOAD_FIXED_EMPTY_FOR_NONLEAF
#define db_private_free_and_init(thrd, ptr)
#define OR_PUT_BTID(ptr, btid)
#define ER_BTREE_LOAD_FAILED
#define pgbuf_fix(thread_p, vpid, fetch_mode, requestmode, condition)
void partition_init_pruning_context(PRUNING_CONTEXT *pinfo)
#define db_private_free(thrd, ptr)
int btree_prepare_bts(THREAD_ENTRY *thread_p, BTREE_SCAN *bts, BTID *btid, INDX_SCAN_ID *index_scan_id_p, key_val_range *kv_range, FILTER_INFO *filter, const OID *match_class_oid, DB_BIGINT *key_limit_upper, DB_BIGINT *key_limit_lower, bool need_to_check_null, void *bts_other)
void or_init(OR_BUF *buf, char *data, int length)
LOG_UNIQUE_STATS tran_stats
static void list_remove_first(BTREE_NODE **list)
#define MVCC_REC_HEADER_INITIALIZER
PR_EVAL_FNC filter_eval_func
need_clear_type need_clear
int partition_prune_partition_index(PRUNING_CONTEXT *pcontext, DB_VALUE *key, OID *class_oid, BTID *btid, int *position)
bool logtb_set_check_interrupt(THREAD_ENTRY *thread_p, bool flag)
OR_CLASSREP * heap_classrepr_get(THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *class_recdes, REPR_ID reprid, int *idx_incache)
int pr_clear_value(DB_VALUE *value)
index_builder_loader_context & m_load_context
static int btree_pack_root_header(RECDES *Rec, BTREE_ROOT_HEADER *header, TP_DOMAIN *key_type)
void log_sysop_abort(THREAD_ENTRY *thread_p)
#define MVCC_SET_FLAG_BITS(rec_header_p, flag)
void destroy_worker_pool(entry_workpool *&worker_pool_arg)
int btree_get_num_visible_from_leaf_and_ovf(THREAD_ENTRY *thread_p, BTID_INT *btid_int, RECDES *leaf_record, int offset_after_key, LEAF_REC *leaf_info, int *max_visible_oids, MVCC_SNAPSHOT *mvcc_snapshot, int *num_visible)
MVCCID logtb_get_current_mvccid(THREAD_ENTRY *thread_p)
void free_xasl_unpack_info(THREAD_ENTRY *thread_p, REFPTR(XASL_UNPACK_INFO, xasl_unpack_info))
bool logtb_is_interrupted(THREAD_ENTRY *thread_p, bool clear, bool *continue_checking)
#define ER_BTREE_UNIQUE_FAILED
static void error(const char *msg)
int btree_get_disk_size_of_key(DB_VALUE *key)
btree_insert_list m_insert_list
#define VPID_ISNULL(vpid_ptr)
int btree_get_prefix_separator(const DB_VALUE *key1, const DB_VALUE *key2, DB_VALUE *prefix_key, TP_DOMAIN *key_domain)
int heap_get_btid_from_index_name(THREAD_ENTRY *thread_p, const OID *p_class_oid, const char *index_name, BTID *p_found_btid)
MVCCID get_global_oldest_visible() const
LOG_TDES * LOG_FIND_CURRENT_TDES(THREAD_ENTRY *thread_p=NULL)
PGSLOTID last_leaf_insert_slotid
bool log_check_system_op_is_started(THREAD_ENTRY *thread_p)
#define HFID_IS_NULL(hfid)
int btree_online_index_check_unique_constraint(THREAD_ENTRY *thread_p, BTID *btid, const char *index_name, OID *class_oid)
int pr_clone_value(const DB_VALUE *src, DB_VALUE *dest)
#define BTREE_IS_PRIMARY_KEY(unique_pk)
PR_EVAL_FNC eval_fnc(THREAD_ENTRY *thread_p, const PRED_EXPR *pr, DB_TYPE *single_node_type)
void on_recycle(context_type &context) override
int btree_node_header_undo_log(THREAD_ENTRY *thread_p, VFID *vfid, PAGE_PTR page_ptr)
MVCC_SNAPSHOT * mvcc_snapshot
int pr_is_prefix_key_type(DB_TYPE type)
int btree_initialize_new_page(THREAD_ENTRY *thread_p, PAGE_PTR page, void *args)
BTREE_OVERFLOW_HEADER * btree_get_overflow_header(THREAD_ENTRY *thread_p, PAGE_PTR page_ptr)
void btree_leaf_change_first_object(THREAD_ENTRY *thread_p, RECDES *recp, BTID_INT *btid, OID *oidp, OID *class_oidp, BTREE_MVCC_INFO *mvcc_info, int *key_offset, char **rv_undo_data_ptr, char **rv_redo_data_ptr)
#define BTID_COPY(btid_ptr1, btid_ptr2)
void BTREE_MVCC_SET_HEADER_FIXED_SIZE(MVCC_REC_HEADER *p_mvcc_rec_header)
BTID * xbtree_load_index(THREAD_ENTRY *thread_p, BTID *btid, const char *bt_name, TP_DOMAIN *key_type, OID *class_oids, int n_classes, int n_attrs, int *attr_ids, int *attrs_prefix_length, HFID *hfids, int unique_pk, int not_null_flag, OID *fk_refcls_oid, BTID *fk_refcls_pk_btid, const char *fk_name, char *pred_stream, int pred_stream_size, char *func_pred_stream, int func_pred_stream_size, int func_col_id, int func_attr_index_start)
#define MVCC_GET_DELID(header)
bool prm_get_bool_value(PARAM_ID prm_id)
#define OR_PUT_INT(ptr, val)
static int btree_advance_to_next_slot_and_fix_page(THREAD_ENTRY *thread_p, BTID_INT *btid, VPID *vpid, PAGE_PTR *pg_ptr, INT16 *slot_id, DB_VALUE *key, bool *clear_key, bool is_desc, int *key_cnt, BTREE_NODE_HEADER **header, MVCC_SNAPSHOT *mvcc)
HEAP_CACHE_ATTRINFO * cache_attrinfo
int btree_locate_key(THREAD_ENTRY *thread_p, BTID_INT *btid_int, DB_VALUE *key, VPID *pg_vpid, INT16 *slot_id, PAGE_PTR *leaf_page_out, bool *found_p)
void log_sysop_attach_to_outer(THREAD_ENTRY *thread_p)
std::vector< key_oid * > m_sorted_keys_oids
void log_sysop_commit(THREAD_ENTRY *thread_p)
static SORT_STATUS btree_sort_get_next(THREAD_ENTRY *thread_p, RECDES *temp_recdes, void *arg)
int btree_leaf_get_first_object(BTID_INT *btid, RECDES *recp, OID *oidp, OID *class_oid, BTREE_MVCC_INFO *mvcc_info)
int btree_multicol_key_has_null(DB_VALUE *key)
int db_make_null(DB_VALUE *value)
char * pr_valstring(const DB_VALUE *val)
#define ER_IB_ERROR_ABORT
#define DB_IS_NULL(value)
#define LOAD_FIXED_EMPTY_FOR_LEAF
int qexec_clear_pred_context(THREAD_ENTRY *thread_p, pred_expr_with_context *pred_filter, bool dealloc_dbvalues)
std::vector< key_oid > m_keys_oids
bool btree_clear_key_value(bool *clear_flag, DB_VALUE *key_value)
MVCC_SNAPSHOT_FUNC snapshot_fnc
int btree_init_node_header(THREAD_ENTRY *thread_p, const VFID *vfid, PAGE_PTR page_ptr, BTREE_NODE_HEADER *header, bool redo)
#define BTID_IS_NULL(btid)
int * attrs_prefix_length
int setval(DB_VALUE *dest, const DB_VALUE *src, bool copy) const
HEAP_SCANCACHE hfscan_cache
void heap_attrinfo_end(THREAD_ENTRY *thread_p, HEAP_CACHE_ATTRINFO *attr_info)
enum mvcc_satisfies_snapshot_result MVCC_SATISFIES_SNAPSHOT_RESULT
SCAN_CODE heap_next(THREAD_ENTRY *thread_p, const HFID *hfid, OID *class_oid, OID *next_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, int ispeeking)
void push_task(entry_workpool *worker_pool_arg, entry_task *exec_p)
void retire_system_worker()
static int btree_load_check_fk(THREAD_ENTRY *thread_p, const LOAD_ARGS *load_args_local, const SORT_ARGS *sort_args_local)
int qexec_clear_func_pred(THREAD_ENTRY *thread_p, func_pred *fpr)
DB_VALUE_COMPARE_RESULT index_cmpdisk(const void *memptr1, const void *memptr2, const tp_domain *domain, int do_coercion, int total_order, int *start_colp) const
int logtb_delete_global_unique_stats(THREAD_ENTRY *thread_p, BTID *btid)
int or_pad(OR_BUF *buf, int length)
int btree_read_record(THREAD_ENTRY *thread_p, BTID_INT *btid, PAGE_PTR pgptr, RECDES *rec, DB_VALUE *key, void *rec_header, BTREE_NODE_TYPE node_type, bool *clear_key, int *offset, int copy_key, BTREE_SCAN *bts)
static void btree_rv_save_root_head(int null_delta, int oid_delta, int key_delta, RECDES *recdes)
LOG_TRAN_BTID_UNIQUE_STATS * logtb_tran_find_btid_stats(THREAD_ENTRY *thread_p, const BTID *btid, bool create)
#define VPID_SET_NULL(vpid_ptr)
bool is_logging_configured(const int logging_flag)
int btree_node_header_redo_log(THREAD_ENTRY *thread_p, VFID *vfid, PAGE_PTR page_ptr)
#define VACUUM_LOG_ADD_DROPPED_FILE_UNDO
int stx_map_stream_to_filter_pred(THREAD_ENTRY *thread_p, pred_expr_with_context **pred, char *pred_stream, int pred_stream_size)
std::atomic_bool m_has_error
#define VFID_SET_NULL(vfid_ptr)
int logtb_tran_update_btid_unique_stats(THREAD_ENTRY *thread_p, const BTID *btid, int n_keys, int n_oids, int n_nulls)
int or_advance(OR_BUF *buf, int offset)
HEAP_CACHE_ATTRINFO attr_info
int spage_insert_at(THREAD_ENTRY *thread_p, PAGE_PTR page_p, PGSLOTID slot_id, RECDES *record_descriptor_p)
HEAP_CACHE_ATTRINFO * cache_pred
static int btree_is_slot_visible(THREAD_ENTRY *thread_p, BTID_INT *btid, PAGE_PTR pg_ptr, MVCC_SNAPSHOT *mvcc_snapshot, int slot_id, bool *is_slot_visible)
int btree_packed_mvccinfo_size(BTREE_MVCC_INFO *mvcc_info)
int get_disk_size_of_value(const DB_VALUE *value) const
#define BTREE_SET_UNIQUE_VIOLATION_ERROR(THREAD, KEY, OID, C_OID, BTID, BTNM)
#define BTREE_INIT_SCAN(bts)
XASL_UNPACK_INFO * unpack_info
int pr_midxkey_element_disk_size(char *mem, DB_DOMAIN *domain)