From e732d6bf5c461a1f083257d4269a9724ff18ed0d Mon Sep 17 00:00:00 2001 From: chimyue Date: Wed, 13 Mar 2024 13:50:40 +0000 Subject: [PATCH] add expr and item_type placeholder for real-time materialized view and materialized view rewrite --- deps/oblib/src/lib/ob_name_def.h | 1 + src/objit/include/objit/common/ob_item_type.h | 4 ++++ src/sql/engine/expr/ob_expr_eval_functions.cpp | 1 + src/sql/engine/ob_physical_plan.cpp | 7 +++++-- src/sql/engine/ob_physical_plan.h | 2 ++ src/sql/engine/ob_physical_plan_ctx.cpp | 10 +++++++++- src/sql/engine/ob_physical_plan_ctx.h | 3 +++ 7 files changed, 25 insertions(+), 3 deletions(-) diff --git a/deps/oblib/src/lib/ob_name_def.h b/deps/oblib/src/lib/ob_name_def.h index 36a6d9eba..a837cbe97 100644 --- a/deps/oblib/src/lib/ob_name_def.h +++ b/deps/oblib/src/lib/ob_name_def.h @@ -1076,4 +1076,5 @@ #define N_INNER_DECODE_LIKE "inner_decode_like" #define N_EXTRACT_CERT_EXPIRED_TIME "extract_cert_expired_time" #define N_INNER_ROW_CMP_VALUE "inner_row_cmp_value" +#define N_SYS_LAST_REFRESH_SCN "last_refresh_scn" #endif //OCEANBASE_LIB_OB_NAME_DEF_H_ diff --git a/src/objit/include/objit/common/ob_item_type.h b/src/objit/include/objit/common/ob_item_type.h index 525139522..121dc60ed 100755 --- a/src/objit/include/objit/common/ob_item_type.h +++ b/src/objit/include/objit/common/ob_item_type.h @@ -875,6 +875,7 @@ typedef enum ObItemType T_FUN_SYS_GTID_SUBTRACT = 2013, T_FUN_SYS_WAIT_FOR_EXECUTED_GTID_SET = 2014, T_FUN_SYS_WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS = 2015, + T_FUN_SYS_LAST_REFRESH_SCN = 2016, T_MAX_OP = 3000, @@ -2428,6 +2429,9 @@ typedef enum ObItemType T_PARALLEL_DAS_DML, T_DISABLE_PARALLEL_DAS_DML, T_ENABLE_LOB_PREFETCH, + T_MV_OPTIONS, + T_MV_REWRITE, + T_MV_NO_REWRITE, T_MAX //Attention: add a new type before T_MAX } ObItemType; diff --git a/src/sql/engine/expr/ob_expr_eval_functions.cpp b/src/sql/engine/expr/ob_expr_eval_functions.cpp index 124a9ccf7..4767e916f 100644 --- a/src/sql/engine/expr/ob_expr_eval_functions.cpp +++ b/src/sql/engine/expr/ob_expr_eval_functions.cpp @@ -1131,6 +1131,7 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = { NULL, // ObExprGTIDSubtract::eval_subtract, /* 687 */ NULL, // ObExprWaitForExecutedGTIDSet::eval_wait_for_executed_gtid_set, /* 688 */ NULL, // ObExprWaitUntilSQLThreadAfterGTIDs::eval_wait_until_sql_thread_after_gtids /* 689 */ + NULL, // ObExprLastRefreshScn::eval_last_refresh_scn /* 690 */ }; static ObExpr::EvalBatchFunc g_expr_eval_batch_functions[] = { diff --git a/src/sql/engine/ob_physical_plan.cpp b/src/sql/engine/ob_physical_plan.cpp index 1fad12635..e5f789474 100644 --- a/src/sql/engine/ob_physical_plan.cpp +++ b/src/sql/engine/ob_physical_plan.cpp @@ -137,7 +137,8 @@ ObPhysicalPlan::ObPhysicalPlan(MemoryContext &mem_context /* = CURRENT_CONTEXT * subschema_ctx_(allocator_), disable_auto_memory_mgr_(false), all_local_session_vars_(&allocator_), - udf_has_dml_stmt_(false) + udf_has_dml_stmt_(false), + mview_ids_(&allocator_) { } @@ -236,6 +237,7 @@ void ObPhysicalPlan::reset() subschema_ctx_.reset(); all_local_session_vars_.reset(); udf_has_dml_stmt_ = false; + mview_ids_.reset(); } void ObPhysicalPlan::destroy() @@ -797,7 +799,8 @@ OB_SERIALIZE_MEMBER(ObPhysicalPlan, use_rich_format_, disable_auto_memory_mgr_, udf_has_dml_stmt_, - stat_.format_sql_id_); + stat_.format_sql_id_, + mview_ids_); int ObPhysicalPlan::set_table_locations(const ObTablePartitionInfoArray &infos, ObSchemaGetterGuard &schema_guard) diff --git a/src/sql/engine/ob_physical_plan.h b/src/sql/engine/ob_physical_plan.h index 5737d0c57..f79586c7c 100644 --- a/src/sql/engine/ob_physical_plan.h +++ b/src/sql/engine/ob_physical_plan.h @@ -681,6 +681,8 @@ private: public: bool udf_has_dml_stmt_; +private: + common::ObFixedArray mview_ids_; }; inline void ObPhysicalPlan::set_affected_last_insert_id(bool affected_last_insert_id) diff --git a/src/sql/engine/ob_physical_plan_ctx.cpp b/src/sql/engine/ob_physical_plan_ctx.cpp index b99f46019..2e8392c71 100644 --- a/src/sql/engine/ob_physical_plan_ctx.cpp +++ b/src/sql/engine/ob_physical_plan_ctx.cpp @@ -114,7 +114,9 @@ ObPhysicalPlanCtx::ObPhysicalPlanCtx(common::ObIAllocator &allocator) spm_ts_timeout_us_(0), subschema_ctx_(allocator_), enable_rich_format_(false), - all_local_session_vars_(allocator) + all_local_session_vars_(allocator), + mview_ids_(allocator), + last_refresh_scns_(allocator) { } @@ -759,6 +761,8 @@ OB_DEF_SERIALIZE(ObPhysicalPlanCtx) for (int64_t i = 0; OB_SUCC(ret) && i < all_local_session_vars_.count(); ++i) { OB_UNIS_ENCODE(*all_local_session_vars_.at(i)); } + OB_UNIS_ENCODE(mview_ids_); + OB_UNIS_ENCODE(last_refresh_scns_); return ret; } @@ -854,6 +858,8 @@ OB_DEF_SERIALIZE_SIZE(ObPhysicalPlanCtx) for (int64_t i = 0; i < all_local_session_vars_.count(); ++i) { OB_UNIS_ADD_LEN(*all_local_session_vars_.at(i)); } + OB_UNIS_ADD_LEN(mview_ids_); + OB_UNIS_ADD_LEN(last_refresh_scns_); return len; } @@ -977,6 +983,8 @@ OB_DEF_DESERIALIZE(ObPhysicalPlanCtx) LOG_WARN("failed to deserialize param store", K(ret)); } } + OB_UNIS_DECODE(mview_ids_); + OB_UNIS_DECODE(last_refresh_scns_); return ret; } diff --git a/src/sql/engine/ob_physical_plan_ctx.h b/src/sql/engine/ob_physical_plan_ctx.h index cbcc6e3d0..645eb3084 100644 --- a/src/sql/engine/ob_physical_plan_ctx.h +++ b/src/sql/engine/ob_physical_plan_ctx.h @@ -607,6 +607,9 @@ private: bool enable_rich_format_; // for dependant exprs of generated columns common::ObFixedArray all_local_session_vars_; + // for last_refresh_scn expr to get last_refresh_scn for rt mview used in query + common::ObFixedArray mview_ids_; + common::ObFixedArray last_refresh_scns_; }; }