[CP][BUGFIX] fix text substr len 0 error

This commit is contained in:
skylhd
2023-12-19 21:18:19 +00:00
committed by ob-robot
parent 05e1caa093
commit ae8491eec7
3 changed files with 42 additions and 37 deletions

View File

@ -77,6 +77,10 @@ void ObTextStringDatumResult::set_result()
res_datum_->set_string(buffer_, pos_); res_datum_->set_string(buffer_, pos_);
} }
void ObTextStringDatumResult::set_result_null()
{
res_datum_->set_null();
}
int ObTextStringObObjResult::init(int64_t res_len, ObIAllocator *allocator) int ObTextStringObObjResult::init(int64_t res_len, ObIAllocator *allocator)
{ {

View File

@ -41,7 +41,7 @@ public:
int init(int64_t res_len, ObIAllocator *allocator = NULL); int init(int64_t res_len, ObIAllocator *allocator = NULL);
int init_with_batch_idx(int64_t res_len, int64_t batch_idx); int init_with_batch_idx(int64_t res_len, int64_t batch_idx);
void set_result(); void set_result();
void set_result_null();
private: private:
char * buff_alloc (const int64_t size); char * buff_alloc (const int64_t size);

View File

@ -557,7 +557,9 @@ static int eval_substr_text(const ObCollationType &cs_type,
} else if (OB_FAIL(input_iter.get_char_len(total_char_len))) { } else if (OB_FAIL(input_iter.get_char_len(total_char_len))) {
LOG_WARN("get input char len failed", K(ret)); LOG_WARN("get input char len failed", K(ret));
} else if (FALSE_IT(result_byte_len = MIN((pos >= 0 ? total_byte_len - pos + 1 : -pos * mbmaxlen), (MIN((len), (total_char_len)) * mbmaxlen)))) { } else if (FALSE_IT(result_byte_len = MIN((pos >= 0 ? total_byte_len - pos + 1 : -pos * mbmaxlen), (MIN((len), (total_char_len)) * mbmaxlen)))) {
} else if (len < 0 || pos > total_char_len) { } else if (len <= 0 && lib::is_oracle_mode()) {
output_result.set_result_null();
} else if (pos > total_char_len || len <= 0) {
if (!is_batch) { if (!is_batch) {
ret = output_result.init(0); // fill empty lob result ret = output_result.init(0); // fill empty lob result
} else { } else {
@ -574,8 +576,6 @@ static int eval_substr_text(const ObCollationType &cs_type,
} else { } else {
ret = output_result.init_with_batch_idx(result_byte_len, batch_idx); ret = output_result.init_with_batch_idx(result_byte_len, batch_idx);
} }
}
if (OB_FAIL(ret)) { if (OB_FAIL(ret)) {
LOG_WARN("init stringtext result failed", K(ret)); LOG_WARN("init stringtext result failed", K(ret));
} else { } else {
@ -616,6 +616,7 @@ static int eval_substr_text(const ObCollationType &cs_type,
} }
} }
} }
}
return ret; return ret;
} }