forked from oceanbase/seekdb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathob_sql_temp_table.h
More file actions
143 lines (127 loc) · 4.76 KB
/
Copy pathob_sql_temp_table.h
File metadata and controls
143 lines (127 loc) · 4.76 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
* 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.
*/
#ifndef OCEANBASE_SQL_TEMP_TABLE_
#define OCEANBASE_SQL_TEMP_TABLE_
#include "sql/resolver/dml/ob_dml_stmt.h"
#include "sql/resolver/expr/ob_raw_expr.h"
#include "sql/optimizer/ob_sharding_info.h"
#include "observer/ob_server_struct.h"
namespace oceanbase
{
namespace sql
{
struct ObTempTableResultInfo
{
OB_UNIS_VERSION(1);
public:
ObTempTableResultInfo() : addr_(),
interm_result_ids_() {}
virtual ~ObTempTableResultInfo() {}
TO_STRING_KV(K_(addr),
K_(interm_result_ids));
// Server where data is located
ObAddr addr_;
// Dataset key
ObSEArray<uint64_t, 2> interm_result_ids_;
};
class ObSqlTempTableCtx
{
OB_UNIS_VERSION(1);
public:
ObSqlTempTableCtx() : interm_result_infos_(),
temp_table_id_(0),
is_local_interm_result_(true) {}
virtual ~ObSqlTempTableCtx() {}
TO_STRING_KV(K_(interm_result_infos),
K_(temp_table_id),
K_(is_local_interm_result));
// Distribution information of the result set: machine and KEY
ObSEArray<ObTempTableResultInfo, 2> interm_result_infos_;
// Result set belonging to the temp table
uint64_t temp_table_id_;
// Is the result set local
bool is_local_interm_result_;
};
typedef ObIArray<ObRawExpr *> ObRawExprCondition;
struct TableInfo {
TableInfo()
:table_filters_(),
table_item_(NULL),
upper_stmt_(NULL)
{}
virtual ~TableInfo(){}
TO_STRING_KV(
K_(table_filters),
K_(table_item),
K_(upper_stmt)
);
ObSEArray<ObRawExpr *, 4, common::ModulePageAllocator, true> table_filters_;
ObSEArray<ObRawExprCondition *, 4, common::ModulePageAllocator, true> filter_conditions_;
TableItem *table_item_;
ObDMLStmt* upper_stmt_;
};
class ObSqlTempTableInfo
{
public:
ObSqlTempTableInfo() : temp_table_id_(OB_INVALID_ID),
table_name_(),
table_query_(NULL),
table_plan_(NULL) {}
virtual ~ObSqlTempTableInfo() {}
void reset() {
temp_table_id_ = OB_INVALID_ID;
table_name_.reset();
table_query_ = NULL;
table_plan_ = NULL;
table_infos_.reset();
}
TO_STRING_KV(K_(temp_table_id),
K_(table_name),
K_(table_infos));
static int collect_temp_tables(ObIAllocator &allocator,
ObDMLStmt &stmt,
ObIArray<ObSqlTempTableInfo*> &temp_table_infos,
ObQueryCtx *query_ctx,
bool do_collect_filter);
static int collect_specified_temp_table(ObIAllocator &allocator,
ObSelectStmt *specified_query,
const ObIArray<ObDMLStmt *> &upper_stmts,
const ObIArray<TableItem *> &table_items,
ObSqlTempTableInfo &temp_table_info,
bool &all_has_filter);
static int collect_temp_table_filters(ObDMLStmt *stmt,
TableItem *table,
ObIArray<ObRawExpr*> &table_filters,
ObIArray<ObRawExprCondition*> &filter_conditions);
static int collect_table_filters_in_joined_table(JoinedTable *table,
uint64_t table_id,
const ObSqlBitSet<> &table_ids,
ObIArray<ObRawExpr*> &table_filters,
ObIArray<ObRawExprCondition*> &filter_conditions);
static int get_candi_exprs(const ObSqlBitSet<> &table_ids,
ObIArray<ObRawExpr*> &exprs,
ObIArray<ObRawExpr*> &candi_exprs,
ObIArray<ObRawExprCondition*> &candi_conditions);
public:
uint64_t temp_table_id_;
common::ObString table_name_;
ObSelectStmt *table_query_;
ObLogicalOperator *table_plan_;
ObSEArray<TableInfo, 8, common::ModulePageAllocator, true> table_infos_;
};
} /* ns sql*/
} /* ns oceanbase */
#endif //OCEANBASE_SQL_TEMP_TABLE_