[FEAT MERGE] materialized view
This commit is contained in:
@ -915,6 +915,196 @@ OB_SERIALIZE_MEMBER((ObDropResourceUnitArg, ObDDLArg),
|
||||
unit_name_,
|
||||
if_exist_);
|
||||
|
||||
bool ObMViewCompleteRefreshArg::is_valid() const
|
||||
{
|
||||
bool bret = OB_INVALID_TENANT_ID != exec_tenant_id_ &&
|
||||
!based_schema_object_infos_.empty() &&
|
||||
OB_INVALID_TENANT_ID != tenant_id_ &&
|
||||
OB_INVALID_ID != table_id_;
|
||||
for (int64_t i = 0; bret && i < based_schema_object_infos_.count(); ++i) {
|
||||
const ObBasedSchemaObjectInfo &based_info = based_schema_object_infos_.at(i);
|
||||
bret = (OB_INVALID_TENANT_ID == based_info.schema_tenant_id_ ||
|
||||
tenant_id_ == based_info.schema_tenant_id_) &&
|
||||
OB_INVALID_ID != based_info.schema_id_ &&
|
||||
ObSchemaType::TABLE_SCHEMA == based_info.schema_type_ &&
|
||||
OB_INVALID_VERSION != based_info.schema_version_;
|
||||
}
|
||||
return bret;
|
||||
}
|
||||
|
||||
void ObMViewCompleteRefreshArg::reset()
|
||||
{
|
||||
tenant_id_ = OB_INVALID_TENANT_ID;
|
||||
table_id_ = OB_INVALID_ID;
|
||||
session_id_ = OB_INVALID_ID;
|
||||
sql_mode_ = 0;
|
||||
last_refresh_scn_.reset();
|
||||
tz_info_.reset();
|
||||
tz_info_wrap_.reset();
|
||||
for (int64_t i = 0; i < ObNLSFormatEnum::NLS_MAX; ++i) {
|
||||
nls_formats_[i].reset();
|
||||
}
|
||||
parent_task_id_ = 0;
|
||||
allocator_.reset();
|
||||
ObDDLArg::reset();
|
||||
}
|
||||
|
||||
int ObMViewCompleteRefreshArg::assign(const ObMViewCompleteRefreshArg &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (this != &other) {
|
||||
reset();
|
||||
if (OB_FAIL(ObDDLArg::assign(other))) {
|
||||
LOG_WARN("fail to assign ddl arg", KR(ret));
|
||||
} else {
|
||||
tenant_id_ = other.tenant_id_;
|
||||
table_id_ = other.table_id_;
|
||||
session_id_ = other.session_id_;
|
||||
sql_mode_ = other.sql_mode_;
|
||||
last_refresh_scn_ = other.last_refresh_scn_;
|
||||
parent_task_id_ = other.parent_task_id_;
|
||||
if (OB_FAIL(tz_info_.assign(other.tz_info_))) {
|
||||
LOG_WARN("fail to assign tz info", KR(ret), "tz_info", other.tz_info_);
|
||||
} else if (OB_FAIL(tz_info_wrap_.deep_copy(other.tz_info_wrap_))) {
|
||||
LOG_WARN("fail to deep copy tz info wrap", KR(ret), "tz_info_wrap", other.tz_info_wrap_);
|
||||
}
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < ObNLSFormatEnum::NLS_MAX; i++) {
|
||||
if (OB_FAIL(ob_write_string(allocator_, other.nls_formats_[i], nls_formats_[i]))) {
|
||||
LOG_WARN("fail to deep copy nls format", KR(ret), K(i), "nls_format", other.nls_formats_[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_DEF_SERIALIZE(ObMViewCompleteRefreshArg)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_UNLIKELY(!is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), KPC(this));
|
||||
} else {
|
||||
BASE_SER((, ObDDLArg));
|
||||
LST_DO_CODE(OB_UNIS_ENCODE,
|
||||
tenant_id_,
|
||||
table_id_,
|
||||
session_id_,
|
||||
sql_mode_,
|
||||
last_refresh_scn_,
|
||||
tz_info_,
|
||||
tz_info_wrap_);
|
||||
OB_UNIS_ENCODE_ARRAY(nls_formats_, ObNLSFormatEnum::NLS_MAX);
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
LST_DO_CODE(OB_UNIS_ENCODE, parent_task_id_);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_DEF_DESERIALIZE(ObMViewCompleteRefreshArg)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
reset();
|
||||
int64_t nls_formats_count = -1;
|
||||
ObString nls_formats[ObNLSFormatEnum::NLS_MAX];
|
||||
BASE_DESER((, ObDDLArg));
|
||||
LST_DO_CODE(OB_UNIS_DECODE,
|
||||
tenant_id_,
|
||||
table_id_,
|
||||
session_id_,
|
||||
sql_mode_,
|
||||
last_refresh_scn_,
|
||||
tz_info_,
|
||||
tz_info_wrap_);
|
||||
OB_UNIS_DECODE(nls_formats_count);
|
||||
if (OB_SUCC(ret)) {
|
||||
if (OB_UNLIKELY(ObNLSFormatEnum::NLS_MAX != nls_formats_count)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("unexpected nls formats count", KR(ret), K(nls_formats_count));
|
||||
}
|
||||
OB_UNIS_DECODE_ARRAY(nls_formats, nls_formats_count);
|
||||
for (int64_t i = 0; OB_SUCC(ret) && i < nls_formats_count; i++) {
|
||||
if (OB_FAIL(ob_write_string(allocator_, nls_formats[i], nls_formats_[i]))) {
|
||||
LOG_WARN("fail to deep copy nls format", KR(ret), K(i), K(nls_formats[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
LST_DO_CODE(OB_UNIS_DECODE, parent_task_id_);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_DEF_SERIALIZE_SIZE(ObMViewCompleteRefreshArg)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
int64_t len = 0;
|
||||
if (OB_UNLIKELY(!is_valid())) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid argument", KR(ret), KPC(this));
|
||||
} else {
|
||||
BASE_ADD_LEN((, ObDDLArg));
|
||||
LST_DO_CODE(OB_UNIS_ADD_LEN,
|
||||
tenant_id_,
|
||||
table_id_,
|
||||
session_id_,
|
||||
sql_mode_,
|
||||
last_refresh_scn_,
|
||||
tz_info_,
|
||||
tz_info_wrap_);
|
||||
OB_UNIS_ADD_LEN_ARRAY(nls_formats_, ObNLSFormatEnum::NLS_MAX);
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
LST_DO_CODE(OB_UNIS_ADD_LEN, parent_task_id_);
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
len = -1;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObMViewCompleteRefreshRes,
|
||||
task_id_,
|
||||
trace_id_);
|
||||
|
||||
bool ObMViewRefreshInfo::is_valid() const
|
||||
{
|
||||
return OB_INVALID_ID != mview_table_id_ &&
|
||||
refresh_scn_.is_valid() &&
|
||||
OB_INVALID_TIMESTAMP != start_time_ &&
|
||||
(!last_refresh_scn_.is_valid() || last_refresh_scn_ < refresh_scn_);
|
||||
}
|
||||
|
||||
void ObMViewRefreshInfo::reset()
|
||||
{
|
||||
mview_table_id_ = OB_INVALID_ID;
|
||||
last_refresh_scn_.reset();
|
||||
refresh_scn_.reset();
|
||||
start_time_ = OB_INVALID_TIMESTAMP;
|
||||
is_mview_complete_refresh_ = false;
|
||||
}
|
||||
|
||||
int ObMViewRefreshInfo::assign(const ObMViewRefreshInfo &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (this != &other) {
|
||||
mview_table_id_ = other.mview_table_id_;
|
||||
last_refresh_scn_ = other.last_refresh_scn_;
|
||||
refresh_scn_ = other.refresh_scn_;
|
||||
start_time_ = other.start_time_;
|
||||
is_mview_complete_refresh_ = other.is_mview_complete_refresh_;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObMViewRefreshInfo,
|
||||
mview_table_id_,
|
||||
last_refresh_scn_,
|
||||
refresh_scn_,
|
||||
start_time_,
|
||||
is_mview_complete_refresh_);
|
||||
|
||||
/// pool
|
||||
|
||||
DEF_TO_STRING(ObCreateResourcePoolArg)
|
||||
@ -1636,6 +1826,19 @@ DEF_TO_STRING(ObCreateVertialPartitionArg)
|
||||
OB_SERIALIZE_MEMBER((ObCreateVertialPartitionArg, ObDDLArg),
|
||||
vertical_partition_columns_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObMVAdditionalInfo,
|
||||
container_table_schema_,
|
||||
mv_refresh_info_);
|
||||
|
||||
int ObMVAdditionalInfo::assign(const ObMVAdditionalInfo &other)
|
||||
{
|
||||
int ret = common::OB_SUCCESS;
|
||||
OZ(container_table_schema_.assign(other.container_table_schema_));
|
||||
OX(mv_refresh_info_ = other.mv_refresh_info_);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool ObCreateTableArg::is_valid() const
|
||||
{
|
||||
// index_arg_list can be empty
|
||||
@ -1643,6 +1846,28 @@ bool ObCreateTableArg::is_valid() const
|
||||
&& !schema_.get_table_name_str().empty();
|
||||
}
|
||||
|
||||
int ObCreateTableArg::assign(const ObCreateTableArg &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
OZ(ObDDLArg::assign(other));
|
||||
OX(if_not_exist_ = other.if_not_exist_);
|
||||
OZ(schema_.assign(other.schema_));
|
||||
OZ(index_arg_list_.assign(other.index_arg_list_));
|
||||
OZ(foreign_key_arg_list_.assign(other.foreign_key_arg_list_));
|
||||
OZ(constraint_list_.assign(other.constraint_list_));
|
||||
OX(db_name_ = other.db_name_);
|
||||
OX(last_replay_log_id_ = other.last_replay_log_id_);
|
||||
OX(is_inner_ = other.is_inner_);
|
||||
OZ(vertical_partition_arg_list_.assign(other.vertical_partition_arg_list_));
|
||||
OZ(error_info_.assign(other.error_info_));
|
||||
OX(is_alter_view_ = other.is_alter_view_);
|
||||
OZ(sequence_ddl_arg_.assign(other.sequence_ddl_arg_));
|
||||
OZ(dep_infos_.assign(other.dep_infos_));
|
||||
OZ(mv_ainfo_.assign(other.mv_ainfo_));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
DEF_TO_STRING(ObCreateTableArg)
|
||||
{
|
||||
int64_t pos = 0;
|
||||
@ -1677,7 +1902,8 @@ OB_SERIALIZE_MEMBER((ObCreateTableArg, ObDDLArg),
|
||||
error_info_,
|
||||
is_alter_view_,
|
||||
sequence_ddl_arg_,
|
||||
dep_infos_);
|
||||
dep_infos_,
|
||||
mv_ainfo_);
|
||||
|
||||
bool ObCreateTableArg::is_allow_when_upgrade() const
|
||||
{
|
||||
@ -2254,7 +2480,8 @@ OB_DEF_SERIALIZE(ObAlterTableArg)
|
||||
foreign_key_checks_,
|
||||
is_add_to_scheduler_,
|
||||
inner_sql_exec_addr_,
|
||||
local_session_var_);
|
||||
local_session_var_,
|
||||
mview_refresh_info_);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2344,7 +2571,8 @@ OB_DEF_DESERIALIZE(ObAlterTableArg)
|
||||
foreign_key_checks_,
|
||||
is_add_to_scheduler_,
|
||||
inner_sql_exec_addr_,
|
||||
local_session_var_);
|
||||
local_session_var_,
|
||||
mview_refresh_info_);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2387,7 +2615,8 @@ OB_DEF_SERIALIZE_SIZE(ObAlterTableArg)
|
||||
foreign_key_checks_,
|
||||
is_add_to_scheduler_,
|
||||
inner_sql_exec_addr_,
|
||||
local_session_var_);
|
||||
local_session_var_,
|
||||
mview_refresh_info_);
|
||||
}
|
||||
|
||||
if (OB_FAIL(ret)) {
|
||||
@ -2924,6 +3153,72 @@ DEF_TO_STRING(ObRenameIndexArg)
|
||||
|
||||
OB_SERIALIZE_MEMBER((ObRenameIndexArg, ObIndexArg), origin_index_name_, new_index_name_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObCreateMLogArg::PurgeOptions,
|
||||
purge_mode_,
|
||||
start_datetime_expr_,
|
||||
next_datetime_expr_,
|
||||
exec_env_);
|
||||
|
||||
bool ObCreateMLogArg::is_valid() const
|
||||
{
|
||||
return (OB_INVALID_TENANT_ID != tenant_id_)
|
||||
&& !database_name_.empty()
|
||||
&& !table_name_.empty()
|
||||
&& purge_options_.is_valid();
|
||||
}
|
||||
|
||||
DEF_TO_STRING(ObCreateMLogArg)
|
||||
{
|
||||
int64_t pos = 0;
|
||||
J_OBJ_START();
|
||||
pos += ObDDLArg::to_string(buf + pos, buf_len - pos);
|
||||
J_KV(K_(database_name),
|
||||
K_(table_name),
|
||||
K_(mlog_name),
|
||||
K_(tenant_id),
|
||||
K_(base_table_id),
|
||||
K_(mlog_table_id),
|
||||
K_(session_id),
|
||||
K_(with_rowid),
|
||||
K_(with_primary_key),
|
||||
K_(with_sequence),
|
||||
K_(include_new_values),
|
||||
K_(purge_options),
|
||||
K_(mlog_schema),
|
||||
K_(store_columns),
|
||||
K_(nls_date_format),
|
||||
K_(nls_timestamp_format),
|
||||
K_(nls_timestamp_tz_format),
|
||||
K_(sql_mode));
|
||||
J_OBJ_END();
|
||||
return pos;
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER((ObCreateMLogArg, ObDDLArg),
|
||||
database_name_,
|
||||
table_name_,
|
||||
mlog_name_,
|
||||
tenant_id_,
|
||||
base_table_id_,
|
||||
mlog_table_id_,
|
||||
session_id_,
|
||||
with_rowid_,
|
||||
with_primary_key_,
|
||||
with_sequence_,
|
||||
include_new_values_,
|
||||
purge_options_,
|
||||
mlog_schema_,
|
||||
store_columns_,
|
||||
nls_date_format_,
|
||||
nls_timestamp_format_,
|
||||
nls_timestamp_tz_format_,
|
||||
sql_mode_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObCreateMLogRes,
|
||||
mlog_table_id_,
|
||||
schema_version_,
|
||||
task_id_);
|
||||
|
||||
bool ObCreateForeignKeyArg::is_valid() const
|
||||
{
|
||||
return ObIndexArg::is_valid() && !parent_table_.empty()
|
||||
@ -5000,6 +5295,29 @@ bool ObUpdateIndexStatusArg::is_valid() const
|
||||
&& status_ < INDEX_STATUS_MAX;
|
||||
}
|
||||
|
||||
int ObUpdateMViewStatusArg::assign(const ObUpdateMViewStatusArg &other)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (this != &other) {
|
||||
if (OB_FAIL(ObDDLArg::assign(other))) {
|
||||
LOG_WARN("fail to assign ddl arg", KR(ret));
|
||||
} else {
|
||||
mview_table_id_ = other.mview_table_id_;
|
||||
mv_available_flag_ = other.mv_available_flag_;
|
||||
convert_status_ = other.convert_status_;
|
||||
in_offline_ddl_white_list_ = other.in_offline_ddl_white_list_;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ObUpdateMViewStatusArg::is_valid() const
|
||||
{
|
||||
return (OB_INVALID_ID != mview_table_id_)
|
||||
&& (ObMVAvailableFlag::IS_MV_UNAVAILABLE == mv_available_flag_
|
||||
|| ObMVAvailableFlag::IS_MV_AVAILABLE == mv_available_flag_);
|
||||
}
|
||||
|
||||
OB_SERIALIZE_MEMBER((ObUpdateIndexStatusArg, ObDDLArg),
|
||||
index_table_id_,
|
||||
status_,
|
||||
@ -5008,6 +5326,12 @@ OB_SERIALIZE_MEMBER((ObUpdateIndexStatusArg, ObDDLArg),
|
||||
data_table_id_,
|
||||
database_name_);
|
||||
|
||||
OB_SERIALIZE_MEMBER((ObUpdateMViewStatusArg, ObDDLArg),
|
||||
mview_table_id_,
|
||||
mv_available_flag_,
|
||||
convert_status_,
|
||||
in_offline_ddl_white_list_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObMergeFinishArg, server_, frozen_version_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObDebugSyncActionArg, reset_, clear_, action_);
|
||||
|
||||
Reference in New Issue
Block a user