[FEAT MERGE] Solidify session vars for functional index

This commit is contained in:
2149
2023-12-12 06:42:36 +00:00
committed by ob-robot
parent db82b0b5cd
commit 58aad590f1
189 changed files with 3671 additions and 1554 deletions

View File

@ -19,6 +19,7 @@
#include "share/object/ob_obj_cast.h"
#include "sql/session/ob_sql_session_info.h"
#include "sql/engine/ob_exec_context.h"
#include "sql/engine/expr/ob_expr_util.h"
namespace oceanbase
{
@ -186,10 +187,10 @@ int ObExprTimeStampDiff::eval_timestamp_diff(const ObExpr &expr, ObEvalCtx &ctx,
ObDatum *u = NULL;
ObDatum *l = NULL;
ObDatum *r = NULL;
const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session();
if (OB_ISNULL(session)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("session is NULL", K(ret));
ObSolidifiedVarsGetter helper(expr, ctx, ctx.exec_ctx_.get_my_session());
const common::ObTimeZoneInfo *tz_info = NULL;
if (OB_FAIL(helper.get_time_zone_info(tz_info))) {
LOG_WARN("get tz info failed", K(ret));
} else if (OB_FAIL(expr.eval_param_value(ctx, u, l, r))) {
LOG_WARN("eval arg failed", K(ret));
} else if (u->is_null()) {
@ -201,7 +202,7 @@ int ObExprTimeStampDiff::eval_timestamp_diff(const ObExpr &expr, ObEvalCtx &ctx,
int64_t res_int = 0;
bool is_null = false;
if (OB_FAIL(calc(res_int, is_null, u->get_int(), l->get_datetime(),
r->get_datetime(), session->get_timezone_info()))) {
r->get_datetime(), tz_info))) {
LOG_WARN("calc failed", K(ret));
} else if (is_null) {
res.set_null();
@ -226,5 +227,14 @@ int ObExprTimeStampDiff::cg_expr(ObExprCGCtx &ctx, const ObRawExpr &raw_expr,
return ret;
}
DEF_SET_LOCAL_SESSION_VARS(ObExprTimeStampDiff, raw_expr) {
int ret = OB_SUCCESS;
if (is_mysql_mode()) {
SET_LOCAL_SYSVAR_CAPACITY(1);
EXPR_ADD_LOCAL_SYSVAR(SYS_VAR_TIME_ZONE);
}
return ret;
}
} //namespace sql
} //namespace oceanbase