[CP] to issue<55739667>:fix truncate table cause pl cache mismatch after alter table add/drop column

This commit is contained in:
hanr881
2024-08-15 14:24:14 +00:00
committed by ob-robot
parent 14be3cb8fb
commit df78b19c9a

View File

@ -76,17 +76,30 @@ int PCVPlSchemaObj::deep_copy_column_infos(const ObTableSchema *schema)
ret = OB_INVALID_ARGUMENT; ret = OB_INVALID_ARGUMENT;
LOG_WARN("unexpected null argument", K(ret), K(schema), K(inner_alloc_)); LOG_WARN("unexpected null argument", K(ret), K(schema), K(inner_alloc_));
} else { } else {
void *obj_buf = nullptr; ObTableSchema::const_column_iterator cs_iter = schema->column_begin();
ObPLTableColumnInfo *column_info = nullptr; ObTableSchema::const_column_iterator cs_iter_end = schema->column_end();
column_cnt_ = schema->get_column_count(); int64_t real_column_cnt = 0;
for (; OB_SUCC(ret) && cs_iter != cs_iter_end; cs_iter++) {
const ObColumnSchemaV2 &column_schema = **cs_iter;
if (!column_schema.is_hidden()) {
real_column_cnt++;
}
}
if (OB_SUCC(ret)) {
column_cnt_ = real_column_cnt;
column_infos_.set_allocator(inner_alloc_); column_infos_.set_allocator(inner_alloc_);
if (OB_FAIL(column_infos_.init(column_cnt_))) { if (OB_FAIL(column_infos_.init(column_cnt_))) {
LOG_WARN("failed to init column_infos", K(ret)); LOG_WARN("failed to init column_infos", K(ret));
} else { } else {
ObTableSchema::const_column_iterator cs_iter = schema->column_begin(); void *obj_buf = nullptr;
ObTableSchema::const_column_iterator cs_iter_end = schema->column_end(); ObPLTableColumnInfo *column_info = nullptr;
cs_iter = schema->column_begin();
cs_iter_end = schema->column_end();
for (; OB_SUCC(ret) && cs_iter != cs_iter_end; cs_iter++) { for (; OB_SUCC(ret) && cs_iter != cs_iter_end; cs_iter++) {
const ObColumnSchemaV2 &column_schema = **cs_iter; const ObColumnSchemaV2 &column_schema = **cs_iter;
if (column_schema.is_hidden()) {
// do nothing
} else {
if (nullptr == (obj_buf = inner_alloc_->alloc(sizeof(ObPLTableColumnInfo)))) { if (nullptr == (obj_buf = inner_alloc_->alloc(sizeof(ObPLTableColumnInfo)))) {
ret = OB_ALLOCATE_MEMORY_FAILED; ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to allocate memory", K(ret)); LOG_WARN("failed to allocate memory", K(ret));
@ -115,9 +128,11 @@ int PCVPlSchemaObj::deep_copy_column_infos(const ObTableSchema *schema)
} }
} }
} }
}
CK (column_cnt_ == column_infos_.count()); CK (column_cnt_ == column_infos_.count());
} }
} }
}
return ret; return ret;
} }
@ -400,6 +415,9 @@ int ObPLObjectValue::obtain_new_column_infos(share::schema::ObSchemaGetterGuard
ObTableSchema::const_column_iterator cs_iter_end = table_schema->column_end(); ObTableSchema::const_column_iterator cs_iter_end = table_schema->column_end();
for (; OB_SUCC(ret) && cs_iter != cs_iter_end; cs_iter++) { for (; OB_SUCC(ret) && cs_iter != cs_iter_end; cs_iter++) {
const ObColumnSchemaV2 &column_schema = **cs_iter; const ObColumnSchemaV2 &column_schema = **cs_iter;
if (column_schema.is_hidden()) {
// do nothing
} else {
column_info.column_id_ = column_schema.get_column_id(); column_info.column_id_ = column_schema.get_column_id();
column_info.meta_type_ = column_schema.get_meta_type(); column_info.meta_type_ = column_schema.get_meta_type();
column_info.charset_type_ = column_schema.get_charset_type(); column_info.charset_type_ = column_schema.get_charset_type();
@ -409,6 +427,7 @@ int ObPLObjectValue::obtain_new_column_infos(share::schema::ObSchemaGetterGuard
OZ (column_infos.push_back(column_info)); OZ (column_infos.push_back(column_info));
} }
} }
}
return ret; return ret;
} }