init push

This commit is contained in:
oceanbase-admin
2021-05-31 22:56:52 +08:00
commit cea7de1475
7020 changed files with 5689869 additions and 0 deletions

View File

@ -0,0 +1,88 @@
/**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/expr/ob_expr_fun_values.h"
#include "sql/engine/ob_physical_plan_ctx.h"
#include "sql/engine/ob_physical_plan.h"
#include "sql/ob_sql_utils.h"
using namespace oceanbase::common;
namespace oceanbase {
namespace sql {
ObExprFunValues::ObExprFunValues(ObIAllocator& alloc)
: ObFuncExprOperator(alloc, T_FUN_SYS_VALUES, N_VALUES, 1, NOT_ROW_DIMENSION)
{}
ObExprFunValues::~ObExprFunValues()
{}
int ObExprFunValues::calc_result_type1(ObExprResType& type, ObExprResType& text, common::ObExprTypeCtx& type_ctx) const
{
UNUSED(type_ctx);
type.set_type(text.get_type());
type.set_collation_level(text.get_collation_level());
type.set_collation_type(text.get_collation_type());
type.set_accuracy(text.get_accuracy());
return OB_SUCCESS;
}
int ObExprFunValues::calc_result1(ObObj& result, const ObObj& text, ObExprCtx& expr_ctx) const
{
int ret = OB_SUCCESS;
if (OB_ISNULL(expr_ctx.phy_plan_ctx_) || OB_ISNULL(expr_ctx.phy_plan_ctx_->get_phy_plan())) {
ret = OB_ERR_UNEXPECTED;
SQL_ENG_LOG(WARN, "invalid phy plan ctx", K(expr_ctx.phy_plan_ctx_));
} else if (OB_FAIL(ObSQLUtils::set_compatible_cast_mode((expr_ctx).my_session_, (expr_ctx).cast_mode_))) {
SQL_ENG_LOG(WARN, "set_compatible_cast_mode failed", K(ret));
} else {
if (ObSQLUtils::is_insert_update_scope(expr_ctx.cast_mode_)) {
result = text;
} else {
result.set_null();
}
}
return ret;
}
int ObExprFunValues::cg_expr(ObExprCGCtx&, const ObRawExpr&, ObExpr& rt_expr) const
{
int ret = OB_SUCCESS;
CK(1 == rt_expr.arg_cnt_);
rt_expr.eval_func_ = &ObExprFunValues::eval_values;
return ret;
}
int ObExprFunValues::eval_values(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
{
// values() meaningful only in insert on duplicate update clause (extra_ set to 1),
// return NULL otherwise.
int ret = OB_SUCCESS;
if (expr.extra_) {
// in insert update scope
ObDatum* arg = NULL;
if (OB_FAIL(expr.eval_param_value(ctx, arg))) {
LOG_WARN("evaluate parameter value failed", K(ret));
} else {
expr_datum.set_datum(*arg);
}
} else {
expr_datum.set_null();
}
return ret;
}
} // namespace sql
} // namespace oceanbase