fix group_concat truncate bug
This commit is contained in:
@ -2215,7 +2215,18 @@ int ObAggregateFunction::get_result(ObNewRow &row, const common::ObTimeZoneInfo
|
||||
ret = OB_ERR_TOO_LONG_STRING_IN_CONCAT;
|
||||
LOG_WARN("result of string concatenation is too long", K(ret), K(pos), K(append_len), K(concat_str_max_len));
|
||||
} else {
|
||||
LOG_USER_WARN(OB_ERR_CUT_VALUE_GROUP_CONCAT, gconcat_cur_row_num_ + 1);
|
||||
int64_t well_formed_len = 0;
|
||||
int32_t well_formed_error = 0;
|
||||
if (OB_FAIL(ObCharset::well_formed_len(cexpr->get_collation_type(),
|
||||
sep_str.ptr(),
|
||||
append_len,
|
||||
well_formed_len,
|
||||
well_formed_error))) {
|
||||
LOG_WARN("invalid string for charset", K(ret), K(cs_type), K(sep_str));
|
||||
} else {
|
||||
append_len = well_formed_len;
|
||||
LOG_USER_WARN(OB_ERR_CUT_VALUE_GROUP_CONCAT, gconcat_cur_row_num_ + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
@ -2260,7 +2271,18 @@ int ObAggregateFunction::get_result(ObNewRow &row, const common::ObTimeZoneInfo
|
||||
ret = OB_ERR_TOO_LONG_STRING_IN_CONCAT;
|
||||
LOG_WARN("result of string concatenation is too long", K(ret), K(concat_str_max_len));
|
||||
} else {
|
||||
LOG_USER_WARN(OB_ERR_CUT_VALUE_GROUP_CONCAT, gconcat_cur_row_num_ + 1);
|
||||
int64_t well_formed_len = 0;
|
||||
int32_t well_formed_error = 0;
|
||||
if (OB_FAIL(ObCharset::well_formed_len(cexpr->get_collation_type(),
|
||||
tmp_str.ptr(),
|
||||
append_len,
|
||||
well_formed_len,
|
||||
well_formed_error))) {
|
||||
LOG_WARN("invalid string for charset", K(ret), K(cs_type), K(tmp_str));
|
||||
} else {
|
||||
append_len = well_formed_len;
|
||||
LOG_USER_WARN(OB_ERR_CUT_VALUE_GROUP_CONCAT, gconcat_cur_row_num_ + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
|
||||
@ -2620,6 +2620,7 @@ int ObAggregateProcessor::process_aggr_result(const ObChunkDatumStore::StoredRow
|
||||
|
||||
int ObAggregateProcessor::extend_concat_str_buf(
|
||||
const ObString &pad_str,
|
||||
const ObCollationType cs_type,
|
||||
const int64_t pos,
|
||||
const int64_t group_concat_cur_row_num,
|
||||
int64_t &append_len,
|
||||
@ -2659,7 +2660,18 @@ int ObAggregateProcessor::extend_concat_str_buf(
|
||||
LOG_WARN("result of string concatenation is too long", K(ret),
|
||||
K(pad_str.length()), K(pos), K(concat_str_max_len_));
|
||||
} else {
|
||||
LOG_USER_WARN(OB_ERR_CUT_VALUE_GROUP_CONCAT, group_concat_cur_row_num + 1);
|
||||
int64_t well_formed_len = 0;
|
||||
int32_t well_formed_error = 0;
|
||||
if (OB_FAIL(ObCharset::well_formed_len(cs_type,
|
||||
pad_str.ptr(),
|
||||
append_len,
|
||||
well_formed_len,
|
||||
well_formed_error))) {
|
||||
LOG_WARN("invalid string for charset", K(ret), K(cs_type), K(pad_str));
|
||||
} else {
|
||||
append_len = well_formed_len;
|
||||
LOG_USER_WARN(OB_ERR_CUT_VALUE_GROUP_CONCAT, group_concat_cur_row_num + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2900,6 +2912,7 @@ int ObAggregateProcessor::collect_aggr_result(
|
||||
int64_t group_concat_cur_row_num = 0;
|
||||
bool first_item_printed = false;
|
||||
const int64_t group_concat_param_count = aggr_info.group_concat_param_count_;
|
||||
const ObCollationType cs_type = aggr_info.expr_->datum_meta_.cs_type_;
|
||||
while(OB_SUCC(ret)
|
||||
&& !buf_is_full
|
||||
&& OB_SUCC(extra->get_next_row(storted_row))) {
|
||||
@ -2916,7 +2929,7 @@ int ObAggregateProcessor::collect_aggr_result(
|
||||
if (group_concat_cur_row_num != 0) {
|
||||
int64_t append_len = sep_str.length();
|
||||
if (OB_FAIL(extend_concat_str_buf(
|
||||
sep_str, pos, group_concat_cur_row_num, append_len, buf_is_full))) {
|
||||
sep_str, cs_type, pos, group_concat_cur_row_num, append_len, buf_is_full))) {
|
||||
LOG_WARN("failed to extend concat str buf", K(ret));
|
||||
} else if (cur_concat_buf_len_ < append_len + pos) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
@ -2931,7 +2944,7 @@ int ObAggregateProcessor::collect_aggr_result(
|
||||
for (int64_t i = 0; OB_SUCC(ret) && !buf_is_full && i < group_concat_param_count; ++i) {
|
||||
const ObString cell_string = storted_row->cells()[i].get_string();
|
||||
int64_t append_len = cell_string.length();
|
||||
if (OB_FAIL(extend_concat_str_buf(cell_string, pos,
|
||||
if (OB_FAIL(extend_concat_str_buf(cell_string, cs_type, pos,
|
||||
group_concat_cur_row_num, append_len, buf_is_full))) {
|
||||
LOG_WARN("failed to extend concat str buf", K(ret));
|
||||
} else if (cur_concat_buf_len_ < append_len + pos) {
|
||||
|
||||
@ -735,6 +735,7 @@ private:
|
||||
const ObAggrInfo &aggr_info,
|
||||
const int64_t max_cnt);
|
||||
int extend_concat_str_buf(const ObString &pad_str,
|
||||
const ObCollationType cs_type,
|
||||
const int64_t pos,
|
||||
const int64_t group_concat_cur_row_num,
|
||||
int64_t &append_len,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -69,7 +69,13 @@ set group_concat_max_len=10485;
|
||||
select length(group_concat(c1)) from t111_var;
|
||||
select group_concat(c1) from t111_var;
|
||||
|
||||
set group_concat_max_len=29;
|
||||
select group_concat('中文' separator '分隔') from t111_var;
|
||||
set group_concat_max_len=23;
|
||||
select group_concat('中文' separator '分隔') from t111_var;
|
||||
|
||||
set group_concat_max_len=1024;
|
||||
drop table t1, t111_var;
|
||||
--enable_warnings
|
||||
|
||||
connection syscon;
|
||||
|
||||
Reference in New Issue
Block a user