fix result type deduce bug of expr_repeat
This commit is contained in:
@ -46,19 +46,21 @@ int ObExprRepeat::calc_result_type2(ObExprResType &type,
|
||||
ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (!ob_is_text_tc(text.get_type())) {
|
||||
if (!ob_is_text_tc(text.get_type()) && !text.is_null()) {
|
||||
text.set_calc_type(common::ObVarcharType);
|
||||
}
|
||||
if (!count.is_null()) {
|
||||
count.set_calc_type(common::ObIntType);
|
||||
}
|
||||
// Set cast mode for %count parameter, truncate string to integer.
|
||||
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_STRING_INTEGER_TRUNC);
|
||||
// repeat is mysql only epxr.
|
||||
CK(lib::is_mysql_mode());
|
||||
if (OB_SUCC(ret)) {
|
||||
ObObjType res_type = ObMaxType;
|
||||
if (text.is_null() || count.is_null()) {
|
||||
if (text.is_null() && !count.is_null()) {
|
||||
res_type = ObVarcharType;
|
||||
} else if (count.is_literal()) {
|
||||
} else if (count.is_literal() && !count.is_null()) {
|
||||
const ObObj &obj = count.get_param();
|
||||
ObArenaAllocator alloc(ObModIds::OB_SQL_RES_TYPE);
|
||||
const ObDataTypeCastParams dtc_params =
|
||||
|
||||
@ -187,3 +187,9 @@ select collation(TRIM( BOTH _binary'a' FROM _gbk'abc' )) ;
|
||||
| gbk_chinese_ci |
|
||||
+---------------------------------------------------+
|
||||
|
||||
select TRIM(LEADING 'a' FROM TRIM(SUBSTR(REPEAT(NULL, 4 + 1), 1, LEAST(146, 20))));
|
||||
+-----------------------------------------------------------------------------+
|
||||
| TRIM(LEADING 'a' FROM TRIM(SUBSTR(REPEAT(NULL, 4 + 1), 1, LEAST(146, 20)))) |
|
||||
+-----------------------------------------------------------------------------+
|
||||
| NULL |
|
||||
+-----------------------------------------------------------------------------+
|
||||
|
||||
@ -68,5 +68,7 @@ select SUBSTRING( TRIM( BOTH CONVERT( 'a', BINARY( 0 ) ) FROM '+-Ã÷﹢ï
|
||||
select collation(TRIM( BOTH _binary'a' FROM '+-Ã÷﹢﹣±/= â¥â' )) ;
|
||||
select collation(TRIM( BOTH _binary'a' FROM _gbk'abc' )) ;
|
||||
|
||||
select TRIM(LEADING 'a' FROM TRIM(SUBSTR(REPEAT(NULL, 4 + 1), 1, LEAST(146, 20))));
|
||||
|
||||
connection syscon;
|
||||
--sleep 2
|
||||
|
||||
Reference in New Issue
Block a user