From e007f676a5091a91335530907110fa6272222b22 Mon Sep 17 00:00:00 2001 From: qingzhu521 Date: Sun, 7 Apr 2024 06:14:59 +0000 Subject: [PATCH] occupy the pos of mock sys view --- src/objit/include/objit/common/ob_item_type.h | 7 +++++ .../inner_table/ob_inner_table_schema_def.py | 3 +++ .../system_variable/ob_sys_var_class_type.h | 1 + .../ob_system_variable_alias.h | 1 + .../ob_system_variable_factory.cpp | 26 ++++++++++++++++++- .../ob_system_variable_factory.h | 9 ++++++- .../ob_system_variable_init.cpp | 17 +++++++++++- .../ob_system_variable_init.json | 15 +++++++++++ src/sql/resolver/ob_stmt_type.h | 6 +++++ 9 files changed, 82 insertions(+), 3 deletions(-) diff --git a/src/objit/include/objit/common/ob_item_type.h b/src/objit/include/objit/common/ob_item_type.h index 4433e54194..a67815fa3f 100755 --- a/src/objit/include/objit/common/ob_item_type.h +++ b/src/objit/include/objit/common/ob_item_type.h @@ -2461,6 +2461,13 @@ typedef enum ObItemType T_SERVICE_NAME, T_MAX_NET_BANDWIDTH, T_NET_BANDWIDTH_WEIGHT, + T_CREATE_SERVER, + T_ALTER_SERVER, + T_DROP_SERVER, + T_CREATE_LOGFILE_GROUP, + T_ALTER_LOGFILE_GROUP, + T_DROP_LOGFILE_GROUP, + T_MAX //Attention: add a new type before T_MAX } ObItemType; 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 9c6ad4029f..00f8af7e6f 100644 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -15244,6 +15244,9 @@ def_table_schema( ) # 20016: PROFILING +# 20017: OPTIMIZER_TRACE +# 20018: PLUGINS +# 20019: INNODB_SYS_COLUMNS def_table_schema( owner = 'yuzhong.zhao', diff --git a/src/share/system_variable/ob_sys_var_class_type.h b/src/share/system_variable/ob_sys_var_class_type.h index fff512a7ff..a0b0783083 100644 --- a/src/share/system_variable/ob_sys_var_class_type.h +++ b/src/share/system_variable/ob_sys_var_class_type.h @@ -357,6 +357,7 @@ enum ObSysVarClassType SYS_VAR_TRANSACTION_ALLOW_BATCHING = 10249, SYS_VAR_TRANSACTION_PREALLOC_SIZE = 10250, SYS_VAR_TRANSACTION_WRITE_SET_EXTRACTION = 10251, + SYS_VAR_INFORMATION_SCHEMA_STATS_EXPIRY = 10252, }; } diff --git a/src/share/system_variable/ob_system_variable_alias.h b/src/share/system_variable/ob_system_variable_alias.h index 6213e15fdb..f453892f74 100644 --- a/src/share/system_variable/ob_system_variable_alias.h +++ b/src/share/system_variable/ob_system_variable_alias.h @@ -352,6 +352,7 @@ namespace share static const char* const OB_SV_TRANSACTION_ALLOW_BATCHING = "transaction_allow_batching"; static const char* const OB_SV_TRANSACTION_PREALLOC_SIZE = "transaction_prealloc_size"; static const char* const OB_SV_TRANSACTION_WRITE_SET_EXTRACTION = "transaction_write_set_extraction"; + static const char* const OB_SV_INFORMATION_SCHEMA_STATS_EXPIRY = "information_schema_stats_expiry"; } } diff --git a/src/share/system_variable/ob_system_variable_factory.cpp b/src/share/system_variable/ob_system_variable_factory.cpp index fa88e77eed..b9432bf278 100644 --- a/src/share/system_variable/ob_system_variable_factory.cpp +++ b/src/share/system_variable/ob_system_variable_factory.cpp @@ -455,6 +455,7 @@ const char *ObSysVarFactory::SYS_VAR_NAMES_SORTED_BY_NAME[] = { "hostname", "identity", "ignore_builtin_innodb", + "information_schema_stats_expiry", "init_connect", "innodb_adaptive_flushing", "innodb_adaptive_flushing_lwm", @@ -794,6 +795,7 @@ const ObSysVarClassType ObSysVarFactory::SYS_VAR_IDS_SORTED_BY_NAME[] = { SYS_VAR_HOSTNAME, SYS_VAR_IDENTITY, SYS_VAR_IGNORE_BUILTIN_INNODB, + SYS_VAR_INFORMATION_SCHEMA_STATS_EXPIRY, SYS_VAR_INIT_CONNECT, SYS_VAR_INNODB_ADAPTIVE_FLUSHING, SYS_VAR_INNODB_ADAPTIVE_FLUSHING_LWM, @@ -1374,7 +1376,8 @@ const char *ObSysVarFactory::SYS_VAR_NAMES_SORTED_BY_ID[] = { "transaction_alloc_block_size", "transaction_allow_batching", "transaction_prealloc_size", - "transaction_write_set_extraction" + "transaction_write_set_extraction", + "information_schema_stats_expiry" }; bool ObSysVarFactory::sys_var_name_case_cmp(const char *name1, const ObString &name2) @@ -1879,6 +1882,7 @@ int ObSysVarFactory::create_all_sys_vars() + sizeof(ObSysVarTransactionAllowBatching) + sizeof(ObSysVarTransactionPreallocSize) + sizeof(ObSysVarTransactionWriteSetExtraction) + + sizeof(ObSysVarInformationSchemaStatsExpiry) ; void *ptr = NULL; if (OB_ISNULL(ptr = allocator_.alloc(total_mem_size))) { @@ -4911,6 +4915,15 @@ int ObSysVarFactory::create_all_sys_vars() ptr = (void *)((char *)ptr + sizeof(ObSysVarTransactionWriteSetExtraction)); } } + if (OB_SUCC(ret)) { + if (OB_ISNULL(sys_var_ptr = new (ptr)ObSysVarInformationSchemaStatsExpiry())) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_ERROR("fail to new ObSysVarInformationSchemaStatsExpiry", K(ret)); + } else { + store_buf_[ObSysVarsToIdxMap::get_store_idx(static_cast(SYS_VAR_INFORMATION_SCHEMA_STATS_EXPIRY))] = sys_var_ptr; + ptr = (void *)((char *)ptr + sizeof(ObSysVarInformationSchemaStatsExpiry)); + } + } } return ret; @@ -8617,6 +8630,17 @@ int ObSysVarFactory::create_sys_var(ObIAllocator &allocator_, ObSysVarClassType } break; } + case SYS_VAR_INFORMATION_SCHEMA_STATS_EXPIRY: { + void *ptr = NULL; + if (OB_ISNULL(ptr = allocator_.alloc(sizeof(ObSysVarInformationSchemaStatsExpiry)))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_ERROR("fail to alloc memory", K(ret), K(sizeof(ObSysVarInformationSchemaStatsExpiry))); + } else if (OB_ISNULL(sys_var_ptr = new (ptr)ObSysVarInformationSchemaStatsExpiry())) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_ERROR("fail to new ObSysVarInformationSchemaStatsExpiry", K(ret)); + } + break; + } default: { ret = OB_ERR_UNEXPECTED; diff --git a/src/share/system_variable/ob_system_variable_factory.h b/src/share/system_variable/ob_system_variable_factory.h index e0c652a175..1d27af3c3b 100644 --- a/src/share/system_variable/ob_system_variable_factory.h +++ b/src/share/system_variable/ob_system_variable_factory.h @@ -2489,6 +2489,13 @@ public: inline virtual ObSysVarClassType get_type() const { return SYS_VAR_TRANSACTION_WRITE_SET_EXTRACTION; } inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(335); } }; +class ObSysVarInformationSchemaStatsExpiry : public ObIntSysVar +{ +public: + ObSysVarInformationSchemaStatsExpiry() : ObIntSysVar(NULL, NULL, NULL, NULL, NULL) {} + inline virtual ObSysVarClassType get_type() const { return SYS_VAR_INFORMATION_SCHEMA_STATS_EXPIRY; } + inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(336); } +}; class ObSysVarFactory @@ -2509,7 +2516,7 @@ public: static const common::ObString get_sys_var_name_by_id(ObSysVarClassType sys_var_id); const static int64_t MYSQL_SYS_VARS_COUNT = 99; - const static int64_t OB_SYS_VARS_COUNT = 237; + const static int64_t OB_SYS_VARS_COUNT = 238; const static int64_t ALL_SYS_VARS_COUNT = MYSQL_SYS_VARS_COUNT + OB_SYS_VARS_COUNT; const static int64_t INVALID_MAX_READ_STALE_TIME = -1; diff --git a/src/share/system_variable/ob_system_variable_init.cpp b/src/share/system_variable/ob_system_variable_init.cpp index a52965c1ea..2db7617d7c 100644 --- a/src/share/system_variable/ob_system_variable_init.cpp +++ b/src/share/system_variable/ob_system_variable_init.cpp @@ -4751,13 +4751,28 @@ static struct VarsInit{ ObSysVars[335].alias_ = "OB_SV_TRANSACTION_WRITE_SET_EXTRACTION" ; }(); + [&] (){ + ObSysVars[336].default_value_ = "86400" ; + ObSysVars[336].info_ = "The number of seconds after which the server will fetch data from storage engine and replace the data in cache." ; + ObSysVars[336].name_ = "information_schema_stats_expiry" ; + ObSysVars[336].data_type_ = ObUInt64Type ; + ObSysVars[336].min_val_ = "0" ; + ObSysVars[336].max_val_ = "31536000" ; + ObSysVars[336].flags_ = ObSysVarFlag::GLOBAL_SCOPE | ObSysVarFlag::SESSION_SCOPE | ObSysVarFlag::MYSQL_ONLY ; + ObSysVars[336].id_ = SYS_VAR_INFORMATION_SCHEMA_STATS_EXPIRY ; + cur_max_var_id = MAX(cur_max_var_id, static_cast(SYS_VAR_INFORMATION_SCHEMA_STATS_EXPIRY)) ; + ObSysVarsIdToArrayIdx[SYS_VAR_INFORMATION_SCHEMA_STATS_EXPIRY] = 336 ; + ObSysVars[336].base_value_ = "86400" ; + ObSysVars[336].alias_ = "OB_SV_INFORMATION_SCHEMA_STATS_EXPIRY" ; + }(); + if (cur_max_var_id >= ObSysVarFactory::OB_MAX_SYS_VAR_ID) { HasInvalidSysVar = true; } } }vars_init; -static int64_t var_amount = 336; +static int64_t var_amount = 337; int64_t ObSysVariables::get_all_sys_var_count(){ return ObSysVarFactory::ALL_SYS_VARS_COUNT;} ObSysVarClassType ObSysVariables::get_sys_var_id(int64_t i){ return ObSysVars[i].id_;} diff --git a/src/share/system_variable/ob_system_variable_init.json b/src/share/system_variable/ob_system_variable_init.json index 4423c763ec..ef45b00a9a 100644 --- a/src/share/system_variable/ob_system_variable_init.json +++ b/src/share/system_variable/ob_system_variable_init.json @@ -4937,5 +4937,20 @@ "info_cn": "", "background_cn": "", "ref_url": "" + }, + "information_schema_stats_expiry": { + "id": 10252, + "name": "information_schema_stats_expiry", + "default_value": "86400", + "base_value": "86400", + "data_type": "uint", + "info": "The number of seconds after which the server will fetch data from storage engine and replace the data in cache.", + "flags": "GLOBAL | SESSION | MYSQL_ONLY", + "info_cn": "", + "background_cn": "", + "ref_url": "", + "min_val": "0", + "max_val": "31536000", + "publish_version": "424" } } diff --git a/src/sql/resolver/ob_stmt_type.h b/src/sql/resolver/ob_stmt_type.h index 45970bcee6..0532b9a9f8 100644 --- a/src/sql/resolver/ob_stmt_type.h +++ b/src/sql/resolver/ob_stmt_type.h @@ -313,6 +313,12 @@ OB_STMT_TYPE_DEF_UNKNOWN_AT(T_SHOW_OPEN_TABLES, err_stmt_type_priv, 312) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_REPAIR_TABLE, no_priv_needed, 313) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_CHECKSUM_TABLE, no_priv_needed, 314) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_SERVICE_NAME, get_sys_tenant_alter_system_priv, 315) +OB_STMT_TYPE_DEF_UNKNOWN_AT(T_CREATE_SERVER, get_sys_tenant_alter_system_priv, 316) +OB_STMT_TYPE_DEF_UNKNOWN_AT(T_ALTER_SERVER, get_sys_tenant_alter_system_priv, 317) +OB_STMT_TYPE_DEF_UNKNOWN_AT(T_DROP_SERVER, get_sys_tenant_alter_system_priv, 318) +OB_STMT_TYPE_DEF_UNKNOWN_AT(T_CREATE_LOGFILE_GROUP, no_priv_needed, 319) +OB_STMT_TYPE_DEF_UNKNOWN_AT(T_ALTER_LOGFILE_GROUP, no_priv_needed, 320) +OB_STMT_TYPE_DEF_UNKNOWN_AT(T_DROP_LOGFILE_GROUP, no_priv_needed, 321) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_MAX, err_stmt_type_priv, 500) #endif