forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_sql_mode_manager.cpp
More file actions
84 lines (75 loc) · 2.46 KB
/
ob_sql_mode_manager.cpp
File metadata and controls
84 lines (75 loc) · 2.46 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
/**
* 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 "lib/string/ob_string.h"
#include "sql/ob_sql_mode_manager.h"
using namespace oceanbase::common;
namespace oceanbase {
namespace sql {
int compatibility_mode2index(const common::ObCompatibilityMode mode, int64_t& index)
{
static const ObCompatibilityMode modes[] = {OCEANBASE_MODE, MYSQL_MODE, ORACLE_MODE};
int ret = OB_ENTRY_NOT_EXIST;
for (int64_t i = 0; OB_ENTRY_NOT_EXIST == ret && i < ARRAYSIZEOF(modes); ++i) {
if (mode == modes[i]) {
index = i;
ret = OB_SUCCESS;
}
}
return ret;
}
/*
int ObSQLModeManager::get_compatibility_index(ObCompatibilityMode comp_mode, int64_t &index) const
{
int ret = OB_ENTRY_NOT_EXIST;
for (int64_t i = 0; i < COMPATIBILITY_MODE_COUNT && OB_ENTRY_NOT_EXIST == ret; i++) {
if (comp_mode == sql_standard_[i].comp_mode_) {
index = i;
ret = OB_SUCCESS;
}
}
return ret;
}
int ObSQLModeManager::set_compatibility_mode(ObCompatibilityMode comp_mode)
{
int ret = OB_SUCCESS;
int64_t index = -1;
if (OB_FAIL(get_compatibility_index(comp_mode, index))) {
OB_LOG(WARN, "fail to get sql mode", K(ret), K(comp_mode));
} else {
current_mode_index_ = index;
}
return ret;
}
ObCompatibilityMode ObSQLModeManager::get_compatibility_mode() const
{
return sql_standard_[current_mode_index_].comp_mode_;
}
void ObSQLModeManager::reset()
{
sql_standard_[0].sql_mode_ = DEFAULT_OCEANBASE_MODE;
sql_standard_[0].comp_mode_ = ObCompatibilityMode::OCEANBASE_MODE;
sql_standard_[1].sql_mode_ = DEFAULT_MYSQL_MODE;
sql_standard_[1].comp_mode_ = ObCompatibilityMode::MYSQL_MODE;
sql_standard_[2].sql_mode_ = DEFAULT_ORACLE_MODE;
sql_standard_[2].comp_mode_ = ObCompatibilityMode::ORACLE_MODE;
}
ObSQLMode ObSQLModeManager::get_sql_mode() const
{
return sql_standard_[current_mode_index_].sql_mode_;
}
void ObSQLModeManager::set_sql_mode(ObSQLMode mode)
{
sql_standard_[current_mode_index_].sql_mode_ = mode;
}
*/
} // namespace sql
} // namespace oceanbase