59 #define NELEMENTS 1024 60 #define _WORDSIZE 8 * sizeof(int) 62 #define MAX_ELEMENTS 1024 63 #define BITSET_WORD_SIZE sizeof (unsigned int) 64 #define BITS_IN_WORD (8 * BITSET_WORD_SIZE) 65 #define BITSET_WORD_COUNT (MAX_ELEMENTS / BITS_IN_WORD) 66 #define BITSET_LENGTH(s) ((((s)->count - 1) / BITS_IN_WORD)+1) 82 #define PARTITIONS_COUNT(pinfo) (((pinfo) == NULL) ? 0 : (pinfo)->count - 1) 84 #define PARTITION_CACHE_NAME "Partitions_Cache" 85 #define PARTITION_CACHE_SIZE 200 90 #define PARTITION_IS_CACHE_INITIALIZED() (db_Partition_Ht != NULL) 155 OID * partition_oid,
HFID * partition_hfid);
273 for (i = 0; i <
max; i++)
307 for (; v != 0; count++)
313 if (count > s->
count)
364 if ((word & (1 << j)) != 0)
366 it->
next = i * BITS_IN_WORD + j + 1;
367 return (i * BITS_IN_WORD + j);
371 it->
next = (i + 1) * BITS_IN_WORD;
418 for (i = 0; i < entry->
count; i++)
453 if (pinfo->
count == 0)
481 HL_HEAPID old_heap_id = 0;
512 for (i = 0; i < entry_p->
count; i++)
545 for (j = 0; j <
i; j++)
559 if (old_heap_id != 0)
617 *already_exists =
true;
621 *already_exists =
false;
662 if (is_modfied !=
NULL)
670 if (is_modfied !=
NULL)
728 if (db_Partition_Ht ==
NULL)
761 db_Partition_Ht =
NULL;
867 PARTITION_SPEC_TYPE *spec =
NULL;
868 bool is_index =
false;
869 char *btree_name =
NULL;
920 spec[
i].next = &spec[
i + 1];
936 if (btree_name !=
NULL)
954 pinfo->
spec->parts = spec;
972 return left == right;
975 if (left->type != right->type)
1025 if (left->value.arithptr->opcode != right->value.arithptr->opcode)
1032 if (left->value.arithptr->misc_operand != right->value.arithptr->misc_operand)
1059 return left->value.attr_descr.id == right->value.attr_descr.id;
1080 int size = 0,
i = 0, j;
1088 part_collection = part->
values;
1111 for (j = 0; j < size; j++)
1146 for (j = 0; j < size; j++)
1255 int size = 0,
i, idx;
1273 for (
i = 0;
i < size;
i++)
1424 else if (rmin ==
DB_LT)
1469 if (status ==
MATCH_OK && added == 0)
1519 bool is_value =
false;
1593 if (regu->value.funcp->ftype !=
F_MIDXKEY)
1639 if (regu_var ==
NULL)
1643 switch (regu_var->type)
1713 if (key->value.funcp->ftype !=
F_MIDXKEY)
1721 regu_list = key->
value.funcp->operand;
1724 if (regu_list ==
NULL)
1729 regu_list = regu_list->
next;
1732 if (regu_list ==
NULL)
1737 *is_present =
false;
1755 *is_present =
false;
1766 *is_present =
false;
1943 else if (op ==
PO_NE)
1987 switch (key_range->
range)
2139 for (i = 0; i < key->
key_cnt; i++)
2208 if (super_classes !=
NULL)
2216 if (super_count > 1)
2220 else if (super_count != 1)
2226 else if (super_count == 1)
2228 COPY_OID (super_oid, super_classes);
2231 if (super_classes !=
NULL)
2254 bool is_modified =
false;
2255 bool already_exists =
false;
2351 goto reload_from_cache;
2411 while (list !=
NULL)
2441 char *expr_stream =
NULL;
2546 if (var->value.attr_descr.id == attr_id)
2548 var->value.attr_descr.cache_attrinfo = attr_info;
2591 return var->value.attr_descr.id;
2595 if (var->value.arithptr->leftptr !=
NULL)
2604 if (var->value.arithptr->rightptr !=
NULL)
2613 if (var->value.arithptr->thirdptr !=
NULL)
2685 for (i = 0; i < key_count; i++)
2687 if (part_attr_id == keys[i])
2856 spec->pruned =
true;
2862 spec->pruned =
true;
2868 spec->curent =
NULL;
2881 spec->pruned =
true;
2937 spec->pruned =
true;
2955 OID * partition_oid,
HFID * partition_hfid)
2959 bool clear_dbvalues =
false;
2994 clear_dbvalues =
true;
3047 if (!
OID_EQ (class_oid, partition_oid))
3094 OID * superclass_oid)
3097 bool keep_pruning_context =
false;
3103 if (superclass_oid !=
NULL)
3114 if (pcontext ==
NULL)
3118 keep_pruning_context =
false;
3129 keep_pruning_context =
true;
3162 if (superclass_oid !=
NULL)
3168 if (keep_pruning_context && error ==
NO_ERROR)
3200 int pruning_type,
OID * pruned_class_oid,
HFID * pruned_hfid,
OID * superclass_oid)
3205 bool keep_pruning_context =
false;
3210 COPY_OID (pruned_class_oid, class_oid);
3221 if (superclass_oid !=
NULL)
3226 if (pcontext ==
NULL)
3231 keep_pruning_context =
false;
3261 keep_pruning_context =
true;
3296 if (superclass_oid !=
NULL)
3302 if (keep_pruning_context && error ==
NO_ERROR)
3324 if (partition_oid ==
NULL || pcontext ==
NULL)
3332 while (node !=
NULL)
3387 int classrepr_cacheindex = -1;
3388 bool clear_pcontext =
false;
3396 if (classrepr ==
NULL)
3404 clear_pcontext =
true;
3412 if (context.
count == 0)
3415 *partition_oids =
NULL;
3422 *partition_oids =
NULL;
3436 *partition_oids = oids;
3439 if (clear_pcontext ==
true)
3443 if (classrepr !=
NULL)
3453 *partition_oids =
NULL;
3558 HFID partition_hfid;
3559 BTID partition_btid;
3578 COPY_OID (class_oid, &partition_oid);
3579 HFID_COPY (class_hfid, &partition_hfid);
3598 char *btree_name =
NULL;
3620 if (btree_name !=
NULL)
3643 char *btree_name =
NULL;
3645 PARTITION_SPEC_TYPE *part =
NULL;
3666 for (i = 0, part = spec->parts; part !=
NULL; i++, part = part->next)
3671 assert (i == pruned_count);
3672 helper->
count = pruned_count;
3696 for (i = 0, part = spec->parts; part !=
NULL; i++, part = part->next)
3719 if (btree_name !=
NULL)
3740 BTREE_TYPE * btree_typep,
int *is_global_index)
3749 *is_global_index = 0;
3751 if (contextp ==
NULL)
3754 contextp = &context;
3765 if (contextp->
count == 0)
3770 if (btree_typep ==
NULL)
3773 btree_typep = &btree_type;
3784 *is_global_index = 1;
3798 *is_global_index = 1;
3804 if (contextp == &context)
3832 int btree_num_attr = 0;
3834 if (pcontext ==
NULL)
3837 pcontext = &context;
3885 if (pcontext->
attr_info.values[0].state == HEAP_UNINIT_ATTRVALUE)
3897 if (pcontext == &context)
3936 if (pcontext ==
NULL)
regu_variable_node * key1
static MATCH_STATUS partition_prune_hash(PRUNING_CONTEXT *pinfo, const DB_VALUE *val, const PRUNING_OP op, PRUNING_BITSET *pruned)
static int partition_free_cache_entry(PARTITION_CACHE_ENTRY *entry)
void partition_decache_class(THREAD_ENTRY *thread_p, const OID *class_oid)
static int partition_cache_pruning_context(PRUNING_CONTEXT *pinfo, bool *already_exists)
HEAP_CACHE_ATTRINFO attr_info
static MATCH_STATUS partition_prune(PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *arg, const PRUNING_OP op, PRUNING_BITSET *pruned)
int or_rep_id(RECDES *record)
DB_COLLECTION * db_get_set(const DB_VALUE *value)
DB_VALUE_COMPARE_RESULT tp_value_compare(const DB_VALUE *value1, const DB_VALUE *value2, int allow_coercion, int total_order)
bool db_value_type_is_collection(const DB_VALUE *value)
static int partition_prune_heap_scan(PRUNING_CONTEXT *pinfo)
int partition_load_aggregate_helper(PRUNING_CONTEXT *pcontext, access_spec_node *spec, int pruned_count, BTID *root_btid, HIERARCHY_AGGREGATE_HELPER *helper)
enum pruning_op PRUNING_OP
static MATCH_STATUS partition_match_index_key(PRUNING_CONTEXT *pinfo, const KEY_INFO *key, RANGE_TYPE range_type, PRUNING_BITSET *pruned)
int partition_load_pruning_context(THREAD_ENTRY *thread_p, const OID *class_oid, int pruning_type, PRUNING_CONTEXT *pinfo)
#define csect_enter(a, b, c)
int partition_get_partition_oids(THREAD_ENTRY *thread_p, const OID *class_oid, OID **partition_oids, int *count)
const void * mht_put_if_not_exists(MHT_TABLE *ht, const void *key, void *data)
int mht_rem(MHT_TABLE *ht, const void *key, int(*rem_func)(const void *key, void *data, void *args), void *func_args)
static void pruningset_union(PRUNING_BITSET *, const PRUNING_BITSET *)
OR_PARTITION * selected_partition
static void partition_set_specified_partition(PRUNING_CONTEXT *pinfo, const OID *partition_oid)
regu_variable_node * elem
int btree_attrinfo_read_dbvalues(THREAD_ENTRY *thread_p, DB_VALUE *curr_key, int *btree_att_ids, int btree_num_att, HEAP_CACHE_ATTRINFO *attr_info, int func_index_col_id)
#define assert_release(e)
#define ER_PARTITION_NOT_EXIST
func_pred * partition_pred
xasl_unpack_info * fp_cache_context
#define OID_SET_NULL(oidp)
#define ER_BTREE_INVALID_INDEX_ID
static bool pruningset_is_set(const PRUNING_BITSET *, int)
static bool partition_is_reguvar_const(const REGU_VARIABLE *regu_var)
static PARTITION_CACHE_ENTRY * partition_pruning_context_to_cache_entry(PRUNING_CONTEXT *pinfo)
static bool partition_decrement_value(DB_VALUE *val)
#define er_log_debug(...)
static MATCH_STATUS partition_prune_db_val(PRUNING_CONTEXT *pinfo, const DB_VALUE *val, const PRUNING_OP op, PRUNING_BITSET *pruned)
HL_HEAPID db_change_private_heap(THREAD_ENTRY *thread_p, HL_HEAPID heap_id)
int heap_scancache_end(THREAD_ENTRY *thread_p, HEAP_SCANCACHE *scan_cache)
static MATCH_STATUS partition_prune_range(PRUNING_CONTEXT *pinfo, const DB_VALUE *val, const PRUNING_OP op, PRUNING_BITSET *pruned)
enum match_status MATCH_STATUS
#define COPY_OID(dest_oid_ptr, src_oid_ptr)
static void partition_free_partition_predicate(PRUNING_CONTEXT *pinfo)
static int partition_get_value_from_key(PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *key, DB_VALUE *attr_key, bool *is_present)
#define PARTITION_CACHE_SIZE
static void pruningset_set_all(PRUNING_BITSET *)
#define BITSET_WORD_COUNT
static MATCH_STATUS partition_prune_list(PRUNING_CONTEXT *pinfo, const DB_VALUE *val, const PRUNING_OP op, PRUNING_BITSET *pruned)
static int partition_free_cache_entry_kv(const void *key, void *data, void *args)
void mht_destroy(MHT_TABLE *ht)
void partition_clear_pruning_context(PRUNING_CONTEXT *pinfo)
TP_DOMAIN * btree_read_key_type(THREAD_ENTRY *thread_p, BTID *btid)
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,...)
static int pruningset_iterator_next(PRUNING_BITSET_ITERATOR *)
int db_set_get(DB_SET *set, int index, DB_VALUE *value)
REGU_VARIABLE * func_regu
static bool partition_do_regu_variables_match(PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *left, const REGU_VARIABLE *right)
static void pruningset_remove(PRUNING_BITSET *, int)
PRUNING_SCAN_CACHE scan_cache
#define OID_IS_ROOTOID(oidp)
int partition_find_root_class_oid(THREAD_ENTRY *thread_p, const OID *class_oid, OID *super_oid)
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
union cubxasl::pred_expr::@185 pe
DB_SEQ * db_seq_copy(DB_SEQ *source)
int fetch_peek_dbval(THREAD_ENTRY *thread_p, REGU_VARIABLE *regu_var, val_descr *vd, OID *class_oid, OID *obj_oid, QFILE_TUPLE tpl, DB_VALUE **peek_dbval)
static MATCH_STATUS partition_match_key_range(PRUNING_CONTEXT *pinfo, const KEY_RANGE *range, PRUNING_BITSET *pruned)
static int partition_attrinfo_get_key(THREAD_ENTRY *thread_p, PRUNING_CONTEXT *pcontext, DB_VALUE *curr_key, OID *class_oid, BTID *btid, DB_VALUE *partition_key)
static int partition_get_value_from_inarith(PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *src, DB_VALUE *value_p, bool *is_present)
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)
#define heap_classrepr_free_and_init(class_repr, idxp)
void partition_cache_finalize(THREAD_ENTRY *thread_p)
TP_DOMAIN_STATUS tp_value_cast(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain, bool implicit_coercion)
int heap_attrinfo_read_dbvalues(THREAD_ENTRY *thread_p, const OID *inst_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, HEAP_CACHE_ATTRINFO *attr_info)
static int pruningset_to_spec_list(PRUNING_CONTEXT *pinfo, const PRUNING_BITSET *pruned)
#define TP_DOMAIN_TYPE(dom)
unsigned has_partition_info
#define ACCESS_SPEC_CLS_OID(ptr)
#define PARTITIONS_COUNT(pinfo)
int qexec_clear_partition_expression(THREAD_ENTRY *thread_p, regu_variable_node *expr)
static void cleanup(int signo)
void * mht_get(MHT_TABLE *ht, const void *key)
int db_set_has_null(DB_COLLECTION *set)
int heap_attrinfo_clear_dbvalues(HEAP_CACHE_ATTRINFO *attr_info)
static MHT_TABLE * db_Partition_Ht
DB_TIMESTAMPTZ timestamptz
static bool partition_load_context_from_cache(PRUNING_CONTEXT *pinfo, bool *is_modified)
#define MILLISECONDS_OF_ONE_DAY
int db_seq_free(DB_SEQ *seq)
#define db_private_free_and_init(thrd, ptr)
static void pruningset_add(PRUNING_BITSET *, int)
MHT_TABLE * mht_create(const char *name, int est_size, unsigned int(*hash_func)(const void *key, unsigned int ht_size), int(*cmp_func)(const void *key1, const void *key2))
static int partition_cache_entry_to_pruning_context(PRUNING_CONTEXT *pinfo, PARTITION_CACHE_ENTRY *entry_p)
void partition_init_pruning_context(PRUNING_CONTEXT *pinfo)
#define db_private_free(thrd, ptr)
static void partition_set_cache_info_for_expr(REGU_VARIABLE *regu_var, ATTR_ID attr_id, HEAP_CACHE_ATTRINFO *info)
unsigned int oid_hash(const void *key_oid, unsigned int htsize)
#define db_private_alloc(thrd, size)
#define CONST_CAST(dest_type, expr)
OR_PARTITION * partitions
const PRUNING_BITSET * set
int or_set_rep_id(RECDES *record, int repid)
int partition_prune_partition_index(PRUNING_CONTEXT *pcontext, DB_VALUE *key, OID *class_oid, BTID *btid, int *position)
int db_set_size(DB_SET *set)
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)
bool is_scan_cache_started
DB_PARTITION_TYPE partition_type
static int pruningset_popcount(const PRUNING_BITSET *)
int oid_compare_equals(const void *key_oid1, const void *key_oid2)
static int partition_prune_index_scan(PRUNING_CONTEXT *pinfo)
static MATCH_STATUS partition_match_pred_expr(PRUNING_CONTEXT *pinfo, const PRED_EXPR *pr, PRUNING_BITSET *pruned)
void free_xasl_unpack_info(THREAD_ENTRY *thread_p, REFPTR(XASL_UNPACK_INFO, xasl_unpack_info))
int heap_get_index_with_name(THREAD_ENTRY *thread_p, OID *class_oid, const char *index_name, BTID *btid)
static void error(const char *msg)
SCANCACHE_LIST * scan_cache_list
OR_PARTITION * partitions
PRUNING_SCAN_CACHE * partition_new_scancache(PRUNING_CONTEXT *pcontext)
static void pruningset_intersect(PRUNING_BITSET *, const PRUNING_BITSET *)
bool db_value_is_null(const DB_VALUE *value)
static int partition_find_partition_for_record(PRUNING_CONTEXT *pinfo, const OID *class_oid, RECDES *recdes, OID *partition_oid, HFID *partition_hfid)
#define PARTITION_CACHE_NAME
unsigned int mht_get_hash_number(const int ht_size, const DB_VALUE *val)
int db_set_ismember(DB_SET *set, DB_VALUE *value)
int pr_clone_value(const DB_VALUE *src, DB_VALUE *dest)
regu_variable_node * key2
regu_variable_node * elemset
#define csect_enter_as_reader(a, b, c)
#define free_and_init(ptr)
#define BTID_COPY(btid_ptr1, btid_ptr2)
int heap_get_class_partitions(THREAD_ENTRY *thread_p, const OID *class_oid, OR_PARTITION **parts, int *parts_count)
#define PARTITION_IS_CACHE_INITIALIZED()
class regu_variable_node REGU_VARIABLE
int db_get_string_size(const DB_VALUE *value)
static PRUNING_OP partition_rel_op_to_pruning_op(REL_OP op)
static void pruningset_init(PRUNING_BITSET *, int)
#define ER_INVALID_DATA_FOR_PARTITION
#define DB_VALUE_TYPE(value)
int mht_map(const MHT_TABLE *ht, int(*map_func)(const void *key, void *data, void *args), void *func_args)
int db_make_null(DB_VALUE *value)
int partition_prune_spec(THREAD_ENTRY *thread_p, val_descr *vd, access_spec_node *spec)
#define DB_IS_NULL(value)
static int partition_load_partition_predicate(PRUNING_CONTEXT *pinfo, OR_PARTITION *master)
int partition_prune_insert(THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *recdes, HEAP_SCANCACHE *scan_cache, PRUNING_CONTEXT *pcontext, int pruning_type, OID *pruned_class_oid, HFID *pruned_hfid, OID *superclass_oid)
static int partition_find_inherited_btid(THREAD_ENTRY *thread_p, OID *src_class, OID *dest_class, BTID *src_btid, BTID *dest_btid)
#define BTID_IS_NULL(btid)
static void pruningset_copy(PRUNING_BITSET *, const PRUNING_BITSET *)
void heap_attrinfo_end(THREAD_ENTRY *thread_p, HEAP_CACHE_ATTRINFO *attr_info)
unsigned int set[BITSET_WORD_COUNT]
int heap_get_class_supers(THREAD_ENTRY *thread_p, const OID *class_oid, OID **super_oids, int *count)
union cubxasl::eval_term::@184 et
int heap_get_indexinfo_of_btid(THREAD_ENTRY *thread_p, const OID *class_oid, const BTID *btid, BTREE_TYPE *type, int *num_attrs, ATTR_ID **attr_ids, int **attrs_prefix_length, char **btnamepp, int *func_index_col_id)
void heap_clear_partition_info(THREAD_ENTRY *thread_p, OR_PARTITION *parts, int parts_count)
PRUNING_SCAN_CACHE * partition_get_scancache(PRUNING_CONTEXT *pcontext, const OID *partition_oid)
static int partition_get_value_from_regu_var(PRUNING_CONTEXT *pinfo, const REGU_VARIABLE *key, DB_VALUE *value_p, bool *is_value)
static ATTR_ID partition_get_attribute_id(REGU_VARIABLE *regu_var)
bool btree_is_unique_type(BTREE_TYPE type)
#define HFID_COPY(hfid_ptr1, hfid_ptr2)
static int partition_get_position_in_key(PRUNING_CONTEXT *pinfo, BTID *btid)
DB_CONST_C_CHAR db_get_string(const DB_VALUE *value)
int partition_cache_init(THREAD_ENTRY *thread_p)
bool log_is_class_being_modified(THREAD_ENTRY *thread_p, const OID *class_oid)
HEAP_SCANCACHE scan_cache
void heap_free_func_pred_unpack_info(THREAD_ENTRY *thread_p, int n_indexes, FUNC_PRED_UNPACK_INFO *func_indx_preds, int *attr_info_started)
func_pred_unpack_info * func_index_pred
int partition_prune_update(THREAD_ENTRY *thread_p, const OID *class_oid, RECDES *recdes, PRUNING_CONTEXT *pcontext, int pruning_type, OID *pruned_class_oid, HFID *pruned_hfid, OID *superclass_oid)
static void pruningset_iterator_init(const PRUNING_BITSET *, PRUNING_BITSET_ITERATOR *)