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
|
ObExprTypeCtx &type_ctx) const
|
||||||
{
|
{
|
||||||
int ret = OB_SUCCESS;
|
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);
|
text.set_calc_type(common::ObVarcharType);
|
||||||
}
|
}
|
||||||
|
if (!count.is_null()) {
|
||||||
count.set_calc_type(common::ObIntType);
|
count.set_calc_type(common::ObIntType);
|
||||||
|
}
|
||||||
// Set cast mode for %count parameter, truncate string to integer.
|
// Set cast mode for %count parameter, truncate string to integer.
|
||||||
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_STRING_INTEGER_TRUNC);
|
type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_STRING_INTEGER_TRUNC);
|
||||||
// repeat is mysql only epxr.
|
// repeat is mysql only epxr.
|
||||||
CK(lib::is_mysql_mode());
|
CK(lib::is_mysql_mode());
|
||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
ObObjType res_type = ObMaxType;
|
ObObjType res_type = ObMaxType;
|
||||||
if (text.is_null() || count.is_null()) {
|
if (text.is_null() && !count.is_null()) {
|
||||||
res_type = ObVarcharType;
|
res_type = ObVarcharType;
|
||||||
} else if (count.is_literal()) {
|
} else if (count.is_literal() && !count.is_null()) {
|
||||||
const ObObj &obj = count.get_param();
|
const ObObj &obj = count.get_param();
|
||||||
ObArenaAllocator alloc(ObModIds::OB_SQL_RES_TYPE);
|
ObArenaAllocator alloc(ObModIds::OB_SQL_RES_TYPE);
|
||||||
const ObDataTypeCastParams dtc_params =
|
const ObDataTypeCastParams dtc_params =
|
||||||
|
|||||||
@ -187,3 +187,9 @@ select collation(TRIM( BOTH _binary'a' FROM _gbk'abc' )) ;
|
|||||||
| gbk_chinese_ci |
|
| 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 '+-Ã÷﹢﹣±/= â¥â' )) ;
|
||||||
select collation(TRIM( BOTH _binary'a' FROM _gbk'abc' )) ;
|
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;
|
connection syscon;
|
||||||
--sleep 2
|
--sleep 2
|
||||||
|
|||||||
Reference in New Issue
Block a user