[FEAT MERGE] Solidify session vars for functional index
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#include "sql/engine/expr/ob_datum_cast.h"
|
||||
#include "sql/engine/expr/ob_expr_util.h"
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
@ -68,6 +69,9 @@ int ObExprQuarter::calc_quater(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr
|
||||
ObTime ot;
|
||||
ObDateSqlMode date_sql_mode;
|
||||
const ObSQLSessionInfo *session = NULL;
|
||||
ObSQLMode sql_mode = 0;
|
||||
ObSolidifiedVarsGetter helper(expr, ctx, ctx.exec_ctx_.get_my_session());
|
||||
const common::ObTimeZoneInfo *tz_info = NULL;
|
||||
if (OB_ISNULL(session = ctx.exec_ctx_.get_my_session())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session is null", K(ret));
|
||||
@ -75,16 +79,23 @@ int ObExprQuarter::calc_quater(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr
|
||||
LOG_WARN("eval param value failed");
|
||||
} else if (OB_UNLIKELY(param_datum->is_null())) {
|
||||
expr_datum.set_null();
|
||||
} else if (FALSE_IT(date_sql_mode.init(session->get_sql_mode()))) {
|
||||
} else if (OB_FAIL(helper.get_sql_mode(sql_mode))) {
|
||||
LOG_WARN("get sql mode failed", K(ret));
|
||||
} else if (OB_FAIL(helper.get_time_zone_info(tz_info))) {
|
||||
LOG_WARN("get time zone failed", K(ret));
|
||||
} else if (FALSE_IT(date_sql_mode.init(sql_mode))) {
|
||||
} else if (OB_FAIL(ob_datum_to_ob_time_with_date(
|
||||
*param_datum, expr.args_[0]->datum_meta_.type_, expr.args_[0]->datum_meta_.scale_,
|
||||
get_timezone_info(session),
|
||||
tz_info,
|
||||
ot, get_cur_time(ctx.exec_ctx_.get_physical_plan_ctx()),
|
||||
date_sql_mode,
|
||||
expr.args_[0]->obj_meta_.has_lob_header()))) {
|
||||
LOG_WARN("cast to ob time failed", K(ret));
|
||||
uint64_t cast_mode = 0;
|
||||
ObSQLUtils::get_default_cast_mode(session->get_stmt_type(), session, cast_mode);
|
||||
ObSQLUtils::get_default_cast_mode(session->get_stmt_type(),
|
||||
session->is_ignore_stmt(),
|
||||
sql_mode,
|
||||
cast_mode);
|
||||
if (CM_IS_WARN_ON_FAIL(cast_mode)) {
|
||||
ret = OB_SUCCESS;
|
||||
}
|
||||
@ -106,5 +117,18 @@ int ObExprQuarter::is_valid_for_generated_column(const ObRawExpr*expr, const com
|
||||
return ret;
|
||||
}
|
||||
|
||||
DEF_SET_LOCAL_SESSION_VARS(ObExprQuarter, raw_expr) {
|
||||
int ret = OB_SUCCESS;
|
||||
if (is_mysql_mode()) {
|
||||
SET_LOCAL_SYSVAR_CAPACITY(2);
|
||||
EXPR_ADD_LOCAL_SYSVAR(share::SYS_VAR_SQL_MODE);
|
||||
EXPR_ADD_LOCAL_SYSVAR(share::SYS_VAR_TIME_ZONE);
|
||||
} else {
|
||||
SET_LOCAL_SYSVAR_CAPACITY(1);
|
||||
EXPR_ADD_LOCAL_SYSVAR(share::SYS_VAR_TIME_ZONE);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // end namespace sql
|
||||
} // end namespace oceanbase
|
||||
|
||||
Reference in New Issue
Block a user