[cp] adjust definite_key_part
This commit is contained in:
@ -26,9 +26,20 @@ namespace sql
|
||||
void ObKeyPart::reset()
|
||||
{
|
||||
common::ObDLinkBase<ObKeyPart>::reset();
|
||||
reset_key();
|
||||
id_.table_id_ = OB_INVALID_ID;
|
||||
id_.column_id_ = OB_INVALID_ID;
|
||||
pos_.offset_ = -1;
|
||||
key_type_ = T_NORMAL_KEY;
|
||||
item_next_ = NULL;
|
||||
or_next_ = NULL;
|
||||
and_next_ = NULL;
|
||||
rowid_column_idx_ = OB_INVALID_ID;
|
||||
is_phy_rowid_key_part_ = false;
|
||||
}
|
||||
|
||||
void ObKeyPart::reset_key()
|
||||
{
|
||||
if (is_normal_key()) {
|
||||
normal_keypart_->start_.reset();
|
||||
normal_keypart_->end_.reset();
|
||||
@ -41,13 +52,10 @@ void ObKeyPart::reset()
|
||||
like_keypart_->escape_.reset();
|
||||
} else if (is_in_key()) {
|
||||
in_keypart_->reset();
|
||||
} else if (is_geo_key()) {
|
||||
geo_keypart_->wkb_.reset();
|
||||
geo_keypart_->distance_.reset();
|
||||
}
|
||||
key_type_ = T_NORMAL_KEY;
|
||||
item_next_ = NULL;
|
||||
or_next_ = NULL;
|
||||
and_next_ = NULL;
|
||||
rowid_column_idx_ = OB_INVALID_ID;
|
||||
is_phy_rowid_key_part_ = false;
|
||||
}
|
||||
|
||||
// can be unioned as one
|
||||
@ -727,6 +735,31 @@ int ObKeyPart::deep_node_copy(const ObKeyPart &other)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObKeyPart::shallow_node_copy(const ObKeyPart &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
reset_key();
|
||||
id_ = other.id_;
|
||||
pos_ = other.pos_;
|
||||
null_safe_ = other.null_safe_;
|
||||
rowid_column_idx_ = other.rowid_column_idx_;
|
||||
is_phy_rowid_key_part_ = other.is_phy_rowid_key_part_;
|
||||
if (other.is_normal_key()) {
|
||||
normal_keypart_ = other.normal_keypart_;
|
||||
key_type_ = other.key_type_;
|
||||
} else if (other.is_like_key()) {
|
||||
like_keypart_ = other.like_keypart_;
|
||||
key_type_ = other.key_type_;
|
||||
} else if (other.is_in_key()) {
|
||||
in_keypart_ = other.in_keypart_;
|
||||
key_type_ = other.key_type_;
|
||||
} else if (other.is_geo_key()) {
|
||||
geo_keypart_ = other.geo_keypart_;
|
||||
key_type_ = other.key_type_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int InParamMeta::assign(const InParamMeta &other, ObIAllocator &alloc)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
@ -301,6 +301,7 @@ public:
|
||||
{ }
|
||||
virtual ~ObKeyPart() { reset(); }
|
||||
virtual void reset();
|
||||
void reset_key();
|
||||
typedef common::hash::ObHashMap<int64_t, ObSEArray<int64_t, 16>> SameValIdxMap;
|
||||
static int try_cast_value(const ObDataTypeCastParams &dtc_params, ObIAllocator &alloc,
|
||||
const ObKeyPartPos &pos, ObObj &value, int64_t &cmp);
|
||||
@ -407,6 +408,7 @@ public:
|
||||
|
||||
// copy all except next_ pointer
|
||||
int deep_node_copy(const ObKeyPart &other);
|
||||
int shallow_node_copy(const ObKeyPart &other);
|
||||
bool is_phy_rowid_key_part() const { return is_phy_rowid_key_part_; }
|
||||
bool is_logical_rowid_key_part() const {
|
||||
return !is_phy_rowid_key_part_ && rowid_column_idx_ != OB_INVALID_ID; }
|
||||
|
||||
@ -5152,7 +5152,7 @@ int ObQueryRange::link_or_graphs(ObKeyPartList &storage, ObKeyPart *&out_key_pa
|
||||
// Replace unknown value in item_next_ list,
|
||||
// and intersect them.
|
||||
|
||||
int ObQueryRange::definite_key_part(ObKeyPart *&key_part, ObExecContext &exec_ctx,
|
||||
int ObQueryRange::definite_key_part(ObKeyPart *key_part, ObExecContext &exec_ctx,
|
||||
const ObDataTypeCastParams &dtc_params,
|
||||
bool &is_bound_modified)
|
||||
{
|
||||
@ -5182,7 +5182,10 @@ int ObQueryRange::definite_key_part(ObKeyPart *&key_part, ObExecContext &exec_ct
|
||||
}
|
||||
} else if (key_part->is_in_key()) {
|
||||
if (cur->is_phy_rowid_key_part_) {
|
||||
key_part = cur;
|
||||
// in and rowid, always make the result becomes rowid
|
||||
if (OB_FAIL(key_part->shallow_node_copy(*cur))) {
|
||||
LOG_WARN("failed to shallow copy cur", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(key_part->intersect_in(cur))) {
|
||||
LOG_WARN("failed to intersect in", K(ret));
|
||||
}
|
||||
@ -5192,17 +5195,8 @@ int ObQueryRange::definite_key_part(ObKeyPart *&key_part, ObExecContext &exec_ct
|
||||
// in and rowid, always make the result becomes rowid
|
||||
} else if (OB_FAIL(cur->intersect_in(key_part))) {
|
||||
LOG_WARN("failed to intersect in", K(ret));
|
||||
} else {
|
||||
// after intersect, key_part always be false
|
||||
// so change the pointer of key_part
|
||||
ObKeyPart *key_part_or_next = key_part->or_next_;
|
||||
key_part = cur;
|
||||
ObKeyPart *or_tail = key_part;
|
||||
while (key_part_or_next != NULL) {
|
||||
or_tail->or_next_ = key_part_or_next;
|
||||
or_tail = or_tail->or_next_;
|
||||
key_part_or_next = key_part_or_next->or_next_;
|
||||
}
|
||||
} else if (OB_FAIL(key_part->shallow_node_copy(*cur))) {
|
||||
LOG_WARN("failed to shallow copy cur", K(ret));
|
||||
}
|
||||
} else if (OB_FAIL(key_part->intersect(cur, contain_row_))) {
|
||||
LOG_WARN("Intersect key part failed", K(ret));
|
||||
@ -6696,6 +6690,7 @@ int ObQueryRange::direct_get_tablet_ranges(ObIAllocator &allocator,
|
||||
} else {
|
||||
OZ(gen_simple_scan_range(allocator, exec_ctx, ranges, all_single_value_ranges, dtc_params));
|
||||
}
|
||||
LOG_TRACE("get range success", K(ret), K(table_graph_.is_precise_get_), K(ranges));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -7167,7 +7162,9 @@ OB_NOINLINE int ObQueryRange::final_extract_query_range(ObExecContext &exec_ctx,
|
||||
const ObDataTypeCastParams &dtc_params)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
SQL_REWRITE_LOG(DEBUG, "final extract query range", K(table_graph_.is_equal_range_));
|
||||
SQL_REWRITE_LOG(TRACE, "final extract query range", KPC(table_graph_.key_part_head_),
|
||||
K(table_graph_.is_equal_range_),
|
||||
K(contain_in_), K(contain_row_));
|
||||
if (state_ == NEED_PREPARE_PARAMS && NULL != table_graph_.key_part_head_) {
|
||||
ObKeyPartList or_array;
|
||||
// find all key part path and do OR option
|
||||
|
||||
@ -714,7 +714,7 @@ private:
|
||||
int do_row_gt_and(ObKeyPart *l_gt, ObKeyPart *r_gt, ObKeyPart *&res_gt);
|
||||
int do_gt_and(ObKeyPart *l_gt, ObKeyPart *r_gt, ObKeyPart *&res_gt);
|
||||
int link_or_graphs(ObKeyPartList &storage, ObKeyPart *&out_key_part);
|
||||
int definite_key_part(ObKeyPart *&key_part, ObExecContext &exec_ctx,
|
||||
int definite_key_part(ObKeyPart *key_part, ObExecContext &exec_ctx,
|
||||
const common::ObDataTypeCastParams &dtc_params,
|
||||
bool &is_bound_modified);
|
||||
int replace_unknown_value(ObKeyPart *root, ObExecContext &exec_ctx,
|
||||
|
||||
Reference in New Issue
Block a user