[BUGFIX]fix repeat text type
This commit is contained in:
@ -46,7 +46,7 @@ int ObExprRepeat::calc_result_type2(ObExprResType &type,
|
|||||||
ObExprTypeCtx &type_ctx) const
|
ObExprTypeCtx &type_ctx) const
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
int ret = OB_SUCCESS;
|
||||||
if (!text.is_string_type()) {
|
if (!ob_is_text_tc(text.get_type())) {
|
||||||
text.set_calc_type(common::ObVarcharType);
|
text.set_calc_type(common::ObVarcharType);
|
||||||
}
|
}
|
||||||
count.set_calc_type(common::ObIntType);
|
count.set_calc_type(common::ObIntType);
|
||||||
@ -280,6 +280,9 @@ int ObExprRepeat::eval_repeat(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_
|
|||||||
ObDatum *text = NULL;
|
ObDatum *text = NULL;
|
||||||
ObDatum *count = NULL;
|
ObDatum *count = NULL;
|
||||||
int64_t max_size = 0;
|
int64_t max_size = 0;
|
||||||
|
ObEvalCtx::TempAllocGuard tmp_alloc_g(ctx);
|
||||||
|
common::ObIAllocator &tmp_allocator = tmp_alloc_g.get_allocator();
|
||||||
|
ObString text_str;
|
||||||
if (OB_FAIL(expr.args_[0]->eval(ctx, text))
|
if (OB_FAIL(expr.args_[0]->eval(ctx, text))
|
||||||
|| OB_FAIL(expr.args_[1]->eval(ctx, count))) {
|
|| OB_FAIL(expr.args_[1]->eval(ctx, count))) {
|
||||||
LOG_WARN("evaluate parameters failed", K(ret));
|
LOG_WARN("evaluate parameters failed", K(ret));
|
||||||
@ -287,6 +290,9 @@ int ObExprRepeat::eval_repeat(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_
|
|||||||
expr_datum.set_null();
|
expr_datum.set_null();
|
||||||
} else if (OB_FAIL(ctx.exec_ctx_.get_my_session()->get_max_allowed_packet(max_size))) {
|
} else if (OB_FAIL(ctx.exec_ctx_.get_my_session()->get_max_allowed_packet(max_size))) {
|
||||||
LOG_WARN("get max length failed", K(ret));
|
LOG_WARN("get max length failed", K(ret));
|
||||||
|
} else if (OB_FAIL(ObTextStringHelper::read_real_string_data(tmp_allocator, *text,
|
||||||
|
expr.args_[0]->datum_meta_, expr.args_[0]->obj_meta_.has_lob_header(), text_str))) {
|
||||||
|
LOG_WARN("fail to get real data.", K(ret), K(text_str));
|
||||||
} else {
|
} else {
|
||||||
ObExprStrResAlloc expr_res_alloc(expr, ctx);
|
ObExprStrResAlloc expr_res_alloc(expr, ctx);
|
||||||
bool is_null = false;
|
bool is_null = false;
|
||||||
@ -294,10 +300,10 @@ int ObExprRepeat::eval_repeat(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_
|
|||||||
ObString output;
|
ObString output;
|
||||||
if (!ob_is_text_tc(expr.datum_meta_.type_)) {
|
if (!ob_is_text_tc(expr.datum_meta_.type_)) {
|
||||||
ret = repeat(output, is_null,
|
ret = repeat(output, is_null,
|
||||||
text->get_string(), count->get_int(), expr_res_alloc, max_size);
|
text_str, count->get_int(), expr_res_alloc, max_size);
|
||||||
} else { // text tc
|
} else { // text tc
|
||||||
ret = repeat_text(expr.datum_meta_.type_, has_lob_header, output, is_null,
|
ret = repeat_text(expr.datum_meta_.type_, has_lob_header, output, is_null,
|
||||||
text->get_string(), count->get_int(), expr_res_alloc, max_size);
|
text_str, count->get_int(), expr_res_alloc, max_size);
|
||||||
}
|
}
|
||||||
if (OB_FAIL(ret)) {
|
if (OB_FAIL(ret)) {
|
||||||
LOG_WARN("do repeat failed", K(ret));
|
LOG_WARN("do repeat failed", K(ret));
|
||||||
|
|||||||
@ -96,3 +96,13 @@ desc t2;
|
|||||||
| repeat('a',65536) | longtext | YES | | NULL | |
|
| repeat('a',65536) | longtext | YES | | NULL | |
|
||||||
+-------------------+--------------+------+-----+---------+-------+
|
+-------------------+--------------+------+-----+---------+-------+
|
||||||
drop table t2;
|
drop table t2;
|
||||||
|
|
||||||
|
create table t2(c1 text, c2 mediumtext, c3 longtext);
|
||||||
|
insert into t2 values('a','b','c');
|
||||||
|
select repeat(c1, 10),repeat(c2,10),repeat(c3,10) from t2;
|
||||||
|
+----------------+---------------+---------------+
|
||||||
|
| repeat(c1, 10) | repeat(c2,10) | repeat(c3,10) |
|
||||||
|
+----------------+---------------+---------------+
|
||||||
|
| aaaaaaaaaa | bbbbbbbbbb | cccccccccc |
|
||||||
|
+----------------+---------------+---------------+
|
||||||
|
drop table t2;
|
||||||
|
|||||||
@ -41,5 +41,10 @@ drop table t2;
|
|||||||
|
|
||||||
--enable_warnings
|
--enable_warnings
|
||||||
|
|
||||||
|
create table t2(c1 text, c2 mediumtext, c3 longtext);
|
||||||
|
insert into t2 values('a','b','c');
|
||||||
|
select repeat(c1, 10),repeat(c2,10),repeat(c3,10) from t2;
|
||||||
|
drop table t2;
|
||||||
|
|
||||||
connection syscon;
|
connection syscon;
|
||||||
--sleep 2
|
--sleep 2
|
||||||
|
|||||||
Reference in New Issue
Block a user