forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathob_mock_resolver.cpp
More file actions
95 lines (94 loc) · 2.95 KB
/
Copy pathob_mock_resolver.cpp
File metadata and controls
95 lines (94 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Copyright (c) 2025 OceanBase.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define USING_LOG_PREFIX SQL_RESV
#include "sql/resolver/cmd/ob_mock_resolver.h"
#include "sql/resolver/cmd/ob_mock_stmt.h"
namespace oceanbase
{
using namespace oceanbase::common;
namespace sql
{
int ObMockResolver::resolve(const ParseNode& parse_tree)
{
int ret = OB_SUCCESS;
switch (parse_tree.type_) {
case T_FLUSH_PRIVILEGES:
case T_INSTALL_PLUGIN:
case T_UNINSTALL_PLUGIN:
case T_FLUSH_MOCK:
case T_FLUSH_TABLE_MOCK:
case T_HANDLER_MOCK:
case T_SHOW_PLUGINS:
case T_REPAIR_TABLE:
case T_CHECKSUM_TABLE:
case T_CACHE_INDEX:
case T_LOAD_INDEX_INTO_CACHE:
case T_CREATE_SERVER:
case T_ALTER_SERVER:
case T_DROP_SERVER:
case T_CREATE_LOGFILE_GROUP:
case T_ALTER_LOGFILE_GROUP:
case T_DROP_LOGFILE_GROUP:
case T_GRANT_PROXY:
case T_REVOKE_PROXY:
{
ObMockStmt *mock_stmt = NULL;
if (OB_UNLIKELY(NULL == (mock_stmt = create_stmt<ObMockStmt>()))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to create mock stmt");
} else {
const stmt::StmtType stmt_code = type_convert(parse_tree.type_);
if (stmt_code == stmt::T_NONE) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("stmt code is null", K(ret));
} else {
mock_stmt->set_stmt_type(stmt_code);
}
}
break;
}
case T_FLUSH_MOCK_LIST:
{
ObMockStmt *mock_stmt = NULL;
if (OB_UNLIKELY(NULL == (mock_stmt = create_stmt<ObMockStmt>()))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to create mock stmt");
} else {
for (int64_t i = 0; OB_SUCC(ret) && i < parse_tree.num_child_; ++i) {
ParseNode *node = parse_tree.children_[i];
if (OB_NOT_NULL(node)) {
if (node->type_ != T_FLUSH_MOCK && node->type_ != T_FLUSH_PRIVILEGES) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected parse tree type", K(ret), K(node->type_));
} else if (OB_FAIL(mock_stmt->add_stmt(type_convert(node->type_)))) {
LOG_WARN("failed to add stmt", K(ret), K(node->type_));
}
}
}
if (OB_SUCC(ret)) {
mock_stmt->set_stmt_type(stmt::T_FLUSH_MOCK_LIST);
}
}
break;
}
default:
ret = OB_ERR_UNEXPECTED;
LOG_WARN("unexpected parse tree type", K(ret), K(parse_tree.type_));
}
return ret;
}
}
}