ob_transform_pre_process.h 23.4 KB
Newer Older
O
oceanbase-admin 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
/**
 * 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_TRANSFORM_PRE_PROCESS_H_
#define OB_TRANSFORM_PRE_PROCESS_H_

#include "sql/rewrite/ob_transform_rule.h"
#include "sql/resolver/dml/ob_select_stmt.h"
#include "sql/rewrite/ob_transform_utils.h"
#include "sql/ob_sql_context.h"

W
wangzelin.wzl 已提交
21 22
namespace oceanbase
{
O
oceanbase-admin 已提交
23

W
wangzelin.wzl 已提交
24 25
namespace sql
{
O
oceanbase-admin 已提交
26 27 28

typedef std::pair<uint64_t, uint64_t> JoinTableIdPair;

W
wangzelin.wzl 已提交
29 30
class ObTransformPreProcess: public ObTransformRule
{
G
gm 已提交
31
public:
W
wangzelin.wzl 已提交
32 33 34 35 36 37 38 39 40 41 42 43
  explicit ObTransformPreProcess(ObTransformerCtx *ctx)
     : ObTransformRule(ctx, TransMethod::POST_ORDER) { }
  virtual ~ObTransformPreProcess() {}

  virtual int transform_one_stmt(common::ObIArray<ObParentDMLStmt> &parent_stmts,
                                 ObDMLStmt *&stmt,
                                 bool &trans_happened) override;

  static int transform_expr(ObRawExprFactory &expr_factory,
                            const ObSQLSessionInfo &session,
                            ObRawExpr *&expr,
                            bool &trans_happened);
G
gm 已提交
44
private:
W
wangzelin.wzl 已提交
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
  virtual int need_transform(const common::ObIArray<ObParentDMLStmt> &parent_stmts,
                             const int64_t current_level,
                             const ObDMLStmt &stmt,
                             bool &need_trans) override;
// used for transform in expr to or exprs
struct DistinctObjMeta
{
  ObObjType obj_type_;
  ObCollationType coll_type_;
  ObCollationLevel coll_level_;

  DistinctObjMeta(ObObjType obj_type, ObCollationType coll_type, ObCollationLevel coll_level)
    : obj_type_(obj_type), coll_type_(coll_type), coll_level_(coll_level)
  {
    if (!ObDatumFuncs::is_string_type(obj_type_)) {
      coll_type_ = CS_TYPE_MAX;
      coll_level_ = CS_LEVEL_INVALID;
O
oceanbase-admin 已提交
62
    }
W
wangzelin.wzl 已提交
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
  }
  DistinctObjMeta()
    : obj_type_(common::ObMaxType), coll_type_(common::CS_TYPE_MAX) , coll_level_(CS_LEVEL_INVALID){}

  bool operator==(const DistinctObjMeta &other) const
  {
    bool cs_level_equal = lib::is_oracle_mode() ? true : (coll_level_ == other.coll_level_);
    return obj_type_ == other.obj_type_ && coll_type_ == other.coll_type_ && cs_level_equal;
  }
  TO_STRING_KV(K_(obj_type), K_(coll_type));
};

  /*
   * following functions are used to add all rowkey columns
   */
  int add_all_rowkey_columns_to_stmt(ObDMLStmt *stmt, bool &trans_happened);
  int add_all_rowkey_columns_to_stmt(const ObTableSchema &table_schema,
                                     const TableItem &table_item,
                                     ObRawExprFactory &expr_factory,
                                     ObDMLStmt &stmt,
                                     ObIArray<ColumnItem> &column_items);
O
oceanbase-admin 已提交
84 85 86 87

  /*
   * following functions are for grouping sets and multi rollup
   */
