[CP] fix bug about timestampdiff and timestampadd
This commit is contained in:
@ -46,17 +46,14 @@ inline int ObExprTimeStampAdd::calc_result_type3(ObExprResType &type,
|
||||
ObExprResType ×tamp,
|
||||
common::ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
UNUSED(unit);
|
||||
UNUSED(interval);
|
||||
UNUSED(timestamp);
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
ObCompatibilityMode compat_mode = get_compatibility_mode();
|
||||
//not timestamp. compatible with mysql.
|
||||
type.set_varchar();
|
||||
type.set_length(common::ObAccuracy::MAX_ACCURACY2[compat_mode][common::ObTimestampType].precision_
|
||||
+ common::ObAccuracy::MAX_ACCURACY2[compat_mode][common::ObTimestampType].scale_ + 1);
|
||||
//timestamp.set_calc_type(common::ObDateTimeType);
|
||||
type.set_length(common::ObAccuracy::MAX_ACCURACY2[compat_mode][common::ObDateTimeType].precision_
|
||||
+ common::ObAccuracy::MAX_ACCURACY2[compat_mode][common::ObDateTimeType].scale_ + 1);
|
||||
type.set_collation_level(common::CS_LEVEL_IMPLICIT);
|
||||
//not connection collation. compatible with mysql.
|
||||
type.set_collation_type(common::ObCharset::get_default_collation(common::ObCharset::get_default_charset()));
|
||||
@ -216,7 +213,7 @@ int calc_timestampadd_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datu
|
||||
int64_t interval_int = interval_datum->get_int();
|
||||
int64_t res = 0;
|
||||
ObTime ot;
|
||||
ObTimeConvertCtx cvrt_ctx(get_timezone_info(ctx.exec_ctx_.get_my_session()), true);
|
||||
ObTimeConvertCtx cvrt_ctx(get_timezone_info(ctx.exec_ctx_.get_my_session()), false);
|
||||
char *buf = NULL;
|
||||
int64_t buf_len = OB_CAST_TO_VARCHAR_MAX_LENGTH;
|
||||
int64_t out_len = 0;
|
||||
@ -233,7 +230,7 @@ int calc_timestampadd_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datu
|
||||
} else if (OB_ISNULL(buf = expr.get_str_res_mem(ctx, buf_len))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("allocate memory failed", K(ret), K(buf_len));
|
||||
} else if (OB_FAIL(common_datetime_string(ObTimestampType, ObVarcharType,
|
||||
} else if (OB_FAIL(common_datetime_string(ObDateTimeType, ObVarcharType,
|
||||
expr.args_[2]->datum_meta_.scale_, false,
|
||||
res, ctx, buf, buf_len, out_len))) {
|
||||
LOG_WARN("common_datetime_string failed", K(ret), K(res), K(expr));
|
||||
|
||||
Reference in New Issue
Block a user