Files
oceanbase/src/sql/optimizer/ob_log_insert.h
wangzelin.wzl 93a1074b0c patch 4.0
2022-10-24 17:57:12 +08:00

114 lines
3.5 KiB
C++

/**
* 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_LOG_INSERT_H
#define _OB_LOG_INSERT_H 1
#include "ob_logical_operator.h"
#include "ob_log_del_upd.h"
#include "sql/resolver/dml/ob_insert_stmt.h"
namespace oceanbase
{
namespace sql
{
class ObSelectLogPlan;
class ObLogInsert : public ObLogDelUpd
{
public:
ObLogInsert(ObDelUpdLogPlan &plan)
: ObLogDelUpd(plan),
is_replace_(false),
insert_up_(false),
is_insert_select_(false),
constraint_infos_(NULL)
{
}
virtual ~ObLogInsert()
{
}
const char* get_name() const;
void set_replace(bool replace)
{
is_replace_ = replace;
}
bool is_replace() const
{
return is_replace_;
}
virtual int get_op_exprs(ObIArray<ObRawExpr*> &all_exprs) override;
void set_insert_up(bool insert_up)
{
insert_up_ = insert_up;
}
bool get_insert_up()
{
return insert_up_;
}
void set_is_insert_select(bool v) { is_insert_select_ = v; }
bool is_insert_select() const { return is_insert_select_; }
virtual bool is_single_value() const override
{
return NULL != get_stmt() && get_stmt()->is_insert_stmt() &&
static_cast<const ObInsertStmt*>(get_stmt())->is_insert_single_value();
}
const ObIArray<IndexDMLInfo *> &get_replace_index_dml_infos() const
{ return index_replace_infos_; }
ObIArray<IndexDMLInfo *> &get_replace_index_dml_infos()
{ return index_replace_infos_; }
const ObIArray<IndexDMLInfo *> &get_insert_up_index_dml_infos() const
{ return index_upd_infos_; }
ObIArray<IndexDMLInfo *> &get_insert_up_index_dml_infos()
{ return index_upd_infos_; }
/**
* Get the hash value of the INSERT operator
*/
virtual uint64_t hash(uint64_t seed) const override;
virtual int compute_plan_type() override;
virtual int compute_sharding_info() override;
virtual int est_cost() override;
virtual int re_est_cost(EstimateCostInfo &param, double &card, double &cost) override;
int inner_est_cost(double child_card, double &op_cost);
void set_constraint_infos(const common::ObIArray<ObUniqueConstraintInfo> *constraint_infos)
{
constraint_infos_ = constraint_infos;
}
const common::ObIArray<ObUniqueConstraintInfo> *get_constraint_infos() const
{
return constraint_infos_;
}
protected:
virtual int print_my_plan_annotation(char *buf,
int64_t &buf_len,
int64_t &pos,
ExplainType type);
int get_constraint_info_exprs(ObIArray<ObRawExpr*> &all_exprs);
virtual int generate_rowid_expr_for_trigger() override;
virtual int generate_multi_part_partition_id_expr() override;
protected:
bool is_replace_;
common::ObArray<IndexDMLInfo *, common::ModulePageAllocator, true> index_replace_infos_;
// for insert_up update caluse
common::ObArray<IndexDMLInfo *, common::ModulePageAllocator, true> index_upd_infos_;
bool insert_up_; // insert on duplicate update statement
//for SPM Pruning
bool is_insert_select_;
const common::ObIArray<ObUniqueConstraintInfo> *constraint_infos_;
};
}
}
#endif