diff --git a/src/objit/include/objit/common/ob_item_type.h b/src/objit/include/objit/common/ob_item_type.h index 46480d82c2..1b264ce1b6 100755 --- a/src/objit/include/objit/common/ob_item_type.h +++ b/src/objit/include/objit/common/ob_item_type.h @@ -2448,6 +2448,11 @@ typedef enum ObItemType T_FLUSH_MOCK_LIST, T_HANDLER_MOCK, T_SHOW_PLUGINS, + T_PSEUDO_PARTITION_LIST_COL, + T_EXTERNAL_USER_SPECIFIED_PARTITION, + T_ALTER_EXTERNAL_PARTITION_OPTION, + T_ALTER_EXTERNAL_PARTITION_ADD, + T_ALTER_EXTERNAL_PARTITION_DROP, T_MAX //Attention: add a new type before T_MAX } ObItemType; diff --git a/src/share/inner_table/ob_inner_table_schema.101_150.cpp b/src/share/inner_table/ob_inner_table_schema.101_150.cpp index f3eb574170..96c536c812 100644 --- a/src/share/inner_table/ob_inner_table_schema.101_150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.101_150.cpp @@ -12514,6 +12514,21 @@ int ObInnerTableSchema::all_part_schema(ObTableSchema &table_schema) tablet_id_default, tablet_id_default); //default_value } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("external_location", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + OB_MAX_VARBINARY_LENGTH, //column_length + -1, //column_precision + -1, //column_scale + true, //is_nullable + false); //is_autoincrement + } table_schema.set_index_using_type(USING_BTREE); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); @@ -13061,6 +13076,21 @@ int ObInnerTableSchema::all_part_history_schema(ObTableSchema &table_schema) tablet_id_default, tablet_id_default); //default_value } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("external_location", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + OB_MAX_VARBINARY_LENGTH, //column_length + -1, //column_precision + -1, //column_scale + true, //is_nullable + false); //is_autoincrement + } table_schema.set_index_using_type(USING_BTREE); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); diff --git a/src/share/inner_table/ob_inner_table_schema.12051_12100.cpp b/src/share/inner_table/ob_inner_table_schema.12051_12100.cpp index 003a8531b1..1ef2569962 100644 --- a/src/share/inner_table/ob_inner_table_schema.12051_12100.cpp +++ b/src/share/inner_table/ob_inner_table_schema.12051_12100.cpp @@ -9932,6 +9932,21 @@ int ObInnerTableSchema::all_virtual_part_schema(ObTableSchema &table_schema) tablet_id_default, tablet_id_default); //default_value } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("external_location", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + OB_MAX_VARBINARY_LENGTH, //column_length + -1, //column_precision + -1, //column_scale + true, //is_nullable + false); //is_autoincrement + } table_schema.set_index_using_type(USING_BTREE); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); @@ -10463,6 +10478,21 @@ int ObInnerTableSchema::all_virtual_part_history_schema(ObTableSchema &table_sch tablet_id_default, tablet_id_default); //default_value } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("external_location", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + OB_MAX_VARBINARY_LENGTH, //column_length + -1, //column_precision + -1, //column_scale + true, //is_nullable + false); //is_autoincrement + } table_schema.set_index_using_type(USING_BTREE); table_schema.set_row_store_type(ENCODING_ROW_STORE); table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); diff --git a/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp b/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp index c43e2c0201..fe0a383024 100644 --- a/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.15101_15150.cpp @@ -7977,6 +7977,21 @@ int ObInnerTableSchema::all_virtual_part_real_agent_ora_schema(ObTableSchema &ta false); //is_autoincrement } + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("EXTERNAL_LOCATION", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + OB_MAX_VARBINARY_LENGTH, //column_length + -1, //column_precision + -1, //column_scale + true, //is_nullable + false); //is_autoincrement + } + if (OB_SUCC(ret)) { ADD_COLUMN_SCHEMA("GMT_CREATE", //column_name ++column_id, //column_id diff --git a/src/share/inner_table/ob_inner_table_schema_def.py b/src/share/inner_table/ob_inner_table_schema_def.py index a6a3243ab8..7f5944c567 100644 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -1106,7 +1106,8 @@ all_part_def = dict( ('source_partition_id', 'varchar:MAX_VALUE_LENGTH', 'true', ''), ('tablespace_id', 'int', 'false', '-1'), ('partition_type', 'int', 'false', '0'), - ('tablet_id', 'bigint', 'false', 'ObTabletID::INVALID_TABLET_ID') + ('tablet_id', 'bigint', 'false', 'ObTabletID::INVALID_TABLET_ID'), + ('external_location', 'varbinary:OB_MAX_VARBINARY_LENGTH', 'true'), ], ) diff --git a/src/share/ob_rpc_struct.cpp b/src/share/ob_rpc_struct.cpp index 38f9f0ea69..8306f294fe 100755 --- a/src/share/ob_rpc_struct.cpp +++ b/src/share/ob_rpc_struct.cpp @@ -7038,6 +7038,7 @@ void ObAlterTableResArg::reset() schema_type_ = OB_MAX_SCHEMA; schema_id_ = OB_INVALID_ID; schema_version_ = OB_INVALID_VERSION; + part_object_id_ = OB_INVALID_ID; } int ObDDLRes::assign(const ObDDLRes &other) @@ -7080,7 +7081,7 @@ int ObDropDatabaseRes::assign(const ObDropDatabaseRes &other) } OB_SERIALIZE_MEMBER(ObDropDatabaseRes, ddl_res_, affected_row_); -OB_SERIALIZE_MEMBER(ObAlterTableResArg, schema_type_, schema_id_, schema_version_); +OB_SERIALIZE_MEMBER(ObAlterTableResArg, schema_type_, schema_id_, schema_version_, part_object_id_); OB_SERIALIZE_MEMBER(ObAlterTableRes, index_table_id_, constriant_id_, schema_version_, res_arg_array_, ddl_type_, task_id_, ddl_res_array_); OB_SERIALIZE_MEMBER(ObGetTenantSchemaVersionArg, tenant_id_); diff --git a/src/share/ob_rpc_struct.h b/src/share/ob_rpc_struct.h index 559c0a2039..a1c6676773 100755 --- a/src/share/ob_rpc_struct.h +++ b/src/share/ob_rpc_struct.h @@ -8566,7 +8566,8 @@ public: ObAlterTableResArg() : schema_type_(share::schema::OB_MAX_SCHEMA), schema_id_(common::OB_INVALID_ID), - schema_version_(common::OB_INVALID_VERSION) + schema_version_(common::OB_INVALID_VERSION), + part_object_id_(common::OB_INVALID_ID) {} ObAlterTableResArg( const share::schema::ObSchemaType schema_type, @@ -8575,13 +8576,24 @@ public: : schema_type_(schema_type), schema_id_(schema_id), schema_version_(schema_version) + {} + ObAlterTableResArg( + const share::schema::ObSchemaType schema_type, + const uint64_t schema_id, + const int64_t schema_version, + const int64_t part_object_id) + : schema_type_(schema_type), + schema_id_(schema_id), + schema_version_(schema_version), + part_object_id_(part_object_id) {} void reset(); public: - TO_STRING_KV(K_(schema_type), K_(schema_id), K_(schema_version)); + TO_STRING_KV(K_(schema_type), K_(schema_id), K_(schema_version), K_(part_object_id)); share::schema::ObSchemaType schema_type_; uint64_t schema_id_; int64_t schema_version_; + int64_t part_object_id_; }; struct ObDDLRes final diff --git a/src/share/schema/ob_schema_struct.cpp b/src/share/schema/ob_schema_struct.cpp index 8c689d1b1c..189c7b01f2 100644 --- a/src/share/schema/ob_schema_struct.cpp +++ b/src/share/schema/ob_schema_struct.cpp @@ -5382,7 +5382,8 @@ ObBasePartition::ObBasePartition() tablespace_id_(common::OB_INVALID_ID), partition_type_(PARTITION_TYPE_NORMAL), low_bound_val_(), - tablet_id_() + tablet_id_(), + external_location_() { } ObBasePartition::ObBasePartition(common::ObIAllocator *allocator) @@ -5402,7 +5403,8 @@ ObBasePartition::ObBasePartition(common::ObIAllocator *allocator) tablespace_id_(common::OB_INVALID_ID), partition_type_(PARTITION_TYPE_NORMAL), low_bound_val_(), - tablet_id_() + tablet_id_(), + external_location_() { } void ObBasePartition::reset() @@ -5425,6 +5427,7 @@ void ObBasePartition::reset() partition_type_ = PARTITION_TYPE_NORMAL; name_.reset(); ObSchema::reset(); + external_location_.reset(); } int ObBasePartition::assign(const ObBasePartition & src_part) @@ -5444,6 +5447,8 @@ int ObBasePartition::assign(const ObBasePartition & src_part) partition_type_ = src_part.partition_type_; if (OB_FAIL(deep_copy_str(src_part.name_, name_))) { LOG_WARN("Fail to deep copy name", K(ret)); + } else if (OB_FAIL(deep_copy_str(src_part.external_location_, external_location_))) { + LOG_WARN("Fail to deep copy name", K(ret)); } else if (OB_FAIL(set_high_bound_val(src_part.high_bound_val_))) { LOG_WARN("Fail to deep copy high_bound_val_", K(ret)); } else if (OB_FAIL(set_low_bound_val(src_part.low_bound_val_))) { @@ -5714,7 +5719,8 @@ OB_DEF_SERIALIZE(ObBasePartition) tablespace_id_, partition_type_, low_bound_val_, - tablet_id_); + tablet_id_, + external_location_); return ret; } @@ -5796,7 +5802,7 @@ OB_DEF_DESERIALIZE(ObBasePartition) if (FAILEDx(low_bound_val.deserialize(buf, data_len, pos, true))) { LOG_WARN("fail to deserialze low_bound_val", KR(ret)); } - LST_DO_CODE(OB_UNIS_DECODE, tablet_id_); + LST_DO_CODE(OB_UNIS_DECODE, tablet_id_, external_location_); if (OB_SUCC(ret) && OB_FAIL(set_low_bound_val(low_bound_val))) { LOG_WARN("Fail to deep copy low_bound_val", K(ret), K(low_bound_val)); } @@ -5809,7 +5815,7 @@ OB_DEF_SERIALIZE_SIZE(ObBasePartition) LST_DO_CODE(OB_UNIS_ADD_LEN, tenant_id_, table_id_, part_id_, schema_version_, name_, high_bound_val_, status_, part_idx_, is_empty_partition_name_, - tablespace_id_, partition_type_, low_bound_val_, tablet_id_); + tablespace_id_, partition_type_, low_bound_val_, tablet_id_, external_location_); len += serialization::encoded_length_vi64(list_row_values_.count()); for (int64_t i = 0; i < list_row_values_.count(); i ++) { len += list_row_values_.at(i).get_serialize_size(); @@ -5827,6 +5833,7 @@ int64_t ObBasePartition::get_deep_copy_size() const list_row_size += list_row_values_.at(i).get_deep_copy_size(); } deep_copy_size += list_row_size * 2 - 1; + deep_copy_size += external_location_.length() + 1; return deep_copy_size; } diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index 235afd6b52..b36c21c6e4 100755 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -145,7 +145,9 @@ static const uint64_t OB_MIN_ID = 0;//used for lower_bound // table_flags stored in __all_table.table_flag #define CASCADE_RLS_OBJECT_FLAG (INT64_C(1) << 0) - +#define EXTERNAL_TABLE_USER_SPECIFIED_PARTITION_FLAG (INT64_C(1) << 1) +#define EXTERNAL_TABLE_AUTO_REFRESH_FLAG (INT64_C(1) << 2) +#define EXTERNAL_TABLE_CREATE_ON_REFRESH_FLAG (INT64_C(1) << 3) // schema array size static const int64_t SCHEMA_SMALL_MALLOC_BLOCK_SIZE = 64; static const int64_t SCHEMA_MALLOC_BLOCK_SIZE = 128; @@ -2119,9 +2121,13 @@ public: // convert character set. int convert_character_for_range_columns_part(const ObCollationType &to_collation); int convert_character_for_list_columns_part(const ObCollationType &to_collation); + int set_external_location(common::ObString &location) + { return deep_copy_str(location, external_location_); } + const common::ObString &get_external_location() const + { return external_location_; } VIRTUAL_TO_STRING_KV(K_(tenant_id), K_(table_id), K_(part_id), K_(name), K_(low_bound_val), K_(high_bound_val), K_(list_row_values), K_(part_idx), - K_(is_empty_partition_name), K_(tablet_id)); + K_(is_empty_partition_name), K_(tablet_id), K_(external_location)); protected: uint64_t tenant_id_; uint64_t table_id_; @@ -2149,6 +2155,7 @@ protected: PartitionType partition_type_; common::ObRowkey low_bound_val_; ObTabletID tablet_id_; + common::ObString external_location_; }; class ObSubPartition; diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result index 38b7dc797e..84ccff0a1b 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_sys.result @@ -2888,6 +2888,7 @@ source_partition_id varchar(4096) YES tablespace_id bigint(20) NO -1 partition_type bigint(20) NO 0 tablet_id bigint(20) NO 0 +external_location varbinary(65536) YES NULL select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_part; IF(count(*) >= 0, 1, 0) 1 @@ -2924,6 +2925,7 @@ source_partition_id varchar(4096) YES tablespace_id bigint(20) YES -1 partition_type bigint(20) YES 0 tablet_id bigint(20) YES 0 +external_location varbinary(65536) YES NULL select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_part_history; IF(count(*) >= 0, 1, 0) 1