forked from oceanbase/oceanbase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathob_sql_init.h
More file actions
117 lines (109 loc) · 4.38 KB
/
ob_sql_init.h
File metadata and controls
117 lines (109 loc) · 4.38 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* 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 _OB_SQL_INIT_H
#define _OB_SQL_INIT_H 1
#include "lib/alloc/malloc_hook.h"
#include "engine/ob_phy_operator.h"
#include "engine/ob_physical_plan.h"
#include "sql/engine/expr/ob_sql_expression.h"
#include "sql/engine/expr/ob_expr_operator.h"
#include "sql/engine/expr/ob_expr_uuid.h"
#include "sql/engine/expr/ob_expr_res_type_map.h"
#include "sql/engine/expr/ob_expr_extra_info_factory.h"
#include "sql/plan_cache/ob_plan_cache_value.h"
#include "sql/plan_cache/ob_plan_set.h"
#include "sql/executor/ob_root_transmit.h"
#include "sql/executor/ob_distributed_scheduler.h"
#include "sql/executor/ob_task_runner_notifier_service.h"
#include "sql/executor/ob_interm_result_manager.h"
#include "sql/executor/ob_interm_result_pool.h"
#include "sql/executor/ob_mini_task_executor.h"
#include "sql/engine/px/ob_px_sqc_handler.h"
#include "sql/ob_end_trans_callback.h"
#include "sql/plan_cache/ob_cache_object_factory.h"
#include "lib/alloc/ob_malloc_allocator.h"
#include "share/object/ob_obj_cast.h"
#include "engine/ob_serializable_function.h"
namespace oceanbase {
namespace sql {
// inline void register_phy_operator_classes()
//{
// ObRootTransmit *root_trans = new (std::nothrow) ObRootTransmit();
// delete root_trans;
//}
inline int init_sql_factories()
{
// ATTENTION: don't delete this log, it's used to init thread local variable LogBufferMgr in ObLog.
SQL_LOG(INFO, "init sql factories");
int ret = common::OB_SUCCESS;
if (OB_FAIL(ObAPMiniTaskMgrGFactory::get_instance()->init())) {
} else if (OB_FAIL(ObPxSqcHandlerFactory::get_instance()->init())) {
SQL_LOG(ERROR, "failed to init sqc handler", K(ret));
} else {
ObExprOperatorFactory::register_expr_operators();
ObExprExtraInfoFactory::register_expr_extra_infos();
// register_phy_operator_classes();
}
if (OB_FAIL(ret)) {
SQL_LOG(ERROR, "failed to init sql factories", K(ret));
}
return ret;
}
inline int init_sql_expr_static_var()
{
int ret = common::OB_SUCCESS;
lib::ObMallocAllocator* allocator = NULL;
const lib::ObMemAttr attr(common::OB_SYS_TENANT_ID, ObModIds::OB_NUMBER);
if (OB_FAIL(ObExprTRDateFormat::init())) {
SQL_LOG(ERROR, "failed to init vars in oracle trunc", K(ret));
} else if (OB_FAIL(ObExprUuid::init())) {
SQL_LOG(ERROR, "failed to init vars in uuid", K(ret));
} else if (OB_ISNULL(allocator = lib::ObMallocAllocator::get_instance())) {
ret = OB_ERR_UNEXPECTED;
SQL_LOG(ERROR, "allocator is null", K(ret));
} else if (OB_FAIL(common::ObNumberConstValue::init(*allocator, attr))) {
SQL_LOG(ERROR, "failed to init ObNumberConstValue", K(ret));
} else if (OB_FAIL(ARITH_RESULT_TYPE_ORACLE.init())) {
SQL_LOG(ERROR, "failed to init ORACLE_ARITH_RESULT_TYPE", K(ret));
} else if (OB_FAIL(ObCharsetUtils::init(*allocator))) {
SQL_LOG(ERROR, "fail to init ObCharsetUtils", K(ret));
}
return ret;
}
inline int init_sql_executor_singletons()
{
int ret = common::OB_SUCCESS;
if (OB_FAIL(ObIntermResultItemPool::build_instance())) {
SQL_LOG(ERROR, "fail to build ObIntermResultItemPool instance", K(ret));
} else if (OB_FAIL(ObIntermResultPool::build_instance())) {
SQL_LOG(ERROR, "fail to build ObIntermResultPool instance", K(ret));
} else if (OB_FAIL(ObIntermResultManager::build_instance())) {
SQL_LOG(ERROR, "fail to build ObIntermResultManager instance", K(ret));
} else if (OB_FAIL(ObTaskRunnerNotifierService::build_instance())) {
SQL_LOG(ERROR, "fail to build ObTaskRunnerNotifierService instance", K(ret));
} else if (OB_FAIL(ObDistributedSchedulerManager::build_instance())) {
SQL_LOG(ERROR, "fail to build ObDistributedSchedulerManager instance", K(ret));
} else {
ObFuncSerialization::init();
}
if (OB_FAIL(ret)) {
SQL_LOG(ERROR, "fail to init sql singletons", K(ret));
}
return ret;
}
inline void print_sql_stat()
{
// do nothing
}
} // end namespace sql
} // end namespace oceanbase
#endif /* _OB_SQL_INIT_H */