W
wangzelin.wzl 已提交
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
  int transform_for_grouping_sets_and_multi_rollup(ObDMLStmt *&stmt, bool &trans_happened);
  int add_generated_table_as_temp_table(ObTransformerCtx *ctx,
                                        ObDMLStmt *stmt);
  int replace_with_set_stmt_view(ObSelectStmt *origin_stmt,
                                 ObSelectStmt *grouping_sets_view,
                                 ObSelectStmt *&union_stmt);
  int create_set_view_stmt(ObSelectStmt *origin_stmt,
                           ObSelectStmt *&set_view_stmt);
  int create_select_list_from_grouping_sets(ObSelectStmt *stmt,
                                            common::ObIArray<ObGroupbyExpr> &groupby_exprs_list,
                                            int64_t cur_index,
                                            ObIArray<ObRawExpr*> &old_exprs,
                                            ObIArray<ObRawExpr*> &new_exprs,
                                            int64_t origin_groupby_num = -1);
  int64_t get_total_count_of_groupby_stmt(ObIArray<ObGroupingSetsItem> &grouping_sets_items,
                                          ObIArray<ObMultiRollupItem> &multi_rollup_items);

  int get_groupby_exprs_list(ObIArray<ObGroupingSetsItem> &grouping_sets_items,
                             ObIArray<ObMultiRollupItem> &multi_rollup_items,
                             ObIArray<ObGroupbyExpr> &groupby_exprs_list);

  int expand_multi_rollup_items(ObIArray<ObMultiRollupItem> &multi_rollup_items,
                                ObIArray<ObGroupbyExpr> &rollup_list_exprs);

  int combination_two_rollup_list(ObIArray<ObGroupbyExpr> &rollup_list_exprs1,
                                  ObIArray<ObGroupbyExpr> &rollup_list_exprs2,
                                  ObIArray<ObGroupbyExpr> &rollup_list_exprs);
O
oceanbase-admin 已提交
115

W
wangzelin.wzl 已提交
116 117 118 119
  /*
   * following functions are for hierarchical query
   */
  int transform_for_hierarchical_query(ObDMLStmt *stmt, bool &trans_happened);
O
oceanbase-admin 已提交
120

W
wangzelin.wzl 已提交
121 122 123 124 125 126 127
  /**
   * @brief create_connect_by_view
   * 为层次查询构建一个spj,封装所有与层次查询相关的计算
   * 包括所有的from item、where condition内的join条件
   * 外层引用的connect by相关运算及伪列作为视图投影
   */
  int create_connect_by_view(ObSelectStmt &stmt);
O
oceanbase-admin 已提交
128

W
wangzelin.wzl 已提交
129 130 131 132 133 134
  /**
   * @brief create_and_mock_join_view
   * 将所有的from item及其相关的连接谓词分离成一个spj
   * 并且copy一份构成connect by的右孩子节点
   */
  int create_and_mock_join_view(ObSelectStmt &stmt);
O
oceanbase-admin 已提交
135

W
wangzelin.wzl 已提交
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
  /**
   * @brirf classify_join_conds
   * 将stmt的where condition分成普通的连接谓词和其他谓词
   * 普通的连接谓词:引用两张表以上的谓词,并且不含有LEVEL、CONNECT_BY_ISLEAF、
   * CONNECT_BY_ISCYCLE、PRIOR、CONNECT_BY_ROOT
   */
  int classify_join_conds(ObSelectStmt &stmt,
                          ObIArray<ObRawExpr *> &normal_join_conds,
                          ObIArray<ObRawExpr *> &other_conds);

  int is_cond_in_one_from_item(ObSelectStmt &stmt, ObRawExpr *expr, bool &in_from_item);

  int extract_connect_by_related_exprs(ObSelectStmt &stmt, ObIArray<ObRawExpr*> &special_exprs);

  int extract_connect_by_related_exprs(ObRawExpr *expr, ObIArray<ObRawExpr*> &special_exprs);

  uint64_t get_real_tid(uint64_t tid, ObSelectStmt &stmt);

	/*
	 * follow functions are used for eliminate having
	 */
	int eliminate_having(ObDMLStmt *stmt, bool &trans_happened);

	/*
	 * following functions are used to replace func is serving tenant
	 */
	int replace_func_is_serving_tenant(ObDMLStmt *&stmt, bool &trans_happened);
	int recursive_replace_func_is_serving_tenant(ObDMLStmt &stmt,
                                               ObRawExpr *&cond_expr,
                                               bool &trans_happened);
	int calc_const_raw_expr_and_get_int(const ObStmt &stmt,
                                      ObRawExpr *const_expr,
                                      ObExecContext &exec_ctx,
                                      ObSQLSessionInfo *session,
                                      ObIAllocator &allocator,
                                      int64_t &result);

  int transform_for_merge_into(ObDMLStmt *stmt, bool &trans_happened);

	/*
	 * following functions are used for temporary and se table
	 */
	int transform_for_temporary_table(ObDMLStmt *&stmt, bool &trans_happened);
	int add_filter_for_temporary_table(ObDMLStmt &stmt,
	                                   const TableItem &table_item);
	int collect_all_tableitem(ObDMLStmt *stmt,
                            TableItem *table_item,
                            common::ObArray<TableItem*> &table_item_list);

  int transform_exprs(ObDMLStmt *stmt, bool &trans_happened);
  int transform_for_nested_aggregate(ObDMLStmt *&stmt, bool &trans_happened);
  int generate_child_level_aggr_stmt(ObSelectStmt *stmt, ObSelectStmt *&sub_stmt);
  int get_first_level_output_exprs(ObSelectStmt *sub_stmt,
                                   common::ObIArray<ObRawExpr*>& inner_aggr_exprs);
  int generate_parent_level_aggr_stmt(ObSelectStmt *&stmt, ObSelectStmt *sub_stmt);
  int remove_nested_aggr_exprs(ObSelectStmt *stmt);
  int construct_column_items_from_exprs(const ObIArray<ObRawExpr*> &column_exprs,
                                        ObIArray<ColumnItem> &column_items);
