init push
This commit is contained in:
66
src/sql/engine/expr/ob_expr_shadow_uk_project.cpp
Normal file
66
src/sql/engine/expr/ob_expr_shadow_uk_project.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 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_shadow_uk_project.h"
|
||||
|
||||
namespace oceanbase {
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
int ObExprShadowUKProject::cg_expr(ObExprCGCtx&, const ObRawExpr& raw_expr, ObExpr& rt_expr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
UNUSED(raw_expr);
|
||||
CK(rt_expr.arg_cnt_ >= 2);
|
||||
rt_expr.eval_func_ = ObExprShadowUKProject::shadow_uk_project;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprShadowUKProject::shadow_uk_project(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool need_shadow_columns = false;
|
||||
if (OB_FAIL(expr.eval_param_value(ctx))) {
|
||||
LOG_WARN("evaluate parameters values failed", K(ret));
|
||||
} else if (lib::is_mysql_mode()) {
|
||||
// mysql compatible: as long as there is a null column in the unique index key,
|
||||
// the shadow column needs to be filled
|
||||
bool rowkey_has_null = false;
|
||||
for (int64_t i = 0; !rowkey_has_null && i < expr.arg_cnt_ - 1; i++) {
|
||||
ObDatum& v = expr.locate_param_datum(ctx, i);
|
||||
rowkey_has_null = v.is_null();
|
||||
}
|
||||
need_shadow_columns = rowkey_has_null;
|
||||
} else {
|
||||
// oracle compatible: only when the unique index key is all null columns,
|
||||
// the shadow column needs to be filled
|
||||
bool is_rowkey_all_null = true;
|
||||
for (int64_t i = 0; is_rowkey_all_null && i < expr.arg_cnt_ - 1; i++) {
|
||||
ObDatum& v = expr.locate_param_datum(ctx, i);
|
||||
is_rowkey_all_null = v.is_null();
|
||||
}
|
||||
need_shadow_columns = is_rowkey_all_null;
|
||||
}
|
||||
if (!need_shadow_columns) {
|
||||
datum.set_null();
|
||||
} else {
|
||||
ObDatum& v = expr.locate_param_datum(ctx, expr.arg_cnt_ - 1);
|
||||
datum.set_datum(v);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
Reference in New Issue
Block a user