[CP] enhance GTT
This commit is contained in:
@ -332,6 +332,7 @@
|
||||
#include "ob_expr_uniform.h"
|
||||
#include "ob_expr_prefix_pattern.h"
|
||||
#include "ob_expr_initcap.h"
|
||||
#include "ob_expr_temp_table_ssid.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
@ -1033,8 +1034,8 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = {
|
||||
ObExprUpdateXml::eval_update_xml, /* 603 */
|
||||
ObExprJoinFilter::eval_range_filter, /* 604 */
|
||||
ObExprJoinFilter::eval_in_filter, /* 605 */
|
||||
ObExprCurrentScn::eval_current_scn /* 606 */
|
||||
//ObExprTempTableSSID::calc_temp_table_ssid, /* 607 */
|
||||
ObExprCurrentScn::eval_current_scn, /* 606 */
|
||||
ObExprTempTableSSID::calc_temp_table_ssid, /* 607 */
|
||||
};
|
||||
|
||||
static ObExpr::EvalBatchFunc g_expr_eval_batch_functions[] = {
|
||||
|
||||
@ -401,6 +401,7 @@
|
||||
#include "sql/engine/expr/ob_expr_xml_serialize.h"
|
||||
#include "sql/engine/expr/ob_expr_xmlcast.h"
|
||||
#include "sql/engine/expr/ob_expr_update_xml.h"
|
||||
#include "sql/engine/expr/ob_expr_temp_table_ssid.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
namespace oceanbase
|
||||
@ -1305,6 +1306,7 @@ void ObExprOperatorFactory::register_expr_operators()
|
||||
REG_OP_ORCL(ObExprXmlSerialize);
|
||||
REG_OP_ORCL(ObExprXmlcast);
|
||||
REG_OP_ORCL(ObExprUpdateXml);
|
||||
REG_OP_ORCL(ObExprTempTableSSID);
|
||||
}
|
||||
|
||||
bool ObExprOperatorFactory::is_expr_op_type_valid(ObExprOperatorType type)
|
||||
|
||||
92
src/sql/engine/expr/ob_expr_temp_table_ssid.cpp
Normal file
92
src/sql/engine/expr/ob_expr_temp_table_ssid.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// (C) Copyright 2011-2023 Alibaba Inc. All Rights Reserved.
|
||||
// Authors:
|
||||
// jim.wjh <>
|
||||
//
|
||||
#define USING_LOG_PREFIX SQL_ENG
|
||||
#include "ob_expr_temp_table_ssid.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
|
||||
ObExprTempTableSSID::ObExprTempTableSSID(ObIAllocator &alloc)
|
||||
: ObFuncExprOperator(alloc, T_FUN_GET_TEMP_TABLE_SESSID, N_TEMP_TABLE_SSID, 1, NOT_VALID_FOR_GENERATED_COL, NOT_ROW_DIMENSION)
|
||||
{
|
||||
}
|
||||
|
||||
ObExprTempTableSSID::~ObExprTempTableSSID()
|
||||
{
|
||||
}
|
||||
|
||||
int ObExprTempTableSSID::calc_result_type1(ObExprResType &type, ObExprResType &type1, ObExprTypeCtx &type_ctx) const
|
||||
{
|
||||
UNUSED(type1);
|
||||
UNUSED(type_ctx);
|
||||
int ret = OB_SUCCESS;
|
||||
type.set_int();
|
||||
type.set_precision(ObAccuracy::DDL_DEFAULT_ACCURACY[ObIntType].precision_);
|
||||
type.set_scale(DEFAULT_SCALE_FOR_INTEGER);
|
||||
type1.set_calc_type(ObIntType);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprTempTableSSID::calc_temp_table_ssid(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObDatum *param = NULL;
|
||||
if (OB_ISNULL(ctx.exec_ctx_.get_my_session())) {
|
||||
ret = OB_ERR_UNDEFINED;
|
||||
} else if (OB_FAIL(expr.args_[0]->eval(ctx, param))) {
|
||||
LOG_WARN("fail to eval param", K(ret));
|
||||
} else if (expr.args_[0]->datum_meta_.type_ != ObIntType) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid object", K(ret));
|
||||
} else {
|
||||
switch (param->get_int()) {
|
||||
case GTT_SESSION_SCOPE:
|
||||
res.set_int(ctx.exec_ctx_.get_my_session()->get_gtt_session_scope_unique_id());
|
||||
break;
|
||||
case GTT_TRANS_SCOPE:
|
||||
res.set_int(ctx.exec_ctx_.get_my_session()->get_gtt_trans_scope_unique_id());
|
||||
break;
|
||||
default:
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid object", K(ret), KPC(param));
|
||||
}
|
||||
LOG_DEBUG("get result", K(res.get_int()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObExprTempTableSSID::cg_expr(
|
||||
ObExprCGCtx &op_cg_ctx,
|
||||
const ObRawExpr &raw_expr,
|
||||
ObExpr &rt_expr) const
|
||||
{
|
||||
UNUSED(op_cg_ctx);
|
||||
UNUSED(raw_expr);
|
||||
int ret = OB_SUCCESS;
|
||||
rt_expr.eval_func_ = calc_temp_table_ssid;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
45
src/sql/engine/expr/ob_expr_temp_table_ssid.h
Normal file
45
src/sql/engine/expr/ob_expr_temp_table_ssid.h
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Copyright (c) 2011-2023 Alibaba Inc. All Rights Reserved.
|
||||
// Author:
|
||||
// jim.wjh <>
|
||||
|
||||
|
||||
#ifndef _OB_EXPR_TEMP_TABLE_SSID_H
|
||||
#define _OB_EXPR_TEMP_TABLE_SSID_H
|
||||
#include "sql/engine/expr/ob_expr_operator.h"
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
|
||||
class ObExprTempTableSSID : public ObFuncExprOperator
|
||||
{
|
||||
public:
|
||||
enum {GTT_SESSION_SCOPE, GTT_TRANS_SCOPE, MAX_GTT_SCOPTE};
|
||||
public:
|
||||
explicit ObExprTempTableSSID(common::ObIAllocator &alloc);
|
||||
virtual ~ObExprTempTableSSID();
|
||||
int calc_result_type1(ObExprResType &type, ObExprResType &type1, common::ObExprTypeCtx &type_ctx) const override;
|
||||
int cg_expr(ObExprCGCtx &op_cg_ctx, const ObRawExpr &raw_expr, ObExpr &rt_expr) const override;
|
||||
static int calc_temp_table_ssid(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExprTempTableSSID);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _OB_EXPR_TEMP_TABLE_SSID_H
|
||||
Reference in New Issue
Block a user