init push
This commit is contained in:
51
src/sql/resolver/prepare/ob_deallocate_resolver.cpp
Normal file
51
src/sql/resolver/prepare/ob_deallocate_resolver.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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_RESV
|
||||
#include "sql/resolver/prepare/ob_deallocate_resolver.h"
|
||||
|
||||
namespace oceanbase {
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
int ObDeallocateResolver::resolve(const ParseNode& parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (parse_tree.num_child_ != 1) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", "num_child", parse_tree.num_child_, K(ret));
|
||||
} else {
|
||||
ObDeallocateStmt* deallocate_stmt = NULL;
|
||||
if (OB_ISNULL(deallocate_stmt = create_stmt<ObDeallocateStmt>())) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("create deallocate stmt failed", K(ret));
|
||||
} else {
|
||||
stmt_ = deallocate_stmt;
|
||||
// resolver stmt name
|
||||
if (OB_ISNULL(parse_tree.children_[0])) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(parse_tree.children_[0]), K(ret));
|
||||
} else {
|
||||
ObString name(parse_tree.children_[0]->str_len_, parse_tree.children_[0]->str_value_);
|
||||
ObPsStmtId ps_id = OB_INVALID_ID;
|
||||
if (OB_FAIL(session_info_->get_prepare_id(name, ps_id))) {
|
||||
LOG_WARN("failed to get prepare id", K(ret));
|
||||
} else {
|
||||
deallocate_stmt->set_prepare_id(ps_id);
|
||||
deallocate_stmt->set_prepare_name(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
40
src/sql/resolver/prepare/ob_deallocate_resolver.h
Normal file
40
src/sql/resolver/prepare/ob_deallocate_resolver.h
Normal file
@ -0,0 +1,40 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_RESOLVER_DML_OB_DEALLOCATE_RESOLVER_H_
|
||||
#define OCEANBASE_SQL_RESOLVER_DML_OB_DEALLOCATE_RESOLVER_H_
|
||||
|
||||
#include "sql/resolver/ob_stmt_resolver.h"
|
||||
#include "sql/resolver/prepare/ob_deallocate_stmt.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObDeallocateResolver : public ObStmtResolver {
|
||||
public:
|
||||
explicit ObDeallocateResolver(ObResolverParams& params) : ObStmtResolver(params)
|
||||
{}
|
||||
virtual ~ObDeallocateResolver()
|
||||
{}
|
||||
|
||||
virtual int resolve(const ParseNode& parse_tree);
|
||||
ObDeallocateStmt* get_deallocate_stmt()
|
||||
{
|
||||
return static_cast<ObDeallocateStmt*>(stmt_);
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(ObDeallocateResolver);
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
||||
#endif /*OCEANBASE_SQL_RESOLVER_DML_OB_DEALLOCATE_RESOLVER_H_*/
|
||||
19
src/sql/resolver/prepare/ob_deallocate_stmt.cpp
Normal file
19
src/sql/resolver/prepare/ob_deallocate_stmt.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "sql/resolver/prepare/ob_deallocate_stmt.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
namespace oceanbase {
|
||||
namespace sql {} // namespace sql
|
||||
} // namespace oceanbase
|
||||
56
src/sql/resolver/prepare/ob_deallocate_stmt.h
Normal file
56
src/sql/resolver/prepare/ob_deallocate_stmt.h
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_RESOVLER_PREPARE_DEALLOCATE_STMT_H_
|
||||
#define OCEANBASE_SQL_RESOVLER_PREPARE_DEALLOCATE_STMT_H_
|
||||
|
||||
#include "sql/resolver/cmd/ob_cmd_stmt.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObDeallocateStmt : public ObCMDStmt {
|
||||
public:
|
||||
ObDeallocateStmt() : ObCMDStmt(stmt::T_DEALLOCATE), prepare_name_(), prepare_id_(OB_INVALID_ID)
|
||||
{}
|
||||
virtual ~ObDeallocateStmt()
|
||||
{}
|
||||
|
||||
inline void set_prepare_name(const common::ObString& name)
|
||||
{
|
||||
prepare_name_ = name;
|
||||
}
|
||||
const common::ObString& get_prepare_name() const
|
||||
{
|
||||
return prepare_name_;
|
||||
}
|
||||
inline void set_prepare_id(ObPsStmtId id)
|
||||
{
|
||||
prepare_id_ = id;
|
||||
}
|
||||
inline ObPsStmtId get_prepare_id() const
|
||||
{
|
||||
return prepare_id_;
|
||||
}
|
||||
|
||||
TO_STRING_KV(N_STMT_NAME, prepare_name_, N_SQL_ID, prepare_id_);
|
||||
|
||||
private:
|
||||
common::ObString prepare_name_;
|
||||
ObPsStmtId prepare_id_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObDeallocateStmt);
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
||||
#endif // OCEANBASE_SQL_RESOLVER_PREPARE_DEALLOCATE_STMT_H_
|
||||
90
src/sql/resolver/prepare/ob_execute_resolver.cpp
Normal file
90
src/sql/resolver/prepare/ob_execute_resolver.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* 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_RESV
|
||||
#include "sql/resolver/prepare/ob_execute_resolver.h"
|
||||
#include "sql/resolver/ob_resolver_utils.h"
|
||||
#include "sql/plan_cache/ob_prepare_stmt_struct.h"
|
||||
|
||||
namespace oceanbase {
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
|
||||
int ObExecuteResolver::resolve(const ParseNode& parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObExecuteStmt* execute_stmt = NULL;
|
||||
if (parse_tree.num_child_ != 2 || OB_ISNULL(session_info_)) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", "num_child", parse_tree.num_child_, K(allocator_), K(ret));
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_ISNULL(execute_stmt = create_stmt<ObExecuteStmt>())) {
|
||||
ret = OB_SQL_RESOLVER_NO_MEMORY;
|
||||
LOG_WARN("failed to create execute stmt", K(ret));
|
||||
} else {
|
||||
stmt_ = execute_stmt;
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
// resolver stmt name
|
||||
if (OB_ISNULL(parse_tree.children_[0])) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(parse_tree.children_[0]), K(ret));
|
||||
} else {
|
||||
ObString name(parse_tree.children_[0]->str_len_, parse_tree.children_[0]->str_value_);
|
||||
ObPsSessionInfo* ps_session_info = NULL;
|
||||
ObPsStmtId ps_id = OB_INVALID_ID;
|
||||
stmt::StmtType ps_type = stmt::T_NONE;
|
||||
if (OB_FAIL(session_info_->get_prepare_id(name, ps_id))) {
|
||||
LOG_WARN("failed to get prepare id", K(ret));
|
||||
} else if (OB_FAIL(session_info_->get_ps_session_info(ps_id, ps_session_info))) {
|
||||
LOG_WARN("failed to get ps session info", K(ret));
|
||||
} else if (OB_ISNULL(ps_session_info)) {
|
||||
LOG_WARN("ps session info is NULL", K(name), K(ps_id), K(ret));
|
||||
} else {
|
||||
ps_type = ps_session_info->get_stmt_type();
|
||||
execute_stmt->set_prepare_id(ps_id);
|
||||
execute_stmt->set_prepare_type(ps_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
// resolver variable
|
||||
if (OB_SUCC(ret)) {
|
||||
if (NULL == parse_tree.children_[1]) {
|
||||
// do nothing
|
||||
} else if (parse_tree.children_[1]->type_ != T_ARGUMENT_LIST) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", K(parse_tree.children_[1]->type_), K(ret));
|
||||
} else {
|
||||
ParseNode* arguments = parse_tree.children_[1];
|
||||
for (int32_t i = 0; OB_SUCC(ret) && i < arguments->num_child_; ++i) {
|
||||
if (OB_ISNULL(arguments->children_[i])) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argumenet", K(arguments->children_[i]), K(ret));
|
||||
} else {
|
||||
ObRawExpr* param_expr = NULL;
|
||||
if (OB_FAIL(ObResolverUtils::resolve_const_expr(params_, *arguments->children_[i], param_expr, NULL))) {
|
||||
LOG_WARN("failed to resolve const expr", K(ret));
|
||||
} else if (OB_FAIL(execute_stmt->add_param(param_expr))) {
|
||||
LOG_WARN("failed to add param", K(ret));
|
||||
} else { /*do nothing*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
39
src/sql/resolver/prepare/ob_execute_resolver.h
Normal file
39
src/sql/resolver/prepare/ob_execute_resolver.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_RESOLVER_PREPARE_OB_EXECUTE_RESOLVER_
|
||||
#define OCEANBASE_SQL_RESOLVER_PREPARE_OB_EXECUTE_RESOLVER_
|
||||
|
||||
#include "sql/resolver/ob_stmt_resolver.h"
|
||||
#include "sql/resolver/prepare/ob_execute_stmt.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObExecuteResolver : public ObStmtResolver {
|
||||
public:
|
||||
explicit ObExecuteResolver(ObResolverParams& params) : ObStmtResolver(params)
|
||||
{}
|
||||
virtual ~ObExecuteResolver()
|
||||
{}
|
||||
|
||||
virtual int resolve(const ParseNode& parse_tree);
|
||||
ObExecuteStmt* get_execute_stmt()
|
||||
{
|
||||
return static_cast<ObExecuteStmt*>(stmt_);
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
#endif /*OCEANBASE_SQL_RESOLVER_DML_OB_EXECUTE_RESOLVER_H_*/
|
||||
21
src/sql/resolver/prepare/ob_execute_stmt.cpp
Normal file
21
src/sql/resolver/prepare/ob_execute_stmt.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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_RESV
|
||||
|
||||
#include "sql/resolver/prepare/ob_execute_stmt.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
namespace oceanbase {
|
||||
namespace sql {} // namespace sql
|
||||
} // namespace oceanbase
|
||||
71
src/sql/resolver/prepare/ob_execute_stmt.h
Normal file
71
src/sql/resolver/prepare/ob_execute_stmt.h
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_RESOLVER_PREPARE_EXECUTE_STMT_
|
||||
#define OCEANBASE_SQL_RESOLVER_PREPARE_EXECUTE_STMT_
|
||||
|
||||
#include "lib/container/ob_array.h"
|
||||
#include "sql/resolver/cmd/ob_cmd_stmt.h"
|
||||
#include "sql/session/ob_sql_session_info.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObExecuteStmt : public ObCMDStmt {
|
||||
public:
|
||||
ObExecuteStmt()
|
||||
: ObCMDStmt(stmt::T_EXECUTE), prepare_id_(common::OB_INVALID_ID), prepare_type_(stmt::T_NONE), params_()
|
||||
{}
|
||||
virtual ~ObExecuteStmt()
|
||||
{}
|
||||
|
||||
inline ObPsStmtId get_prepare_id() const
|
||||
{
|
||||
return prepare_id_;
|
||||
}
|
||||
inline void set_prepare_id(ObPsStmtId id)
|
||||
{
|
||||
prepare_id_ = id;
|
||||
}
|
||||
inline stmt::StmtType get_prepare_type() const
|
||||
{
|
||||
return prepare_type_;
|
||||
}
|
||||
inline void set_prepare_type(stmt::StmtType type)
|
||||
{
|
||||
prepare_type_ = type;
|
||||
}
|
||||
inline const common::ObIArray<const sql::ObRawExpr*>& get_params() const
|
||||
{
|
||||
return params_;
|
||||
}
|
||||
inline int set_params(common::ObIArray<const sql::ObRawExpr*>& params)
|
||||
{
|
||||
return append(params_, params);
|
||||
}
|
||||
inline int add_param(const sql::ObRawExpr* param)
|
||||
{
|
||||
return params_.push_back(param);
|
||||
}
|
||||
|
||||
TO_STRING_KV(N_SQL_ID, prepare_id_, N_STMT_TYPE, prepare_type_, N_PARAM, params_);
|
||||
|
||||
private:
|
||||
ObPsStmtId prepare_id_;
|
||||
stmt::StmtType prepare_type_;
|
||||
common::ObArray<const sql::ObRawExpr*> params_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObExecuteStmt);
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
||||
#endif // OCEANBASE_SQL_RESOLVER_PREPARE_EXECUTE_STMT_
|
||||
63
src/sql/resolver/prepare/ob_prepare_resolver.cpp
Normal file
63
src/sql/resolver/prepare/ob_prepare_resolver.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 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_RESV
|
||||
|
||||
#include "sql/resolver/prepare/ob_prepare_resolver.h"
|
||||
#include "sql/resolver/ob_resolver_utils.h"
|
||||
namespace oceanbase {
|
||||
using namespace common;
|
||||
namespace sql {
|
||||
|
||||
int ObPrepareResolver::resolve(const ParseNode& parse_tree)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
ObPrepareStmt* prepare_stmt = NULL;
|
||||
const ParseNode* name_node = parse_tree.children_[0];
|
||||
const ParseNode* stmt_node = parse_tree.children_[1];
|
||||
if (OB_ISNULL(name_node) || OB_ISNULL(stmt_node)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid prepare node", K(name_node), K(stmt_node), K(ret));
|
||||
} else if (OB_ISNULL(prepare_stmt = create_stmt<ObPrepareStmt>())) {
|
||||
ret = OB_SQL_RESOLVER_NO_MEMORY;
|
||||
LOG_WARN("failed to create execute stmt", K(ret));
|
||||
} else {
|
||||
stmt_ = prepare_stmt;
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (T_IDENT != name_node->type_) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid name node", K(name_node->type_), K(ret));
|
||||
} else {
|
||||
prepare_stmt->set_prepare_name(ObString(name_node->str_len_, name_node->str_value_));
|
||||
}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
if (T_VARCHAR == stmt_node->type_ || T_HEX_STRING == stmt_node->type_ || T_OP_GET_USER_VAR == stmt_node->type_) {
|
||||
ObRawExpr* stmt_expr = NULL;
|
||||
if (OB_FAIL(ObResolverUtils::resolve_const_expr(params_, *stmt_node, stmt_expr, NULL))) {
|
||||
LOG_WARN("failed to resolve const expr", K(ret));
|
||||
} else {
|
||||
prepare_stmt->set_prepare_sql(stmt_expr);
|
||||
}
|
||||
} else {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("invalid name node", K(name_node->type_), K(ret));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
39
src/sql/resolver/prepare/ob_prepare_resolver.h
Normal file
39
src/sql/resolver/prepare/ob_prepare_resolver.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SRC_SQL_RESOLVER_PREPARE_OB_PREPARE_RESOLVER_H_
|
||||
#define OCEANBASE_SRC_SQL_RESOLVER_PREPARE_OB_PREPARE_RESOLVER_H_
|
||||
|
||||
#include "sql/resolver/ob_stmt_resolver.h"
|
||||
#include "sql/resolver/prepare/ob_prepare_stmt.h"
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObPrepareResolver : public ObStmtResolver {
|
||||
public:
|
||||
explicit ObPrepareResolver(ObResolverParams& params) : ObStmtResolver(params)
|
||||
{}
|
||||
virtual ~ObPrepareResolver()
|
||||
{}
|
||||
|
||||
virtual int resolve(const ParseNode& parse_tree);
|
||||
ObPrepareStmt* get_prepare_stmt()
|
||||
{
|
||||
return static_cast<ObPrepareStmt*>(stmt_);
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
||||
#endif /* OCEANBASE_SRC_SQL_RESOLVER_PREPARE_OB_PREPARE_RESOLVER_H_ */
|
||||
21
src/sql/resolver/prepare/ob_prepare_stmt.cpp
Normal file
21
src/sql/resolver/prepare/ob_prepare_stmt.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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_RESV
|
||||
|
||||
#include "sql/resolver/prepare/ob_prepare_stmt.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
namespace oceanbase {
|
||||
namespace sql {} // namespace sql
|
||||
} // namespace oceanbase
|
||||
57
src/sql/resolver/prepare/ob_prepare_stmt.h
Normal file
57
src/sql/resolver/prepare/ob_prepare_stmt.h
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SRC_SQL_RESOLVER_PREPARE_OB_PREPARE_STMT_H_
|
||||
#define OCEANBASE_SRC_SQL_RESOLVER_PREPARE_OB_PREPARE_STMT_H_
|
||||
|
||||
#include "lib/container/ob_array.h"
|
||||
#include "lib/string/ob_string.h"
|
||||
#include "sql/resolver/cmd/ob_cmd_stmt.h"
|
||||
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
class ObPrepareStmt : public ObCMDStmt {
|
||||
public:
|
||||
ObPrepareStmt() : ObCMDStmt(stmt::T_PREPARE), prepare_name_(), prepare_sql_(NULL)
|
||||
{}
|
||||
virtual ~ObPrepareStmt()
|
||||
{}
|
||||
|
||||
inline void set_prepare_name(const common::ObString& name)
|
||||
{
|
||||
prepare_name_ = name;
|
||||
}
|
||||
inline const common::ObString& get_prepare_name() const
|
||||
{
|
||||
return prepare_name_;
|
||||
}
|
||||
inline void set_prepare_sql(ObRawExpr* stmt)
|
||||
{
|
||||
prepare_sql_ = stmt;
|
||||
}
|
||||
inline const ObRawExpr* get_prepare_sql() const
|
||||
{
|
||||
return prepare_sql_;
|
||||
}
|
||||
|
||||
TO_STRING_KV(N_STMT_NAME, prepare_name_, N_PREPARE_SQL, prepare_sql_);
|
||||
|
||||
private:
|
||||
common::ObString prepare_name_;
|
||||
ObRawExpr* prepare_sql_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObPrepareStmt);
|
||||
};
|
||||
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
||||
#endif /* OCEANBASE_SRC_SQL_RESOLVER_PREPARE_OB_PREPARE_STMT_H_ */
|
||||
Reference in New Issue
Block a user