[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,46 +76,61 @@ 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;
column_infos_.set_allocator(inner_alloc_); for (; OB_SUCC(ret) && cs_iter != cs_iter_end; cs_iter++) {
if (OB_FAIL(column_infos_.init(column_cnt_))) { const ObColumnSchemaV2 &column_schema = **cs_iter;
LOG_WARN("failed to init column_infos", K(ret)); if (!column_schema.is_hidden()) {
} else { real_column_cnt++;
ObTableSchema::const_column_iterator cs_iter = schema->column_begin(); }
ObTableSchema::const_column_iterator cs_iter_end = schema->column_end(); }
for (; OB_SUCC(ret) && cs_iter != cs_iter_end; cs_iter++) { if (OB_SUCC(ret)) {
const ObColumnSchemaV2 &column_schema = **cs_iter; column_cnt_ = real_column_cnt;
if (nullptr == (obj_buf = inner_alloc_->alloc(sizeof(ObPLTableColumnInfo)))) { column_infos_.set_allocator(inner_alloc_);
ret = OB_ALLOCATE_MEMORY_FAILED; if (OB_FAIL(column_infos_.init(column_cnt_))) {
LOG_WARN("failed to allocate memory", K(ret)); LOG_WARN("failed to init column_infos", K(ret));
} else if (FALSE_IT(column_info = new(obj_buf)ObPLTableColumnInfo(inner_alloc_))) { } else {
// do nothing void *obj_buf = nullptr;
} else { ObPLTableColumnInfo *column_info = nullptr;
column_info->column_id_ = column_schema.get_column_id(); cs_iter = schema->column_begin();
column_info->meta_type_ = column_schema.get_meta_type(); cs_iter_end = schema->column_end();
column_info->charset_type_ = column_schema.get_charset_type(); for (; OB_SUCC(ret) && cs_iter != cs_iter_end; cs_iter++) {
column_info->accuracy_ = column_schema.get_accuracy(); const ObColumnSchemaV2 &column_schema = **cs_iter;
OZ (column_info->deep_copy_type_info(column_schema.get_extended_type_info())); if (column_schema.is_hidden()) {
// do nothing
if (OB_SUCC(ret)) { } else {
char *name_buf = NULL; if (nullptr == (obj_buf = inner_alloc_->alloc(sizeof(ObPLTableColumnInfo)))) {
const ObString &column_name = column_schema.get_column_name_str();
if (OB_ISNULL(name_buf =
static_cast<char*>(inner_alloc_->alloc(column_name.length() + 1)))) {
ret = OB_ALLOCATE_MEMORY_FAILED; ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to alloc column name buf", K(ret), K(column_name)); LOG_WARN("failed to allocate memory", K(ret));
} else if (FALSE_IT(column_info = new(obj_buf)ObPLTableColumnInfo(inner_alloc_))) {
// do nothing
} else { } else {
MEMCPY(name_buf, column_name.ptr(), column_name.length()); column_info->column_id_ = column_schema.get_column_id();
ObString deep_copy_name(column_name.length(), name_buf); column_info->meta_type_ = column_schema.get_meta_type();
column_info->column_name_ = deep_copy_name; column_info->charset_type_ = column_schema.get_charset_type();
OZ (column_infos_.push_back(column_info)); column_info->accuracy_ = column_schema.get_accuracy();
OZ (column_info->deep_copy_type_info(column_schema.get_extended_type_info()));
if (OB_SUCC(ret)) {
char *name_buf = NULL;
const ObString &column_name = column_schema.get_column_name_str();
if (OB_ISNULL(name_buf =
static_cast<char*>(inner_alloc_->alloc(column_name.length() + 1)))) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("failed to alloc column name buf", K(ret), K(column_name));
} else {
MEMCPY(name_buf, column_name.ptr(), column_name.length());
ObString deep_copy_name(column_name.length(), name_buf);
column_info->column_name_ = deep_copy_name;
OZ (column_infos_.push_back(column_info));
}
}
} }
} }
} }
CK (column_cnt_ == column_infos_.count());
} }
CK (column_cnt_ == column_infos_.count());
} }
} }
@ -400,13 +415,17 @@ 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;
column_info.column_id_ = column_schema.get_column_id(); if (column_schema.is_hidden()) {
column_info.meta_type_ = column_schema.get_meta_type(); // do nothing
column_info.charset_type_ = column_schema.get_charset_type(); } else {
column_info.accuracy_ = column_schema.get_accuracy(); column_info.column_id_ = column_schema.get_column_id();
OZ (column_info.type_info_.assign(column_schema.get_extended_type_info())); column_info.meta_type_ = column_schema.get_meta_type();
OX (column_info.column_name_ = column_schema.get_column_name_str()); column_info.charset_type_ = column_schema.get_charset_type();
OZ (column_infos.push_back(column_info)); column_info.accuracy_ = column_schema.get_accuracy();
OZ (column_info.type_info_.assign(column_schema.get_extended_type_info()));
OX (column_info.column_name_ = column_schema.get_column_name_str());
OZ (column_infos.push_back(column_info));
}
} }
} }