From 6af7f9ae79cd0ecbafd4b1b88e2886ccdba0c3be Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 1 Nov 2022 06:35:12 +0000 Subject: [PATCH] [bugfix] forbid integer improvement ddl and serialize column obj type to column header --- src/share/schema/ob_table_schema.cpp | 5 +++++ .../blocksstable/encoding/ob_icolumn_encoder.h | 2 +- .../encoding/ob_micro_block_encoder.cpp | 4 ++-- .../blocksstable/ob_block_sstable_struct.h | 15 ++++++++++++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/share/schema/ob_table_schema.cpp b/src/share/schema/ob_table_schema.cpp index 0eb90a830b..33439b4697 100644 --- a/src/share/schema/ob_table_schema.cpp +++ b/src/share/schema/ob_table_schema.cpp @@ -3826,6 +3826,11 @@ int ObTableSchema::check_alter_column_type(const ObColumnSchemaV2 &src_column, || (src_meta.is_varbinary() && dst_meta.is_blob()) || (src_meta.is_text() && (dst_meta.is_text() || dst_meta.is_varchar())) || (src_meta.is_blob() && (dst_meta.is_blob() || dst_meta.is_varbinary())))) { + if (src_meta.is_integer_type() && dst_meta.is_integer_type()) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("Type increment of integer type is not supported", K(ret), K(src_meta), K(dst_meta)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "Type increment of integer type is"); + } // online, do nothing } else { is_offline = true; diff --git a/src/storage/blocksstable/encoding/ob_icolumn_encoder.h b/src/storage/blocksstable/encoding/ob_icolumn_encoder.h index b571f8a57d..cb8bd6fd61 100644 --- a/src/storage/blocksstable/encoding/ob_icolumn_encoder.h +++ b/src/storage/blocksstable/encoding/ob_icolumn_encoder.h @@ -75,7 +75,7 @@ public: EncoderDesc &get_desc() { return desc_; } ObColumnHeader &get_column_header() { return column_header_; } - + ObObjType get_obj_type() { return column_type_.get_type(); } // var data store only virtual int set_data_pos(const int64_t offset, const int64_t length) { diff --git a/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp b/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp index eac3797a02..6660898132 100644 --- a/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp +++ b/src/storage/blocksstable/encoding/ob_micro_block_encoder.cpp @@ -521,15 +521,15 @@ int ObMicroBlockEncoder::store_encoding_meta_and_fix_cols(int64_t &encoding_meta if (OB_FAIL(encoders_.at(i)->store_meta(data_buffer_))) { LOG_WARN("store encoding meta failed", K(ret)); } else { + ObColumnHeader &ch = encoders_.at(i)->get_column_header(); if (data_buffer_.pos() > pos_bak) { - ObColumnHeader &ch = encoders_.at(i)->get_column_header(); ch.offset_ = static_cast(pos_bak - encoding_meta_offset); ch.length_ = static_cast(data_buffer_.pos() - pos_bak); } else if (ObColumnHeader::RAW == encoders_.at(i)->get_type()) { // column header offset records the start pos of the fix data, if needed - ObColumnHeader &ch = encoders_.at(i)->get_column_header(); ch.offset_ = static_cast(pos_bak - encoding_meta_offset); } + ch.obj_type_ = static_cast(encoders_.at(i)->get_obj_type()); } if (OB_SUCC(ret) && !desc.is_var_data_ && desc.need_data_store_) { diff --git a/src/storage/blocksstable/ob_block_sstable_struct.h b/src/storage/blocksstable/ob_block_sstable_struct.h index 700b17662b..adcc4fe1c4 100644 --- a/src/storage/blocksstable/ob_block_sstable_struct.h +++ b/src/storage/blocksstable/ob_block_sstable_struct.h @@ -291,7 +291,7 @@ struct ObColumnHeader int8_t version_; int8_t type_; int8_t attr_; - int8_t reserved_; + uint8_t obj_type_; union { uint32_t extend_value_offset_; // for var column null-bitmap stored continuously uint32_t extend_value_index_; @@ -299,9 +299,16 @@ struct ObColumnHeader uint32_t offset_; uint32_t length_; + static_assert(UINT8_MAX >= ObObjType::ObMaxType, "ObObjType is stored in ObColumnHeader with 1 byte"); ObColumnHeader() { reuse(); } void reuse() { memset(this, 0, sizeof(*this)); } - bool is_valid() const { return version_ == OB_COLUMN_HEADER_V1 && type_ >= 0 && type_ < MAX_TYPE; } + bool is_valid() const + { + return version_ == OB_COLUMN_HEADER_V1 + && type_ >= 0 + && type_ < MAX_TYPE + && obj_type_ < ObObjType::ObMaxType; + } inline bool is_fix_length() const { return attr_ & FIX_LENGTH; } inline bool has_extend_value() const { return attr_ & HAS_EXTEND_VALUE; } @@ -316,6 +323,7 @@ struct ObColumnHeader { return COLUMN_EQUAL == type || COLUMN_SUBSTR == type; } + inline ObObjType get_store_obj_type() const { return static_cast(obj_type_); } inline void set_fix_lenght_attr() { attr_ |= FIX_LENGTH; } inline void set_has_extend_value_attr() { attr_ |= HAS_EXTEND_VALUE; } @@ -323,7 +331,8 @@ struct ObColumnHeader inline void set_last_var_field_attr() { attr_ |= LAST_VAR_FIELD; } inline void set_out_row() { attr_ |= OUT_ROW; } - TO_STRING_KV(K_(version), K_(type), K_(attr), K_(extend_value_offset), K_(offset), K_(length)); + TO_STRING_KV(K_(version), K_(type), K_(attr), K_(obj_type), + K_(extend_value_offset), K_(offset), K_(length)); } __attribute__((packed)); -- GitLab