O
oceanbase-admin 已提交
194
  /*
W
wangzelin.wzl 已提交
195
   * following functions are used to transform in_expr to or_expr
O
oceanbase-admin 已提交
196
   */
W
wangzelin.wzl 已提交
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
  static int transform_in_or_notin_expr_with_row(ObRawExprFactory &expr_factory,
                                                 const ObSQLSessionInfo &session,
                                                 const bool is_in_expr,
                                                 ObRawExpr *&in_expr,
                                                 bool &trans_happened);

  static int transform_in_or_notin_expr_without_row(ObRawExprFactory &expr_factory,
                                                 const ObSQLSessionInfo &session,
                                                 const bool is_in_expr,
                                                 ObRawExpr *&in_epxr,
                                                 bool &trans_happened);

  static int create_partial_expr(ObRawExprFactory &expr_factory,
                                 ObRawExpr *left_expr,
                                 ObIArray<ObRawExpr*> &same_type_exprs,
                                 const bool is_in_expr,
                                 ObIArray<ObRawExpr*> &transed_in_exprs);
O
oceanbase-admin 已提交
214

W
wangzelin.wzl 已提交
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
  /*
   * following functions are used to transform arg_case_expr to case_expr
   */
  static int transform_arg_case_recursively(ObRawExprFactory &expr_factory,
                                                const ObSQLSessionInfo &session,
                                                ObRawExpr *&expr,
                                                bool &trans_happened);
  static int transform_arg_case_expr(ObRawExprFactory &expr_factory,
                                     const ObSQLSessionInfo &session,
                                     ObRawExpr *&expr,
                                     bool &trans_happened);
  static int create_equal_expr_for_case_expr(ObRawExprFactory &expr_factory,
                                             const ObSQLSessionInfo &session,
                                             ObRawExpr *arg_expr,
                                             ObRawExpr *when_expr,
                                             const ObExprResType &case_res_type,
                                             ObOpRawExpr *&equal_expr);
  static int add_row_type_to_array_no_dup(common::ObIArray<ObSEArray<DistinctObjMeta, 4>> &row_type_array,
                                          const ObSEArray<DistinctObjMeta, 4> &row_type);

  static bool is_same_row_type(const common::ObIArray<DistinctObjMeta> &left,
                               const common::ObIArray<DistinctObjMeta> &right);

  static int get_final_transed_or_and_expr(
      ObRawExprFactory &expr_factory,
      const ObSQLSessionInfo &session,
      const bool is_in_expr,
      common::ObIArray<ObRawExpr *> &transed_in_exprs,
      ObRawExpr *&final_or_expr);

  static int check_and_transform_in_or_notin(ObRawExprFactory &expr_factory,
                                             const ObSQLSessionInfo &session,
                                             ObRawExpr *&in_expr,
                                             bool &trans_happened);
  static int replace_in_or_notin_recursively(ObRawExprFactory &expr_factory,
                                             const ObSQLSessionInfo &session,
                                             ObRawExpr *&root_expr,
                                             bool &trans_happened);
  int transformer_aggr_expr(ObDMLStmt *stmt, bool &trans_happened);
  int transform_rownum_as_limit_offset(const ObIArray<ObParentDMLStmt> &parent_stmts,
                                       ObDMLStmt *&stmt,
                                       bool &trans_happened);
  int transform_common_rownum_as_limit(ObDMLStmt *&stmt, bool &trans_happened);
  int try_transform_common_rownum_as_limit(ObDMLStmt *stmt, ObRawExpr *&limit_expr);
  int transform_generated_rownum_as_limit(const ObIArray<ObParentDMLStmt> &parent_stmts,
                                          ObDMLStmt *stmt,
                                          bool &trans_happened);
  int try_transform_generated_rownum_as_limit_offset(ObDMLStmt *upper_stmt,
                                                     ObSelectStmt *select_stmt,
                                                     ObRawExpr *&limit_expr,
                                                     ObRawExpr *&offset_expr);
  int transform_generated_rownum_eq_cond(ObRawExpr *eq_value,
                                         ObRawExpr *&limit_expr,
                                         ObRawExpr *&offset_expr);
  int expand_grouping_sets_items(common::ObIArray<ObGroupingSetsItem> &grouping_sets_items,
                                 common::ObIArray<ObGroupbyExpr> &grouping_sets_exprs);
  int replace_select_and_having_exprs(ObSelectStmt *select_stmt,
                                      ObIArray<ObRawExpr*> &old_exprs,
                                      ObIArray<ObRawExpr*> &new_exprs,
                                      ObIArray<ObGroupbyExpr> &groupby_exprs_list,
                                      int64_t cur_index = -1,
                                      int64_t origin_groupby_num = -1);
  int replace_stmt_special_exprs(ObSelectStmt *select_stmt,
                                 ObRawExpr *&expr,
                                 common::ObIArray<ObRawExpr*> &old_exprs,
                                 common::ObIArray<ObRawExpr*> &new_exprs,
                                 ObIArray<ObGroupbyExpr> &groupby_exprs_list,
                                 bool ignore_const = false,
                                 int64_t cur_index = -1,
                                 int64_t origin_groupby_num = -1);
  int replace_aggr_exprs_in_select_and_having(ObRawExpr *&expr,
                                              ObIArray<ObRawExpr*> &groupby_exprs,
                                              ObIArray<ObRawExpr*> &rollup_exprs,
                                              ObIArray<ObAggFunRawExpr*> &aggr_items,
                                              ObIArray<ObGroupbyExpr> &groupby_exprs_list,
                                              int64_t cur_index,
                                              ObIArray<ObRawExpr*> &old_exprs,
                                              ObIArray<ObRawExpr*> &new_exprs,
                                              ObRelIds &rel_ids,
                                              int64_t origin_groupby_num = -1,
                                              bool using_rel_ids = true);
  int calc_grouping_in_grouping_sets(ObRawExpr *&expr,
                                     ObIArray<ObRawExpr*> &groupby_exprs,
                                     ObIArray<ObRawExpr*> &rollup_exprs,
                                     ObIArray<ObAggFunRawExpr*> &aggr_items,
                                     ObIArray<ObRawExpr*> &old_exprs,
                                     ObIArray<ObRawExpr*> &new_exprs,
                                     ObRelIds &rel_ids,
                                     bool using_rel_ids = true);
  int calc_grouping_id_in_grouping_sets(ObRawExpr *&expr,
                                        ObIArray<ObRawExpr*> &groupby_exprs,
                                        ObIArray<ObRawExpr*> &rollup_exprs,
                                        ObIArray<ObAggFunRawExpr*> &aggr_items,
                                        ObIArray<ObRawExpr*> &old_exprs,
                                        ObIArray<ObRawExpr*> &new_exprs,
                                        ObRelIds &rel_ids,
                                        bool using_rel_ids = true);
  int calc_group_id_in_grouping_sets(ObRawExpr *&expr,
                                     ObIArray<ObRawExpr*> &groupby_exprs,
                                     ObIArray<ObRawExpr*> &rollup_exprs,
                                     ObIArray<ObAggFunRawExpr*> &aggr_items,
                                     ObIArray<ObGroupbyExpr> &groupby_exprs_list,
                                     int64_t cur_index,
                                     ObIArray<ObRawExpr*> &old_exprs,
                                     ObIArray<ObRawExpr*> &new_exprs,
                                     ObRelIds &rel_ids,
                                     int64_t origin_groupby_num = -1,
                                     bool using_rel_ids = true);
  bool is_select_expr_in_other_groupby_exprs(ObRawExpr *expr,
                                             ObIArray<ObGroupbyExpr> &groupby_exprs_list,
                                             int64_t cur_index);
  bool is_expr_in_select_item(ObIArray<SelectItem> &select_items,
                              ObRawExpr *expr);
  int extract_select_expr_and_replace_expr(ObRawExpr *expr,
                                           ObIArray<ObRawExpr*> &groupby_exprs,
                                           ObIArray<ObRawExpr*> &rollup_exprs,
                                           ObIArray<ObAggFunRawExpr*> &aggr_items,
                                           ObIArray<ObGroupbyExpr> &groupby_exprs_list,
                                           int64_t cur_index,
                                           ObIArray<SelectItem> &select_items,
                                           ObIArray<ObRawExpr*> &old_exprs,
                                           ObIArray<ObRawExpr*> &new_exprs,
                                           ObRelIds &rel_ids,
                                           int64_t origin_groupby_num = -1);
  int extract_stmt_replace_expr(ObSelectStmt *select_stmt, ObIArray<ObRawExpr*> &old_exprs);
  int extract_replace_expr_from_select_expr(ObRawExpr *expr,
                                            ObSelectStmt *select_stmt,
                                            ObIArray<ObRawExpr*> &old_exprs);

  int replace_group_id_in_stmt(ObSelectStmt *stmt);
  int replace_group_id_in_expr_recursive(ObRawExpr *&expr);
   /*
   * following functions are used for transform rowid in subquery
   */
  int transformer_rowid_expr(ObDMLStmt *stmt, bool &trans_happened);
