diff --git a/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h b/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h index 8d88142b80..c7dfbd2f1a 100644 --- a/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h +++ b/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h @@ -1128,6 +1128,9 @@ PCODE_DEF(OB_TRIM_KEY_LIST, 0x1618) //proxy user //PCODE_DEF(OB_ALTER_USER_PROXY, 0x1620) +// global sequence service +// PCODE_DEF(OB_GAIS_NEXT_SEQUENCE_REQUEST, 0x1621) + //**** 注意:在此行之前增加新的RPC ID ****** // //占位须知: diff --git a/src/share/inner_table/ob_inner_table_schema.12101_12150.cpp b/src/share/inner_table/ob_inner_table_schema.12101_12150.cpp index 9df77f49a9..6bd0528040 100644 --- a/src/share/inner_table/ob_inner_table_schema.12101_12150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.12101_12150.cpp @@ -4403,6 +4403,25 @@ int ObInnerTableSchema::all_virtual_sequence_object_schema(ObTableSchema &table_ is_system_generated_default, is_system_generated_default); //default_value } + + if (OB_SUCC(ret)) { + ObObj flag_default; + flag_default.set_int(0); + ADD_COLUMN_SCHEMA_T("flag", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + flag_default, + flag_default); //default_value + } 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); @@ -4689,6 +4708,25 @@ int ObInnerTableSchema::all_virtual_sequence_object_history_schema(ObTableSchema true, //is_nullable false); //is_autoincrement } + + if (OB_SUCC(ret)) { + ObObj flag_default; + flag_default.set_int(0); + ADD_COLUMN_SCHEMA_T("flag", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + flag_default, + flag_default); //default_value + } 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 e196bd1b50..f0be8f484c 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 @@ -8895,6 +8895,21 @@ int ObInnerTableSchema::all_virtual_sequence_object_real_agent_ora_schema(ObTabl false); //is_autoincrement } + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("FLAG", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObNumberType, //column_type + CS_TYPE_INVALID, //column_collation_type + 38, //column_length + 38, //column_precision + 0, //column_scale + false, //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.201_250.cpp b/src/share/inner_table/ob_inner_table_schema.201_250.cpp index 831f47cec2..62c8dbed8c 100644 --- a/src/share/inner_table/ob_inner_table_schema.201_250.cpp +++ b/src/share/inner_table/ob_inner_table_schema.201_250.cpp @@ -1653,6 +1653,25 @@ int ObInnerTableSchema::all_sequence_object_schema(ObTableSchema &table_schema) is_system_generated_default, is_system_generated_default); //default_value } + + if (OB_SUCC(ret)) { + ObObj flag_default; + flag_default.set_int(0); + ADD_COLUMN_SCHEMA_T("flag", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + flag_default, + flag_default); //default_value + } 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); @@ -1955,6 +1974,25 @@ int ObInnerTableSchema::all_sequence_object_history_schema(ObTableSchema &table_ true, //is_nullable false); //is_autoincrement } + + if (OB_SUCC(ret)) { + ObObj flag_default; + flag_default.set_int(0); + ADD_COLUMN_SCHEMA_T("flag", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(int64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + flag_default, + flag_default); //default_value + } 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_def.py b/src/share/inner_table/ob_inner_table_schema_def.py index 0a05f45cd0..5c5cdb2b4f 100644 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -1785,6 +1785,7 @@ def_table_schema( ('order_flag', 'bool', 'false'), ('cycle_flag', 'bool', 'false'), ('is_system_generated', 'bool', 'false', 'false'), + ('flag', 'int', 'false', 0), ], ) @@ -1813,6 +1814,7 @@ def_table_schema( ('order_flag', 'bool', 'true'), ('cycle_flag', 'bool', 'true'), ('is_system_generated', 'bool', 'true'), + ('flag', 'int', 'false', 0), ], ) diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index b7b902aea8..a84b3daac7 100755 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -6888,6 +6888,11 @@ public: // inline void set_cache_size(int64_t val) { option_.set_cache_size(val); } inline void set_cycle_flag(bool cycle) { option_.set_cycle_flag(cycle); } inline void set_order_flag(bool order) { option_.set_order_flag(order); } + inline void set_flag(int64_t flag) { option_.set_flag(flag); } + inline void set_cache_order_mode(ObSequenceCacheOrderMode mode) + { + option_.set_cache_order_mode(mode); + } // Temporary compatibility code, in order to support max_value etc. as Number type // int set_max_value(const common::ObString &str); @@ -6918,8 +6923,13 @@ public: //inline int64_t get_increment_by() const { return option_.get_increment_by(); } //inline int64_t get_start_with() const { return option_.get_start_with(); } //inline int64_t get_cache_size() const { return option_.get_cache_size(); } + inline int64_t get_flag() const { return option_.get_flag(); } inline bool get_cycle_flag() const { return option_.get_cycle_flag(); } inline bool get_order_flag() const { return option_.get_order_flag(); } + inline ObSequenceCacheOrderMode get_cache_order_mode() const + { + return option_.get_cache_order_mode(); + } inline const common::ObString &get_sequence_name() const { return name_; } inline const char *get_sequence_name_str() const { return extract_str(name_); } inline share::ObSequenceOption &get_sequence_option() { return option_; } diff --git a/src/share/sequence/ob_sequence_option.cpp b/src/share/sequence/ob_sequence_option.cpp index c183e46fd2..b543df0063 100644 --- a/src/share/sequence/ob_sequence_option.cpp +++ b/src/share/sequence/ob_sequence_option.cpp @@ -28,7 +28,8 @@ OB_SERIALIZE_MEMBER(ObSequenceOption, minvalue_, cache_, cycle_, - order_); + order_, + flag_); ObSequenceMaxMinInitializer::ObSequenceMaxMinInitializer() @@ -125,6 +126,7 @@ int ObSequenceOption::assign(const share::ObSequenceOption &from) OZ(cache_.assign(from.cache_)); cycle_ = from.cycle_; order_ = from.order_; + flag_ = from.flag_; return ret; } diff --git a/src/share/sequence/ob_sequence_option.h b/src/share/sequence/ob_sequence_option.h index 452a472fc3..8e68b1dc5d 100644 --- a/src/share/sequence/ob_sequence_option.h +++ b/src/share/sequence/ob_sequence_option.h @@ -138,7 +138,11 @@ public: } }; - +enum ObSequenceCacheOrderMode +{ + OLD_ACTION = 0, + NEW_ACTION = 1, +}; class ObSequenceOption { @@ -153,7 +157,8 @@ public: minvalue_(), cache_(static_cast(20)), cycle_(false), - order_(false) + order_(false), + flag_(0) { set_nomaxvalue(); set_nominvalue(); @@ -172,6 +177,8 @@ public: OB_INLINE int set_cache_size(const common::number::ObNumber & value) { return cache_.set(value); } OB_INLINE void set_cycle_flag(bool flag) { cycle_ = flag; } OB_INLINE void set_order_flag(bool flag) { order_ = flag; } + OB_INLINE void set_flag(int64_t flag) { flag_ = flag; } + OB_INLINE void set_cache_order_mode(ObSequenceCacheOrderMode mode) { cache_order_mode_ = mode; } OB_INLINE const common::number::ObNumber &get_increment_by() const { return increment_by_.val(); } OB_INLINE const common::number::ObNumber &get_start_with() const { return start_with_.val(); } @@ -180,6 +187,8 @@ public: OB_INLINE const common::number::ObNumber &get_cache_size() const { return cache_.val(); } OB_INLINE bool get_cycle_flag() const { return cycle_; } OB_INLINE bool get_order_flag() const { return order_; } + OB_INLINE int64_t get_flag() const { return flag_; } + OB_INLINE ObSequenceCacheOrderMode get_cache_order_mode() const { return cache_order_mode_; } // helper func @@ -212,6 +221,7 @@ public: cache_.set(static_cast(20)); cycle_ = false; order_ = false; + flag_ = 0; } /* 如果 bitset 中未设置,则使用 from 中的值, @@ -254,6 +264,10 @@ public: !opt_bitset.has_member(ObSequenceArg::NOORDER)) { order_ = from.order_; } + // The flag field will not be modified through alter, just copy the value in from. + if (OB_SUCC(ret)) { + flag_ = from.flag_; + } return ret; } @@ -275,6 +289,12 @@ private: ObSequenceValue cache_; bool cycle_; bool order_; + union { + int64_t flag_; + struct { + ObSequenceCacheOrderMode cache_order_mode_:1; + }; + }; }; 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 13af312c3b..d8e4c20c13 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 @@ -3726,6 +3726,7 @@ cache_size decimal(28,0) NO NULL order_flag tinyint(4) NO NULL cycle_flag tinyint(4) NO NULL is_system_generated tinyint(4) NO 0 +flag bigint(20) NO 0 select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_sequence_object; IF(count(*) >= 0, 1, 0) 1 @@ -3747,6 +3748,7 @@ cache_size decimal(28,0) YES NULL order_flag tinyint(4) YES NULL cycle_flag tinyint(4) YES NULL is_system_generated tinyint(4) YES NULL +flag bigint(20) NO 0 select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_sequence_object_history; IF(count(*) >= 0, 1, 0) 1