implement of any value expr in mysql mode

This commit is contained in:
al0
2021-11-29 11:30:40 +08:00
committed by LINxiansheng
parent d467ca3d3f
commit a2b5b77779
11 changed files with 404 additions and 13 deletions

View File

@ -0,0 +1,67 @@
/*
* Copyright 2014-2021 Alibaba Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* ob_expr_any_value.cpp is for any_value function
*
* Date: 2021/7/9
*
* Authors:
* ailing.lcq<ailing.lcq@alibaba-inc.com>
*
*/
#include "sql/engine/expr/ob_expr_any_value.h"
using namespace oceanbase::common;
namespace oceanbase {
namespace sql {
ObExprAnyValue::ObExprAnyValue(ObIAllocator &alloc)
: ObFuncExprOperator(alloc, T_FUN_SYS_ANY_VALUE, N_ANY_VAL, 1, NOT_ROW_DIMENSION)
{}
ObExprAnyValue::~ObExprAnyValue()
{}
int ObExprAnyValue::calc_result_type1(ObExprResType &type, ObExprResType &arg, common::ObExprTypeCtx &) const
{
int ret = OB_SUCCESS;
type = arg;
return ret;
}
int ObExprAnyValue::calc_result1(common::ObObj &result, const common::ObObj &arg, common::ObExprCtx &expr_ctx) const
{
UNUSED(expr_ctx);
int ret = OB_SUCCESS;
result = arg;
return ret;
}
int ObExprAnyValue::cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr, ObExpr &rt_expr) const
{
UNUSED(raw_expr);
UNUSED(expr_cg_ctx);
rt_expr.eval_func_ = ObExprAnyValue::eval_any_value;
return OB_SUCCESS;
}
int ObExprAnyValue::eval_any_value(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum)
{
int ret = OB_SUCCESS;
ObDatum *arg = NULL;
if (OB_FAIL(expr.eval_param_value(ctx, arg))) {
SERVER_LOG(WARN, "expr evaluate parameter failed", K(ret));
} else {
expr_datum.set_datum(*arg);
}
return ret;
}
} // namespace sql
} // namespace oceanbase

View File

@ -0,0 +1,44 @@
/*
* Copyright 2014-2021 Alibaba Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* ob_expr_any_value.h is for any_value function
*
* Date: 2021/7/9
*
* Authors:
* ailing.lcq<ailing.lcq@alibaba-inc.com>
*
*/
#ifndef _OB_EXPR_ANY_VALUE_H_
#define _OB_EXPR_ANY_VALUE_H_
#include "sql/engine/expr/ob_expr_operator.h"
namespace oceanbase {
namespace sql {
class ObExprAnyValue : public ObFuncExprOperator {
public:
explicit ObExprAnyValue(common::ObIAllocator &alloc);
virtual ~ObExprAnyValue();
virtual int calc_result_type1(
ObExprResType &type, ObExprResType &arg, common::ObExprTypeCtx &type_ctx) const override;
virtual int calc_result1(common::ObObj &result, const common::ObObj &arg, common::ObExprCtx &expr_ctx) const override;
virtual int cg_expr(ObExprCGCtx &expr_cg_ctx, const ObRawExpr &raw_expr, ObExpr &rt_expr) const override;
static int eval_any_value(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum);
private:
DISALLOW_COPY_AND_ASSIGN(ObExprAnyValue) const;
};
} // namespace sql
} // namespace oceanbase
#endif /* _OB_EXPR_ANY_VALUE_H_ */
// select any_value();

View File

@ -186,6 +186,7 @@
#include "ob_expr_convert_tz.h"
#include "ob_expr_degrees.h"
#include "ob_expr_weight_string.h"
#include "ob_expr_any_value.h"
namespace oceanbase {
using namespace common;
@ -671,7 +672,7 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
ObExprPeriodAdd::calc_periodadd, /* 409 */
NULL, /* 410 */
NULL, /* 411 */
NULL, /* 412 */
ObExprAnyValue::eval_any_value, /* 412 */
NULL, /* 413 */
ObExprDegrees::calc_degrees_expr, /* 414 */
NULL, /* 415 */

View File

@ -270,6 +270,7 @@
#include "sql/engine/expr/ob_expr_convert_tz.h"
#include "sql/engine/expr/ob_expr_degrees.h"
#include "sql/engine/expr/ob_expr_weight_string.h"
#include "sql/engine/expr/ob_expr_any_value.h"
using namespace oceanbase::common;
namespace oceanbase {
@ -610,6 +611,7 @@ void ObExprOperatorFactory::register_expr_operators()
REG_OP(ObExprTruncate);
REG_OP(ObExprDllUdf);
REG_OP(ObExprExp);
REG_OP(ObExprAnyValue);
/* subquery comparison experator */
REG_OP(ObExprSubQueryRef);
REG_OP(ObExprSubQueryEqual);