O
oceanbase-admin 已提交
350

W
wangzelin.wzl 已提交
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
  int do_transform_rowid_expr(ObDMLStmt &stmt,
                              ObColumnRefRawExpr *empty_rowid_col_expr,
                              ObRawExpr *&new_rowid_expr);
  int recursive_generate_rowid_select_item(ObSelectStmt *select_stmt,
                                           ObRawExpr *&rowid_expr);
  int check_can_gen_rowid_on_this_table(ObSelectStmt *select_stmt,
                                        TableItem *this_item,
                                        bool &can_gen_rowid);
  int build_rowid_expr(ObSelectStmt *stmt,
                       TableItem *table_item,
                       ObSysFunRawExpr *&rowid_expr);
  int create_rowid_item_for_stmt(ObDMLStmt *select_stmt,
                                 TableItem *table_item,
                                 ObRawExpr *&rowid_expr);
  int add_rowid_constraint(ObDMLStmt &stmt);
O
oceanbase-admin 已提交
366

W
wangzelin.wzl 已提交
367
  int check_stmt_contain_param_expr(ObDMLStmt *stmt, bool &contain);
O
oceanbase-admin 已提交
368

W
wangzelin.wzl 已提交
369
  int check_stmt_can_batch(ObDMLStmt *batch_stmt, bool &can_batch);
