patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -18,14 +18,18 @@
#include "sql/resolver/ob_stmt_type.h"
#include "sql/engine/expr/ob_expr_res_type.h"
#include "sql/resolver/ddl/ob_table_stmt.h"
namespace oceanbase {
namespace share {
namespace schema {
class ObPartition;
class ObSubPartition;
} // namespace schema
} // namespace share
namespace sql {
namespace oceanbase
{
namespace share
{
namespace schema
{
struct ObPartition;
struct ObSubPartition;
}
}
namespace sql
{
class ObExecContext;
class ObRawExpr;
class ObCreateTableStmt;
@ -34,80 +38,141 @@ class ObCreateIndexStmt;
class ObTableStmt;
class ObTablegroupStmt;
class ObPartitionExecutorUtils {
class ObPartitionExecutorUtils
{
public:
const static int OB_DEFAULT_ARRAY_SIZE = 16;
static int calc_values_exprs(ObExecContext& ctx, ObCreateTableStmt& stmt);
static int calc_values_exprs(ObExecContext& ctx, ObCreateIndexStmt& stmt);
static int calc_values_exprs_for_alter_table(
ObExecContext& ctx, share::schema::ObTableSchema& table_schema, ObPartitionedStmt& stmt);
static int calc_values_exprs(ObExecContext &ctx, ObCreateTableStmt &stmt);
static int calc_values_exprs(ObExecContext &ctx, ObCreateIndexStmt &stmt);
static int calc_values_exprs_for_alter_table(ObExecContext &ctx,
share::schema::ObTableSchema &table_schema,
ObPartitionedStmt &stmt);
static int cast_list_expr_to_obj(ObExecContext& ctx, const stmt::StmtType stmt_type, const bool is_subpart,
const int64_t real_part_num, share::schema::ObPartition** partition_array,
share::schema::ObSubPartition** subpartition_array, common::ObIArray<ObRawExpr*>& list_fun_expr,
common::ObIArray<ObRawExpr*>& list_values_exprs);
static int cast_list_expr_to_obj(ObExecContext &ctx,
const stmt::StmtType stmt_type,
const bool is_subpart,
const int64_t real_part_num,
share::schema::ObPartition **partition_array,
share::schema::ObSubPartition **subpartition_array,
common::ObIArray<ObRawExpr *> &list_fun_expr,
common::ObIArray<ObRawExpr *> &list_values_exprs);
static int cast_expr_to_obj(ObExecContext& ctx, const stmt::StmtType stmt_type, bool is_list_part,
common::ObIArray<ObRawExpr*>& partition_fun_expr, common::ObIArray<ObRawExpr*>& partition_value_exprs,
common::ObIArray<common::ObObj>& partition_value_objs);
static int cast_expr_to_obj(ObExecContext &ctx,
const stmt::StmtType stmt_type,
bool is_list_part,
common::ObIArray<ObRawExpr *> &partition_fun_expr,
common::ObIArray<ObRawExpr *> &partition_value_exprs,
common::ObIArray<common::ObObj> &partition_value_objs);
static int set_range_part_high_bound(ObExecContext& ctx, const stmt::StmtType stmt_type,
share::schema::ObTableSchema& table_schema, ObPartitionedStmt& stmt, bool is_subpart);
static int set_range_part_high_bound(ObExecContext &ctx,
const stmt::StmtType stmt_type,
share::schema::ObTableSchema &table_schema,
ObPartitionedStmt &stmt,
bool is_subpart);
static int check_transition_interval_valid(const stmt::StmtType stmt_type,
ObExecContext &ctx,
ObRawExpr *transition_expr,
ObRawExpr *interval_expr);
static int set_interval_value(ObExecContext &ctx,
const stmt::StmtType stmt_type,
share::schema::ObTableSchema &table_schema,
ObRawExpr *interval_expr);
/*--------------tablegroup related start------------------*/
static int calc_values_exprs(ObExecContext& ctx, ObCreateTablegroupStmt& stmt);
static int calc_values_exprs(ObExecContext &ctx, ObCreateTablegroupStmt &stmt);
static int calc_values_exprs(ObExecContext& ctx, ObCreateTablegroupStmt& stmt, bool is_subpart);
static int calc_values_exprs(ObExecContext &ctx, ObCreateTablegroupStmt &stmt, bool is_subpart);
static int cast_range_expr_to_obj(ObExecContext& ctx, ObCreateTablegroupStmt& stmt, bool is_subpart,
common::ObIArray<common::ObObj>& range_partition_obj);
static int cast_range_expr_to_obj(ObExecContext& ctx, common::ObIArray<ObRawExpr*>& range_values_exprs,
const int64_t fun_expr_num, const stmt::StmtType stmt_type, const bool is_subpart, const int64_t real_part_num,
share::schema::ObPartition** partition_array, share::schema::ObSubPartition** subpartition_array,
common::ObIArray<common::ObObj>& range_partition_obj);
static int cast_range_expr_to_obj(ObExecContext &ctx,
ObCreateTablegroupStmt &stmt,
bool is_subpart,
common::ObIArray<common::ObObj> &range_partition_obj);
static int cast_list_expr_to_obj(ObExecContext& ctx, ObCreateTablegroupStmt& stmt, bool is_subpar);
static int cast_range_expr_to_obj(ObExecContext &ctx,
common::ObIArray<ObRawExpr *> &range_values_exprs,
const int64_t fun_expr_num,
const stmt::StmtType stmt_type,
const bool is_subpart,
const int64_t real_part_num,
share::schema::ObPartition **partition_array,
share::schema::ObSubPartition **subpartition_array,
common::ObIArray<common::ObObj> &range_partition_obj);
static int cast_list_expr_to_obj(ObExecContext& ctx, ObTablegroupStmt& stmt, const bool is_subpart,
share::schema::ObPartition** partition_array, share::schema::ObSubPartition** subpartition_array);
static int cast_list_expr_to_obj(ObExecContext &ctx,
ObCreateTablegroupStmt &stmt,
bool is_subpar);
static int cast_expr_to_obj(ObExecContext& ctx, int64_t fun_expr_num,
common::ObIArray<ObRawExpr*>& range_values_exprs, common::ObIArray<common::ObObj>& range_partition_obj);
static int cast_list_expr_to_obj(ObExecContext &ctx,
ObTablegroupStmt &stmt,
const bool is_subpart,
share::schema::ObPartition **partition_array,
share::schema::ObSubPartition **subpartition_array);
static int cast_expr_to_obj(ObExecContext &ctx,
int64_t fun_expr_num,
common::ObIArray<ObRawExpr *> &range_values_exprs,
common::ObIArray<common::ObObj> &range_partition_obj);
/*--------------tablegroup related end------------------*/
static int calc_range_values_exprs(ObExecContext& ctx, ObCreateIndexStmt& stmt);
static int calc_range_values_exprs(ObExecContext &ctx, ObCreateIndexStmt &stmt);
template <typename T>
static int check_increasing_range_value(T** array, int64_t part_num, const stmt::StmtType stmt_type);
template<typename T>
static int check_increasing_range_value(T **array,
int64_t part_num,
const stmt::StmtType stmt_type);
static int expr_cal_and_cast(const sql::stmt::StmtType &stmt_type,
bool is_list_part,
ObExecContext &ctx,
const common::ObObjType fun_expr_type,
const common::ObCollationType fun_collation_type,
ObRawExpr *expr,
common::ObObj &value_obj);
static int expr_cal_and_cast_with_check_varchar_len(const stmt::StmtType &stmt_type,
bool is_list_part,
ObExecContext &ctx,
const sql::ObExprResType &dst_res_type,
ObRawExpr *expr,
common::ObObj &value_obj);
static int expr_cal_and_cast(const sql::stmt::StmtType& stmt_type, bool is_list_part, ObExecContext& ctx,
const common::ObObjType fun_expr_type, const common::ObCollationType fun_collation_type, ObRawExpr* expr,
common::ObObj& value_obj);
static int set_list_part_rows(ObExecContext &ctx,
ObPartitionedStmt &stmt,
const stmt::StmtType stmt_type,
share::schema::ObTableSchema &table_schema,
ObIArray<ObRawExpr *> &list_fun_exprs,
ObIArray<ObRawExpr *> &list_values_exprs,
bool is_subpart);
static int expr_cal_and_cast_with_check_varchar_len(const stmt::StmtType& stmt_type, bool is_list_part,
ObExecContext& ctx, const sql::ObExprResType& dst_res_type, ObRawExpr* expr, common::ObObj& value_obj);
static int set_individual_range_part_high_bound(ObExecContext &ctx,
const stmt::StmtType stmt_type,
share::schema::ObTableSchema &table_schema,
ObPartitionedStmt &stmt);
static int set_list_part_rows(ObExecContext& ctx, const stmt::StmtType stmt_type,
share::schema::ObTableSchema& table_schema, ObIArray<ObRawExpr*>& list_fun_exprs,
ObIArray<ObRawExpr*>& list_values_exprs, bool is_subpart);
static int set_individual_list_part_rows(ObExecContext &ctx,
ObPartitionedStmt &stmt,
const stmt::StmtType stmt_type,
share::schema::ObTableSchema &table_schema,
ObIArray<ObRawExpr *> &list_fun_exprs,
ObDDLStmt::array_array_t &list_values_exprs_array);
static int set_individual_range_part_high_bound(ObExecContext& ctx, const stmt::StmtType stmt_type,
share::schema::ObTableSchema& table_schema, ObPartitionedStmt& stmt);
static int set_individual_list_part_rows(ObExecContext& ctx, const stmt::StmtType stmt_type,
share::schema::ObTableSchema& table_schema, ObIArray<ObRawExpr*>& list_fun_exprs,
ObDDLStmt::array_array_t& list_values_exprs_array);
static int row_expr_to_array(ObRawExpr* row_expr, ObIArray<ObRawExpr*>& list_values_expr_array);
static int row_expr_to_array(ObRawExpr *row_expr,
ObIArray<ObRawExpr *> &list_values_expr_array);
private:
static int calc_values_exprs(ObExecContext& ctx, const stmt::StmtType stmt_type,
share::schema::ObTableSchema& table_schema, ObPartitionedStmt& stmt, bool is_subpart);
static int calc_values_exprs(ObExecContext &ctx,
const stmt::StmtType stmt_type,
share::schema::ObTableSchema &table_schema,
ObPartitionedStmt &stmt,
bool is_subpart);
static int sort_list_paritition_if_need(share::schema::ObTableSchema& table_schema);
static int sort_list_paritition_if_need(share::schema::ObTableSchema &table_schema);
};
} // end namespace sql
} // end namespace oceanbase
} //end namespace sql
} //end namespace oceanbase
#endif // OCEANBASE_SQL_OB_PARTITION_EXECUTOR_UTILS_
#endif //OCEANBASE_SQL_OB_PARTITION_EXECUTOR_UTILS_