patch 4.0
This commit is contained in:
@ -14,18 +14,24 @@
|
||||
#include "sql/engine/expr/ob_expr_exists.h"
|
||||
#include "common/row/ob_row_iterator.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace oceanbase
|
||||
{
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
namespace sql
|
||||
{
|
||||
|
||||
ObExprExists::ObExprExists(ObIAllocator& alloc)
|
||||
: ObSubQueryRelationalExpr(alloc, T_OP_EXISTS, N_EXISTS, 1, NOT_ROW_DIMENSION)
|
||||
{}
|
||||
ObExprExists::ObExprExists(ObIAllocator &alloc)
|
||||
: ObSubQueryRelationalExpr(alloc, T_OP_EXISTS, N_EXISTS, 1, NOT_ROW_DIMENSION)
|
||||
{
|
||||
}
|
||||
|
||||
ObExprExists::~ObExprExists()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
int ObExprExists::calc_result_type1(ObExprResType& type, ObExprResType& type1, ObExprTypeCtx& type_ctx) const
|
||||
int ObExprExists::calc_result_type1(ObExprResType &type,
|
||||
ObExprResType &type1,
|
||||
ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
UNUSED(type_ctx);
|
||||
int ret = OB_SUCCESS;
|
||||
@ -37,46 +43,12 @@ int ObExprExists::calc_result_type1(ObExprResType& type, ObExprResType& type1, O
|
||||
type.set_precision(DEFAULT_PRECISION_FOR_BOOL);
|
||||
type.set_scale(ObAccuracy::DDL_DEFAULT_ACCURACY[ObIntType].scale_);
|
||||
}
|
||||
// flag
|
||||
type.set_result_flag(OB_MYSQL_NOT_NULL_FLAG);
|
||||
//flag
|
||||
type.set_result_flag(NOT_NULL_FLAG);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprExists::calc_result1(ObObj& result, const ObObj& obj1, ObExprCtx& expr_ctx) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t query_idx = OB_INVALID_INDEX;
|
||||
ObNewRow* row = NULL;
|
||||
ObNewRowIterator* row_iter = NULL;
|
||||
if (OB_ISNULL(expr_ctx.subplan_iters_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("expr_ctx.subplan_iters_ is null");
|
||||
} else {
|
||||
ObIArray<ObNewRowIterator*>* row_iters = expr_ctx.subplan_iters_;
|
||||
if (OB_FAIL(obj1.get_int(query_idx))) {
|
||||
LOG_WARN("get int failed", K(obj1), K(ret));
|
||||
} else if (OB_UNLIKELY(query_idx < 0 || query_idx >= row_iters->count())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("query_idx is invalid", "row_iter_count", row_iters->count(), K(query_idx), K(ret));
|
||||
} else if (OB_ISNULL(row_iter = row_iters->at(query_idx))) {
|
||||
ret = OB_ERR_NULL_VALUE;
|
||||
LOG_WARN("row iterator is null", K(query_idx));
|
||||
} else if (OB_FAIL(row_iter->get_next_row(row))) {
|
||||
if (OB_LIKELY(OB_ITER_END == ret)) {
|
||||
ret = OB_SUCCESS;
|
||||
result.set_int32(0);
|
||||
} else {
|
||||
LOG_WARN("get next row failed", K(ret));
|
||||
}
|
||||
} else {
|
||||
result.set_int32(1);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprExists::cg_expr(ObExprCGCtx&, const ObRawExpr&, ObExpr& rt_expr) const
|
||||
int ObExprExists::cg_expr(ObExprCGCtx &, const ObRawExpr &, ObExpr &rt_expr) const
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
CK(1 == rt_expr.arg_cnt_);
|
||||
@ -84,7 +56,8 @@ int ObExprExists::cg_expr(ObExprCGCtx&, const ObRawExpr&, ObExpr& rt_expr) const
|
||||
return ret;
|
||||
};
|
||||
|
||||
int ObExprExists::exists_eval(const ObExpr& expr, ObEvalCtx& ctx, ObDatum& expr_datum)
|
||||
int ObExprExists::exists_eval(
|
||||
const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
bool exists = false;
|
||||
|
||||
Reference in New Issue
Block a user