O
oceanbase-admin 已提交
370

W
wangzelin.wzl 已提交
371
  int check_contain_param_expr(ObDMLStmt *stmt, TableItem *table_item, bool &contain_param);
O
oceanbase-admin 已提交
372

W
wangzelin.wzl 已提交
373 374 375 376
  int transform_for_upd_del_batch_stmt(ObDMLStmt *batch_stmt,
                                       ObSelectStmt* inner_view_stmt,
                                       bool &trans_happened);
  int create_inner_view_stmt(ObDMLStmt *batch_stmt, ObSelectStmt*& inner_view_stmt);
O
oceanbase-admin 已提交
377

W
wangzelin.wzl 已提交
378 379
  int transform_for_ins_batch_stmt(ObDMLStmt *batch_stmt, bool &trans_happened);
  int transform_for_batch_stmt(ObDMLStmt *batch_stmt, bool &trans_happened);
O
oceanbase-admin 已提交
380

W
wangzelin.wzl 已提交
381 382 383 384
  int formalize_batch_stmt(ObDMLStmt *batch_stmt,
                          ObSelectStmt* inner_view_stmt,
                          const ObIArray<ObRawExpr *> &other_exprs,
                          bool &trans_happened);
O
oceanbase-admin 已提交
385

W
wangzelin.wzl 已提交
386
  int mock_select_list_for_upd_del(ObDMLStmt &batch_stmt, ObSelectStmt &inner_view);
O
oceanbase-admin 已提交
387

W
wangzelin.wzl 已提交
388 389 390
  int mock_select_list_for_ins_values(ObDMLStmt &batch_stmt,
                                      ObSelectStmt &inner_view,
                                      bool &trans_happened);
O
oceanbase-admin 已提交
391

W
wangzelin.wzl 已提交
392 393 394
  int mock_select_list_for_ins_select(ObDMLStmt &batch_stmt,
                                      ObSelectStmt &inner_view,
                                      bool &trans_happened);
O
oceanbase-admin 已提交
395

W
wangzelin.wzl 已提交
396
  int create_stmt_id_expr(ObPseudoColumnRawExpr *&stmt_id_expr);
O
oceanbase-admin 已提交
397

W
wangzelin.wzl 已提交
398 399 400 401 402
  int create_params_expr(ObPseudoColumnRawExpr *&pseudo_param_expr,
                         ObRawExpr *origin_param_expr,
                         int64_t name_id);
  int create_params_exprs(ObDMLStmt &batch_stmt,
                         ObIArray<ObRawExpr*> &params_exprs);
O
oceanbase-admin 已提交
403

W
wangzelin.wzl 已提交
404
  int mock_select_list_for_inner_view(ObDMLStmt &batch_stmt, ObSelectStmt &inner_view);
O
oceanbase-admin 已提交
405

W
wangzelin.wzl 已提交
406
  int transform_full_outer_join(ObDMLStmt *&stmt, bool &trans_happened);
407

W
wangzelin.wzl 已提交
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
  int check_join_condition(ObDMLStmt *stmt,
                           JoinedTable *table,
                           bool &has_equal,
                           bool &has_subquery);

  /**
   * @brief recursively_eliminate_full_join
   * 以左-右-后的方式后续遍历from item及semi from item中的joined_table结构
   */
  int recursively_eliminate_full_join(ObDMLStmt &stmt,
                                      TableItem &table_item,
                                      bool &trans_happened);

  /**
   * @brief expand_full_outer_join
   * for select stmt contains a single full outer join, expand to left join union all anti join
O
oceanbase-admin 已提交
424
   */
W
wangzelin.wzl 已提交
425 426 427 428 429 430 431 432 433 434
  int expand_full_outer_join(ObSelectStmt *&ref_query);

  int create_select_items_for_semi_join(ObDMLStmt *stmt,
                                        TableItem *from_table_item,
                                        const ObIArray<SelectItem> &select_items,
                                        ObIArray<SelectItem> &output_select_items);

  int switch_left_outer_to_semi_join(ObSelectStmt *&sub_stmt,
                                     JoinedTable *joined_table,
                                     const ObIArray<SelectItem> &select_items);
O
oceanbase-admin 已提交
435

W
wangzelin.wzl 已提交
436 437 438
  int extract_idx_from_table_items(ObDMLStmt *sub_stmt,
                                   const TableItem *table_item,
                                   ObSqlBitSet<> &rel_ids);
O
obdev 已提交
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
  int transform_rollup_exprs(ObDMLStmt *stmt, bool &trans_happened);
  int get_rollup_const_exprs(ObSelectStmt *stmt,
                             ObIArray<ObRawExpr*> &const_exprs,
                             ObIArray<ObRawExpr*> &const_remove_const_exprs,
                             ObIArray<ObRawExpr*> &exec_params,
                             ObIArray<ObRawExpr*> &exec_params_remove_const_exprs,
                             ObIArray<ObRawExpr*> &column_ref_exprs,
                             ObIArray<ObRawExpr*> &column_ref_remove_const_exprs,
                             bool &trans_happened);
  int replace_remove_const_exprs(ObSelectStmt *stmt,
                                ObIArray<ObRawExpr*> &const_exprs,
                                ObIArray<ObRawExpr*> &const_remove_const_exprs,
                                ObIArray<ObRawExpr*> &exec_params,
                                ObIArray<ObRawExpr*> &exec_params_remove_const_exprs,
                                ObIArray<ObRawExpr*> &column_ref_exprs,
                                ObIArray<ObRawExpr*> &column_ref_remove_const_exprs);
G
gm 已提交
455
private:
O
oceanbase-admin 已提交
456 457 458
  DISALLOW_COPY_AND_ASSIGN(ObTransformPreProcess);
};

W
wangzelin.wzl 已提交
459 460
}
}
O
oceanbase-admin 已提交
461 462

#endif /* OB_TRANSFORM_PRE_PROCESS_H_ */