From 5ce9ef5136346715df339eef03be367855eaac35 Mon Sep 17 00:00:00 2001 From: yinyj17 Date: Mon, 27 May 2024 11:18:00 +0000 Subject: [PATCH] [FEAT MERGE] patch 423 sql compatible features to 432 Co-authored-by: akaError Co-authored-by: JinmaoLi Co-authored-by: qingzhu521 --- deps/oblib/src/lib/ob_define.h | 4 +- deps/oblib/src/lib/ob_name_def.h | 2 + deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h | 2 + src/observer/CMakeLists.txt | 5 + .../mysql/ob_mysql_request_manager.cpp | 10 +- src/observer/mysql/obmp_connect.cpp | 66 +- src/observer/mysql/obmp_connect.h | 3 + src/observer/mysql/obmp_debug.cpp | 81 ++ src/observer/mysql/obmp_debug.h | 42 + src/observer/mysql/obmp_init_db.cpp | 5 +- src/observer/mysql/obmp_process_info.cpp | 49 ++ src/observer/mysql/obmp_process_info.h | 39 + src/observer/mysql/obmp_process_kill.cpp | 53 ++ src/observer/mysql/obmp_process_kill.h | 41 + src/observer/mysql/obmp_query.cpp | 1 + src/observer/mysql/obmp_query.h | 1 + src/observer/mysql/obmp_refresh.cpp | 78 ++ src/observer/mysql/obmp_refresh.h | 42 + src/observer/ob_srv_xlator.cpp | 28 + src/observer/ob_srv_xlator_rootserver.cpp | 1 + .../ob_all_virtual_compatibility_control.cpp | 143 ++++ .../ob_all_virtual_compatibility_control.h | 45 + .../virtual_table/ob_gv_sql_audit.cpp | 6 +- .../ob_information_columns_table.cpp | 10 +- .../ob_information_user_privileges_table.cpp | 6 + .../virtual_table/ob_mysql_user_table.cpp | 6 +- src/observer/virtual_table/ob_show_grants.cpp | 9 + .../virtual_table/ob_show_processlist.cpp | 4 +- .../virtual_table/ob_table_columns.cpp | 5 +- .../virtual_table/ob_tenant_all_tables.cpp | 7 +- .../virtual_table/ob_tenant_all_tables.h | 113 +++ .../virtual_table/ob_tenant_show_tables.cpp | 5 +- .../ob_virtual_table_iterator_factory.cpp | 18 +- src/pl/ob_pl.cpp | 3 + src/pl/ob_pl_resolver.cpp | 1 + src/rootserver/ob_ddl_operator.cpp | 141 +++- src/rootserver/ob_ddl_operator.h | 7 + src/rootserver/ob_ddl_service.cpp | 179 +++- src/rootserver/ob_ddl_service.h | 2 + src/rootserver/ob_ddl_sql_generator.cpp | 6 + src/rootserver/ob_root_service.cpp | 21 + src/rootserver/ob_root_service.h | 1 + src/rootserver/ob_rs_rpc_processor.h | 2 + src/rootserver/ob_schema_history_recycler.cpp | 4 +- src/share/CMakeLists.txt | 1 + .../ob_inner_table_schema.12451_12500.cpp | 769 ++++++++++++++++++ .../ob_inner_table_schema.15401_15450.cpp | 283 +++++++ .../ob_inner_table_schema.20001_20050.cpp | 50 ++ .../ob_inner_table_schema.21001_21050.cpp | 4 +- .../ob_inner_table_schema.21201_21250.cpp | 4 +- .../ob_inner_table_schema.21301_21350.cpp | 6 +- .../ob_inner_table_schema.21501_21550.cpp | 50 ++ .../ob_inner_table_schema.25101_25150.cpp | 2 +- .../ob_inner_table_schema.25301_25350.cpp | 50 ++ .../ob_inner_table_schema.28001_28050.cpp | 4 +- .../ob_inner_table_schema.28101_28150.cpp | 4 +- .../ob_inner_table_schema.28201_28250.cpp | 437 ++++++++++ .../ob_inner_table_schema.501_550.cpp | 714 ++++++++++++++++ .../ob_inner_table_schema.50501_50550.cpp | 540 ++++++++++++ .../ob_inner_table_schema.60501_60550.cpp | 360 ++++++++ src/share/inner_table/ob_inner_table_schema.h | 132 ++- .../inner_table/ob_inner_table_schema.lob.cpp | 2 +- .../inner_table/ob_inner_table_schema.vt.cpp | 21 + .../ob_inner_table_schema_constants.h | 52 ++ .../inner_table/ob_inner_table_schema_def.py | 345 +++++++- .../ob_inner_table_schema_misc.ipp | 121 +++ src/share/inner_table/table_id_to_name | 39 + src/share/ob_cluster_version.h | 1 + src/share/ob_common_rpc_proxy.h | 1 + src/share/ob_compatibility_control.cpp | 187 +++++ src/share/ob_compatibility_control.h | 99 +++ .../ob_compatibility_control_feature_def.h | 36 + .../ob_compatibility_security_feature_def.h | 20 + src/share/ob_rpc_struct.cpp | 47 ++ src/share/ob_rpc_struct.h | 42 +- src/share/ob_upgrade_utils.cpp | 60 ++ src/share/ob_upgrade_utils.h | 12 +- src/share/ob_virtual_table_iterator.cpp | 2 +- src/share/schema/ob_priv_sql_service.cpp | 108 ++- src/share/schema/ob_priv_sql_service.h | 16 + src/share/schema/ob_priv_type.h | 6 +- src/share/schema/ob_schema_getter_guard.cpp | 129 ++- src/share/schema/ob_schema_retrieve_utils.h | 15 + src/share/schema/ob_schema_retrieve_utils.ipp | 150 ++++ src/share/schema/ob_schema_service.h | 2 + .../schema/ob_schema_service_sql_impl.cpp | 237 +++++- src/share/schema/ob_schema_service_sql_impl.h | 20 + src/share/schema/ob_schema_struct.cpp | 159 ++++ src/share/schema/ob_schema_struct.h | 77 +- src/share/schema/ob_server_schema_service.h | 7 +- src/share/schema/ob_user_sql_service.cpp | 235 +++++- src/share/schema/ob_user_sql_service.h | 26 + .../system_variable/ob_system_variable.cpp | 184 +++++ .../system_variable/ob_system_variable.h | 44 + .../ob_system_variable_factory.h | 8 +- .../ob_system_variable_init.cpp | 10 + .../ob_system_variable_init.json | 10 + src/sql/CMakeLists.txt | 6 + .../engine/cmd/ob_alter_system_executor.cpp | 3 +- src/sql/engine/cmd/ob_kill_executor.cpp | 1 - src/sql/engine/cmd/ob_mock_executor.cpp | 33 + src/sql/engine/cmd/ob_mock_executor.h | 37 + src/sql/engine/cmd/ob_role_cmd_executor.cpp | 2 +- src/sql/engine/cmd/ob_table_executor.cpp | 72 +- src/sql/engine/cmd/ob_user_cmd_executor.cpp | 72 +- src/sql/engine/cmd/ob_user_cmd_executor.h | 19 +- .../engine/expr/ob_expr_eval_functions.cpp | 9 +- .../ob_expr_inner_table_option_printer.cpp | 212 +++++ .../expr/ob_expr_inner_table_option_printer.h | 65 ++ .../engine/expr/ob_expr_operator_factory.cpp | 7 + src/sql/engine/expr/ob_expr_password.cpp | 118 +++ src/sql/engine/expr/ob_expr_password.h | 44 + src/sql/engine/expr/ob_expr_replace.cpp | 30 +- src/sql/engine/expr/ob_expr_sys_context.cpp | 78 ++ src/sql/engine/expr/ob_expr_sys_context.h | 9 + .../expr/ob_expr_sys_privilege_check.cpp | 5 +- src/sql/engine/expr/ob_expr_trim.cpp | 2 +- src/sql/engine/expr/ob_expr_util.cpp | 16 + src/sql/engine/expr/ob_expr_util.h | 1 + src/sql/executor/ob_cmd_executor.cpp | 11 + src/sql/monitor/ob_exec_stat.h | 3 + src/sql/ob_result_set.cpp | 30 +- src/sql/ob_result_set.h | 7 +- src/sql/ob_sql.cpp | 31 +- src/sql/ob_sql_utils.cpp | 74 ++ src/sql/ob_sql_utils.h | 10 + src/sql/optimizer/ob_log_for_update.cpp | 65 +- src/sql/optimizer/ob_log_plan.cpp | 197 ++++- src/sql/optimizer/ob_log_plan.h | 6 + src/sql/parser/ob_fast_parser.cpp | 23 + src/sql/parser/ob_fast_parser.h | 1 + src/sql/parser/sql_parser_mysql_mode.l | 15 + src/sql/parser/sql_parser_mysql_mode.y | 461 +++++++---- .../plan_cache/ob_sql_parameterization.cpp | 37 +- src/sql/plan_cache/ob_sql_parameterization.h | 3 +- src/sql/printer/ob_dml_stmt_printer.cpp | 2 +- src/sql/printer/ob_select_stmt_printer.cpp | 3 + src/sql/privilege_check/ob_ora_priv_check.cpp | 1 + .../privilege_check/ob_privilege_check.cpp | 253 +++++- src/sql/privilege_check/ob_privilege_check.h | 6 +- src/sql/resolver/cmd/ob_mock_resolver.cpp | 46 ++ src/sql/resolver/cmd/ob_mock_resolver.h | 38 + src/sql/resolver/cmd/ob_mock_stmt.h | 36 + src/sql/resolver/cmd/ob_show_resolver.cpp | 62 +- src/sql/resolver/cmd/ob_show_resolver.h | 1 + .../resolver/cmd/ob_variable_set_resolver.cpp | 29 +- .../dcl/ob_alter_user_profile_resolver.cpp | 26 +- .../dcl/ob_alter_user_proxy_resolver.cpp | 261 ++++++ .../dcl/ob_alter_user_proxy_resolver.h | 40 + .../resolver/dcl/ob_alter_user_proxy_stmt.cpp | 28 + .../resolver/dcl/ob_alter_user_proxy_stmt.h | 59 ++ .../resolver/dcl/ob_drop_user_resolver.cpp | 11 +- src/sql/resolver/dcl/ob_drop_user_stmt.h | 3 + src/sql/resolver/dcl/ob_grant_resolver.cpp | 21 +- src/sql/resolver/dcl/ob_revoke_resolver.cpp | 21 +- src/sql/resolver/ddl/ob_alter_outline_stmt.h | 1 + .../resolver/ddl/ob_alter_table_resolver.cpp | 5 +- .../resolver/ddl/ob_create_index_resolver.cpp | 10 +- src/sql/resolver/ddl/ob_create_outline_stmt.h | 1 + .../ddl/ob_create_profile_resolver.cpp | 6 +- .../resolver/ddl/ob_create_table_resolver.cpp | 44 +- .../resolver/ddl/ob_create_table_resolver.h | 1 + src/sql/resolver/ddl/ob_create_table_stmt.cpp | 6 +- src/sql/resolver/ddl/ob_create_table_stmt.h | 14 + src/sql/resolver/ddl/ob_ddl_resolver.cpp | 12 +- src/sql/resolver/ddl/ob_ddl_resolver.h | 2 +- src/sql/resolver/ddl/ob_drop_outline_stmt.h | 1 + src/sql/resolver/ddl/ob_sequence_stmt.h | 1 + .../resolver/ddl/ob_use_database_resolver.cpp | 5 +- src/sql/resolver/dml/ob_delete_resolver.cpp | 11 +- src/sql/resolver/dml/ob_dml_resolver.cpp | 29 +- src/sql/resolver/dml/ob_dml_resolver.h | 2 +- src/sql/resolver/dml/ob_dml_stmt.cpp | 39 +- src/sql/resolver/dml/ob_dml_stmt.h | 9 +- src/sql/resolver/dml/ob_select_resolver.cpp | 23 +- src/sql/resolver/dml/ob_select_stmt.cpp | 47 +- src/sql/resolver/dml/ob_select_stmt.h | 42 + src/sql/resolver/dml/ob_update_resolver.cpp | 6 +- src/sql/resolver/expr/ob_raw_expr.h | 4 +- .../expr/ob_raw_expr_resolver_impl.cpp | 9 +- src/sql/resolver/ob_resolver.cpp | 11 + src/sql/resolver/ob_resolver_utils.cpp | 58 +- src/sql/resolver/ob_resolver_utils.h | 2 + src/sql/resolver/ob_stmt.h | 1 + src/sql/resolver/ob_stmt_type.h | 18 +- .../rewrite/ob_transform_aggr_subquery.cpp | 5 + src/sql/rewrite/ob_transform_pre_process.cpp | 638 ++++++++++++++- src/sql/rewrite/ob_transform_pre_process.h | 21 + src/sql/rewrite/ob_transform_utils.cpp | 6 +- src/sql/rewrite/ob_transform_utils.h | 3 +- .../ob_transform_where_subquery_pullup.cpp | 5 + src/sql/session/ob_basic_session_info.cpp | 99 ++- src/sql/session/ob_basic_session_info.h | 25 +- src/sql/session/ob_sql_session_info.cpp | 15 +- src/sql/session/ob_sql_session_info.h | 2 +- src/sql/udr/ob_udr_utils.cpp | 6 +- .../r/mysql/information_schema.result | 80 ++ .../r/mysql/information_schema_desc.result | 2 +- .../r/mysql/desc_sys_views_in_mysql.result | 39 + .../r/mysql/desc_sys_views_in_sys.result | 42 + .../mysql/desc_virtual_table_in_mysql.result | 10 + .../r/mysql/desc_virtual_table_in_sys.result | 60 ++ .../r/mysql/inner_table_overall.result | 11 + .../r/mysql/user_privileges.result | 12 +- .../sql/resolver/expr/test_raw_expr_hash.cpp | 4 + .../resolver/expr/test_raw_expr_resolver.cpp | 5 + .../resolver/expr/test_raw_expr_to_str.cpp | 4 + unittest/sql/rewrite/test_query_range.cpp | 10 + 208 files changed, 11028 insertions(+), 495 deletions(-) create mode 100644 src/observer/mysql/obmp_debug.cpp create mode 100644 src/observer/mysql/obmp_debug.h create mode 100644 src/observer/mysql/obmp_process_info.cpp create mode 100644 src/observer/mysql/obmp_process_info.h create mode 100644 src/observer/mysql/obmp_process_kill.cpp create mode 100644 src/observer/mysql/obmp_process_kill.h create mode 100644 src/observer/mysql/obmp_refresh.cpp create mode 100644 src/observer/mysql/obmp_refresh.h create mode 100644 src/observer/virtual_table/ob_all_virtual_compatibility_control.cpp create mode 100644 src/observer/virtual_table/ob_all_virtual_compatibility_control.h create mode 100644 src/share/ob_compatibility_control.cpp create mode 100644 src/share/ob_compatibility_control.h create mode 100644 src/share/ob_compatibility_control_feature_def.h create mode 100644 src/share/ob_compatibility_security_feature_def.h create mode 100644 src/sql/engine/cmd/ob_mock_executor.cpp create mode 100644 src/sql/engine/cmd/ob_mock_executor.h create mode 100644 src/sql/engine/expr/ob_expr_inner_table_option_printer.cpp create mode 100644 src/sql/engine/expr/ob_expr_inner_table_option_printer.h create mode 100644 src/sql/engine/expr/ob_expr_password.cpp create mode 100644 src/sql/engine/expr/ob_expr_password.h create mode 100644 src/sql/resolver/cmd/ob_mock_resolver.cpp create mode 100644 src/sql/resolver/cmd/ob_mock_resolver.h create mode 100644 src/sql/resolver/cmd/ob_mock_stmt.h create mode 100644 src/sql/resolver/dcl/ob_alter_user_proxy_resolver.cpp create mode 100644 src/sql/resolver/dcl/ob_alter_user_proxy_resolver.h create mode 100644 src/sql/resolver/dcl/ob_alter_user_proxy_stmt.cpp create mode 100644 src/sql/resolver/dcl/ob_alter_user_proxy_stmt.h diff --git a/deps/oblib/src/lib/ob_define.h b/deps/oblib/src/lib/ob_define.h index 7f804adc16..08522bcf00 100644 --- a/deps/oblib/src/lib/ob_define.h +++ b/deps/oblib/src/lib/ob_define.h @@ -832,6 +832,8 @@ const uint64_t COLUMN_GROUP_START_ID = 1000; const uint64_t DEFAULT_CUSTOMIZED_CG_NUM = 2; const int64_t OB_CG_NAME_PREFIX_LENGTH = 5; // length of cg prefix like "__cg_" const int64_t OB_MAX_COLUMN_GROUP_NAME_LENGTH = OB_MAX_COLUMN_NAME_LENGTH * OB_MAX_CHAR_LEN + OB_CG_NAME_PREFIX_LENGTH; //(max_column_name_length(128) * ob_max_char_len(3)) + prefix +const int64_t MAX_NAME_CHAR_LEN = 64; + //Oracle const int64_t MAX_ORACLE_COMMENT_LENGTH = 4000; @@ -1507,7 +1509,7 @@ const char *const OB_MYSQL_OCI_CLIENT_NAME = "OceanBase Connector/C"; const char *const OB_MYSQL_JAVA_CLIENT_MODE_NAME = "__ob_java_client"; const char *const OB_MYSQL_OCI_CLIENT_MODE_NAME = "__ob_libobclient"; const char *const OB_MYSQL_JDBC_CLIENT_MODE_NAME = "__ob_jdbc_client"; - +const char *const OB_MYSQL_CLIENT_PROXY_USER_NAME = "__ob_client_proxy_user_name"; const char *const OB_MYSQL_CLIENT_ATTRIBUTE_CAPABILITY_FLAG = "__ob_client_attribute_capability_flag"; enum ObClientMode diff --git a/deps/oblib/src/lib/ob_name_def.h b/deps/oblib/src/lib/ob_name_def.h index de862f71b2..2bb315da82 100644 --- a/deps/oblib/src/lib/ob_name_def.h +++ b/deps/oblib/src/lib/ob_name_def.h @@ -1119,4 +1119,6 @@ #define N_PRIV_ST_MAKEVALID "_st_makevalid" #define N_CAN_ACCESS_TRIGGER "can_access_trigger" #define N_SDO_RELATE "sdo_relate" +#define N_INNER_TABLE_OPTION_PRINTER "inner_table_option_printer" +#define N_INNER_TABLE_SEQUENCE_GETTER "inner_table_sequence_getter" #endif //OCEANBASE_LIB_OB_NAME_DEF_H_ 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 ead6e5c414..e9878bd381 100644 --- a/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h +++ b/deps/oblib/src/rpc/obrpc/ob_rpc_packet_list.h @@ -1147,6 +1147,7 @@ PCODE_DEF(OB_TRIM_KEY_LIST, 0x1618) //proxy user //PCODE_DEF(OB_ALTER_USER_PROXY, 0x1620) +PCODE_DEF(OB_ALTER_USER_PROXY, 0x1620) // global sequence service // PCODE_DEF(OB_GAIS_NEXT_SEQUENCE_REQUEST, 0x1621) @@ -1157,6 +1158,7 @@ PCODE_DEF(OB_CAL_STANDBY_TENANT_PHY_RESOURCE, 0x1623) //PCODE_DEF(OB_UPDATE_MVIEW_REFERENCE_TABLE_STATUS, 0x1624) //PCODE_DEF(OB_DO_EVENT_DDL, 0x1625) + //**** 注意:在此行之前增加新的RPC ID ****** // //占位须知: diff --git a/src/observer/CMakeLists.txt b/src/observer/CMakeLists.txt index d0d26454ce..297fc6cf70 100644 --- a/src/observer/CMakeLists.txt +++ b/src/observer/CMakeLists.txt @@ -82,6 +82,10 @@ ob_set_subtarget(ob_server mysql mysql/obmp_packet_sender.cpp mysql/obmp_ping.cpp mysql/obmp_query.cpp + mysql/obmp_process_info.cpp + mysql/obmp_process_kill.cpp + mysql/obmp_debug.cpp + mysql/obmp_refresh.cpp mysql/obmp_reset_connection.cpp mysql/obmp_statistic.cpp mysql/obmp_stmt_close.cpp @@ -427,6 +431,7 @@ ob_set_subtarget(ob_server virtual_table virtual_table/ob_all_virtual_storage_ha_error_diagnose.cpp virtual_table/ob_all_virtual_storage_ha_perf_diagnose.cpp virtual_table/ob_all_virtual_sys_variable_default_value.cpp + virtual_table/ob_all_virtual_compatibility_control.cpp ) ob_server_add_target(ob_server) diff --git a/src/observer/mysql/ob_mysql_request_manager.cpp b/src/observer/mysql/ob_mysql_request_manager.cpp index 45135851c5..24f434d9d7 100644 --- a/src/observer/mysql/ob_mysql_request_manager.cpp +++ b/src/observer/mysql/ob_mysql_request_manager.cpp @@ -170,7 +170,8 @@ int ObMySQLRequestManager::record_request(const ObAuditRecordData &audit_record, + audit_record.user_name_len_ + audit_record.db_name_len_ + audit_record.params_value_len_ - + audit_record.rule_name_len_; + + audit_record.rule_name_len_ + + audit_record.proxy_user_name_len_; if (NULL == (buf = (char*)alloc(total_size))) { if (REACH_TIME_INTERVAL(100 * 1000)) { SERVER_LOG(WARN, "record concurrent fifoallocator alloc mem failed", @@ -221,6 +222,13 @@ int ObMySQLRequestManager::record_request(const ObAuditRecordData &audit_record, record->data_.db_name_ = buf + pos; pos += db_len; } + //deep copy proxy_user_name + if ((audit_record.proxy_user_name_len_ > 0) && (NULL != audit_record.proxy_user_name_)) { + int64_t user_len = min(audit_record.proxy_user_name_len_, OB_MAX_USER_NAME_LENGTH); + MEMCPY(buf + pos, audit_record.proxy_user_name_, user_len); + record->data_.proxy_user_name_ = buf + pos; + pos += user_len; + } //for find bug // only print this log if enable_perf_event is enable, // for `receive_ts_` might be invalid if `enable_perf_event` is false diff --git a/src/observer/mysql/obmp_connect.cpp b/src/observer/mysql/obmp_connect.cpp index 3ae570f015..5275cd1411 100644 --- a/src/observer/mysql/obmp_connect.cpp +++ b/src/observer/mysql/obmp_connect.cpp @@ -43,6 +43,7 @@ #include "sql/monitor/ob_security_audit_utils.h" #include "sql/privilege_check/ob_privilege_check.h" #include "sql/privilege_check/ob_ora_priv_check.h" +#include "lib/utility/ob_backtrace.h" using namespace oceanbase::share; using namespace oceanbase::common; @@ -287,6 +288,23 @@ int ObMPConnect::init_connect_process(ObString &init_sql, return ret; } +int ObMPConnect::get_proxy_user_name(ObString &proxied_user) +{ + int ret = OB_SUCCESS; + ObString user_key_str; + bool found_user = false; + proxied_user.reset(); + user_key_str.assign_ptr(OB_MYSQL_CLIENT_PROXY_USER_NAME , static_cast(STRLEN(OB_MYSQL_CLIENT_PROXY_USER_NAME))); + for (int64_t i = 0; i < hsr_.get_connect_attrs().count() && OB_SUCC(ret) && !found_user; ++i) { + const ObStringKV &kv = hsr_.get_connect_attrs().at(i); + if (user_key_str == kv.key_) { + proxied_user.assign_ptr(kv.value_.ptr(), kv.value_.length()); + found_user = true; + } + } + return ret; +} + int ObMPConnect::process() { int ret = deser_ret_; @@ -533,6 +551,8 @@ int ObMPConnect::load_privilege_info(ObSQLSessionInfo &session) } ObString host_name; + uint64_t proxy_user_id = OB_INVALID_ID; + bool is_proxy = false; uint64_t client_attr_cap_flags = 0; if (true) { // TODO, checker ret @@ -563,6 +583,37 @@ int ObMPConnect::load_privilege_info(ObSQLSessionInfo &session) } } + lib::Worker::CompatMode compat_mode = lib::Worker::CompatMode::INVALID; + if (OB_FAIL(ret)) { + } else if (OB_FAIL(ObCompatModeGetter::get_tenant_mode(conn->tenant_id_, compat_mode))) { + LOG_WARN("fail to get tenant mode in convert_oracle_object_name", K(ret)); + } else if (compat_mode == lib::Worker::CompatMode::ORACLE) { + ObString proxied_user; + if (OB_FAIL(get_proxy_user_name(proxied_user))) { + LOG_WARN("get proxy user info failed", K(ret)); + } else if (!proxied_user.empty()) { + uint64_t tenant_data_version = 0; + if (OB_FAIL(GET_MIN_DATA_VERSION(conn->tenant_id_, tenant_data_version))) { + LOG_WARN("get tenant data version failed", K(ret)); + } else if (!ObSQLUtils::is_data_version_ge_423_or_432(tenant_data_version)) { + ret = OB_PASSWORD_WRONG; + LOG_WARN("tenant version is below 423 or 432", K(ret)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "connect proxy user is not supported when data version is below 4.2.3 or 4.3.2"); + } else if (proxied_user.length() > OB_MAX_USER_NAME_BUF_LENGTH) { + ret = OB_SIZE_OVERFLOW; + LOG_WARN("proxy user name too long", K(ret)); + } else { + MEMCPY(proxied_user_name_var_, proxied_user.ptr(), proxied_user.length()); + proxied_user_name_var_[proxied_user.length()] = '\0'; + proxied_user_name_.assign(proxied_user_name_var_, proxied_user.length()); + if (OB_FAIL(convert_oracle_object_name(conn->tenant_id_, proxied_user_name_))) { + LOG_WARN("fail to convert oracle db name", K(ret)); + } + } + } else { + proxied_user_name_.reset(); + } + } share::schema::ObSessionPrivInfo session_priv; const ObSysVariableSchema *sys_variable_schema = NULL; if (OB_FAIL(ret)) { @@ -583,12 +634,17 @@ int ObMPConnect::load_privilege_info(ObSQLSessionInfo &session) share::schema::ObUserLoginInfo login_info; login_info.tenant_name_ = tenant_name_; login_info.user_name_ = user_name_; + login_info.proxied_user_name_ = proxied_user_name_; login_info.client_ip_ = client_ip_; SSL *ssl_st = SQL_REQ_OP.get_sql_ssl_st(req_); const ObUserInfo *user_info = NULL; // 当 oracle 模式下,用户登录没有指定 schema_name 时,将其默认设置为对应的 user_name if (OB_SUCC(ret) && ORACLE_MODE == session.get_compatibility_mode() && db_name_.empty()) { - login_info.db_ = user_name_; + if (proxied_user_name_.empty()) { + login_info.db_ = user_name_; + } else { + login_info.db_ = proxied_user_name_; + } } else if (!db_name_.empty()) { ObString db_name = db_name_; ObNameCaseMode mode = OB_NAME_CASE_INVALID; @@ -728,10 +784,14 @@ int ObMPConnect::load_privilege_info(ObSQLSessionInfo &session) host_name = session_priv.host_name_; uint64_t db_id = OB_INVALID_ID; const ObTenantSchema *tenant_schema = NULL; - if (OB_FAIL(session.set_user(user_name_, session_priv.host_name_, session_priv.user_id_))) { + if (OB_FAIL(session.set_user(session_priv.user_name_, session_priv.host_name_, session_priv.user_id_))) { LOG_WARN("failed to set_user", K(ret)); } else if (OB_FAIL(session.set_real_client_ip_and_port(client_ip_, client_port_))) { LOG_WARN("failed to set_real_client_ip_and_port", K(ret)); + } else if (OB_FAIL(session.set_proxy_user(session_priv.proxy_user_name_, + session_priv.proxy_host_name_, + session_priv.proxy_user_id_))) { + LOG_WARN("failed to set proxy user"); } else if (OB_FAIL(session.set_default_database(session_priv.db_))) { LOG_WARN("failed to set default database", K(ret), K(session_priv.db_)); } else if (OB_FAIL(schema_guard.get_tenant_info(session_priv.tenant_id_, tenant_schema))) { @@ -796,7 +856,7 @@ int ObMPConnect::load_privilege_info(ObSQLSessionInfo &session) } } } - LOG_DEBUG("obmp connect info:", K_(tenant_name), K_(user_name), + LOG_DEBUG("obmp connect info:", K(ret), K_(tenant_name), K_(user_name), K(host_name), K_(client_ip), "database", hsr_.get_database(), K(hsr_.get_capability_flags().capability_), K(session.is_client_use_lob_locator()), diff --git a/src/observer/mysql/obmp_connect.h b/src/observer/mysql/obmp_connect.h index 939acea444..07dcbb58f2 100644 --- a/src/observer/mysql/obmp_connect.h +++ b/src/observer/mysql/obmp_connect.h @@ -126,15 +126,18 @@ private: int set_proxy_version(ObSMConnection &conn); int set_client_version(ObSMConnection &conn); + int get_proxy_user_name(ObString &real_user); private: DISALLOW_COPY_AND_ASSIGN(ObMPConnect); obmysql::OMPKHandshakeResponse hsr_; common::ObString user_name_; + common::ObString proxied_user_name_; common::ObString client_ip_; common::ObString tenant_name_; common::ObString db_name_; char client_ip_buf_[common::MAX_IP_ADDR_LENGTH + 1]; char user_name_var_[OB_MAX_USER_NAME_BUF_LENGTH]; + char proxied_user_name_var_[OB_MAX_USER_NAME_BUF_LENGTH]; char db_name_var_[OB_MAX_DATABASE_NAME_BUF_LENGTH]; int deser_ret_; int32_t client_port_; diff --git a/src/observer/mysql/obmp_debug.cpp b/src/observer/mysql/obmp_debug.cpp new file mode 100644 index 0000000000..4d12639e8e --- /dev/null +++ b/src/observer/mysql/obmp_debug.cpp @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SERVER + +#include "observer/mysql/obmp_debug.h" +#include "observer/mysql/obmp_utils.h" +#include "observer/mysql/ob_mysql_result_set.h" +#include "rpc/obmysql/ob_mysql_packet.h" + + +namespace oceanbase +{ +using namespace common; +using namespace obmysql; + +namespace observer +{ +ObMPDebug::ObMPDebug(const ObGlobalContext &gctx) + : ObMPBase(gctx) +{ +} + +ObMPDebug::~ObMPDebug() +{ +} + +int ObMPDebug::deserialize() +{ + int ret = 0; + return OB_SUCCESS; +} + +int ObMPDebug::process() +{ + int ret = OB_SUCCESS; + sql::ObSQLSessionInfo *session = NULL; + bool need_response_error = true; //temporary placeholder + const ObMySQLRawPacket &pkt = reinterpret_cast(req_->get_packet()); + if (OB_FAIL(get_session(session))) { + LOG_WARN("get session fail", K(ret)); + } else if (OB_ISNULL(session)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("sql session info is null", K(ret)); + } else if (FALSE_IT(session->set_txn_free_route(pkt.txn_free_route()))) { + } else if (OB_FAIL(process_extra_info(*session, pkt, need_response_error))) { + LOG_WARN("fail get process extra info", K(ret)); + } else if (FALSE_IT(session->post_sync_session_info())) { + } else if (OB_FAIL(update_transmission_checksum_flag(*session))) { + LOG_WARN("update transmisson checksum flag failed", K(ret)); + } else if (FALSE_IT(session->update_last_active_time())) { + } else { + ObArenaAllocator allocator; // no use, just a param for ObMySQLResultSet() + SMART_VAR(ObMySQLResultSet, result, *session, allocator) {// use default values + if (OB_FAIL(send_eof_packet(*session, result))) { + LOG_WARN("fail to send eof pakcet in debug response", K(ret)); + } + } + } + if (OB_LIKELY(NULL != session)) { + revert_session(session); + } + if (OB_FAIL(ret)) { + if (OB_FAIL(send_error_packet(ret, NULL))) { // overwrite ret ? + OB_LOG(WARN,"response debug packet fail", K(ret)); + } + } + return ret; +} + +} // namespace observer +} // namespace oceanbase diff --git a/src/observer/mysql/obmp_debug.h b/src/observer/mysql/obmp_debug.h new file mode 100644 index 0000000000..142be36e3a --- /dev/null +++ b/src/observer/mysql/obmp_debug.h @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_OBSERVER_MYSQL_OBMP_DEBUG_H_ +#define OCEANBASE_OBSERVER_MYSQL_OBMP_DEBUG_H_ + +#include "observer/mysql/obmp_base.h" + +namespace oceanbase +{ +namespace observer +{ + +class ObMPDebug : public ObMPBase +{ +public: + static const obmysql::ObMySQLCmd COM = obmysql::COM_DEBUG; + explicit ObMPDebug(const ObGlobalContext &gctx); + virtual ~ObMPDebug(); + +protected: + int process(); + int deserialize(); + +private: + DISALLOW_COPY_AND_ASSIGN(ObMPDebug); +}; // end of class ObMPDebug + +} // end of namespace observer +} // end of namespace oceanbase + + +#endif // OCEANBASE_OBSERVER_MYSQL_OBMP_DEBUG_H_ diff --git a/src/observer/mysql/obmp_init_db.cpp b/src/observer/mysql/obmp_init_db.cpp index 3927bc0f9a..498a28327f 100644 --- a/src/observer/mysql/obmp_init_db.cpp +++ b/src/observer/mysql/obmp_init_db.cpp @@ -217,8 +217,9 @@ int ObMPInitDB::do_process(sql::ObSQLSessionInfo *session) ret = OB_ERR_NO_DB_PRIVILEGE; LOG_WARN("can only access oceanbase database when tenant changed", K(ret)); } else { - session->get_session_priv_info(session_priv); - if (OB_FAIL(ObSQLUtils::cvt_db_name_to_org(schema_guard, session, db_name_, NULL/*allocator*/))) { + if (OB_FAIL(session->get_session_priv_info(session_priv))) { + LOG_WARN("fail to get session priv info", K(ret)); + } else if (OB_FAIL(ObSQLUtils::cvt_db_name_to_org(schema_guard, session, db_name_, NULL/*allocator*/))) { LOG_WARN("fail to cvt db name to orignal", K(db_name_), K(ret)); } else if (OB_FAIL(schema_guard.check_db_access(session_priv, db_name_))) { LOG_WARN("fail to check db access.", K_(db_name), K(ret)); diff --git a/src/observer/mysql/obmp_process_info.cpp b/src/observer/mysql/obmp_process_info.cpp new file mode 100644 index 0000000000..88bfa23f64 --- /dev/null +++ b/src/observer/mysql/obmp_process_info.cpp @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SERVER + +#include "observer/mysql/obmp_process_info.h" + +namespace oceanbase +{ +using namespace common; +using namespace obmysql; +using namespace rpc; + +namespace observer +{ +ObMPProcessInfo::ObMPProcessInfo(const ObGlobalContext &gctx) + : ObMPQuery(gctx) +{ +} + +ObMPProcessInfo::~ObMPProcessInfo() +{ +} + +int ObMPProcessInfo::deserialize() +{ + int ret = OB_SUCCESS; + const char *process_info_sql = "/*+TRIGGERED BY COM_PROCESS_INFO*/ SHOW PROCESSLIST"; + if ( (OB_ISNULL(req_)) || (req_->get_type() != ObRequest::OB_MYSQL)) { + ret = OB_INVALID_ARGUMENT; + LOG_ERROR("invalid request", K(ret), K(req_)); + } else { + assign_sql(process_info_sql, STRLEN(process_info_sql)); + } + return ret; +} + + +} // namespace observer +} // namespace oceanbase diff --git a/src/observer/mysql/obmp_process_info.h b/src/observer/mysql/obmp_process_info.h new file mode 100644 index 0000000000..743bb2a217 --- /dev/null +++ b/src/observer/mysql/obmp_process_info.h @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_OBSERVER_MYSQL_OBMP_PROCESS_INFO_H_ +#define OCEANBASE_OBSERVER_MYSQL_OBMP_PROCESS_INFO_H_ + +#include "observer/mysql/obmp_query.h" + +namespace oceanbase +{ +namespace observer +{ + +class ObMPProcessInfo : public ObMPQuery +{ +public: + //static const obmysql::ObMySQLCmd COM = obmysql::COM_PROCESS_INFO; + explicit ObMPProcessInfo(const ObGlobalContext &gctx); + virtual ~ObMPProcessInfo(); +protected: + int deserialize() override; +private: + DISALLOW_COPY_AND_ASSIGN(ObMPProcessInfo); +}; // end of class ObMPProcessInfo + +} // end of namespace observer +} // end of namespace oceanbase + + +#endif // OCEANBASE_OBSERVER_MYSQL_OBMP_PROCESS_INFO_H_ diff --git a/src/observer/mysql/obmp_process_kill.cpp b/src/observer/mysql/obmp_process_kill.cpp new file mode 100644 index 0000000000..98381853be --- /dev/null +++ b/src/observer/mysql/obmp_process_kill.cpp @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SERVER + +#include "observer/mysql/obmp_process_kill.h" + +namespace oceanbase +{ +using namespace common; +using namespace obmysql; +using namespace rpc; + +namespace observer +{ +ObMPProcessKill::ObMPProcessKill(const ObGlobalContext &gctx) + : ObMPQuery(gctx) +{ +} + +ObMPProcessKill::~ObMPProcessKill() +{ +} + +int ObMPProcessKill::deserialize() +{ + int ret = OB_SUCCESS; + const char *kill_sql_fmt = "/*+TRIGGERED BY COM_PROCESS_INFO*/ KILL %u"; + uint32_t sessid = 0; + if ( (OB_ISNULL(req_)) || (req_->get_type() != ObRequest::OB_MYSQL)) { + ret = OB_INVALID_ARGUMENT; + LOG_ERROR("invalid request", K(ret), K(req_)); + } else { + const ObMySQLRawPacket &pkt = reinterpret_cast(req_->get_packet()); + sessid = *(reinterpret_cast(pkt.get_cdata())); + snprintf(kill_sql_buf_, KILL_SQL_BUF_SIZE, kill_sql_fmt, sessid); + assign_sql(kill_sql_buf_, STRLEN(kill_sql_buf_)); + } + return ret; +} + + +} // namespace observer +} // namespace oceanbase diff --git a/src/observer/mysql/obmp_process_kill.h b/src/observer/mysql/obmp_process_kill.h new file mode 100644 index 0000000000..4ce722a32f --- /dev/null +++ b/src/observer/mysql/obmp_process_kill.h @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_OBSERVER_MYSQL_OBMP_PROCESS_KILL_H_ +#define OCEANBASE_OBSERVER_MYSQL_OBMP_PROCESS_KILL_H_ + +#include "observer/mysql/obmp_query.h" + +namespace oceanbase +{ +namespace observer +{ + +class ObMPProcessKill : public ObMPQuery +{ +public: + const static int64_t KILL_SQL_BUF_SIZE = 64; //actually 16 byte is enough, 32 byte is for safty + //static const obmysql::ObMySQLCmd COM = obmysql::COM_PROCESS_INFO; + explicit ObMPProcessKill(const ObGlobalContext &gctx); + virtual ~ObMPProcessKill(); +protected: + int deserialize() override; +private: + char kill_sql_buf_[KILL_SQL_BUF_SIZE]; + DISALLOW_COPY_AND_ASSIGN(ObMPProcessKill); +}; // end of class ObMPProcessKill + +} // end of namespace observer +} // end of namespace oceanbase + + +#endif // OCEANBASE_OBSERVER_MYSQL_OBMP_PROCESS_KILL_H_ diff --git a/src/observer/mysql/obmp_query.cpp b/src/observer/mysql/obmp_query.cpp index 9ae0839f20..f9d87fc5a0 100644 --- a/src/observer/mysql/obmp_query.cpp +++ b/src/observer/mysql/obmp_query.cpp @@ -1218,6 +1218,7 @@ int ObMPQuery::is_readonly_stmt(ObMySQLResultSet &result, bool &is_readonly) case stmt::T_SHOW_GRANTS: case stmt::T_SHOW_QUERY_RESPONSE_TIME: case stmt::T_SHOW_RECYCLEBIN: + case stmt::T_SHOW_PROFILE: case stmt::T_SHOW_SEQUENCES: case stmt::T_HELP: case stmt::T_USE_DATABASE: diff --git a/src/observer/mysql/obmp_query.h b/src/observer/mysql/obmp_query.h index ebaa2ce720..fabb42a9cb 100644 --- a/src/observer/mysql/obmp_query.h +++ b/src/observer/mysql/obmp_query.h @@ -61,6 +61,7 @@ protected: int deserialize(); int check_readonly_stmt(ObMySQLResultSet &result); int is_readonly_stmt(ObMySQLResultSet &result, bool &is_readonly); + void assign_sql(const char * sql, int64_t sql_length) { sql_.assign_ptr(sql, sql_length); } private: int response_result(ObMySQLResultSet &result, bool force_sync_resp, bool &async_resp_used); int get_tenant_schema_info_(const uint64_t tenant_id, diff --git a/src/observer/mysql/obmp_refresh.cpp b/src/observer/mysql/obmp_refresh.cpp new file mode 100644 index 0000000000..e464c3305e --- /dev/null +++ b/src/observer/mysql/obmp_refresh.cpp @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SERVER + +#include "observer/mysql/obmp_refresh.h" +#include "observer/mysql/obmp_utils.h" +#include "rpc/obmysql/ob_mysql_packet.h" + + +namespace oceanbase +{ +using namespace common; +using namespace obmysql; + +namespace observer +{ +ObMPRefresh::ObMPRefresh(const ObGlobalContext &gctx) + : ObMPBase(gctx) +{ +} + +ObMPRefresh::~ObMPRefresh() +{ +} + +int ObMPRefresh::deserialize() +{ + int ret = 0; + return OB_SUCCESS; +} + +int ObMPRefresh::process() +{ + int ret = OB_SUCCESS; + sql::ObSQLSessionInfo *session = NULL; + bool need_response_error = true; //temporary placeholder + const ObMySQLRawPacket &pkt = reinterpret_cast(req_->get_packet()); + if (OB_FAIL(get_session(session))) { + LOG_WARN("get session fail", K(ret)); + } else if (OB_ISNULL(session)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("sql session info is null", K(ret)); + } else if (FALSE_IT(session->set_txn_free_route(pkt.txn_free_route()))) { + } else if (OB_FAIL(process_extra_info(*session, pkt, need_response_error))) { + LOG_WARN("fail get process extra info", K(ret)); + } else if (FALSE_IT(session->post_sync_session_info())) { + } else if (OB_FAIL(update_transmission_checksum_flag(*session))) { + LOG_WARN("update transmisson checksum flag failed", K(ret)); + } else if (FALSE_IT(session->update_last_active_time())) { + } else { + ObOKPParam ok_param; // use default values + if (OB_FAIL(send_ok_packet(*session, ok_param))) { + LOG_WARN("fail to send ok pakcet in refresh response", K(ok_param), K(ret)); + } + } + if (OB_LIKELY(NULL != session)) { + revert_session(session); + } + if (OB_FAIL(ret)) { + if (OB_FAIL(send_error_packet(ret, NULL))) { // overwrite ret ? + OB_LOG(WARN,"response refresh packet fail", K(ret)); + } + } + return ret; +} + +} // namespace observer +} // namespace oceanbase diff --git a/src/observer/mysql/obmp_refresh.h b/src/observer/mysql/obmp_refresh.h new file mode 100644 index 0000000000..38ebcb2b3f --- /dev/null +++ b/src/observer/mysql/obmp_refresh.h @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_OBSERVER_MYSQL_OBMP_REFRESH_H_ +#define OCEANBASE_OBSERVER_MYSQL_OBMP_REFRESH_H_ + +#include "observer/mysql/obmp_base.h" + +namespace oceanbase +{ +namespace observer +{ + +class ObMPRefresh : public ObMPBase +{ +public: + static const obmysql::ObMySQLCmd COM = obmysql::COM_REFRESH; + explicit ObMPRefresh(const ObGlobalContext &gctx); + virtual ~ObMPRefresh(); + +protected: + int process(); + int deserialize(); + +private: + DISALLOW_COPY_AND_ASSIGN(ObMPRefresh); +}; // end of class ObMPRefresh + +} // end of namespace observer +} // end of namespace oceanbase + + +#endif // OCEANBASE_OBSERVER_MYSQL_OBMP_REFRESH_H_ diff --git a/src/observer/ob_srv_xlator.cpp b/src/observer/ob_srv_xlator.cpp index 76d8ae924e..bff67ad7ef 100644 --- a/src/observer/ob_srv_xlator.cpp +++ b/src/observer/ob_srv_xlator.cpp @@ -57,6 +57,10 @@ #include "observer/mysql/obmp_reset_connection.h" #include "observer/mysql/obmp_auth_response.h" #include "observer/mysql/obmp_set_option.h" +#include "observer/mysql/obmp_process_kill.h" +#include "observer/mysql/obmp_process_info.h" +#include "observer/mysql/obmp_debug.h" +#include "observer/mysql/obmp_refresh.h" #include "observer/table/ob_table_rpc_processor.h" #include "observer/table/ob_table_execute_processor.h" @@ -212,8 +216,32 @@ int ObSrvMySQLXlator::translate(rpc::ObRequest &req, ObReqProcessor *&processor) } else { processor = p; } + } else if (pkt.get_cmd() == obmysql::COM_PROCESS_INFO) { + char *buf = (&co_ep_rpcp_buf)->obmp_query_buffer_; + ObMPProcessInfo *p = new (buf) ObMPProcessInfo(gctx_); + if (OB_ISNULL(p)) { + ret = OB_ALLOCATE_MEMORY_FAILED; + } else if (OB_FAIL(p->init())) { + SERVER_LOG(ERROR, "Init ObMPProcessInfo fail", K(ret)); + p->~ObMPProcessInfo(); + } else { + processor = p; + } + } else if (pkt.get_cmd() == obmysql::COM_PROCESS_KILL) { + char *buf = (&co_ep_rpcp_buf)->obmp_query_buffer_; + ObMPProcessKill *p = new (buf) ObMPProcessKill(gctx_); + if (OB_ISNULL(p)) { + ret = OB_ALLOCATE_MEMORY_FAILED; + } else if (OB_FAIL(p->init())) { + SERVER_LOG(ERROR, "Init ObMPProcessKill fail", K(ret)); + p->~ObMPProcessKill(); + } else { + processor = p; + } } else { switch (pkt.get_cmd()) { + MYSQL_PROCESSOR(ObMPDebug, gctx_); + MYSQL_PROCESSOR(ObMPRefresh, gctx_); MYSQL_PROCESSOR(ObMPQuit, gctx_); MYSQL_PROCESSOR(ObMPPing, gctx_); MYSQL_PROCESSOR(ObMPInitDB, gctx_); diff --git a/src/observer/ob_srv_xlator_rootserver.cpp b/src/observer/ob_srv_xlator_rootserver.cpp index 9842b6d271..42e6e49e21 100644 --- a/src/observer/ob_srv_xlator_rootserver.cpp +++ b/src/observer/ob_srv_xlator_rootserver.cpp @@ -288,5 +288,6 @@ void oceanbase::observer::init_srv_xlator_for_rootserver(ObSrvRpcXlator *xlator) RPC_PROCESSOR(rootserver::ObGetRootKeyP, *gctx_.root_service_); RPC_PROCESSOR(rootserver::ObReloadMasterKeyP, *gctx_.root_service_); #endif + RPC_PROCESSOR(rootserver::ObRpcAlterUserProxyP, *gctx_.root_service_); } diff --git a/src/observer/virtual_table/ob_all_virtual_compatibility_control.cpp b/src/observer/virtual_table/ob_all_virtual_compatibility_control.cpp new file mode 100644 index 0000000000..ca3d7819a1 --- /dev/null +++ b/src/observer/virtual_table/ob_all_virtual_compatibility_control.cpp @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SERVER +#include "observer/virtual_table/ob_all_virtual_compatibility_control.h" +#include "share/ob_compatibility_control.h" +#include "sql/session/ob_sql_session_info.h" + +namespace oceanbase +{ +namespace observer +{ +using namespace oceanbase::common; +using namespace oceanbase::share; + +ObVirtualCompatibilityConflictControl::ObVirtualCompatibilityConflictControl() + : ObVirtualTableScannerIterator() +{ +} + +ObVirtualCompatibilityConflictControl::~ObVirtualCompatibilityConflictControl() +{ + reset(); +} + +void ObVirtualCompatibilityConflictControl::reset() +{ +} + +int ObVirtualCompatibilityConflictControl::inner_get_next_row(common::ObNewRow *&row) +{ + int ret = OB_SUCCESS; + if (!start_to_read_) { + if (OB_FAIL(fill_scanner())) { + SERVER_LOG(WARN, "fail to fill scanner", K(ret)); + } else { + start_to_read_ = true; + } + } + if (OB_SUCCESS == ret && start_to_read_) { + if (OB_FAIL(scanner_it_.get_next_row(cur_row_))) { + if (OB_ITER_END != ret) { + SERVER_LOG(WARN, "fail to get next row", K(ret)); + } + } else { + row = &cur_row_; + } + } + return ret; +} + +int ObVirtualCompatibilityConflictControl::fill_scanner() +{ + int ret = OB_SUCCESS; + ObObj *cells = NULL; + const ObICompatInfo **infos = NULL; + int64_t info_len = 0; + ObCompatControl::get_compat_feature_infos(infos, info_len); + ObCollationType coll_type = ObCharset::get_default_collation(ObCharset::get_default_charset()); + uint64_t compat_version = 0; + if (OB_ISNULL(allocator_) || OB_ISNULL(session_)) { + ret = OB_NOT_INIT; + LOG_WARN("allocator is NULL", K(ret)); + } else if (output_column_ids_.count() > 0 && OB_ISNULL(cells = cur_row_.cells_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("cur row cell is NULL", K(ret)); + } else if (OB_ISNULL(infos) || OB_UNLIKELY(ObCompatFeatureType::COMPAT_FEATURE_END > info_len)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("invalid compat feature info array", K(ret), KP(infos), K(info_len)); + } else if (OB_FAIL(session_->get_compatibility_version(compat_version))) { + LOG_WARN("failed to get compat version", K(ret)); + } + for (int64_t i = 0; OB_SUCC(ret) && i < ObCompatFeatureType::COMPAT_FEATURE_END; ++i) { + int cell_idx = 0; + const ObICompatInfo *info = infos[i]; + if (OB_ISNULL(info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } + for (int64_t j = 0; OB_SUCC(ret) && j < output_column_ids_.count(); ++j) { + int64_t col_id = output_column_ids_.at(j); + switch(col_id) { + case TENAND_ID: { + cells[cell_idx].set_int(MTL_ID()); + break; + } + case NAME: { + cells[cell_idx].set_varchar(info->name_); + cells[cell_idx].set_collation_type(coll_type); + break; + } + case DESCRIPTION: { + cells[cell_idx].set_varchar(info->description_); + cells[cell_idx].set_collation_type(coll_type); + break; + } + case IS_ENABLE: { + cells[cell_idx].set_bool(info->is_valid_version(compat_version)); + break; + } + case ENABLE_VERSIONS: { + ObString range_str; + if (OB_FAIL(info->print_version_range(range_str, *allocator_))) { + LOG_WARN("failed to print version range", K(ret)); + } else { + cells[cell_idx].set_lob_value(ObLongTextType, range_str.ptr(), + static_cast(range_str.length())); + cells[cell_idx].set_collation_type(coll_type); + } + break; + } + default: { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("invalid column id", K(ret), K(cell_idx), K(j), K(col_id)); + break; + } + } + if (OB_SUCC(ret)) { + cell_idx++; + } + } + if (OB_SUCC(ret) && OB_FAIL(scanner_.add_row(cur_row_))) { + LOG_WARN("failed to add row", K(ret), K(cur_row_)); + } + } + if (OB_SUCC(ret)) { + scanner_it_ = scanner_.begin(); + start_to_read_ = true; + } + return ret; +} + +} +} diff --git a/src/observer/virtual_table/ob_all_virtual_compatibility_control.h b/src/observer/virtual_table/ob_all_virtual_compatibility_control.h new file mode 100644 index 0000000000..c8c5dde54b --- /dev/null +++ b/src/observer/virtual_table/ob_all_virtual_compatibility_control.h @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2023 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_ +#define OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_ + +#include "share/ob_virtual_table_scanner_iterator.h" + +namespace oceanbase +{ +namespace observer +{ +class ObVirtualCompatibilityConflictControl : public common::ObVirtualTableScannerIterator +{ +public: + ObVirtualCompatibilityConflictControl(); + ~ObVirtualCompatibilityConflictControl(); + virtual void reset() override; + virtual int inner_get_next_row(common::ObNewRow *&row) override; +private: + enum COLUMN_ID_LIST + { + TENAND_ID = common::OB_APP_MIN_COLUMN_ID, + NAME, + DESCRIPTION, + IS_ENABLE, + ENABLE_VERSIONS + }; + int fill_scanner(); +private: + DISALLOW_COPY_AND_ASSIGN(ObVirtualCompatibilityConflictControl); +}; + +} /* namespace observer */ +} /* namespace oceanbase */ +#endif /* OCEANBASE_OBSERVER_VIRTUAL_TABLE_OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_ */ diff --git a/src/observer/virtual_table/ob_gv_sql_audit.cpp b/src/observer/virtual_table/ob_gv_sql_audit.cpp index 051358624c..a3d5624e49 100644 --- a/src/observer/virtual_table/ob_gv_sql_audit.cpp +++ b/src/observer/virtual_table/ob_gv_sql_audit.cpp @@ -567,7 +567,7 @@ int ObGvSqlAudit::fill_cells(obmysql::ObMySQLRequestRecord &record) ObObj *cells = cur_row_.cells_; const bool is_perf_event_closed = record.data_.is_perf_event_closed_; - if (OB_ISNULL(cells)) { + if (OB_ISNULL(cells) || OB_ISNULL(allocator_)) { ret = OB_INVALID_ARGUMENT; SERVER_LOG(WARN, "invalid argument", K(cells)); } else { @@ -1080,7 +1080,9 @@ int ObGvSqlAudit::fill_cells(obmysql::ObMySQLRequestRecord &record) cells[cell_idx].set_int(record.data_.total_ssstore_read_row_count_); } break; case PROXY_USER_NAME: { - cells[cell_idx].set_null(); + int64_t len = min(record.data_.proxy_user_name_len_, OB_MAX_USER_NAME_LENGTH); + cells[cell_idx].set_varchar(record.data_.proxy_user_name_, + static_cast(len)); } break; //format_sql_id case FORMAT_SQL_ID: { diff --git a/src/observer/virtual_table/ob_information_columns_table.cpp b/src/observer/virtual_table/ob_information_columns_table.cpp index c1af3faafe..278b662075 100644 --- a/src/observer/virtual_table/ob_information_columns_table.cpp +++ b/src/observer/virtual_table/ob_information_columns_table.cpp @@ -813,8 +813,9 @@ int ObInfoSchemaColumnsTable::fill_row_cells(const ObString &database_name, int64_t buf_len = 200; int64_t pos = 0; ObSessionPrivInfo session_priv; - session_->get_session_priv_info(session_priv); - if (OB_UNLIKELY(!session_priv.is_valid())) { + if (OB_FAIL(session_->get_session_priv_info(session_priv))) { + SERVER_LOG(WARN, "fail to get session priv info", K(ret)); + } else if (OB_UNLIKELY(!session_priv.is_valid())) { ret = OB_INVALID_ARGUMENT; SERVER_LOG(WARN, "session priv is invalid", "tenant_id", session_priv.tenant_id_, "user_id", session_priv.user_id_, K(ret)); @@ -1208,8 +1209,9 @@ int ObInfoSchemaColumnsTable::fill_row_cells(const common::ObString &database_na int64_t buf_len = 200; int64_t pos = 0; ObSessionPrivInfo session_priv; - session_->get_session_priv_info(session_priv); - if (OB_UNLIKELY(!session_priv.is_valid())) { + if (OB_FAIL(session_->get_session_priv_info(session_priv))) { + SERVER_LOG(WARN, "fail to get session priv info", K(ret)); + } else if (OB_UNLIKELY(!session_priv.is_valid())) { ret = OB_INVALID_ARGUMENT; SERVER_LOG(WARN, "session priv is invalid", "tenant_id", session_priv.tenant_id_, "user_id", session_priv.user_id_, K(ret)); diff --git a/src/observer/virtual_table/ob_information_user_privileges_table.cpp b/src/observer/virtual_table/ob_information_user_privileges_table.cpp index 78495a8d9c..cdc27e2548 100644 --- a/src/observer/virtual_table/ob_information_user_privileges_table.cpp +++ b/src/observer/virtual_table/ob_information_user_privileges_table.cpp @@ -66,6 +66,12 @@ ObInfoSchemaUserPrivilegesTable::StaticInit::StaticInit() "ALTER ROUTINE"; ObInfoSchemaUserPrivilegesTable::priv_type_strs[OB_PRIV_CREATE_ROUTINE_SHIFT] = "CREATE ROUTINE"; + ObInfoSchemaUserPrivilegesTable::priv_type_strs[OB_PRIV_CREATE_TABLESPACE_SHIFT] = + "CREATE TABLESPACE"; + ObInfoSchemaUserPrivilegesTable::priv_type_strs[OB_PRIV_SHUTDOWN_SHIFT] = + "SHUTDOWN"; + ObInfoSchemaUserPrivilegesTable::priv_type_strs[OB_PRIV_RELOAD_SHIFT] = + "RELOAD"; } ObInfoSchemaUserPrivilegesTable::ObInfoSchemaUserPrivilegesTable() diff --git a/src/observer/virtual_table/ob_mysql_user_table.cpp b/src/observer/virtual_table/ob_mysql_user_table.cpp index 3997aac133..397d441661 100644 --- a/src/observer/virtual_table/ob_mysql_user_table.cpp +++ b/src/observer/virtual_table/ob_mysql_user_table.cpp @@ -123,8 +123,8 @@ int ObMySQLUserTable::inner_get_next_row(common::ObNewRow *&row) EXIST_PRIV_CASE(DELETE); EXIST_PRIV_CASE(CREATE); EXIST_PRIV_CASE(DROP); - NO_EXIST_PRIV_CASE(RELOAD); - NO_EXIST_PRIV_CASE(SHUTDOWN); + EXIST_PRIV_CASE(RELOAD); + EXIST_PRIV_CASE(SHUTDOWN); EXIST_PRIV_CASE(PROCESS); EXIST_PRIV_CASE(FILE); EXIST_PRIV_CASE(GRANT); @@ -147,7 +147,7 @@ int ObMySQLUserTable::inner_get_next_row(common::ObNewRow *&row) EXIST_PRIV_CASE(CREATE_USER); NO_EXIST_PRIV_CASE(EVENT); NO_EXIST_PRIV_CASE(TRIGGER); - NO_EXIST_PRIV_CASE(CREATE_TABLESPACE); + EXIST_PRIV_CASE(CREATE_TABLESPACE); COLUMN_SET_WITH_TYPE(SSL_TYPE, varchar, ssl_type_str); COLUMN_SET_WITH_TYPE(SSL_CIPHER, varchar, user_info->get_ssl_cipher()); COLUMN_SET_WITH_TYPE(X509_ISSUER, varchar, user_info->get_x509_issuer()); diff --git a/src/observer/virtual_table/ob_show_grants.cpp b/src/observer/virtual_table/ob_show_grants.cpp index 23d8dce418..eeb1c9eec1 100644 --- a/src/observer/virtual_table/ob_show_grants.cpp +++ b/src/observer/virtual_table/ob_show_grants.cpp @@ -886,6 +886,15 @@ int ObShowGrants::print_privs_to_buff( if ((priv_set & OB_PRIV_CREATE_ROUTINE) && OB_SUCCESS == ret) { ret = BUF_PRINTF(" CREATE ROUTINE,"); } + if ((priv_set & OB_PRIV_CREATE_TABLESPACE) && OB_SUCCESS == ret) { + ret = BUF_PRINTF(" CREATE TABLESPACE,"); + } + if ((priv_set & OB_PRIV_SHUTDOWN) && OB_SUCCESS == ret) { + ret = BUF_PRINTF(" SHUTDOWN,"); + } + if ((priv_set & OB_PRIV_RELOAD) && OB_SUCCESS == ret) { + ret = BUF_PRINTF(" RELOAD,"); + } if (OB_SUCCESS == ret && pos > 0) { pos--; //Delete last ',' } diff --git a/src/observer/virtual_table/ob_show_processlist.cpp b/src/observer/virtual_table/ob_show_processlist.cpp index abf82c0481..0d8efdae9e 100644 --- a/src/observer/virtual_table/ob_show_processlist.cpp +++ b/src/observer/virtual_table/ob_show_processlist.cpp @@ -481,7 +481,9 @@ bool ObShowProcesslist::FillScanner::operator()(sql::ObSQLSessionMgr::Key key, O break; } case PROXY_USER_NAME: { - cur_row_->cells_[cell_idx].set_null(); + cur_row_->cells_[cell_idx].set_varchar(sess_info->get_proxy_user_name()); + cur_row_->cells_[cell_idx].set_collation_type(ObCharset::get_default_collation( + ObCharset::get_default_charset())); break; } case SERVICE_NAME: { diff --git a/src/observer/virtual_table/ob_table_columns.cpp b/src/observer/virtual_table/ob_table_columns.cpp index a027082128..80fdbcc3d6 100644 --- a/src/observer/virtual_table/ob_table_columns.cpp +++ b/src/observer/virtual_table/ob_table_columns.cpp @@ -357,8 +357,9 @@ int ObTableColumns::fill_row_cells(const ObTableSchema &table_schema, ret = OB_ALLOCATE_MEMORY_FAILED; LOG_ERROR("fail to allocate memory", K(ret)); } else { - session_->get_session_priv_info(session_priv); - if (OB_UNLIKELY(!session_priv.is_valid())) { + if (OB_FAIL(session_->get_session_priv_info(session_priv))) { + LOG_WARN("fail to get session priv info", K(ret)); + } else if (OB_UNLIKELY(!session_priv.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("Session priv is invalid", "tenant_id", session_priv.tenant_id_, "user_id", session_priv.user_id_, K(ret)); diff --git a/src/observer/virtual_table/ob_tenant_all_tables.cpp b/src/observer/virtual_table/ob_tenant_all_tables.cpp index 6e18ba5a3e..9a98e720b1 100644 --- a/src/observer/virtual_table/ob_tenant_all_tables.cpp +++ b/src/observer/virtual_table/ob_tenant_all_tables.cpp @@ -32,7 +32,7 @@ namespace oceanbase { namespace observer { - +/*ObTenantAllTables is deprecated, please modify NEW_TABLE_STATUS_SQL or NEW_TABLE_STATUS_SQL_ORA directly*/ #define TABLE_STATUS_SQL "select /*+ leading(a) no_use_nl(ts)*/" \ "cast( coalesce(ts.row_cnt,0) as unsigned) as table_rows," \ "cast( coalesce(ts.data_size,0) as unsigned) as data_length," \ @@ -620,8 +620,9 @@ int ObTenantAllTables::inner_get_next_row() is_allow = false; } else { priv_info.reset(); - session_->get_session_priv_info(priv_info); - if (OB_FAIL(schema_guard_->check_table_show(priv_info, database_name, + if (OB_FAIL(session_->get_session_priv_info(priv_info))) { + SERVER_LOG(WARN, "fail to get session priv info", K(ret)); + } else if (OB_FAIL(schema_guard_->check_table_show(priv_info, database_name, table_schema->get_table_name_str(), is_allow))) { SERVER_LOG(WARN, "check show table priv failed", K(ret)); } diff --git a/src/observer/virtual_table/ob_tenant_all_tables.h b/src/observer/virtual_table/ob_tenant_all_tables.h index 82e86a198e..b50150f5e9 100644 --- a/src/observer/virtual_table/ob_tenant_all_tables.h +++ b/src/observer/virtual_table/ob_tenant_all_tables.h @@ -41,6 +41,119 @@ class ObTableSchema; namespace observer { +#define NEW_TABLE_STATUS_SQL "select /*+ leading(a) no_use_nl(ts)*/" \ + "a.database_id as DATABASE_ID," \ + "a.table_name as TABLE_NAME," \ + "a.table_type as TABLE_TYPE," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE 'oceanbase' END as ENGINE," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE 0 END as VERSION," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE store_format END as ROW_FORMAT," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE cast( coalesce(ts.row_cnt,0) as unsigned) END as ROWS," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE cast( coalesce(ts.avg_row_len, 0) as unsigned) END as AVG_ROW_LENGTH," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE cast( coalesce(ts.data_size,0) as unsigned) END as DATA_LENGTH," \ + "NULL as MAX_DATA_LENGTH," \ + "NULL as INDEX_LENGTH," \ + "NULL as DATA_FREE," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE inner_table_sequence_getter(effective_tenant_id(), a.table_id, a.autoinc_column_id) END as AUTO_INCREMENT," \ + "a.gmt_create as CREATE_TIME," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE a.gmt_modified END as UPDATE_TIME," \ + "NULL as CHECK_TIME," \ + "CASE a.collation_type " \ + "WHEN 45 THEN 'utf8mb4_general_ci' " \ + "WHEN 46 THEN 'utf8mb4_bin' " \ + "WHEN 63 THEN 'binary' " \ + "ELSE NULL END as COLLATION," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE 0 END as CHECKSUM," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE inner_table_option_printer(effective_tenant_id(), a.database_id, a.table_id) END as CREATE_OPTIONS," \ + "CASE a.table_type WHEN 4 THEN 'VIEW' ELSE a.comment END as COMMENT " \ + "from " \ + "(" \ + "select tenant_id," \ + "database_id," \ + "table_id," \ + "table_name, " \ + "table_type," \ + "gmt_create," \ + "gmt_modified," \ + "store_format," \ + "CASE table_type WHEN 4 THEN NULL ELSE collation_type END as collation_type," \ + "comment," \ + "autoinc_column_id " \ + "from oceanbase.__all_table where table_type in (0, 1, 2, 3, 4, 14)) a " \ + "join oceanbase.__all_database b " \ + "on a.database_id = b.database_id " \ + "and a.tenant_id = b.tenant_id " \ + "left join (" \ + "select tenant_id," \ + "table_id," \ + "row_cnt," \ + "avg_row_len," \ + "row_cnt * avg_row_len as data_size " \ + "from oceanbase.__all_table_stat " \ + "where partition_id = -1 or partition_id = table_id) ts " \ + "on a.table_id = ts.table_id " \ + "and a.tenant_id = ts.tenant_id " \ + "and a.table_type in (0, 1, 2, 3, 4, 14) " \ + "and b.database_name != '__recyclebin' " \ + "and b.in_recyclebin = 0 " \ + "and 0 = sys_privilege_check('table_acc', effective_tenant_id(), b.database_name, a.table_name) " + +#define NEW_TABLE_STATUS_SQL_ORA "select /*+ leading(a) no_use_nl(ts)*/" \ + "a.database_id as DATABASE_ID," \ + "a.table_name as TABLE_NAME," \ + "a.table_type as TABLE_TYPE," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE 'oceanbase' END as ENGINE," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE 0 END as VERSION," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE store_format END as ROW_FORMAT," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE coalesce(ts.row_cnt,0) END as \"ROWS\"," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE coalesce(ts.avg_row_len, 0) END as AVG_ROW_LENGTH," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE coalesce(ts.data_size,0) END as DATA_LENGTH," \ + "NULL as MAX_DATA_LENGTH," \ + "NULL as INDEX_LENGTH," \ + "NULL as DATA_FREE," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE inner_table_sequence_getter(effective_tenant_id(), a.table_id, a.autoinc_column_id) END as AUTO_INCREMENT," \ + "a.gmt_create as CREATE_TIME," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE a.gmt_modified END as UPDATE_TIME," \ + "NULL as CHECK_TIME," \ + "CASE a.collation_type " \ + "WHEN 45 THEN 'utf8mb4_general_ci' " \ + "WHEN 46 THEN 'utf8mb4_bin' " \ + "WHEN 63 THEN 'binary' " \ + "ELSE NULL END as COLLATION," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE 0 END as CHECKSUM," \ + "CASE a.table_type WHEN 4 THEN NULL ELSE inner_table_option_printer(effective_tenant_id(), a.database_id, a.table_id) END as CREATE_OPTIONS," \ + "CASE a.table_type WHEN 4 THEN 'VIEW' ELSE a.cmt END as \"COMMENT\" " \ + "from " \ + "(" \ + "select tenant_id," \ + "database_id," \ + "table_id," \ + "table_name, " \ + "table_type," \ + "gmt_create," \ + "gmt_modified," \ + "store_format," \ + "CASE table_type WHEN 4 THEN NULL ELSE collation_type END as collation_type," \ + "\"COMMENT\" as cmt," \ + "autoinc_column_id " \ + "from SYS.ALL_VIRTUAL_TABLE_REAL_AGENT where table_type in (0, 1, 2, 3, 4, 14)) a " \ + "join SYS.ALL_VIRTUAL_DATABASE_REAL_AGENT b " \ + "on a.database_id = b.database_id " \ + "and a.tenant_id = b.tenant_id " \ + "left join (" \ + "select tenant_id," \ + "table_id," \ + "row_cnt," \ + "avg_row_len," \ + "row_cnt * avg_row_len as data_size " \ + "from SYS.ALL_VIRTUAL_TABLE_STAT_REAL_AGENT " \ + "where partition_id = -1 or partition_id = table_id) ts " \ + "on a.table_id = ts.table_id " \ + "and a.tenant_id = ts.tenant_id " \ + "and a.table_type in (0, 1, 2, 3, 4, 14) " \ + "and b.database_name != '__recyclebin' " \ + "and b.in_recyclebin = 0 " + class ObTenantAllTables : public common::ObVirtualTableIterator { diff --git a/src/observer/virtual_table/ob_tenant_show_tables.cpp b/src/observer/virtual_table/ob_tenant_show_tables.cpp index 0566485b71..1d8c106603 100644 --- a/src/observer/virtual_table/ob_tenant_show_tables.cpp +++ b/src/observer/virtual_table/ob_tenant_show_tables.cpp @@ -196,8 +196,9 @@ int ObTenantShowTables::inner_get_next_row() is_allow = false; } else { priv_info.reset(); - session_->get_session_priv_info(priv_info); - if (OB_FAIL(schema_guard_->check_table_show(priv_info, database_name, + if (OB_FAIL(session_->get_session_priv_info(priv_info))) { + SERVER_LOG(WARN, "fail to get session priv info", K(ret)); + } else if (OB_FAIL(schema_guard_->check_table_show(priv_info, database_name, table_schema->get_table_name_str(), is_allow))) { SERVER_LOG(WARN, "check show table priv failed", K(ret)); } diff --git a/src/observer/virtual_table/ob_virtual_table_iterator_factory.cpp b/src/observer/virtual_table/ob_virtual_table_iterator_factory.cpp index 476eba5922..7bc6f76940 100644 --- a/src/observer/virtual_table/ob_virtual_table_iterator_factory.cpp +++ b/src/observer/virtual_table/ob_virtual_table_iterator_factory.cpp @@ -230,6 +230,7 @@ #include "observer/virtual_table/ob_all_virtual_nic_info.h" #include "observer/virtual_table/ob_all_virtual_sys_variable_default_value.h" #include "observer/virtual_table/ob_information_schema_enable_roles_table.h" +#include "observer/virtual_table/ob_all_virtual_compatibility_control.h" namespace oceanbase { @@ -1241,8 +1242,11 @@ int ObVTIterCreator::create_vt_iter(ObVTableScanParam ¶ms, if (OB_SUCC(NEW_VIRTUAL_TABLE(ObShowGrants, show_grants))) { show_grants->set_tenant_id(real_tenant_id); show_grants->set_user_id(session->get_user_id()); - session->get_session_priv_info(show_grants->get_session_priv()); - vt_iter = static_cast(show_grants); + if (OB_FAIL(session->get_session_priv_info(show_grants->get_session_priv()))) { + SERVER_LOG(WARN, "fail to get session priv info", K(ret)); + } else { + vt_iter = static_cast(show_grants); + } } break; } @@ -2741,6 +2745,16 @@ int ObVTIterCreator::create_vt_iter(ObVTableScanParam ¶ms, } break; } + case OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_TID: { + ObVirtualCompatibilityConflictControl *compatibility_control = NULL; + if (OB_FAIL(NEW_VIRTUAL_TABLE(ObVirtualCompatibilityConflictControl, compatibility_control))) { + SERVER_LOG(ERROR, "ObVirtualCompatibilityConflictControl construct fail", K(ret)); + } else { + compatibility_control->set_allocator(&allocator); + vt_iter = static_cast(compatibility_control); + } + break; + } END_CREATE_VT_ITER_SWITCH_LAMBDA #define AGENT_VIRTUAL_TABLE_CREATE_ITER diff --git a/src/pl/ob_pl.cpp b/src/pl/ob_pl.cpp index e8e47ee3c7..27292cfd85 100644 --- a/src/pl/ob_pl.cpp +++ b/src/pl/ob_pl.cpp @@ -3798,6 +3798,9 @@ int ObPL::check_exec_priv( exec_ctx.get_my_session()->get_database_name(), session_priv))) { LOG_WARN("fail to get_session_priv_info", K(ret)); + } else if (OB_FAIL(exec_ctx.get_my_session()->get_security_version( + session_priv.security_version_))) { + LOG_WARN("fail to get security version", K(ret)); } else if (OB_UNLIKELY(!session_priv.is_valid())) { ret = OB_INVALID_ARGUMENT; LOG_WARN("Session priv is invalid", "tenant_id", session_priv.tenant_id_, diff --git a/src/pl/ob_pl_resolver.cpp b/src/pl/ob_pl_resolver.cpp index 1dc8583212..2c9d46cd1c 100644 --- a/src/pl/ob_pl_resolver.cpp +++ b/src/pl/ob_pl_resolver.cpp @@ -5521,6 +5521,7 @@ int ObPLResolver::check_and_record_stmt_type(ObPLFunctionAST &func, case stmt::T_SHOW_TABLEGROUPS: case stmt::T_HELP: case stmt::T_SHOW_RECYCLEBIN: + case stmt::T_SHOW_PROFILE: case stmt::T_SHOW_RESTORE_PREVIEW: case stmt::T_SHOW_TENANT: case stmt::T_SHOW_SEQUENCES: diff --git a/src/rootserver/ob_ddl_operator.cpp b/src/rootserver/ob_ddl_operator.cpp index cd1b6fb716..e84ad55114 100644 --- a/src/rootserver/ob_ddl_operator.cpp +++ b/src/rootserver/ob_ddl_operator.cpp @@ -7255,7 +7255,7 @@ int ObDDLOperator::lock_user( LOG_WARN("User not exist", K(ret)); } else if (locked != user_info->get_is_locked()) { int64_t new_schema_version = OB_INVALID_VERSION; - ObUserInfo new_user_info; + ObUserInfo new_user_info; if (OB_FAIL(new_user_info.assign(*user_info))) { LOG_WARN("assign failed", K(ret)); } else { @@ -8388,6 +8388,20 @@ int ObDDLOperator::grant_revoke_role( role_info->get_user_name(), role_info->get_host_name()))) { LOG_WARN("append sql failed", K(ret)); + } else if (!is_grant) { + for (int64_t j = 0; OB_SUCC(ret) && j < user_info.get_proxied_user_info_cnt(); j++) { + const ObProxyInfo *proxy_info = user_info.get_proxied_user_info_by_idx(j); + if (OB_ISNULL(proxy_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } + for (int64_t k = 0; OB_SUCC(ret) && k < proxy_info->role_id_cnt_; k++) { + if (proxy_info->get_role_id_by_idx(k) == role_id) { + OZ (schema_service->get_priv_sql_service().grant_proxy_role(tenant_id, user_info.get_user_id(), + proxy_info->user_id_, role_id, new_schema_version, trans, is_grant)); + } + } + } } } } @@ -11675,6 +11689,131 @@ int ObDDLOperator::drop_directory(const ObString &ddl_str, } //----End of functions for directory object---- + +int ObDDLOperator::alter_user_proxy(const ObUserInfo* client_user_info, + const ObUserInfo* proxy_user_info, + const uint64_t flags, + const bool is_grant, + const ObIArray &role_ids, + ObIArray &users_to_update, + ObMySQLTransaction &trans) +{ + int ret = OB_SUCCESS; + int64_t new_schema_version = OB_INVALID_VERSION; + ObSchemaService *schema_sql_service = schema_service_.get_schema_service(); + ObArray cur_role_ids; + if (OB_ISNULL(schema_sql_service) || OB_ISNULL(client_user_info) || OB_ISNULL(proxy_user_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("schema_service must not null", K(ret)); + } else if (OB_FAIL(schema_service_.gen_new_schema_version(client_user_info->get_tenant_id(), new_schema_version))) { + LOG_WARN("fail to gen new schema_version", K(ret), K(client_user_info->get_tenant_id())); + } else { + bool found = false; + for (int64_t i = 0; OB_SUCC(ret) && !found && i < client_user_info->get_proxied_user_info_cnt(); i++) { + const ObProxyInfo *proxy_info = client_user_info->get_proxied_user_info_by_idx(i); + if (OB_ISNULL(proxy_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (proxy_info->user_id_ == proxy_user_info->get_user_id()) { + found = true; + for (int64_t j = 0; OB_SUCC(ret) && j < proxy_info->role_id_cnt_; j++) { + OZ (cur_role_ids.push_back(proxy_info->get_role_id_by_idx(j))); + } + } + } + if (OB_FAIL(ret)) { + } else if (!found) { + if (!is_grant) { + ret = OB_ERR_CANNOT_REVOKE_PRIVILEGES_YOU_DID_NOT_GRANT; + LOG_WARN("revoke no such grant", K(ret)); + } + } + } + ObArray role_to_add; + ObArray role_to_del; + for (int64_t i = 0; OB_SUCC(ret) && i < role_ids.count(); i++) { + bool found = false; + for (int64_t j = 0; OB_SUCC(ret) && !found && j < cur_role_ids.count(); j++) { + if (cur_role_ids.at(j) == role_ids.at(i)) { + found = true; + } + } + if (OB_SUCC(ret) && !found) { + if (OB_FAIL(role_to_add.push_back(role_ids.at(i)))) { + LOG_WARN("push back failed", K(ret)); + } + } + } + + for (int64_t i = 0; OB_SUCC(ret) && i < cur_role_ids.count(); i++) { + bool found = false; + for (int64_t j = 0; OB_SUCC(ret) && !found && j < role_ids.count(); j++) { + if (cur_role_ids.at(i) == role_ids.at(j)) { + found = true; + } + } + if (OB_SUCC(ret) && !found) { + if (OB_FAIL(role_to_del.push_back(cur_role_ids.at(i)))) { + LOG_WARN("push back failed", K(ret)); + } + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(schema_sql_service->get_priv_sql_service().grant_proxy(client_user_info->get_tenant_id(), + client_user_info->get_user_id(), proxy_user_info->get_user_id(), flags, new_schema_version, trans, is_grant))) { + LOG_WARN("grant proxy failed", KPC(proxy_user_info), KPC(client_user_info), K(new_schema_version), K(ret)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < role_to_add.count(); i++) { + if (OB_FAIL(schema_sql_service->get_priv_sql_service().grant_proxy_role(client_user_info->get_tenant_id(), + client_user_info->get_user_id(), proxy_user_info->get_user_id(), role_to_add.at(i), new_schema_version, trans, true/*grant*/))) { + LOG_WARN("grant proxy role failed", KPC(proxy_user_info), KPC(client_user_info), K(new_schema_version), K(ret)); + } + } + for (int64_t i = 0; OB_SUCC(ret) && i < role_to_del.count(); i++) { + if (OB_FAIL(schema_sql_service->get_priv_sql_service().grant_proxy_role(client_user_info->get_tenant_id(), + client_user_info->get_user_id(), proxy_user_info->get_user_id(), role_to_del.at(i), new_schema_version, trans, false/*delete*/))) { + LOG_WARN("grant proxy role failed", KPC(proxy_user_info), KPC(client_user_info), K(new_schema_version), K(ret)); + } + } + } + if (OB_SUCC(ret)) { + bool found_client_user = false; + bool found_proxy_user = false; + for (int64_t i = 0; OB_SUCC(ret) && !(found_client_user && found_proxy_user) && i < users_to_update.count(); i++) { + if (users_to_update.at(i).get_user_id() == client_user_info->get_user_id()) { + found_client_user = true; + } + if (users_to_update.at(i).get_user_id() == proxy_user_info->get_user_id()) { + found_proxy_user = true; + } + } + if (OB_SUCC(ret)) { + if (!found_client_user) { + if (OB_FAIL(users_to_update.push_back(*client_user_info))) { + LOG_WARN("fail to push back", K(ret)); + } else if (is_grant) { + users_to_update.at(users_to_update.count() - 1).set_proxy_activated_flag(ObProxyActivatedFlag::PROXY_BEEN_ACTIVATED_BEFORE); + } + } + } + if (OB_SUCC(ret)) { + if (client_user_info->get_user_id() == proxy_user_info->get_user_id()) { + //skip + } else if (!found_proxy_user) { + if (OB_FAIL(users_to_update.push_back(*proxy_user_info))) { + LOG_WARN("fail to push back", K(ret)); + } else if (is_grant) { + users_to_update.at(users_to_update.count() - 1).set_proxy_activated_flag(ObProxyActivatedFlag::PROXY_BEEN_ACTIVATED_BEFORE); + } + } + } + } + } + + return ret; +} + //----Functions for rls object---- int ObDDLOperator::create_rls_policy(ObRlsPolicySchema &schema, ObMySQLTransaction &trans, diff --git a/src/rootserver/ob_ddl_operator.h b/src/rootserver/ob_ddl_operator.h index 4c9197f24c..ff720bea16 100644 --- a/src/rootserver/ob_ddl_operator.h +++ b/src/rootserver/ob_ddl_operator.h @@ -1061,6 +1061,13 @@ public: common::number::ObNumber &next_value); int alter_target_sequence_start_with(const ObSequenceSchema &sequence_schema, common::ObMySQLTransaction &trans); + int alter_user_proxy(const ObUserInfo* client_user_info, + const ObUserInfo* proxy_user_info, + const uint64_t flags, + const bool is_grant, + const ObIArray &role_ids, + ObIArray &users_to_update, + ObMySQLTransaction &trans); private: virtual int set_need_flush_ora( share::schema::ObSchemaGetterGuard &schema_guard, diff --git a/src/rootserver/ob_ddl_service.cpp b/src/rootserver/ob_ddl_service.cpp index 04ce0019f4..293c54330e 100755 --- a/src/rootserver/ob_ddl_service.cpp +++ b/src/rootserver/ob_ddl_service.cpp @@ -168,6 +168,12 @@ namespace rootserver LOG_WARN("failed to print value in buf", K(value), K(ret));\ }\ } +#define VAR_UINT_TO_STRING(buf, value) \ + if (OB_SUCC(ret)) {\ + if (OB_FAIL(databuff_printf(buf, OB_MAX_SYS_PARAM_VALUE_LENGTH, "%lu", static_cast(value)))) {\ + LOG_WARN("failed to print value in buf", K(value), K(ret));\ + }\ + } #define GRANT_SYS_ROLE_NUM 2 /* len of role array is 2 */ #define GRANT_ROLE_MIN_ROLE_NUM 3 /* min len of role array is 3 */ @@ -6169,34 +6175,6 @@ int ObDDLService::lock_tables_of_database(const ObDatabaseSchema &database_schem return ret; } -int ObDDLService::check_parallel_ddl_conflict( - share::schema::ObSchemaGetterGuard &schema_guard, - const obrpc::ObDDLArg &arg) -{ - int ret = OB_SUCCESS; - int64_t schema_version = OB_INVALID_VERSION; - - if (arg.is_need_check_based_schema_objects()) { - for (int64_t i = 0; OB_SUCC(ret) && (i < arg.based_schema_object_infos_.count()); ++i) { - const ObBasedSchemaObjectInfo &info = arg.based_schema_object_infos_.at(i); - if (OB_FAIL(schema_guard.get_schema_version( - info.schema_type_, - info.schema_tenant_id_ == OB_INVALID_TENANT_ID ? arg.exec_tenant_id_: info.schema_tenant_id_, - info.schema_id_, - schema_version))) { - LOG_WARN("failed to get_schema_version", K(ret), K(arg.exec_tenant_id_), K(info)); - } else if (OB_INVALID_VERSION == schema_version) { - ret = OB_ERR_PARALLEL_DDL_CONFLICT; - LOG_WARN("schema_version is OB_INVALID_VERSION", K(ret), K(info)); - } else if (schema_version != info.schema_version_) { - ret = OB_ERR_PARALLEL_DDL_CONFLICT; - LOG_WARN("schema_version is not equal to info.schema_version_", K(ret), K(schema_version), K(info)); - } - } - } - - return ret; -} int ObDDLService::lock_tables_in_recyclebin(const ObDatabaseSchema &database_schema, ObMySQLTransaction &trans) { @@ -20676,6 +20654,34 @@ int ObDDLService::check_table_schema_is_legal(const ObDatabaseSchema & database_ return ret; } +int ObDDLService::check_parallel_ddl_conflict( + share::schema::ObSchemaGetterGuard &schema_guard, + const obrpc::ObDDLArg &arg) +{ + int ret = OB_SUCCESS; + int64_t schema_version = OB_INVALID_VERSION; + + if (arg.is_need_check_based_schema_objects()) { + for (int64_t i = 0; OB_SUCC(ret) && (i < arg.based_schema_object_infos_.count()); ++i) { + const ObBasedSchemaObjectInfo &info = arg.based_schema_object_infos_.at(i); + if (OB_FAIL(schema_guard.get_schema_version( + info.schema_type_, + info.schema_tenant_id_ == OB_INVALID_TENANT_ID ? arg.exec_tenant_id_: info.schema_tenant_id_, + info.schema_id_, + schema_version))) { + LOG_WARN("failed to get_schema_version", K(ret), K(arg.exec_tenant_id_), K(info)); + } else if (OB_INVALID_VERSION == schema_version) { + ret = OB_ERR_PARALLEL_DDL_CONFLICT; + LOG_WARN("schema_version is OB_INVALID_VERSION", K(ret), K(info)); + } else if (schema_version != info.schema_version_) { + ret = OB_ERR_PARALLEL_DDL_CONFLICT; + LOG_WARN("schema_version is not equal to info.schema_version_", K(ret), K(schema_version), K(info)); + } + } + } + + return ret; +} int ObDDLService::new_truncate_table(const obrpc::ObTruncateTableArg &arg, obrpc::ObDDLRes &ddl_res, const SCN &frozen_version) @@ -31555,6 +31561,14 @@ int ObDDLService::grant_revoke_user( 0 != (priv_set & OB_PRIV_CREATE_ROUTINE))) { ret = OB_NOT_SUPPORTED; LOG_WARN("some column of user info is not empty when MIN_DATA_VERSION is below DATA_VERSION_4_3_1_0 or DATA_VERSION_4_2_2_0", K(ret), K(priv_set)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "grant or revoke execute/alter routine/create routine privilege"); + } else if (!ObSQLUtils::is_data_version_ge_423_or_432(compat_version) && !is_ora_mode + && (0 != (priv_set & OB_PRIV_CREATE_TABLESPACE) || + 0 != (priv_set & OB_PRIV_SHUTDOWN) || + 0 != (priv_set & OB_PRIV_RELOAD))) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("some column of user info is not empty when MIN_DATA_VERSION is below DATA_VERSION_4_2_3_0 or DATA_VERSION_4_3_2_0", K(ret), K(priv_set)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "grant or revoke create tablespace/shutdown/reload privilege"); } else if (OB_FAIL(trans.start(sql_proxy_, tenant_id, refreshed_schema_version))) { LOG_WARN("Start transaction failed", KR(ret), K(tenant_id), K(refreshed_schema_version)); } else { @@ -36502,7 +36516,8 @@ int ObDDLService::init_system_variables( ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid arguments", KR(ret), K(sys_params), K(params_capacity), K(var_amount)); } else { - HEAP_VAR(char[OB_MAX_SYS_PARAM_VALUE_LENGTH], val_buf) { + HEAP_VARS_2((char[OB_MAX_SYS_PARAM_VALUE_LENGTH], val_buf), + (char[OB_MAX_SYS_PARAM_VALUE_LENGTH], version_buf)) { // name_case_mode if (is_meta_tenant(tenant_id)) { sys_variable_schema.set_name_case_mode(OB_ORIGIN_AND_INSENSITIVE); @@ -36528,6 +36543,8 @@ int ObDDLService::init_system_variables( int64_t set_sys_var_count = arg.sys_var_list_.count(); bool use_default_parallel_servers_target = true; + bool explicit_set_compatibility_version = false; + bool explicit_set_security_version = false; for (int64_t j = 0; OB_SUCC(ret) && j < set_sys_var_count; ++j) { ObSysVarIdValue sys_var; if (OB_FAIL(arg.sys_var_list_.at(j, sys_var))) { @@ -36552,6 +36569,10 @@ int ObDDLService::init_system_variables( } } else if (SYS_VAR_PARALLEL_SERVERS_TARGET == sys_var.sys_id_) { use_default_parallel_servers_target = false; + } else if (SYS_VAR_OB_COMPATIBILITY_VERSION == sys_var.sys_id_) { + explicit_set_compatibility_version = true; + } else if (SYS_VAR_OB_SECURITY_VERSION == sys_var.sys_id_) { + explicit_set_security_version = true; } } } // end for @@ -36622,6 +36643,15 @@ int ObDDLService::init_system_variables( SET_TENANT_VARIABLE(SYS_VAR_PARALLEL_SERVERS_TARGET, val_buf); } + VAR_UINT_TO_STRING(version_buf, CLUSTER_CURRENT_VERSION); + if (OB_SUCC(ret) && !(is_user_tenant(tenant_id) && explicit_set_compatibility_version)) { + SET_TENANT_VARIABLE(SYS_VAR_OB_COMPATIBILITY_VERSION, version_buf); + } + + if (OB_SUCC(ret) && !(is_user_tenant(tenant_id) && explicit_set_security_version)) { + SET_TENANT_VARIABLE(SYS_VAR_OB_SECURITY_VERSION, version_buf); + } + if (FAILEDx(update_mysql_tenant_sys_var( tenant_schema, sys_variable_schema, sys_params, params_capacity))) { LOG_WARN("failed to update_mysql_tenant_sys_var", @@ -38257,6 +38287,97 @@ int ObDDLService::handle_rls_context_ddl(const obrpc::ObRlsContextDDLArg &arg) return ret; } +int ObDDLService::alter_user_proxy(const ObAlterUserProxyArg &arg) +{ + int ret = OB_SUCCESS; + uint64_t tenant_id = arg.tenant_id_; + ObSchemaGetterGuard schema_guard; + + if (OB_FAIL(check_inner_stat())) { + LOG_WARN("check inner stat failed", K(ret)); + } else if (OB_ISNULL(schema_service_->get_schema_service())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_UNLIKELY(!is_valid_tenant_id(tenant_id))) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid input schema", K(ret), K(tenant_id)); + } else if (OB_FAIL(get_tenant_schema_guard_with_version_in_inner_table(tenant_id, schema_guard))) { + LOG_WARN("fail to get schema guard", K(ret), K(tenant_id)); + } else if (OB_FAIL(check_parallel_ddl_conflict(schema_guard, arg))) { + LOG_WARN("check parallel ddl conflict failed", K(ret)); + } + if (OB_SUCC(ret)) { + ObDDLSQLTransaction trans(schema_service_); + ObDDLOperator ddl_operator(*schema_service_, *sql_proxy_); + int64_t refreshed_schema_version = 0; + if (OB_FAIL(schema_guard.get_schema_version(tenant_id, refreshed_schema_version))) { + LOG_WARN("failed to get tenant schema version", KR(ret), K(tenant_id)); + } else if (OB_FAIL(trans.start(sql_proxy_, tenant_id, refreshed_schema_version))) { + LOG_WARN("start transaction failed", KR(ret), K(tenant_id), K(refreshed_schema_version)); + } + if (OB_SUCC(ret)) { + ObArray users_to_update; + for (int64_t i = 0; OB_SUCC(ret) && i < arg.role_ids_.count(); i++) { + const ObUserInfo *role_user = NULL; + if (OB_FAIL(schema_guard.get_user_info(tenant_id, arg.role_ids_.at(i), role_user))) { + LOG_WARN("get user info failed", K(arg.role_ids_.at(i)), K(ret)); + } else if (OB_ISNULL(role_user)) { + ret = OB_ROLE_NOT_EXIST; + LOG_WARN("role not existed", K(ret)); + } + } + for (int64_t i = 0; OB_SUCC(ret) && i < arg.client_user_ids_.count(); i++) { + const ObUserInfo *client_user_info = NULL; + if (OB_FAIL(schema_guard.get_user_info(tenant_id, arg.client_user_ids_.at(i), client_user_info))) { + LOG_WARN("get user failed", K(ret)); + } else if (OB_ISNULL(client_user_info)) { + ret = OB_ERR_USER_NOT_EXIST; + LOG_WARN("user not existed", K(ret)); + } + for (int64_t j = 0; OB_SUCC(ret) && j < arg.proxy_user_ids_.count(); j++) { + const ObUserInfo *proxy_user_info = NULL; + if (OB_FAIL(schema_guard.get_user_info(tenant_id, arg.proxy_user_ids_.at(j), proxy_user_info))) { + LOG_WARN("get user failed", K(ret)); + } else if (OB_ISNULL(proxy_user_info)) { + ret = OB_ERR_USER_NOT_EXIST; + LOG_WARN("user not existed", K(ret)); + } else if (OB_FAIL(ddl_operator.alter_user_proxy(client_user_info, proxy_user_info, + arg.flags_, arg.is_grant_, arg.role_ids_, users_to_update, trans))) { + LOG_WARN("alter user proxy failed", K(client_user_info), K(proxy_user_info), K(ret)); + } + } + } + if (OB_SUCC(ret)) { + if (users_to_update.empty()) { + //do nothing + } else if (OB_FAIL(schema_service_->get_schema_service()->get_user_sql_service().update_user_proxy_info( + arg.tenant_id_, + users_to_update, + &arg.ddl_stmt_str_, + trans))) { + LOG_WARN("Failed to grant or revoke user", K(users_to_update), K(ret)); + } + } + } + + if (trans.is_started()) { + int temp_ret = OB_SUCCESS; + if (OB_SUCCESS != (temp_ret = trans.end(OB_SUCC(ret)))) { + LOG_WARN("trans end failed", "is_commit", OB_SUCCESS == ret, K(temp_ret)); + ret = (OB_SUCC(ret)) ? temp_ret : ret; + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(publish_schema(tenant_id))) { + LOG_WARN("publish schema failed", K(ret)); + } + } + + } + return ret; +} + int ObDDLService::ddl_wlock() { const int64_t timeout_us = THIS_WORKER.is_timeout_ts_valid() ? diff --git a/src/rootserver/ob_ddl_service.h b/src/rootserver/ob_ddl_service.h index 92f94b7c7d..028669cdc4 100644 --- a/src/rootserver/ob_ddl_service.h +++ b/src/rootserver/ob_ddl_service.h @@ -870,6 +870,7 @@ int check_table_udt_id_is_exist(share::schema::ObSchemaGetterGuard &schema_guard int alter_user_profile(const obrpc::ObAlterUserProfileArg &arg); int alter_user_default_role(const obrpc::ObAlterUserProfileArg &arg); + int alter_user_proxy(const obrpc::ObAlterUserProxyArg &arg); int get_all_users_in_tenant_with_profile(const uint64_t tenant_id, const uint64_t profile_id, share::schema::ObSchemaGetterGuard &schema_guard, @@ -2109,6 +2110,7 @@ public: obrpc::ObSrvRpcProxy &rpc_proxy, const common::ObIArray &init_configs, const common::ObIArray &addrs); + #ifdef OB_BUILD_TDE_SECURITY int check_need_create_root_key(const obrpc::ObCreateTenantArg &arg, bool &need_create); int get_root_key_from_primary(const obrpc::ObCreateTenantArg &arg, diff --git a/src/rootserver/ob_ddl_sql_generator.cpp b/src/rootserver/ob_ddl_sql_generator.cpp index a83ef6a492..03b0d36329 100644 --- a/src/rootserver/ob_ddl_sql_generator.cpp +++ b/src/rootserver/ob_ddl_sql_generator.cpp @@ -109,6 +109,12 @@ int ObDDLSqlGenerator::get_priv_name(const int64_t priv, const char *&name) name = "ALTER ROUTINE"; break; case OB_PRIV_CREATE_ROUTINE: name = "CREATE ROUTINE"; break; + case OB_PRIV_CREATE_TABLESPACE: + name = "CREATE TABLESPACE"; break; + case OB_PRIV_SHUTDOWN: + name = "SHUTDOWN"; break; + case OB_PRIV_RELOAD: + name = "RELOAD"; break; default: { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid priv", K(ret), K(priv)); diff --git a/src/rootserver/ob_root_service.cpp b/src/rootserver/ob_root_service.cpp index ca6b83b141..4fdd9a85a2 100755 --- a/src/rootserver/ob_root_service.cpp +++ b/src/rootserver/ob_root_service.cpp @@ -6332,6 +6332,27 @@ int ObRootService::alter_user_profile(const ObAlterUserProfileArg &arg) return ret; } +int ObRootService::alter_user_proxy(const obrpc::ObAlterUserProxyArg &arg, obrpc::ObAlterUserProxyRes &res) +{ + int ret = OB_SUCCESS; + uint64_t tenant_data_version = 0; + if (!inited_) { + ret = OB_NOT_INIT; + LOG_WARN("not init", K(ret)); + } else if (!arg.is_valid()) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid arg", K(arg), K(ret)); + } else if (OB_FAIL(GET_MIN_DATA_VERSION(arg.tenant_id_, tenant_data_version))) { + LOG_WARN("get tenant data version failed", K(ret)); + } else if (!ObSQLUtils::is_data_version_ge_423_or_432(tenant_data_version)) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "alter user grant connect through is not supported when data version is below 4.2.3 or 4.3.2"); + } else if (OB_FAIL(ddl_service_.alter_user_proxy(arg))){ + LOG_WARN("alter user failed", K(arg), K(ret)); + } + return ret; +} + int ObRootService::create_directory(const obrpc::ObCreateDirectoryArg &arg) { int ret = OB_SUCCESS; diff --git a/src/rootserver/ob_root_service.h b/src/rootserver/ob_root_service.h index cc84cc9917..008ab81f61 100644 --- a/src/rootserver/ob_root_service.h +++ b/src/rootserver/ob_root_service.h @@ -550,6 +550,7 @@ public: int revoke_routine(const obrpc::ObRevokeRoutineArg &arg); int revoke_syspriv(const obrpc::ObRevokeSysPrivArg &arg); int alter_user_profile(const obrpc::ObAlterUserProfileArg &arg); + int alter_user_proxy(const obrpc::ObAlterUserProxyArg &arg, obrpc::ObAlterUserProxyRes &res); int alter_role(const obrpc::ObAlterRoleArg &arg); //----End of functions for managing privileges---- diff --git a/src/rootserver/ob_rs_rpc_processor.h b/src/rootserver/ob_rs_rpc_processor.h index e383ddcd48..c58292875e 100644 --- a/src/rootserver/ob_rs_rpc_processor.h +++ b/src/rootserver/ob_rs_rpc_processor.h @@ -565,6 +565,8 @@ DEFINE_RS_RPC_PROCESSOR(obrpc::OB_GET_ROOT_KEY, ObGetRootKeyP, handle_get_root_k DEFINE_RS_RPC_PROCESSOR(obrpc::OB_RELOAD_MASTER_KEY, ObReloadMasterKeyP, reload_master_key(arg_, result_)); #endif +DEFINE_DDL_RS_RPC_PROCESSOR(obrpc::OB_ALTER_USER_PROXY, ObRpcAlterUserProxyP, alter_user_proxy(arg_, result_)); + #undef DEFINE_RS_RPC_PROCESSOR_ #undef DEFINE_RS_RPC_PROCESSOR #undef DEFINE_LIMITED_RS_RPC_PROCESSOR diff --git a/src/rootserver/ob_schema_history_recycler.cpp b/src/rootserver/ob_schema_history_recycler.cpp index 12db7e5504..f965ba0e00 100644 --- a/src/rootserver/ob_schema_history_recycler.cpp +++ b/src/rootserver/ob_schema_history_recycler.cpp @@ -809,10 +809,12 @@ int ObSchemaHistoryRecycler::try_recycle_schema_history( // tablegroup's partition will be recycled as table's partition ret = OB_SUCCESS; // overwrite ret - // ----------------------------- user/role --------------------------------------- + // ----------------------------- user/role/proxy --------------------------------------- RECYCLE_FIRST_SCHEMA(RECYCLE_AND_COMPRESS, user, OB_ALL_USER_HISTORY_TNAME, user_id); // TODO: should be tested //RECYCLE_SECOND_SCHEMA(role_grantee, OB_ALL_TENANT_ROLE_GRANTEE_MAP_HISTORY_TNAME, grantee_id, role_id); + RECYCLE_SECOND_SCHEMA(proxy, OB_ALL_USER_PROXY_INFO_HISTORY_TNAME, client_user_id, proxy_user_id); + RECYCLE_THIRD_SCHEMA(proxy_role, OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TNAME, client_user_id, proxy_user_id, role_id); ret = OB_SUCCESS; // overwrite ret // ---------------------------- outline ------------------------------------------ diff --git a/src/share/CMakeLists.txt b/src/share/CMakeLists.txt index af15431e7d..82b6f7cced 100644 --- a/src/share/CMakeLists.txt +++ b/src/share/CMakeLists.txt @@ -188,6 +188,7 @@ ob_set_subtarget(ob_share common ob_throttling_utils.cpp ob_storage_ha_diagnose_struct.cpp ob_storage_ha_diagnose_operator.cpp + ob_compatibility_control.cpp ) ob_set_subtarget(ob_share common_mixed diff --git a/src/share/inner_table/ob_inner_table_schema.12451_12500.cpp b/src/share/inner_table/ob_inner_table_schema.12451_12500.cpp index 376153b41f..20fe94355d 100644 --- a/src/share/inner_table/ob_inner_table_schema.12451_12500.cpp +++ b/src/share/inner_table/ob_inner_table_schema.12451_12500.cpp @@ -2484,6 +2484,775 @@ int ObInnerTableSchema::all_virtual_tracepoint_info_schema(ObTableSchema &table_ return ret; } +int ObInnerTableSchema::all_virtual_compatibility_control_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(0); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(VIRTUAL_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("name", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_INVALID, //column_collation_type + OB_MAX_CONFIG_NAME_LEN, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("description", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_INVALID, //column_collation_type + OB_MAX_CONFIG_INFO_LEN, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("is_enable", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTinyIntType, //column_type + CS_TYPE_INVALID, //column_collation_type + 1, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("enable_versions", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObLongTextType, //column_type + CS_TYPE_INVALID, //column_collation_type + 0, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + table_schema.set_index_using_type(USING_HASH); + table_schema.set_row_store_type(ENCODING_ROW_STORE); + table_schema.set_store_format(OB_STORE_FORMAT_DYNAMIC_MYSQL); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_virtual_user_proxy_info_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_VIRTUAL_USER_PROXY_INFO_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(3); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(VIRTUAL_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_USER_PROXY_INFO_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + ++column_id, //column_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + ++column_id, //column_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + ++column_id, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA_TS("gmt_create", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(ObPreciseDateTime), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + false); //is_on_update_for_timestamp + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA_TS("gmt_modified", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(ObPreciseDateTime), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + false); //is_on_update_for_timestamp + } + + if (OB_SUCC(ret)) { + ObObj credential_type_default; + credential_type_default.set_int(0); + ADD_COLUMN_SCHEMA_T("credential_type", //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 + credential_type_default, + credential_type_default); //default_value + } + + if (OB_SUCC(ret)) { + ObObj flags_default; + flags_default.set_int(0); + ADD_COLUMN_SCHEMA_T("flags", //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 + flags_default, + flags_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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_virtual_user_proxy_info_history_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_VIRTUAL_USER_PROXY_INFO_HISTORY_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(4); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(VIRTUAL_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_USER_PROXY_INFO_HISTORY_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + ++column_id, //column_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + ++column_id, //column_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + ++column_id, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("schema_version", //column_name + ++column_id, //column_id + 4, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA_TS("gmt_create", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(ObPreciseDateTime), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + false); //is_on_update_for_timestamp + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA_TS("gmt_modified", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(ObPreciseDateTime), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + false); //is_on_update_for_timestamp + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("is_deleted", //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 + } + + if (OB_SUCC(ret)) { + ObObj credential_type_default; + credential_type_default.set_int(0); + ADD_COLUMN_SCHEMA_T("credential_type", //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 + true, //is_nullable + false, //is_autoincrement + credential_type_default, + credential_type_default); //default_value + } + + if (OB_SUCC(ret)) { + ObObj flags_default; + flags_default.set_int(0); + ADD_COLUMN_SCHEMA_T("flags", //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 + true, //is_nullable + false, //is_autoincrement + flags_default, + flags_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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_virtual_user_proxy_role_info_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(4); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(VIRTUAL_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + ++column_id, //column_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + ++column_id, //column_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + ++column_id, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("role_id", //column_name + ++column_id, //column_id + 4, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA_TS("gmt_create", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(ObPreciseDateTime), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + false); //is_on_update_for_timestamp + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA_TS("gmt_modified", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(ObPreciseDateTime), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + false); //is_on_update_for_timestamp + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_virtual_user_proxy_role_info_history_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_HISTORY_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(5); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(VIRTUAL_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_HISTORY_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + ++column_id, //column_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + ++column_id, //column_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + ++column_id, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("role_id", //column_name + ++column_id, //column_id + 4, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("schema_version", //column_name + ++column_id, //column_id + 5, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA_TS("gmt_create", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(ObPreciseDateTime), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + false); //is_on_update_for_timestamp + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA_TS("gmt_modified", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(ObPreciseDateTime), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false, //is_autoincrement + false); //is_on_update_for_timestamp + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("is_deleted", //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 + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + int ObInnerTableSchema::all_virtual_tenant_resource_limit_schema(ObTableSchema &table_schema) { int ret = OB_SUCCESS; diff --git a/src/share/inner_table/ob_inner_table_schema.15401_15450.cpp b/src/share/inner_table/ob_inner_table_schema.15401_15450.cpp index 9e5f471e8b..f69d770f44 100644 --- a/src/share/inner_table/ob_inner_table_schema.15401_15450.cpp +++ b/src/share/inner_table/ob_inner_table_schema.15401_15450.cpp @@ -6954,6 +6954,289 @@ int ObInnerTableSchema::all_virtual_tracepoint_info_ora_schema(ObTableSchema &ta return ret; } +int ObInnerTableSchema::all_virtual_user_proxy_info_real_agent_ora_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_ORA_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(3); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(VIRTUAL_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCollationType::CS_TYPE_UTF8MB4_BIN); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("TENANT_ID", //column_name + ++column_id, //column_id + 1, //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("CLIENT_USER_ID", //column_name + ++column_id, //column_id + 2, //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("PROXY_USER_ID", //column_name + ++column_id, //column_id + 3, //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("CREDENTIAL_TYPE", //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("FLAGS", //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 + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampLTZType, //column_type + CS_TYPE_INVALID, //column_collation_type + 0, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("GMT_MODIFIED", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampLTZType, //column_type + CS_TYPE_INVALID, //column_collation_type + 0, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_virtual_user_proxy_role_info_real_agent_ora_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_ORA_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(4); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(VIRTUAL_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCollationType::CS_TYPE_UTF8MB4_BIN); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("TENANT_ID", //column_name + ++column_id, //column_id + 1, //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("CLIENT_USER_ID", //column_name + ++column_id, //column_id + 2, //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("PROXY_USER_ID", //column_name + ++column_id, //column_id + 3, //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("ROLE_ID", //column_name + ++column_id, //column_id + 4, //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 + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampLTZType, //column_type + CS_TYPE_INVALID, //column_collation_type + 0, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("GMT_MODIFIED", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampLTZType, //column_type + CS_TYPE_INVALID, //column_collation_type + 0, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + } // end namespace share } // end namespace oceanbase diff --git a/src/share/inner_table/ob_inner_table_schema.20001_20050.cpp b/src/share/inner_table/ob_inner_table_schema.20001_20050.cpp index 64cce99417..1e95e8d45d 100644 --- a/src/share/inner_table/ob_inner_table_schema.20001_20050.cpp +++ b/src/share/inner_table/ob_inner_table_schema.20001_20050.cpp @@ -725,6 +725,56 @@ int ObInnerTableSchema::routines_schema(ObTableSchema &table_schema) return ret; } +int ObInnerTableSchema::profiling_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_INFORMATION_SCHEMA_ID); + table_schema.set_table_id(OB_PROFILING_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(0); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(SYSTEM_VIEW); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_PROFILING_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(00000000000000000000 as SIGNED) as QUERY_ID, CAST(00000000000000000000 as SIGNED) as SEQ, CAST('' as CHAR(30)) as STATE, CAST(0.000000 as DECIMAL(9, 6)) as DURATION, CAST(NULL as DECIMAL(9, 6)) as CPU_USER, CAST(NULL as DECIMAL(9, 6)) as CPU_SYSTEM, CAST(00000000000000000000 as SIGNED) as CONTEXT_VOLUNTARY, CAST(00000000000000000000 as SIGNED) as CONTEXT_INVOLUNTARY, CAST(00000000000000000000 as SIGNED) as BLOCK_OPS_IN, CAST(00000000000000000000 as SIGNED) as BLOCK_OPS_OUT, CAST(00000000000000000000 as SIGNED) as MESSAGES_SENT, CAST(00000000000000000000 as SIGNED) as MESSAGES_RECEIVED, CAST(00000000000000000000 as SIGNED) as PAGE_FAULTS_MAJOR, CAST(00000000000000000000 as SIGNED) as PAGE_FAULTS_MINOR, CAST(00000000000000000000 as SIGNED) as SWAPS, CAST(NULL as CHAR(30)) as SOURCE_FUNCTION, CAST(NULL as CHAR(20)) as SOURCE_FILE, CAST(00000000000000000000 as SIGNED) as SOURCE_LINE FROM DUAL limit 0; )__"))) { + LOG_ERROR("fail to set view_definition", K(ret)); + } + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + } // end namespace share } // end namespace oceanbase diff --git a/src/share/inner_table/ob_inner_table_schema.21001_21050.cpp b/src/share/inner_table/ob_inner_table_schema.21001_21050.cpp index 729807ddc7..c77f3a6135 100644 --- a/src/share/inner_table/ob_inner_table_schema.21001_21050.cpp +++ b/src/share/inner_table/ob_inner_table_schema.21001_21050.cpp @@ -760,7 +760,7 @@ int ObInnerTableSchema::gv_ob_sql_audit_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__(select svr_ip as SVR_IP, svr_port as SVR_PORT, request_id as REQUEST_ID, execution_id as SQL_EXEC_ID, trace_id as TRACE_ID, session_id as SID, client_ip as CLIENT_IP, client_port as CLIENT_PORT, tenant_id as TENANT_ID, tenant_name as TENANT_NAME, effective_tenant_id as EFFECTIVE_TENANT_ID, user_id as USER_ID, user_name as USER_NAME, user_group as USER_GROUP, user_client_ip as USER_CLIENT_IP, db_id as DB_ID, db_name as DB_NAME, sql_id as SQL_ID, query_sql as QUERY_SQL, plan_id as PLAN_ID, affected_rows as AFFECTED_ROWS, return_rows as RETURN_ROWS, partition_cnt as PARTITION_CNT, ret_code as RET_CODE, qc_id as QC_ID, dfo_id as DFO_ID, sqc_id as SQC_ID, worker_id as WORKER_ID, event as EVENT, p1text as P1TEXT, p1 as P1, p2text as P2TEXT, p2 as P2, p3text as P3TEXT, p3 as P3, `level` as `LEVEL`, wait_class_id as WAIT_CLASS_ID, `wait_class#` as `WAIT_CLASS#`, wait_class as WAIT_CLASS, state as STATE, wait_time_micro as WAIT_TIME_MICRO, total_wait_time_micro as TOTAL_WAIT_TIME_MICRO, total_waits as TOTAL_WAITS, rpc_count as RPC_COUNT, plan_type as PLAN_TYPE, is_inner_sql as IS_INNER_SQL, is_executor_rpc as IS_EXECUTOR_RPC, is_hit_plan as IS_HIT_PLAN, request_time as REQUEST_TIME, elapsed_time as ELAPSED_TIME, net_time as NET_TIME, net_wait_time as NET_WAIT_TIME, queue_time as QUEUE_TIME, decode_time as DECODE_TIME, get_plan_time as GET_PLAN_TIME, execute_time as EXECUTE_TIME, application_wait_time as APPLICATION_WAIT_TIME, concurrency_wait_time as CONCURRENCY_WAIT_TIME, user_io_wait_time as USER_IO_WAIT_TIME, schedule_time as SCHEDULE_TIME, row_cache_hit as ROW_CACHE_HIT, bloom_filter_cache_hit as BLOOM_FILTER_CACHE_HIT, block_cache_hit as BLOCK_CACHE_HIT, disk_reads as DISK_READS, retry_cnt as RETRY_CNT, table_scan as TABLE_SCAN, consistency_level as CONSISTENCY_LEVEL, memstore_read_row_count as MEMSTORE_READ_ROW_COUNT, ssstore_read_row_count as SSSTORE_READ_ROW_COUNT, data_block_read_cnt as DATA_BLOCK_READ_CNT, data_block_cache_hit as DATA_BLOCK_CACHE_HIT, index_block_read_cnt as INDEX_BLOCK_READ_CNT, index_block_cache_hit as INDEX_BLOCK_CACHE_HIT, blockscan_block_cnt as BLOCKSCAN_BLOCK_CNT, blockscan_row_cnt as BLOCKSCAN_ROW_CNT, pushdown_storage_filter_row_cnt as PUSHDOWN_STORAGE_FILTER_ROW_CNT, request_memory_used as REQUEST_MEMORY_USED, expected_worker_count as EXPECTED_WORKER_COUNT, used_worker_count as USED_WORKER_COUNT, sched_info as SCHED_INFO, fuse_row_cache_hit as FUSE_ROW_CACHE_HIT, ps_client_stmt_id as PS_CLIENT_STMT_ID, ps_inner_stmt_id as PS_INNER_STMT_ID, transaction_id as TX_ID, snapshot_version as SNAPSHOT_VERSION, request_type as REQUEST_TYPE, is_batched_multi_stmt as IS_BATCHED_MULTI_STMT, ob_trace_info as OB_TRACE_INFO, plan_hash as PLAN_HASH, lock_for_read_time as LOCK_FOR_READ_TIME, params_value as PARAMS_VALUE, rule_name as RULE_NAME, partition_hit as PARTITION_HIT, case when tx_internal_route_flag & 96 = 32 then 1 else 0 end as TX_INTERNAL_ROUTING, tx_internal_route_version as TX_STATE_VERSION, flt_trace_id as FLT_TRACE_ID, pl_trace_id as PL_TRACE_ID, plsql_exec_time as PLSQL_EXEC_TIME, total_memstore_read_row_count as TOTAL_MEMSTORE_READ_ROW_COUNT, total_ssstore_read_row_count as TOTAL_SSSTORE_READ_ROW_COUNT from oceanbase.__all_virtual_sql_audit )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__(select svr_ip as SVR_IP, svr_port as SVR_PORT, request_id as REQUEST_ID, execution_id as SQL_EXEC_ID, trace_id as TRACE_ID, session_id as SID, client_ip as CLIENT_IP, client_port as CLIENT_PORT, tenant_id as TENANT_ID, tenant_name as TENANT_NAME, effective_tenant_id as EFFECTIVE_TENANT_ID, user_id as USER_ID, user_name as USER_NAME, user_group as USER_GROUP, user_client_ip as USER_CLIENT_IP, db_id as DB_ID, db_name as DB_NAME, sql_id as SQL_ID, query_sql as QUERY_SQL, plan_id as PLAN_ID, affected_rows as AFFECTED_ROWS, return_rows as RETURN_ROWS, partition_cnt as PARTITION_CNT, ret_code as RET_CODE, qc_id as QC_ID, dfo_id as DFO_ID, sqc_id as SQC_ID, worker_id as WORKER_ID, event as EVENT, p1text as P1TEXT, p1 as P1, p2text as P2TEXT, p2 as P2, p3text as P3TEXT, p3 as P3, `level` as `LEVEL`, wait_class_id as WAIT_CLASS_ID, `wait_class#` as `WAIT_CLASS#`, wait_class as WAIT_CLASS, state as STATE, wait_time_micro as WAIT_TIME_MICRO, total_wait_time_micro as TOTAL_WAIT_TIME_MICRO, total_waits as TOTAL_WAITS, rpc_count as RPC_COUNT, plan_type as PLAN_TYPE, is_inner_sql as IS_INNER_SQL, is_executor_rpc as IS_EXECUTOR_RPC, is_hit_plan as IS_HIT_PLAN, request_time as REQUEST_TIME, elapsed_time as ELAPSED_TIME, net_time as NET_TIME, net_wait_time as NET_WAIT_TIME, queue_time as QUEUE_TIME, decode_time as DECODE_TIME, get_plan_time as GET_PLAN_TIME, execute_time as EXECUTE_TIME, application_wait_time as APPLICATION_WAIT_TIME, concurrency_wait_time as CONCURRENCY_WAIT_TIME, user_io_wait_time as USER_IO_WAIT_TIME, schedule_time as SCHEDULE_TIME, row_cache_hit as ROW_CACHE_HIT, bloom_filter_cache_hit as BLOOM_FILTER_CACHE_HIT, block_cache_hit as BLOCK_CACHE_HIT, disk_reads as DISK_READS, retry_cnt as RETRY_CNT, table_scan as TABLE_SCAN, consistency_level as CONSISTENCY_LEVEL, memstore_read_row_count as MEMSTORE_READ_ROW_COUNT, ssstore_read_row_count as SSSTORE_READ_ROW_COUNT, data_block_read_cnt as DATA_BLOCK_READ_CNT, data_block_cache_hit as DATA_BLOCK_CACHE_HIT, index_block_read_cnt as INDEX_BLOCK_READ_CNT, index_block_cache_hit as INDEX_BLOCK_CACHE_HIT, blockscan_block_cnt as BLOCKSCAN_BLOCK_CNT, blockscan_row_cnt as BLOCKSCAN_ROW_CNT, pushdown_storage_filter_row_cnt as PUSHDOWN_STORAGE_FILTER_ROW_CNT, request_memory_used as REQUEST_MEMORY_USED, expected_worker_count as EXPECTED_WORKER_COUNT, used_worker_count as USED_WORKER_COUNT, sched_info as SCHED_INFO, fuse_row_cache_hit as FUSE_ROW_CACHE_HIT, ps_client_stmt_id as PS_CLIENT_STMT_ID, ps_inner_stmt_id as PS_INNER_STMT_ID, transaction_id as TX_ID, snapshot_version as SNAPSHOT_VERSION, request_type as REQUEST_TYPE, is_batched_multi_stmt as IS_BATCHED_MULTI_STMT, ob_trace_info as OB_TRACE_INFO, plan_hash as PLAN_HASH, lock_for_read_time as LOCK_FOR_READ_TIME, params_value as PARAMS_VALUE, rule_name as RULE_NAME, partition_hit as PARTITION_HIT, case when tx_internal_route_flag & 96 = 32 then 1 else 0 end as TX_INTERNAL_ROUTING, tx_internal_route_version as TX_STATE_VERSION, flt_trace_id as FLT_TRACE_ID, pl_trace_id as PL_TRACE_ID, plsql_exec_time as PLSQL_EXEC_TIME, total_memstore_read_row_count as TOTAL_MEMSTORE_READ_ROW_COUNT, total_ssstore_read_row_count as TOTAL_SSSTORE_READ_ROW_COUNT, proxy_user as PROXY_USER from oceanbase.__all_virtual_sql_audit )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } @@ -1360,7 +1360,7 @@ int ObInnerTableSchema::v_ob_sql_audit_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT SVR_IP, SVR_PORT, REQUEST_ID, SQL_EXEC_ID, TRACE_ID, SID, CLIENT_IP, CLIENT_PORT, TENANT_ID, TENANT_NAME, EFFECTIVE_TENANT_ID, USER_ID, USER_NAME, USER_GROUP, USER_CLIENT_IP, DB_ID, DB_NAME, SQL_ID, QUERY_SQL, PLAN_ID, AFFECTED_ROWS, RETURN_ROWS, PARTITION_CNT, RET_CODE, QC_ID, DFO_ID, SQC_ID, WORKER_ID, EVENT, P1TEXT, P1, P2TEXT, P2, P3TEXT, P3, `LEVEL`, WAIT_CLASS_ID, `WAIT_CLASS#`, WAIT_CLASS, STATE, WAIT_TIME_MICRO, TOTAL_WAIT_TIME_MICRO, TOTAL_WAITS, RPC_COUNT, PLAN_TYPE, IS_INNER_SQL, IS_EXECUTOR_RPC, IS_HIT_PLAN, REQUEST_TIME, ELAPSED_TIME, NET_TIME, NET_WAIT_TIME, QUEUE_TIME, DECODE_TIME, GET_PLAN_TIME, EXECUTE_TIME, APPLICATION_WAIT_TIME, CONCURRENCY_WAIT_TIME, USER_IO_WAIT_TIME, SCHEDULE_TIME, ROW_CACHE_HIT, BLOOM_FILTER_CACHE_HIT, BLOCK_CACHE_HIT, DISK_READS, RETRY_CNT, TABLE_SCAN, CONSISTENCY_LEVEL, MEMSTORE_READ_ROW_COUNT, SSSTORE_READ_ROW_COUNT, DATA_BLOCK_READ_CNT, DATA_BLOCK_CACHE_HIT, INDEX_BLOCK_READ_CNT, INDEX_BLOCK_CACHE_HIT, BLOCKSCAN_BLOCK_CNT, BLOCKSCAN_ROW_CNT, PUSHDOWN_STORAGE_FILTER_ROW_CNT, REQUEST_MEMORY_USED, EXPECTED_WORKER_COUNT, USED_WORKER_COUNT, SCHED_INFO, FUSE_ROW_CACHE_HIT, PS_CLIENT_STMT_ID, PS_INNER_STMT_ID, TX_ID, SNAPSHOT_VERSION, REQUEST_TYPE, IS_BATCHED_MULTI_STMT, OB_TRACE_INFO, PLAN_HASH, LOCK_FOR_READ_TIME, PARAMS_VALUE, RULE_NAME, PARTITION_HIT, TX_INTERNAL_ROUTING, TX_STATE_VERSION, FLT_TRACE_ID, PL_TRACE_ID, PLSQL_EXEC_TIME, TOTAL_MEMSTORE_READ_ROW_COUNT, TOTAL_SSSTORE_READ_ROW_COUNT FROM oceanbase.GV$OB_SQL_AUDIT WHERE svr_ip=HOST_IP() AND svr_port=RPC_PORT() )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT SVR_IP, SVR_PORT, REQUEST_ID, SQL_EXEC_ID, TRACE_ID, SID, CLIENT_IP, CLIENT_PORT, TENANT_ID, TENANT_NAME, EFFECTIVE_TENANT_ID, USER_ID, USER_NAME, USER_GROUP, USER_CLIENT_IP, DB_ID, DB_NAME, SQL_ID, QUERY_SQL, PLAN_ID, AFFECTED_ROWS, RETURN_ROWS, PARTITION_CNT, RET_CODE, QC_ID, DFO_ID, SQC_ID, WORKER_ID, EVENT, P1TEXT, P1, P2TEXT, P2, P3TEXT, P3, `LEVEL`, WAIT_CLASS_ID, `WAIT_CLASS#`, WAIT_CLASS, STATE, WAIT_TIME_MICRO, TOTAL_WAIT_TIME_MICRO, TOTAL_WAITS, RPC_COUNT, PLAN_TYPE, IS_INNER_SQL, IS_EXECUTOR_RPC, IS_HIT_PLAN, REQUEST_TIME, ELAPSED_TIME, NET_TIME, NET_WAIT_TIME, QUEUE_TIME, DECODE_TIME, GET_PLAN_TIME, EXECUTE_TIME, APPLICATION_WAIT_TIME, CONCURRENCY_WAIT_TIME, USER_IO_WAIT_TIME, SCHEDULE_TIME, ROW_CACHE_HIT, BLOOM_FILTER_CACHE_HIT, BLOCK_CACHE_HIT, DISK_READS, RETRY_CNT, TABLE_SCAN, CONSISTENCY_LEVEL, MEMSTORE_READ_ROW_COUNT, SSSTORE_READ_ROW_COUNT, DATA_BLOCK_READ_CNT, DATA_BLOCK_CACHE_HIT, INDEX_BLOCK_READ_CNT, INDEX_BLOCK_CACHE_HIT, BLOCKSCAN_BLOCK_CNT, BLOCKSCAN_ROW_CNT, PUSHDOWN_STORAGE_FILTER_ROW_CNT, REQUEST_MEMORY_USED, EXPECTED_WORKER_COUNT, USED_WORKER_COUNT, SCHED_INFO, FUSE_ROW_CACHE_HIT, PS_CLIENT_STMT_ID, PS_INNER_STMT_ID, TX_ID, SNAPSHOT_VERSION, REQUEST_TYPE, IS_BATCHED_MULTI_STMT, OB_TRACE_INFO, PLAN_HASH, LOCK_FOR_READ_TIME, PARAMS_VALUE, RULE_NAME, PARTITION_HIT, TX_INTERNAL_ROUTING, TX_STATE_VERSION, FLT_TRACE_ID, PL_TRACE_ID, PLSQL_EXEC_TIME, TOTAL_MEMSTORE_READ_ROW_COUNT, TOTAL_SSSTORE_READ_ROW_COUNT, PROXY_USER FROM oceanbase.GV$OB_SQL_AUDIT WHERE svr_ip=HOST_IP() AND svr_port=RPC_PORT() )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema.21201_21250.cpp b/src/share/inner_table/ob_inner_table_schema.21201_21250.cpp index 54897d73bc..c0b674e9bd 100644 --- a/src/share/inner_table/ob_inner_table_schema.21201_21250.cpp +++ b/src/share/inner_table/ob_inner_table_schema.21201_21250.cpp @@ -1060,7 +1060,7 @@ int ObInnerTableSchema::gv_ob_processlist_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT SVR_IP, SVR_PORT, SQL_PORT, ID, USER, HOST, DB, TENANT, COMMAND, TIME, TOTAL_TIME, STATE, INFO, PROXY_SESSID, MASTER_SESSID, USER_CLIENT_IP, USER_HOST, RETRY_CNT, RETRY_INFO, SQL_ID, TRANS_ID, THREAD_ID, SSL_CIPHER, TRACE_ID, TRANS_STATE, ACTION, MODULE, CLIENT_INFO, LEVEL, SAMPLE_PERCENTAGE, RECORD_POLICY, LB_VID, LB_VIP, LB_VPORT, IN_BYTES, OUT_BYTES, USER_CLIENT_PORT, cast(total_cpu_time as SIGNED) as TOTAL_CPU_TIME FROM oceanbase.__all_virtual_processlist )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT SVR_IP, SVR_PORT, SQL_PORT, ID, USER, HOST, DB, TENANT, COMMAND, TIME, TOTAL_TIME, STATE, INFO, PROXY_SESSID, MASTER_SESSID, USER_CLIENT_IP, USER_HOST, RETRY_CNT, RETRY_INFO, SQL_ID, TRANS_ID, THREAD_ID, SSL_CIPHER, TRACE_ID, TRANS_STATE, ACTION, MODULE, CLIENT_INFO, LEVEL, SAMPLE_PERCENTAGE, RECORD_POLICY, LB_VID, LB_VIP, LB_VPORT, IN_BYTES, OUT_BYTES, USER_CLIENT_PORT, cast(total_cpu_time as SIGNED) as TOTAL_CPU_TIME, PROXY_USER FROM oceanbase.__all_virtual_processlist )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } @@ -1110,7 +1110,7 @@ int ObInnerTableSchema::v_ob_processlist_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT SVR_IP, SVR_PORT, SQL_PORT, ID, USER, HOST, DB, TENANT, COMMAND, TIME, TOTAL_TIME, STATE, INFO, PROXY_SESSID, MASTER_SESSID, USER_CLIENT_IP, USER_HOST, RETRY_CNT, RETRY_INFO, SQL_ID, TRANS_ID, THREAD_ID, SSL_CIPHER, TRACE_ID, TRANS_STATE, ACTION, MODULE, CLIENT_INFO, LEVEL, SAMPLE_PERCENTAGE, RECORD_POLICY, LB_VID, LB_VIP, LB_VPORT, IN_BYTES, OUT_BYTES, USER_CLIENT_PORT, cast(total_cpu_time as SIGNED) as TOTAL_CPU_TIME FROM oceanbase.GV$OB_PROCESSLIST WHERE SVR_IP = host_ip() AND SVR_PORT = rpc_port() )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT SVR_IP, SVR_PORT, SQL_PORT, ID, USER, HOST, DB, TENANT, COMMAND, TIME, TOTAL_TIME, STATE, INFO, PROXY_SESSID, MASTER_SESSID, USER_CLIENT_IP, USER_HOST, RETRY_CNT, RETRY_INFO, SQL_ID, TRANS_ID, THREAD_ID, SSL_CIPHER, TRACE_ID, TRANS_STATE, ACTION, MODULE, CLIENT_INFO, LEVEL, SAMPLE_PERCENTAGE, RECORD_POLICY, LB_VID, LB_VIP, LB_VPORT, IN_BYTES, OUT_BYTES, USER_CLIENT_PORT, cast(total_cpu_time as SIGNED) as TOTAL_CPU_TIME, PROXY_USER FROM oceanbase.GV$OB_PROCESSLIST WHERE SVR_IP = host_ip() AND SVR_PORT = rpc_port() )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema.21301_21350.cpp b/src/share/inner_table/ob_inner_table_schema.21301_21350.cpp index 2fe9a1b450..5e47bb3704 100644 --- a/src/share/inner_table/ob_inner_table_schema.21301_21350.cpp +++ b/src/share/inner_table/ob_inner_table_schema.21301_21350.cpp @@ -1567,7 +1567,7 @@ int ObInnerTableSchema::dba_ob_users_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT USER_NAME, HOST, PASSWD, INFO, (CASE WHEN PRIV_ALTER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER, (CASE WHEN PRIV_CREATE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE, (CASE WHEN PRIV_DELETE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DELETE, (CASE WHEN PRIV_DROP = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DROP, (CASE WHEN PRIV_GRANT_OPTION = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_GRANT_OPTION, (CASE WHEN PRIV_INSERT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_INSERT, (CASE WHEN PRIV_UPDATE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_UPDATE, (CASE WHEN PRIV_SELECT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SELECT, (CASE WHEN PRIV_INDEX = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_INDEX, (CASE WHEN PRIV_CREATE_VIEW = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_VIEW, (CASE WHEN PRIV_SHOW_VIEW = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SHOW_VIEW, (CASE WHEN PRIV_SHOW_DB = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SHOW_DB, (CASE WHEN PRIV_CREATE_USER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_USER, (CASE WHEN PRIV_SUPER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SUPER, (CASE WHEN IS_LOCKED = 0 THEN 'NO' ELSE 'YES' END) AS IS_LOCKED, (CASE WHEN PRIV_PROCESS = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_PROCESS, (CASE WHEN PRIV_CREATE_SYNONYM = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_SYNONYM, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, (CASE WHEN TYPE = 0 THEN 'USER' ELSE 'ROLE' END) AS TYPE, PROFILE_ID, PASSWORD_LAST_CHANGED, (CASE WHEN PRIV_FILE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_FILE, (CASE WHEN PRIV_ALTER_TENANT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER_TENANT, (CASE WHEN PRIV_ALTER_SYSTEM = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER_SYSTEM, (CASE WHEN PRIV_CREATE_RESOURCE_POOL = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_RESOURCE_POOL, (CASE WHEN PRIV_CREATE_RESOURCE_UNIT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_RESOURCE_UNIT, MAX_CONNECTIONS, MAX_USER_CONNECTIONS, (CASE WHEN PRIV_REPL_SLAVE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_REPL_SLAVE, (CASE WHEN PRIV_REPL_CLIENT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_REPL_CLIENT, (CASE WHEN PRIV_DROP_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DROP_DATABASE_LINK, (CASE WHEN PRIV_CREATE_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_DATABASE_LINK, (CASE WHEN (PRIV_OTHERS & (1 << 0)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_EXECUTE, (CASE WHEN (PRIV_OTHERS & (1 << 1)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_ALTER_ROUTINE, (CASE WHEN (PRIV_OTHERS & (1 << 2)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_ROUTINE FROM OCEANBASE.__all_user; )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT USER_NAME, HOST, PASSWD, INFO, (CASE WHEN PRIV_ALTER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER, (CASE WHEN PRIV_CREATE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE, (CASE WHEN PRIV_DELETE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DELETE, (CASE WHEN PRIV_DROP = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DROP, (CASE WHEN PRIV_GRANT_OPTION = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_GRANT_OPTION, (CASE WHEN PRIV_INSERT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_INSERT, (CASE WHEN PRIV_UPDATE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_UPDATE, (CASE WHEN PRIV_SELECT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SELECT, (CASE WHEN PRIV_INDEX = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_INDEX, (CASE WHEN PRIV_CREATE_VIEW = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_VIEW, (CASE WHEN PRIV_SHOW_VIEW = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SHOW_VIEW, (CASE WHEN PRIV_SHOW_DB = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SHOW_DB, (CASE WHEN PRIV_CREATE_USER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_USER, (CASE WHEN PRIV_SUPER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SUPER, (CASE WHEN IS_LOCKED = 0 THEN 'NO' ELSE 'YES' END) AS IS_LOCKED, (CASE WHEN PRIV_PROCESS = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_PROCESS, (CASE WHEN PRIV_CREATE_SYNONYM = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_SYNONYM, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, (CASE WHEN TYPE = 0 THEN 'USER' ELSE 'ROLE' END) AS TYPE, PROFILE_ID, PASSWORD_LAST_CHANGED, (CASE WHEN PRIV_FILE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_FILE, (CASE WHEN PRIV_ALTER_TENANT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER_TENANT, (CASE WHEN PRIV_ALTER_SYSTEM = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER_SYSTEM, (CASE WHEN PRIV_CREATE_RESOURCE_POOL = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_RESOURCE_POOL, (CASE WHEN PRIV_CREATE_RESOURCE_UNIT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_RESOURCE_UNIT, MAX_CONNECTIONS, MAX_USER_CONNECTIONS, (CASE WHEN PRIV_REPL_SLAVE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_REPL_SLAVE, (CASE WHEN PRIV_REPL_CLIENT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_REPL_CLIENT, (CASE WHEN PRIV_DROP_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DROP_DATABASE_LINK, (CASE WHEN PRIV_CREATE_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_DATABASE_LINK, (CASE WHEN (PRIV_OTHERS & (1 << 0)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_EXECUTE, (CASE WHEN (PRIV_OTHERS & (1 << 1)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_ALTER_ROUTINE, (CASE WHEN (PRIV_OTHERS & (1 << 2)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_ROUTINE, (CASE WHEN (PRIV_OTHERS & (1 << 3)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_TABLESPACE, (CASE WHEN (PRIV_OTHERS & (1 << 4)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_SHUTDOWN, (CASE WHEN (PRIV_OTHERS & (1 << 5)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_RELOAD FROM OCEANBASE.__all_user; )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } @@ -1617,7 +1617,7 @@ int ObInnerTableSchema::cdb_ob_users_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT TENANT_ID, USER_NAME, HOST, PASSWD, INFO, (CASE WHEN PRIV_ALTER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER, (CASE WHEN PRIV_CREATE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE, (CASE WHEN PRIV_DELETE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DELETE, (CASE WHEN PRIV_DROP = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DROP, (CASE WHEN PRIV_GRANT_OPTION = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_GRANT_OPTION, (CASE WHEN PRIV_INSERT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_INSERT, (CASE WHEN PRIV_UPDATE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_UPDATE, (CASE WHEN PRIV_SELECT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SELECT, (CASE WHEN PRIV_INDEX = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_INDEX, (CASE WHEN PRIV_CREATE_VIEW = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_VIEW, (CASE WHEN PRIV_SHOW_VIEW = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SHOW_VIEW, (CASE WHEN PRIV_SHOW_DB = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SHOW_DB, (CASE WHEN PRIV_CREATE_USER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_USER, (CASE WHEN PRIV_SUPER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SUPER, (CASE WHEN IS_LOCKED = 0 THEN 'NO' ELSE 'YES' END) AS IS_LOCKED, (CASE WHEN PRIV_PROCESS = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_PROCESS, (CASE WHEN PRIV_CREATE_SYNONYM = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_SYNONYM, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, (CASE WHEN TYPE = 0 THEN 'USER' ELSE 'ROLE' END) AS TYPE, PROFILE_ID, PASSWORD_LAST_CHANGED, (CASE WHEN PRIV_FILE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_FILE, (CASE WHEN PRIV_ALTER_TENANT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER_TENANT, (CASE WHEN PRIV_ALTER_SYSTEM = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER_SYSTEM, (CASE WHEN PRIV_CREATE_RESOURCE_POOL = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_RESOURCE_POOL, (CASE WHEN PRIV_CREATE_RESOURCE_UNIT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_RESOURCE_UNIT, MAX_CONNECTIONS, MAX_USER_CONNECTIONS, (CASE WHEN PRIV_REPL_SLAVE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_REPL_SLAVE, (CASE WHEN PRIV_REPL_CLIENT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_REPL_CLIENT, (CASE WHEN PRIV_DROP_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DROP_DATABASE_LINK, (CASE WHEN PRIV_CREATE_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_DATABASE_LINK, (CASE WHEN (PRIV_OTHERS & (1 << 0)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_EXECUTE, (CASE WHEN (PRIV_OTHERS & (1 << 1)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_ALTER_ROUTINE, (CASE WHEN (PRIV_OTHERS & (1 << 2)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_ROUTINE FROM OCEANBASE.__all_virtual_user; )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT TENANT_ID, USER_NAME, HOST, PASSWD, INFO, (CASE WHEN PRIV_ALTER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER, (CASE WHEN PRIV_CREATE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE, (CASE WHEN PRIV_DELETE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DELETE, (CASE WHEN PRIV_DROP = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DROP, (CASE WHEN PRIV_GRANT_OPTION = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_GRANT_OPTION, (CASE WHEN PRIV_INSERT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_INSERT, (CASE WHEN PRIV_UPDATE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_UPDATE, (CASE WHEN PRIV_SELECT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SELECT, (CASE WHEN PRIV_INDEX = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_INDEX, (CASE WHEN PRIV_CREATE_VIEW = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_VIEW, (CASE WHEN PRIV_SHOW_VIEW = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SHOW_VIEW, (CASE WHEN PRIV_SHOW_DB = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SHOW_DB, (CASE WHEN PRIV_CREATE_USER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_USER, (CASE WHEN PRIV_SUPER = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_SUPER, (CASE WHEN IS_LOCKED = 0 THEN 'NO' ELSE 'YES' END) AS IS_LOCKED, (CASE WHEN PRIV_PROCESS = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_PROCESS, (CASE WHEN PRIV_CREATE_SYNONYM = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_SYNONYM, SSL_TYPE, SSL_CIPHER, X509_ISSUER, X509_SUBJECT, (CASE WHEN TYPE = 0 THEN 'USER' ELSE 'ROLE' END) AS TYPE, PROFILE_ID, PASSWORD_LAST_CHANGED, (CASE WHEN PRIV_FILE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_FILE, (CASE WHEN PRIV_ALTER_TENANT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER_TENANT, (CASE WHEN PRIV_ALTER_SYSTEM = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_ALTER_SYSTEM, (CASE WHEN PRIV_CREATE_RESOURCE_POOL = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_RESOURCE_POOL, (CASE WHEN PRIV_CREATE_RESOURCE_UNIT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_RESOURCE_UNIT, MAX_CONNECTIONS, MAX_USER_CONNECTIONS, (CASE WHEN PRIV_REPL_SLAVE = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_REPL_SLAVE, (CASE WHEN PRIV_REPL_CLIENT = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_REPL_CLIENT, (CASE WHEN PRIV_DROP_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_DROP_DATABASE_LINK, (CASE WHEN PRIV_CREATE_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_DATABASE_LINK, (CASE WHEN (PRIV_OTHERS & (1 << 0)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_EXECUTE, (CASE WHEN (PRIV_OTHERS & (1 << 1)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_ALTER_ROUTINE, (CASE WHEN (PRIV_OTHERS & (1 << 2)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_ROUTINE, (CASE WHEN (PRIV_OTHERS & (1 << 3)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_TABLESPACE, (CASE WHEN (PRIV_OTHERS & (1 << 4)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_SHUTDOWN, (CASE WHEN (PRIV_OTHERS & (1 << 5)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_RELOAD FROM OCEANBASE.__all_virtual_user; )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } @@ -2067,7 +2067,7 @@ int ObInnerTableSchema::user_privileges_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(CONCAT('''', V.USER_NAME, '''', '@', '''', V.HOST, '''') AS CHAR(81)) AS GRANTEE , CAST('def' AS CHAR(512)) AS TABLE_CATALOG , CAST(V.PRIVILEGE_TYPE AS CHAR(64)) AS PRIVILEGE_TYPE , CAST(V.IS_GRANTABLE AS CHAR(3)) AS IS_GRANTABLE FROM (SELECT U.USER_NAME AS USER_NAME, U.HOST AS HOST, CASE WHEN V1.C1 = 1 AND U.PRIV_ALTER = 1 THEN 'ALTER' WHEN V1.C1 = 2 AND U.PRIV_CREATE = 1 THEN 'CREATE' WHEN V1.C1 = 3 AND U.PRIV_CREATE_USER = 1 THEN 'CREATE USER' WHEN V1.C1 = 4 AND U.PRIV_DELETE = 1 THEN 'DELETE' WHEN V1.C1 = 5 AND U.PRIV_DROP = 1 THEN 'DROP' WHEN V1.C1 = 7 AND U.PRIV_INSERT = 1 THEN 'INSERT' WHEN V1.C1 = 8 AND U.PRIV_UPDATE = 1 THEN 'UPDATE' WHEN V1.C1 = 9 AND U.PRIV_SELECT = 1 THEN 'SELECT' WHEN V1.C1 = 10 AND U.PRIV_INDEX = 1 THEN 'INDEX' WHEN V1.C1 = 11 AND U.PRIV_CREATE_VIEW = 1 THEN 'CREATE VIEW' WHEN V1.C1 = 12 AND U.PRIV_SHOW_VIEW = 1 THEN 'SHOW VIEW' WHEN V1.C1 = 13 AND U.PRIV_SHOW_DB = 1 THEN 'SHOW DATABASES' WHEN V1.C1 = 14 AND U.PRIV_SUPER = 1 THEN 'SUPER' WHEN V1.C1 = 15 AND U.PRIV_PROCESS = 1 THEN 'PROCESS' WHEN V1.C1 = 17 AND U.PRIV_CREATE_SYNONYM = 1 THEN 'CREATE SYNONYM' WHEN V1.C1 = 27 AND U.PRIV_FILE = 1 THEN 'FILE' WHEN V1.C1 = 28 AND U.PRIV_ALTER_TENANT = 1 THEN 'ALTER TENANT' WHEN V1.C1 = 29 AND U.PRIV_ALTER_SYSTEM = 1 THEN 'ALTER SYSTEM' WHEN V1.C1 = 30 AND U.PRIV_CREATE_RESOURCE_POOL = 1 THEN 'CREATE RESOURCE POOL' WHEN V1.C1 = 31 AND U.PRIV_CREATE_RESOURCE_UNIT = 1 THEN 'CREATE RESOURCE UNIT' WHEN V1.C1 = 33 AND U.PRIV_REPL_SLAVE = 1 THEN 'REPLICATION SLAVE' WHEN V1.C1 = 34 AND U.PRIV_REPL_CLIENT = 1 THEN 'REPLICATION CLIENT' WHEN V1.C1 = 35 AND U.PRIV_DROP_DATABASE_LINK = 1 THEN 'DROP DATABASE LINK' WHEN V1.C1 = 36 AND U.PRIV_CREATE_DATABASE_LINK = 1 THEN 'CREATE DATABASE LINK' WHEN V1.C1 = 37 AND (U.PRIV_OTHERS & (1 << 0)) != 0 THEN 'EXECUTE' WHEN V1.C1 = 38 AND (U.PRIV_OTHERS & (1 << 1)) != 0 THEN 'ALTER ROUTINE' WHEN V1.C1 = 39 AND (U.PRIV_OTHERS & (1 << 2)) != 0 THEN 'CREATE ROUTINE' WHEN V1.C1 = 0 AND U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'USAGE' END PRIVILEGE_TYPE , CASE WHEN U.PRIV_GRANT_OPTION = 0 THEN 'NO' WHEN U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'NO' WHEN U.PRIV_GRANT_OPTION = 1 THEN 'YES' END IS_GRANTABLE FROM oceanbase.__all_user U, (SELECT 0 AS C1 UNION ALL SELECT 1 AS C1 UNION ALL SELECT 2 AS C1 UNION ALL SELECT 3 AS C1 UNION ALL SELECT 4 AS C1 UNION ALL SELECT 5 AS C1 UNION ALL SELECT 7 AS C1 UNION ALL SELECT 8 AS C1 UNION ALL SELECT 9 AS C1 UNION ALL SELECT 10 AS C1 UNION ALL SELECT 11 AS C1 UNION ALL SELECT 12 AS C1 UNION ALL SELECT 13 AS C1 UNION ALL SELECT 14 AS C1 UNION ALL SELECT 15 AS C1 UNION ALL SELECT 17 AS C1 UNION ALL SELECT 27 AS C1 UNION ALL SELECT 28 AS C1 UNION ALL SELECT 29 AS C1 UNION ALL SELECT 30 AS C1 UNION ALL SELECT 31 AS C1 UNION ALL SELECT 33 AS C1 UNION ALL SELECT 34 AS C1 UNION ALL SELECT 35 AS C1 UNION ALL SELECT 36 AS C1 UNION ALL SELECT 37 AS C1 UNION ALL SELECT 38 AS C1 UNION ALL SELECT 39 AS C1) V1, (SELECT USER_ID FROM oceanbase.__all_user WHERE TENANT_ID = 0 AND CONCAT(USER_NAME, '@', HOST) = CURRENT_USER()) CURR LEFT JOIN (SELECT USER_ID FROM oceanbase.__all_database_privilege WHERE TENANT_ID = 0 AND DATABASE_NAME = 'mysql' AND PRIV_SELECT = 1) DB ON CURR.USER_ID = DB.USER_ID WHERE U.TENANT_ID = 0 AND (DB.USER_ID IS NOT NULL OR 512 & CURRENT_USER_PRIV() = 512 OR U.USER_ID = CURR.USER_ID)) V WHERE V.PRIVILEGE_TYPE IS NOT NULL )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT CAST(CONCAT('''', V.USER_NAME, '''', '@', '''', V.HOST, '''') AS CHAR(81)) AS GRANTEE , CAST('def' AS CHAR(512)) AS TABLE_CATALOG , CAST(V.PRIVILEGE_TYPE AS CHAR(64)) AS PRIVILEGE_TYPE , CAST(V.IS_GRANTABLE AS CHAR(3)) AS IS_GRANTABLE FROM (SELECT U.USER_NAME AS USER_NAME, U.HOST AS HOST, CASE WHEN V1.C1 = 1 AND U.PRIV_ALTER = 1 THEN 'ALTER' WHEN V1.C1 = 2 AND U.PRIV_CREATE = 1 THEN 'CREATE' WHEN V1.C1 = 3 AND U.PRIV_CREATE_USER = 1 THEN 'CREATE USER' WHEN V1.C1 = 4 AND U.PRIV_DELETE = 1 THEN 'DELETE' WHEN V1.C1 = 5 AND U.PRIV_DROP = 1 THEN 'DROP' WHEN V1.C1 = 7 AND U.PRIV_INSERT = 1 THEN 'INSERT' WHEN V1.C1 = 8 AND U.PRIV_UPDATE = 1 THEN 'UPDATE' WHEN V1.C1 = 9 AND U.PRIV_SELECT = 1 THEN 'SELECT' WHEN V1.C1 = 10 AND U.PRIV_INDEX = 1 THEN 'INDEX' WHEN V1.C1 = 11 AND U.PRIV_CREATE_VIEW = 1 THEN 'CREATE VIEW' WHEN V1.C1 = 12 AND U.PRIV_SHOW_VIEW = 1 THEN 'SHOW VIEW' WHEN V1.C1 = 13 AND U.PRIV_SHOW_DB = 1 THEN 'SHOW DATABASES' WHEN V1.C1 = 14 AND U.PRIV_SUPER = 1 THEN 'SUPER' WHEN V1.C1 = 15 AND U.PRIV_PROCESS = 1 THEN 'PROCESS' WHEN V1.C1 = 17 AND U.PRIV_CREATE_SYNONYM = 1 THEN 'CREATE SYNONYM' WHEN V1.C1 = 23 AND (U.PRIV_OTHERS & (1 << 0)) != 0 THEN 'EXECUTE' WHEN V1.C1 = 27 AND U.PRIV_FILE = 1 THEN 'FILE' WHEN V1.C1 = 28 AND U.PRIV_ALTER_TENANT = 1 THEN 'ALTER TENANT' WHEN V1.C1 = 29 AND U.PRIV_ALTER_SYSTEM = 1 THEN 'ALTER SYSTEM' WHEN V1.C1 = 30 AND U.PRIV_CREATE_RESOURCE_POOL = 1 THEN 'CREATE RESOURCE POOL' WHEN V1.C1 = 31 AND U.PRIV_CREATE_RESOURCE_UNIT = 1 THEN 'CREATE RESOURCE UNIT' WHEN V1.C1 = 33 AND U.PRIV_REPL_SLAVE = 1 THEN 'REPLICATION SLAVE' WHEN V1.C1 = 34 AND U.PRIV_REPL_CLIENT = 1 THEN 'REPLICATION CLIENT' WHEN V1.C1 = 35 AND U.PRIV_DROP_DATABASE_LINK = 1 THEN 'DROP DATABASE LINK' WHEN V1.C1 = 36 AND U.PRIV_CREATE_DATABASE_LINK = 1 THEN 'CREATE DATABASE LINK' WHEN V1.C1 = 37 AND (U.PRIV_OTHERS & (1 << 1)) != 0 THEN 'ALTER ROUTINE' WHEN V1.C1 = 38 AND (U.PRIV_OTHERS & (1 << 2)) != 0 THEN 'CREATE ROUTINE' WHEN V1.C1 = 39 AND (U.PRIV_OTHERS & (1 << 3)) != 0 THEN 'CREATE TABLESPACE' WHEN V1.C1 = 40 AND (U.PRIV_OTHERS & (1 << 4)) != 0 THEN 'SHUTDOWN' WHEN V1.C1 = 41 AND (U.PRIV_OTHERS & (1 << 5)) != 0 THEN 'RELOAD' WHEN V1.C1 = 0 AND U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'USAGE' END PRIVILEGE_TYPE , CASE WHEN U.PRIV_GRANT_OPTION = 0 THEN 'NO' WHEN U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'NO' WHEN U.PRIV_GRANT_OPTION = 1 THEN 'YES' END IS_GRANTABLE FROM oceanbase.__all_user U, (SELECT 0 AS C1 UNION ALL SELECT 1 AS C1 UNION ALL SELECT 2 AS C1 UNION ALL SELECT 3 AS C1 UNION ALL SELECT 4 AS C1 UNION ALL SELECT 5 AS C1 UNION ALL SELECT 7 AS C1 UNION ALL SELECT 8 AS C1 UNION ALL SELECT 9 AS C1 UNION ALL SELECT 10 AS C1 UNION ALL SELECT 11 AS C1 UNION ALL SELECT 12 AS C1 UNION ALL SELECT 13 AS C1 UNION ALL SELECT 14 AS C1 UNION ALL SELECT 15 AS C1 UNION ALL SELECT 17 AS C1 UNION ALL SELECT 23 AS C1 UNION ALL SELECT 27 AS C1 UNION ALL SELECT 28 AS C1 UNION ALL SELECT 29 AS C1 UNION ALL SELECT 30 AS C1 UNION ALL SELECT 31 AS C1 UNION ALL SELECT 33 AS C1 UNION ALL SELECT 34 AS C1 UNION ALL SELECT 35 AS C1 UNION ALL SELECT 36 AS C1 UNION ALL SELECT 37 AS C1 UNION ALL SELECT 38 AS C1 UNION ALL SELECT 39 AS C1 UNION ALL SELECT 40 AS C1 UNION ALL SELECT 41 AS C1) V1, (SELECT USER_ID FROM oceanbase.__all_user WHERE TENANT_ID = 0 AND CONCAT(USER_NAME, '@', HOST) = CURRENT_USER()) CURR LEFT JOIN (SELECT USER_ID FROM oceanbase.__all_database_privilege WHERE TENANT_ID = 0 AND DATABASE_NAME = 'mysql' AND PRIV_SELECT = 1) DB ON CURR.USER_ID = DB.USER_ID WHERE U.TENANT_ID = 0 AND (DB.USER_ID IS NOT NULL OR 512 & CURRENT_USER_PRIV() = 512 OR U.USER_ID = CURR.USER_ID)) V WHERE V.PRIVILEGE_TYPE IS NOT NULL )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema.21501_21550.cpp b/src/share/inner_table/ob_inner_table_schema.21501_21550.cpp index c789af79d1..fa8c8e2210 100644 --- a/src/share/inner_table/ob_inner_table_schema.21501_21550.cpp +++ b/src/share/inner_table/ob_inner_table_schema.21501_21550.cpp @@ -1625,6 +1625,56 @@ int ObInnerTableSchema::v_ob_tracepoint_info_schema(ObTableSchema &table_schema) return ret; } +int ObInnerTableSchema::v_ob_compatibility_control_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_V_OB_COMPATIBILITY_CONTROL_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(0); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(SYSTEM_VIEW); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_V_OB_COMPATIBILITY_CONTROL_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT name as NAME, description as DESCRIPTION, CASE is_enable WHEN 1 THEN 'TRUE' ELSE 'FALSE' END AS IS_ENABLE, enable_versions as ENABLE_VERSIONS FROM oceanbase.__all_virtual_compatibility_control )__"))) { + LOG_ERROR("fail to set view_definition", K(ret)); + } + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + } // end namespace share } // end namespace oceanbase diff --git a/src/share/inner_table/ob_inner_table_schema.25101_25150.cpp b/src/share/inner_table/ob_inner_table_schema.25101_25150.cpp index 9e99fe88e2..9b43552a7a 100644 --- a/src/share/inner_table/ob_inner_table_schema.25101_25150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.25101_25150.cpp @@ -1210,7 +1210,7 @@ int ObInnerTableSchema::user_role_privs_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT CAST(A.USER_NAME AS VARCHAR2(30)) GRANTEE, CAST(B.USER_NAME AS VARCHAR2(30)) GRANTED_ROLE, DECODE(R.ADMIN_OPTION, 0, 'NO', 1, 'YES', '') AS ADMIN_OPTION , DECODE(R.DISABLE_FLAG, 0, 'YES', 1, 'NO', '') AS DEFAULT_ROLE FROM SYS.ALL_VIRTUAL_TENANT_ROLE_GRANTEE_MAP_REAL_AGENT R, SYS.ALL_VIRTUAL_USER_REAL_AGENT A, SYS.ALL_VIRTUAL_USER_REAL_AGENT B WHERE R.GRANTEE_ID = A.USER_ID AND R.ROLE_ID = B.USER_ID AND B.TYPE = 1 AND A.TENANT_ID = EFFECTIVE_TENANT_ID() AND B.TENANT_ID = EFFECTIVE_TENANT_ID() AND A.USER_NAME = SYS_CONTEXT('USERENV','CURRENT_USER'))__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( WITH RV AS ( SELECT R.ROLE_ID, CAST(A.USER_NAME AS VARCHAR2(30)) GRANTEE, CAST(B.USER_NAME AS VARCHAR2(30)) GRANTED_ROLE, DECODE(R.ADMIN_OPTION, 0, 'NO', 1, 'YES', '') AS ADMIN_OPTION , DECODE(R.DISABLE_FLAG, 0, 'YES', 1, 'NO', '') AS DEFAULT_ROLE FROM SYS.ALL_VIRTUAL_TENANT_ROLE_GRANTEE_MAP_REAL_AGENT R, SYS.ALL_VIRTUAL_USER_REAL_AGENT A, SYS.ALL_VIRTUAL_USER_REAL_AGENT B WHERE R.GRANTEE_ID = A.USER_ID AND R.ROLE_ID = B.USER_ID AND B.TYPE = 1 AND A.TENANT_ID = EFFECTIVE_TENANT_ID() AND B.TENANT_ID = EFFECTIVE_TENANT_ID() AND A.USER_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') ), PRV AS ( SELECT PR.ROLE_ID ROLE_ID FROM SYS.ALL_VIRTUAL_USER_REAL_AGENT A, SYS.ALL_VIRTUAL_USER_REAL_AGENT B, SYS.ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT P LEFT JOIN SYS.ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT PR ON P.TENANT_ID = PR.TENANT_ID AND P.CLIENT_USER_ID = PR.CLIENT_USER_ID AND P.PROXY_USER_ID = PR.PROXY_USER_ID WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID() AND A.TENANT_ID = EFFECTIVE_TENANT_ID() AND B.TENANT_ID = EFFECTIVE_TENANT_ID() AND A.USER_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') AND B.USER_NAME = SYS_CONTEXT('USERENV','PROXY_USER') AND P.CLIENT_USER_ID = A.USER_ID AND P.PROXY_USER_ID = B.USER_ID ), PRV_FLAG AS ( SELECT P.FLAGS FLAGS FROM SYS.ALL_VIRTUAL_USER_REAL_AGENT A, SYS.ALL_VIRTUAL_USER_REAL_AGENT B, SYS.ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT P WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID() AND A.TENANT_ID = EFFECTIVE_TENANT_ID() AND B.TENANT_ID = EFFECTIVE_TENANT_ID() AND A.USER_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') AND B.USER_NAME = SYS_CONTEXT('USERENV','PROXY_USER') AND P.CLIENT_USER_ID = A.USER_ID AND P.PROXY_USER_ID = B.USER_ID ) SELECT RV.GRANTEE GRANTEE, RV.GRANTED_ROLE GRANTED_ROLE, RV.ADMIN_OPTION ADMIN_OPTION, RV.DEFAULT_ROLE DEFAULT_ROLE FROM RV LEFT JOIN PRV ON RV.ROLE_ID = PRV.ROLE_ID LEFT JOIN PRV_FLAG ON 1 = 1 WHERE (0 = (SELECT COUNT(ROLE_ID) FROM PRV) AND (PRV_FLAG.FLAGS IS NULL OR PRV_FLAG.FLAGS != 2)) OR (PRV_FLAG.FLAGS = 1) OR (PRV_FLAG.FLAGS = 2 AND 1 = 0) OR (PRV_FLAG.FLAGS = 4 AND RV.ROLE_ID = PRV.ROLE_ID) OR (PRV_FLAG.FLAGS = 8 AND (RV.ROLE_ID != PRV.ROLE_ID OR PRV.ROLE_ID IS NULL)))__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema.25301_25350.cpp b/src/share/inner_table/ob_inner_table_schema.25301_25350.cpp index 1c1c7f44b2..ce518e91a6 100644 --- a/src/share/inner_table/ob_inner_table_schema.25301_25350.cpp +++ b/src/share/inner_table/ob_inner_table_schema.25301_25350.cpp @@ -75,6 +75,56 @@ int ObInnerTableSchema::user_mvref_stmt_stats_ora_schema(ObTableSchema &table_sc return ret; } +int ObInnerTableSchema::proxy_users_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_ORA_SYS_DATABASE_ID); + table_schema.set_table_id(OB_PROXY_USERS_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(0); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(SYSTEM_VIEW); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_PROXY_USERS_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_view_definition(R"__( select cast(U1.USER_NAME as VARCHAR2(128)) as PROXY, cast(U2.USER_NAME as VARCHAR2(128)) as CLIENT, cast(DECODE(P.CREDENTIAL_TYPE, 0, 'NO', 5, 'YES') as VARCHAR2(3)) as AUTHENTICATION, cast(DECODE(case when V.CNT = 0 and P.FLAGS = 4 then 2 when V.CNT = 0 and P.FlAGS = 8 then 1 else P.FLAGS end, 0, NULL, 1, 'PROXY MAY ACTIVATE ALL CLIENT ROLES', 2, 'NO CLIENT ROLES MAY BE ACTIVATED', 4, 'PROXY MAY ACTIVATE ROLE', 5, 'PROXY MAY ACTIVATE ALL CLIENT ROLES', 8, 'PROXY MAY NOT ACTIVATE ROLE') as VARCHAR2(35)) as FLAGS from SYS.ALL_VIRTUAL_USER_REAL_AGENT U1, SYS.ALL_VIRTUAL_USER_REAL_AGENT U2, SYS.ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT P, (SELECT COUNT(B.ROLE_ID) CNT, A.TENANT_ID TENANT_ID, A.PROXY_USER_ID PROXY_USER_ID, A.CLIENT_USER_ID CLIENT_USER_ID FROM SYS.ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT A LEFT JOIN SYS.ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT B ON A.TENANT_ID = B.TENANT_ID AND A.CLIENT_USER_ID = B.CLIENT_USER_ID AND A.PROXY_USER_ID = B.PROXY_USER_ID GROUP BY A.TENANT_ID, A.PROXY_USER_ID, A.CLIENT_USER_ID ) V where U1.TENANT_ID = U2.TENANT_ID and U2.TENANT_ID = P.TENANT_ID and U1.TENANT_ID = EFFECTIVE_TENANT_ID() and U1.USER_ID = P.PROXY_USER_ID and U2.USER_ID = P.CLIENT_USER_ID and V.TENANT_ID = U1.TENANT_ID and V.PROXY_USER_ID = P.PROXY_USER_ID and V.CLIENT_USER_ID = P.CLIENT_USER_ID )__"))) { + LOG_ERROR("fail to set view_definition", K(ret)); + } + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + } // end namespace share } // end namespace oceanbase diff --git a/src/share/inner_table/ob_inner_table_schema.28001_28050.cpp b/src/share/inner_table/ob_inner_table_schema.28001_28050.cpp index 4a3758af8b..2da66b83b9 100644 --- a/src/share/inner_table/ob_inner_table_schema.28001_28050.cpp +++ b/src/share/inner_table/ob_inner_table_schema.28001_28050.cpp @@ -60,7 +60,7 @@ int ObInnerTableSchema::gv_ob_sql_audit_ora_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT svr_ip SVR_IP, svr_port SVR_PORT, request_id REQUEST_ID, execution_id SQL_EXEC_ID, trace_id TRACE_ID, session_id SID, client_ip CLIENT_IP, client_port CLIENT_PORT, tenant_id TENANT_ID, effective_tenant_id EFFECTIVE_TENANT_ID, tenant_name TENANT_NAME, user_id USER_ID, user_name USER_NAME, user_group as USER_GROUP, user_client_ip as USER_CLIENT_IP, db_id DB_ID, db_name DB_NAME, sql_id SQL_ID, query_sql QUERY_SQL, plan_id PLAN_ID, affected_rows AFFECTED_ROWS, return_rows RETURN_ROWS, partition_cnt PARTITION_CNT, ret_code RET_CODE, qc_id QC_ID, dfo_id DFO_ID, sqc_id SQC_ID, worker_id WORKER_ID, event EVENT, p1text P1TEXT, p1 P1, p2text P2TEXT, p2 P2, p3text P3TEXT, p3 P3, "LEVEL" "LEVEL", wait_class_id WAIT_CLASS_ID, "WAIT_CLASS#" "WAIT_CLASS#", wait_class WAIT_CLASS, state STATE, wait_time_micro WAIT_TIME_MICRO, total_wait_time_micro TOTAL_WAIT_TIME_MICRO, total_waits TOTAL_WAITS, rpc_count RPC_COUNT, plan_type PLAN_TYPE, is_inner_sql IS_INNER_SQL, is_executor_rpc IS_EXECUTOR_RPC, is_hit_plan IS_HIT_PLAN, request_time REQUEST_TIME, elapsed_time ELAPSED_TIME, net_time NET_TIME, net_wait_time NET_WAIT_TIME, queue_time QUEUE_TIME, decode_time DECODE_TIME, get_plan_time GET_PLAN_TIME, execute_time EXECUTE_TIME, application_wait_time APPLICATION_WAIT_TIME, concurrency_wait_time CONCURRENCY_WAIT_TIME, user_io_wait_time USER_IO_WAIT_TIME, schedule_time SCHEDULE_TIME, row_cache_hit ROW_CACHE_HIT, bloom_filter_cache_hit BLOOM_FILTER_CACHE_HIT, block_cache_hit BLOCK_CACHE_HIT, disk_reads DISK_READS, retry_cnt RETRY_CNT, table_scan TABLE_SCAN, consistency_level CONSISTENCY_LEVEL, memstore_read_row_count MEMSTORE_READ_ROW_COUNT, ssstore_read_row_count SSSTORE_READ_ROW_COUNT, data_block_read_cnt as DATA_BLOCK_READ_CNT, data_block_cache_hit as DATA_BLOCK_CACHE_HIT, index_block_read_cnt as INDEX_BLOCK_READ_CNT, index_block_cache_hit as INDEX_BLOCK_CACHE_HIT, blockscan_block_cnt as BLOCKSCAN_BLOCK_CNT, blockscan_row_cnt as BLOCKSCAN_ROW_CNT, pushdown_storage_filter_row_cnt as PUSHDOWN_STORAGE_FILTER_ROW_CNT, request_memory_used REQUEST_MEMORY_USED, expected_worker_count EXPECTED_WORKER_COUNT, used_worker_count USED_WORKER_COUNT, sched_info SCHED_INFO, ps_client_stmt_id PS_CLIENT_STMT_ID, ps_inner_stmt_id PS_INNER_STMT_ID, transaction_id as TX_ID, snapshot_version as SNAPSHOT_VERSION, request_type as REQUEST_TYPE, is_batched_multi_stmt as IS_BATCHED_MULTI_STMT, ob_trace_info as OB_TRACE_INFO, plan_hash as PLAN_HASH, params_value as PARAMS_VALUE, rule_name as RULE_NAME, case when bitand(tx_internal_route_flag, 96) = 32 then 1 else 0 end as TX_INTERNAL_ROUTING, tx_internal_route_version as TX_STATE_VERSION, flt_trace_id as FLT_TRACE_ID, pl_trace_id as PL_TRACE_ID, plsql_exec_time as PLSQL_EXEC_TIME, total_memstore_read_row_count as TOTAL_MEMSTORE_READ_ROW_COUNT, total_ssstore_read_row_count as TOTAL_SSSTORE_READ_ROW_COUNT FROM SYS.ALL_VIRTUAL_SQL_AUDIT )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT svr_ip SVR_IP, svr_port SVR_PORT, request_id REQUEST_ID, execution_id SQL_EXEC_ID, trace_id TRACE_ID, session_id SID, client_ip CLIENT_IP, client_port CLIENT_PORT, tenant_id TENANT_ID, effective_tenant_id EFFECTIVE_TENANT_ID, tenant_name TENANT_NAME, user_id USER_ID, user_name USER_NAME, user_group as USER_GROUP, user_client_ip as USER_CLIENT_IP, db_id DB_ID, db_name DB_NAME, sql_id SQL_ID, query_sql QUERY_SQL, plan_id PLAN_ID, affected_rows AFFECTED_ROWS, return_rows RETURN_ROWS, partition_cnt PARTITION_CNT, ret_code RET_CODE, qc_id QC_ID, dfo_id DFO_ID, sqc_id SQC_ID, worker_id WORKER_ID, event EVENT, p1text P1TEXT, p1 P1, p2text P2TEXT, p2 P2, p3text P3TEXT, p3 P3, "LEVEL" "LEVEL", wait_class_id WAIT_CLASS_ID, "WAIT_CLASS#" "WAIT_CLASS#", wait_class WAIT_CLASS, state STATE, wait_time_micro WAIT_TIME_MICRO, total_wait_time_micro TOTAL_WAIT_TIME_MICRO, total_waits TOTAL_WAITS, rpc_count RPC_COUNT, plan_type PLAN_TYPE, is_inner_sql IS_INNER_SQL, is_executor_rpc IS_EXECUTOR_RPC, is_hit_plan IS_HIT_PLAN, request_time REQUEST_TIME, elapsed_time ELAPSED_TIME, net_time NET_TIME, net_wait_time NET_WAIT_TIME, queue_time QUEUE_TIME, decode_time DECODE_TIME, get_plan_time GET_PLAN_TIME, execute_time EXECUTE_TIME, application_wait_time APPLICATION_WAIT_TIME, concurrency_wait_time CONCURRENCY_WAIT_TIME, user_io_wait_time USER_IO_WAIT_TIME, schedule_time SCHEDULE_TIME, row_cache_hit ROW_CACHE_HIT, bloom_filter_cache_hit BLOOM_FILTER_CACHE_HIT, block_cache_hit BLOCK_CACHE_HIT, disk_reads DISK_READS, retry_cnt RETRY_CNT, table_scan TABLE_SCAN, consistency_level CONSISTENCY_LEVEL, memstore_read_row_count MEMSTORE_READ_ROW_COUNT, ssstore_read_row_count SSSTORE_READ_ROW_COUNT, data_block_read_cnt as DATA_BLOCK_READ_CNT, data_block_cache_hit as DATA_BLOCK_CACHE_HIT, index_block_read_cnt as INDEX_BLOCK_READ_CNT, index_block_cache_hit as INDEX_BLOCK_CACHE_HIT, blockscan_block_cnt as BLOCKSCAN_BLOCK_CNT, blockscan_row_cnt as BLOCKSCAN_ROW_CNT, pushdown_storage_filter_row_cnt as PUSHDOWN_STORAGE_FILTER_ROW_CNT, request_memory_used REQUEST_MEMORY_USED, expected_worker_count EXPECTED_WORKER_COUNT, used_worker_count USED_WORKER_COUNT, sched_info SCHED_INFO, ps_client_stmt_id PS_CLIENT_STMT_ID, ps_inner_stmt_id PS_INNER_STMT_ID, transaction_id as TX_ID, snapshot_version as SNAPSHOT_VERSION, request_type as REQUEST_TYPE, is_batched_multi_stmt as IS_BATCHED_MULTI_STMT, ob_trace_info as OB_TRACE_INFO, plan_hash as PLAN_HASH, params_value as PARAMS_VALUE, rule_name as RULE_NAME, case when bitand(tx_internal_route_flag, 96) = 32 then 1 else 0 end as TX_INTERNAL_ROUTING, tx_internal_route_version as TX_STATE_VERSION, flt_trace_id as FLT_TRACE_ID, pl_trace_id as PL_TRACE_ID, plsql_exec_time as PLSQL_EXEC_TIME, total_memstore_read_row_count as TOTAL_MEMSTORE_READ_ROW_COUNT, total_ssstore_read_row_count as TOTAL_SSSTORE_READ_ROW_COUNT, proxy_user as PROXY_USER FROM SYS.ALL_VIRTUAL_SQL_AUDIT )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } @@ -110,7 +110,7 @@ int ObInnerTableSchema::v_ob_sql_audit_ora_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT SVR_IP, SVR_PORT, REQUEST_ID, SQL_EXEC_ID, TRACE_ID, SID, CLIENT_IP, CLIENT_PORT, TENANT_ID, EFFECTIVE_TENANT_ID, TENANT_NAME, USER_ID, USER_NAME, USER_GROUP, USER_CLIENT_IP, DB_ID, DB_NAME, SQL_ID, QUERY_SQL, PLAN_ID, AFFECTED_ROWS, RETURN_ROWS, PARTITION_CNT, RET_CODE, QC_ID, DFO_ID, SQC_ID, WORKER_ID, EVENT, P1TEXT, P1, P2TEXT, P2, P3TEXT, P3, "LEVEL", WAIT_CLASS_ID, "WAIT_CLASS#", WAIT_CLASS, STATE, WAIT_TIME_MICRO, TOTAL_WAIT_TIME_MICRO, TOTAL_WAITS, RPC_COUNT, PLAN_TYPE, IS_INNER_SQL, IS_EXECUTOR_RPC, IS_HIT_PLAN, REQUEST_TIME, ELAPSED_TIME, NET_TIME, NET_WAIT_TIME, QUEUE_TIME, DECODE_TIME, GET_PLAN_TIME, EXECUTE_TIME, APPLICATION_WAIT_TIME, CONCURRENCY_WAIT_TIME, USER_IO_WAIT_TIME, SCHEDULE_TIME, ROW_CACHE_HIT, BLOOM_FILTER_CACHE_HIT, BLOCK_CACHE_HIT, DISK_READS, RETRY_CNT, TABLE_SCAN, CONSISTENCY_LEVEL, MEMSTORE_READ_ROW_COUNT, SSSTORE_READ_ROW_COUNT, DATA_BLOCK_READ_CNT, DATA_BLOCK_CACHE_HIT, INDEX_BLOCK_READ_CNT, INDEX_BLOCK_CACHE_HIT, BLOCKSCAN_BLOCK_CNT, BLOCKSCAN_ROW_CNT, PUSHDOWN_STORAGE_FILTER_ROW_CNT, REQUEST_MEMORY_USED, EXPECTED_WORKER_COUNT, USED_WORKER_COUNT, SCHED_INFO, PS_CLIENT_STMT_ID, PS_INNER_STMT_ID, TX_ID, SNAPSHOT_VERSION, REQUEST_TYPE, IS_BATCHED_MULTI_STMT, OB_TRACE_INFO, PLAN_HASH, PARAMS_VALUE, RULE_NAME, TX_INTERNAL_ROUTING, TX_STATE_VERSION, FLT_TRACE_ID, PL_TRACE_ID, PLSQL_EXEC_TIME, TOTAL_MEMSTORE_READ_ROW_COUNT, TOTAL_SSSTORE_READ_ROW_COUNT FROM SYS.GV$OB_SQL_AUDIT WHERE SVR_IP=HOST_IP() AND SVR_PORT=RPC_PORT() )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__(SELECT SVR_IP, SVR_PORT, REQUEST_ID, SQL_EXEC_ID, TRACE_ID, SID, CLIENT_IP, CLIENT_PORT, TENANT_ID, EFFECTIVE_TENANT_ID, TENANT_NAME, USER_ID, USER_NAME, USER_GROUP, USER_CLIENT_IP, DB_ID, DB_NAME, SQL_ID, QUERY_SQL, PLAN_ID, AFFECTED_ROWS, RETURN_ROWS, PARTITION_CNT, RET_CODE, QC_ID, DFO_ID, SQC_ID, WORKER_ID, EVENT, P1TEXT, P1, P2TEXT, P2, P3TEXT, P3, "LEVEL", WAIT_CLASS_ID, "WAIT_CLASS#", WAIT_CLASS, STATE, WAIT_TIME_MICRO, TOTAL_WAIT_TIME_MICRO, TOTAL_WAITS, RPC_COUNT, PLAN_TYPE, IS_INNER_SQL, IS_EXECUTOR_RPC, IS_HIT_PLAN, REQUEST_TIME, ELAPSED_TIME, NET_TIME, NET_WAIT_TIME, QUEUE_TIME, DECODE_TIME, GET_PLAN_TIME, EXECUTE_TIME, APPLICATION_WAIT_TIME, CONCURRENCY_WAIT_TIME, USER_IO_WAIT_TIME, SCHEDULE_TIME, ROW_CACHE_HIT, BLOOM_FILTER_CACHE_HIT, BLOCK_CACHE_HIT, DISK_READS, RETRY_CNT, TABLE_SCAN, CONSISTENCY_LEVEL, MEMSTORE_READ_ROW_COUNT, SSSTORE_READ_ROW_COUNT, DATA_BLOCK_READ_CNT, DATA_BLOCK_CACHE_HIT, INDEX_BLOCK_READ_CNT, INDEX_BLOCK_CACHE_HIT, BLOCKSCAN_BLOCK_CNT, BLOCKSCAN_ROW_CNT, PUSHDOWN_STORAGE_FILTER_ROW_CNT, REQUEST_MEMORY_USED, EXPECTED_WORKER_COUNT, USED_WORKER_COUNT, SCHED_INFO, PS_CLIENT_STMT_ID, PS_INNER_STMT_ID, TX_ID, SNAPSHOT_VERSION, REQUEST_TYPE, IS_BATCHED_MULTI_STMT, OB_TRACE_INFO, PLAN_HASH, PARAMS_VALUE, RULE_NAME, TX_INTERNAL_ROUTING, TX_STATE_VERSION, FLT_TRACE_ID, PL_TRACE_ID, PLSQL_EXEC_TIME, TOTAL_MEMSTORE_READ_ROW_COUNT, TOTAL_SSSTORE_READ_ROW_COUNT, PROXY_USER FROM SYS.GV$OB_SQL_AUDIT WHERE SVR_IP=HOST_IP() AND SVR_PORT=RPC_PORT() )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema.28101_28150.cpp b/src/share/inner_table/ob_inner_table_schema.28101_28150.cpp index 4b18796bfa..ffb33b17f1 100644 --- a/src/share/inner_table/ob_inner_table_schema.28101_28150.cpp +++ b/src/share/inner_table/ob_inner_table_schema.28101_28150.cpp @@ -960,7 +960,7 @@ int ObInnerTableSchema::gv_ob_processlist_ora_schema(ObTableSchema &table_schema table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT SVR_IP, SVR_PORT, SQL_PORT, ID, "USER", HOST, DB, TENANT, COMMAND, TIME, TOTAL_TIME, STATE, INFO, PROXY_SESSID, MASTER_SESSID, USER_CLIENT_IP, USER_HOST, RETRY_CNT, RETRY_INFO, SQL_ID, TRANS_ID, THREAD_ID, SSL_CIPHER, TRACE_ID, TRANS_STATE, ACTION, MODULE, CLIENT_INFO, "LEVEL", SAMPLE_PERCENTAGE, RECORD_POLICY, LB_VID, LB_VIP, LB_VPORT, IN_BYTES, OUT_BYTES, USER_CLIENT_PORT FROM SYS.ALL_VIRTUAL_PROCESSLIST )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT SVR_IP, SVR_PORT, SQL_PORT, ID, "USER", HOST, DB, TENANT, COMMAND, TIME, TOTAL_TIME, STATE, INFO, PROXY_SESSID, MASTER_SESSID, USER_CLIENT_IP, USER_HOST, RETRY_CNT, RETRY_INFO, SQL_ID, TRANS_ID, THREAD_ID, SSL_CIPHER, TRACE_ID, TRANS_STATE, ACTION, MODULE, CLIENT_INFO, "LEVEL", SAMPLE_PERCENTAGE, RECORD_POLICY, LB_VID, LB_VIP, LB_VPORT, IN_BYTES, OUT_BYTES, USER_CLIENT_PORT, PROXY_USER FROM SYS.ALL_VIRTUAL_PROCESSLIST )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } @@ -1010,7 +1010,7 @@ int ObInnerTableSchema::v_ob_processlist_ora_schema(ObTableSchema &table_schema) table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); if (OB_SUCC(ret)) { - if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT SVR_IP, SVR_PORT, SQL_PORT, ID, "USER", HOST, DB, TENANT, COMMAND, TIME, TOTAL_TIME, STATE, INFO, PROXY_SESSID, MASTER_SESSID, USER_CLIENT_IP, USER_HOST, RETRY_CNT, RETRY_INFO, SQL_ID, TRANS_ID, THREAD_ID, SSL_CIPHER, TRACE_ID, TRANS_STATE, ACTION, MODULE, CLIENT_INFO, "LEVEL", SAMPLE_PERCENTAGE, RECORD_POLICY, LB_VID, LB_VIP, LB_VPORT, IN_BYTES, OUT_BYTES, USER_CLIENT_PORT FROM SYS.GV$OB_PROCESSLIST WHERE SVR_IP = host_ip() AND SVR_PORT = rpc_port() )__"))) { + if (OB_FAIL(table_schema.set_view_definition(R"__( SELECT SVR_IP, SVR_PORT, SQL_PORT, ID, "USER", HOST, DB, TENANT, COMMAND, TIME, TOTAL_TIME, STATE, INFO, PROXY_SESSID, MASTER_SESSID, USER_CLIENT_IP, USER_HOST, RETRY_CNT, RETRY_INFO, SQL_ID, TRANS_ID, THREAD_ID, SSL_CIPHER, TRACE_ID, TRANS_STATE, ACTION, MODULE, CLIENT_INFO, "LEVEL", SAMPLE_PERCENTAGE, RECORD_POLICY, LB_VID, LB_VIP, LB_VPORT, IN_BYTES, OUT_BYTES, USER_CLIENT_PORT, PROXY_USER FROM SYS.GV$OB_PROCESSLIST WHERE SVR_IP = host_ip() AND SVR_PORT = rpc_port() )__"))) { LOG_ERROR("fail to set view_definition", K(ret)); } } diff --git a/src/share/inner_table/ob_inner_table_schema.28201_28250.cpp b/src/share/inner_table/ob_inner_table_schema.28201_28250.cpp index 41a7c84dce..3670ae3d69 100644 --- a/src/share/inner_table/ob_inner_table_schema.28201_28250.cpp +++ b/src/share/inner_table/ob_inner_table_schema.28201_28250.cpp @@ -12493,6 +12493,351 @@ int ObInnerTableSchema::all_column_privilege_idx_column_privilege_name_schema(Ob return ret; } +int ObInnerTableSchema::all_user_proxy_info_idx_user_proxy_info_proxy_user_id_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(3); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(USER_INDEX); + table_schema.set_index_type(INDEX_TYPE_NORMAL_LOCAL); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ++column_id; // for gmt_create + } + + if (OB_SUCC(ret)) { + ++column_id; // for gmt_modified + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TID); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + column_id + 1, //column_id + 1, //rowkey_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + column_id + 3, //column_id + 2, //rowkey_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + column_id + 2, //column_id + 3, //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 + } + table_schema.set_index_status(INDEX_STATUS_AVAILABLE); + table_schema.set_index_type(INDEX_TYPE_NORMAL_LOCAL); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_INFO_TID); + + table_schema.set_max_used_column_id(column_id + 3); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_info_history_idx_user_proxy_info_proxy_user_id_history_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(4); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(USER_INDEX); + table_schema.set_index_type(INDEX_TYPE_NORMAL_LOCAL); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ++column_id; // for gmt_create + } + + if (OB_SUCC(ret)) { + ++column_id; // for gmt_modified + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TID); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + column_id + 1, //column_id + 1, //rowkey_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + column_id + 3, //column_id + 2, //rowkey_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + column_id + 2, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("schema_version", //column_name + column_id + 4, //column_id + 4, //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 + } + table_schema.set_index_status(INDEX_STATUS_AVAILABLE); + table_schema.set_index_type(INDEX_TYPE_NORMAL_LOCAL); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_INFO_HISTORY_TID); + + table_schema.set_max_used_column_id(column_id + 4); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_role_info_history_idx_user_proxy_role_info_proxy_user_id_history_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(5); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(USER_INDEX); + table_schema.set_index_type(INDEX_TYPE_NORMAL_LOCAL); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ++column_id; // for gmt_create + } + + if (OB_SUCC(ret)) { + ++column_id; // for gmt_modified + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TID); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + column_id + 1, //column_id + 1, //rowkey_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + column_id + 3, //column_id + 2, //rowkey_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + column_id + 2, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("role_id", //column_name + column_id + 4, //column_id + 4, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("schema_version", //column_name + column_id + 5, //column_id + 5, //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 + } + table_schema.set_index_status(INDEX_STATUS_AVAILABLE); + table_schema.set_index_type(INDEX_TYPE_NORMAL_LOCAL); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID); + + table_schema.set_max_used_column_id(column_id + 5); + return ret; +} + int ObInnerTableSchema::all_virtual_table_real_agent_ora_idx_data_table_id_real_agent_schema(ObTableSchema &table_schema) { int ret = OB_SUCCESS; @@ -19732,6 +20077,98 @@ int ObInnerTableSchema::all_virtual_dbms_lock_allocated_real_agent_ora_idx_dbms_ return ret; } +int ObInnerTableSchema::all_virtual_user_proxy_info_real_agent_ora_idx_user_proxy_info_proxy_user_id_real_agent_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_INVALID_ID); + table_schema.set_database_id(OB_ORA_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_IDX_USER_PROXY_INFO_PROXY_USER_ID_REAL_AGENT_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(3); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(USER_INDEX); + table_schema.set_index_type(INDEX_TYPE_NORMAL_LOCAL); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_IDX_USER_PROXY_INFO_PROXY_USER_ID_REAL_AGENT_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCollationType::CS_TYPE_UTF8MB4_BIN); + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(0); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("TENANT_ID", //column_name + column_id + 1, //column_id + 1, //rowkey_id + 1, //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("PROXY_USER_ID", //column_name + column_id + 3, //column_id + 2, //rowkey_id + 2, //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("CLIENT_USER_ID", //column_name + column_id + 2, //column_id + 3, //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 + } + table_schema.set_index_status(INDEX_STATUS_AVAILABLE); + table_schema.set_index_type(INDEX_TYPE_NORMAL_LOCAL); + table_schema.set_data_table_id(OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TID); + + table_schema.set_max_used_column_id(column_id + 3); + return ret; +} + } // end namespace share } // end namespace oceanbase diff --git a/src/share/inner_table/ob_inner_table_schema.501_550.cpp b/src/share/inner_table/ob_inner_table_schema.501_550.cpp index d2554ef3a0..b6184e44e4 100644 --- a/src/share/inner_table/ob_inner_table_schema.501_550.cpp +++ b/src/share/inner_table/ob_inner_table_schema.501_550.cpp @@ -1035,6 +1035,720 @@ int ObInnerTableSchema::all_tenant_snapshot_ls_replica_history_schema(ObTableSch return ret; } +int ObInnerTableSchema::all_user_proxy_info_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_INFO_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(3); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(SYSTEM_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_INFO_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ObObj gmt_create_default; + ObObj gmt_create_default_null; + + gmt_create_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG); + gmt_create_default_null.set_null(); + ADD_COLUMN_SCHEMA_TS_T("gmt_create", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_BINARY,//collation_type + 0, //column length + -1, //column_precision + 6, //column_scale + true,//is nullable + false, //is_autoincrement + false, //is_on_update_for_timestamp + gmt_create_default_null, + gmt_create_default) + } + + if (OB_SUCC(ret)) { + ObObj gmt_modified_default; + ObObj gmt_modified_default_null; + + gmt_modified_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG); + gmt_modified_default_null.set_null(); + ADD_COLUMN_SCHEMA_TS_T("gmt_modified", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_BINARY,//collation_type + 0, //column length + -1, //column_precision + 6, //column_scale + true,//is nullable + false, //is_autoincrement + true, //is_on_update_for_timestamp + gmt_modified_default_null, + gmt_modified_default) + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + ++column_id, //column_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + ++column_id, //column_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + ++column_id, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ObObj credential_type_default; + credential_type_default.set_int(0); + ADD_COLUMN_SCHEMA_T("credential_type", //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 + credential_type_default, + credential_type_default); //default_value + } + + if (OB_SUCC(ret)) { + ObObj flags_default; + flags_default.set_int(0); + ADD_COLUMN_SCHEMA_T("flags", //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 + flags_default, + flags_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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_INFO_TID); + table_schema.set_aux_lob_meta_tid(OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TID); + table_schema.set_aux_lob_piece_tid(OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_info_history_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_INFO_HISTORY_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(4); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(SYSTEM_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_INFO_HISTORY_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ObObj gmt_create_default; + ObObj gmt_create_default_null; + + gmt_create_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG); + gmt_create_default_null.set_null(); + ADD_COLUMN_SCHEMA_TS_T("gmt_create", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_BINARY,//collation_type + 0, //column length + -1, //column_precision + 6, //column_scale + true,//is nullable + false, //is_autoincrement + false, //is_on_update_for_timestamp + gmt_create_default_null, + gmt_create_default) + } + + if (OB_SUCC(ret)) { + ObObj gmt_modified_default; + ObObj gmt_modified_default_null; + + gmt_modified_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG); + gmt_modified_default_null.set_null(); + ADD_COLUMN_SCHEMA_TS_T("gmt_modified", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_BINARY,//collation_type + 0, //column length + -1, //column_precision + 6, //column_scale + true,//is nullable + false, //is_autoincrement + true, //is_on_update_for_timestamp + gmt_modified_default_null, + gmt_modified_default) + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + ++column_id, //column_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + ++column_id, //column_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + ++column_id, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("schema_version", //column_name + ++column_id, //column_id + 4, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("is_deleted", //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 + } + + if (OB_SUCC(ret)) { + ObObj credential_type_default; + credential_type_default.set_int(0); + ADD_COLUMN_SCHEMA_T("credential_type", //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 + true, //is_nullable + false, //is_autoincrement + credential_type_default, + credential_type_default); //default_value + } + + if (OB_SUCC(ret)) { + ObObj flags_default; + flags_default.set_int(0); + ADD_COLUMN_SCHEMA_T("flags", //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 + true, //is_nullable + false, //is_autoincrement + flags_default, + flags_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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_INFO_HISTORY_TID); + table_schema.set_aux_lob_meta_tid(OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TID); + table_schema.set_aux_lob_piece_tid(OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_role_info_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_ROLE_INFO_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(4); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(SYSTEM_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_ROLE_INFO_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ObObj gmt_create_default; + ObObj gmt_create_default_null; + + gmt_create_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG); + gmt_create_default_null.set_null(); + ADD_COLUMN_SCHEMA_TS_T("gmt_create", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_BINARY,//collation_type + 0, //column length + -1, //column_precision + 6, //column_scale + true,//is nullable + false, //is_autoincrement + false, //is_on_update_for_timestamp + gmt_create_default_null, + gmt_create_default) + } + + if (OB_SUCC(ret)) { + ObObj gmt_modified_default; + ObObj gmt_modified_default_null; + + gmt_modified_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG); + gmt_modified_default_null.set_null(); + ADD_COLUMN_SCHEMA_TS_T("gmt_modified", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_BINARY,//collation_type + 0, //column length + -1, //column_precision + 6, //column_scale + true,//is nullable + false, //is_autoincrement + true, //is_on_update_for_timestamp + gmt_modified_default_null, + gmt_modified_default) + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + ++column_id, //column_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + ++column_id, //column_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + ++column_id, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("role_id", //column_name + ++column_id, //column_id + 4, //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 + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_ROLE_INFO_TID); + table_schema.set_aux_lob_meta_tid(OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TID); + table_schema.set_aux_lob_piece_tid(OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_role_info_history_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(5); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(SYSTEM_TABLE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ObObj gmt_create_default; + ObObj gmt_create_default_null; + + gmt_create_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG); + gmt_create_default_null.set_null(); + ADD_COLUMN_SCHEMA_TS_T("gmt_create", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_BINARY,//collation_type + 0, //column length + -1, //column_precision + 6, //column_scale + true,//is nullable + false, //is_autoincrement + false, //is_on_update_for_timestamp + gmt_create_default_null, + gmt_create_default) + } + + if (OB_SUCC(ret)) { + ObObj gmt_modified_default; + ObObj gmt_modified_default_null; + + gmt_modified_default.set_ext(ObActionFlag::OP_DEFAULT_NOW_FLAG); + gmt_modified_default_null.set_null(); + ADD_COLUMN_SCHEMA_TS_T("gmt_modified", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObTimestampType, //column_type + CS_TYPE_BINARY,//collation_type + 0, //column length + -1, //column_precision + 6, //column_scale + true,//is nullable + false, //is_autoincrement + true, //is_on_update_for_timestamp + gmt_modified_default_null, + gmt_modified_default) + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("tenant_id", //column_name + ++column_id, //column_id + 1, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("client_user_id", //column_name + ++column_id, //column_id + 2, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("proxy_user_id", //column_name + ++column_id, //column_id + 3, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("role_id", //column_name + ++column_id, //column_id + 4, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("schema_version", //column_name + ++column_id, //column_id + 5, //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 + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("is_deleted", //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 + } + 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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID); + table_schema.set_aux_lob_meta_tid(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TID); + table_schema.set_aux_lob_piece_tid(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + int ObInnerTableSchema::all_mview_dep_schema(ObTableSchema &table_schema) { int ret = OB_SUCCESS; diff --git a/src/share/inner_table/ob_inner_table_schema.50501_50550.cpp b/src/share/inner_table/ob_inner_table_schema.50501_50550.cpp index c4df94db7f..d949d74c30 100644 --- a/src/share/inner_table/ob_inner_table_schema.50501_50550.cpp +++ b/src/share/inner_table/ob_inner_table_schema.50501_50550.cpp @@ -700,6 +700,546 @@ int ObInnerTableSchema::all_tenant_snapshot_ls_replica_history_aux_lob_meta_sche return ret; } +int ObInnerTableSchema::all_user_proxy_info_aux_lob_meta_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(2); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(AUX_LOB_META); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_id", //column_name + ++column_id, //column_id + 1, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + 16, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("seq_id", //column_name + ++column_id, //column_id + 2, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + 8192, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("binary_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("char_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("piece_id", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt64Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_data", //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 + 262144, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TID); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_INFO_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_info_history_aux_lob_meta_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(2); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(AUX_LOB_META); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_id", //column_name + ++column_id, //column_id + 1, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + 16, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("seq_id", //column_name + ++column_id, //column_id + 2, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + 8192, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("binary_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("char_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("piece_id", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt64Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_data", //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 + 262144, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TID); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_INFO_HISTORY_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_role_info_aux_lob_meta_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(2); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(AUX_LOB_META); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_id", //column_name + ++column_id, //column_id + 1, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + 16, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("seq_id", //column_name + ++column_id, //column_id + 2, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + 8192, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("binary_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("char_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("piece_id", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt64Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_data", //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 + 262144, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TID); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_ROLE_INFO_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_role_info_history_aux_lob_meta_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(2); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(AUX_LOB_META); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_id", //column_name + ++column_id, //column_id + 1, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + 16, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("seq_id", //column_name + ++column_id, //column_id + 2, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObVarcharType, //column_type + CS_TYPE_BINARY, //column_collation_type + 8192, //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("binary_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("char_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("piece_id", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt64Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_data", //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 + 262144, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TID); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + int ObInnerTableSchema::all_mview_dep_aux_lob_meta_schema(ObTableSchema &table_schema) { int ret = OB_SUCCESS; diff --git a/src/share/inner_table/ob_inner_table_schema.60501_60550.cpp b/src/share/inner_table/ob_inner_table_schema.60501_60550.cpp index 88999d4df0..58b2f2d835 100644 --- a/src/share/inner_table/ob_inner_table_schema.60501_60550.cpp +++ b/src/share/inner_table/ob_inner_table_schema.60501_60550.cpp @@ -475,6 +475,366 @@ int ObInnerTableSchema::all_tenant_snapshot_ls_replica_history_aux_lob_piece_sch return ret; } +int ObInnerTableSchema::all_user_proxy_info_aux_lob_piece_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(1); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(AUX_LOB_PIECE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("piece_id", //column_name + ++column_id, //column_id + 1, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt64Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("data_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_data", //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 + 32, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TID); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_INFO_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_info_history_aux_lob_piece_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(1); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(AUX_LOB_PIECE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("piece_id", //column_name + ++column_id, //column_id + 1, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt64Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("data_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_data", //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 + 32, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TID); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_INFO_HISTORY_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_role_info_aux_lob_piece_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(1); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(AUX_LOB_PIECE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("piece_id", //column_name + ++column_id, //column_id + 1, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt64Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("data_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_data", //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 + 32, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TID); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_ROLE_INFO_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + +int ObInnerTableSchema::all_user_proxy_role_info_history_aux_lob_piece_schema(ObTableSchema &table_schema) +{ + int ret = OB_SUCCESS; + uint64_t column_id = OB_APP_MIN_COLUMN_ID - 1; + + //generated fields: + table_schema.set_tenant_id(OB_SYS_TENANT_ID); + table_schema.set_tablegroup_id(OB_SYS_TABLEGROUP_ID); + table_schema.set_database_id(OB_SYS_DATABASE_ID); + table_schema.set_table_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TID); + table_schema.set_rowkey_split_pos(0); + table_schema.set_is_use_bloomfilter(false); + table_schema.set_progressive_merge_num(0); + table_schema.set_rowkey_column_num(1); + table_schema.set_load_type(TABLE_LOAD_TYPE_IN_DISK); + table_schema.set_table_type(AUX_LOB_PIECE); + table_schema.set_index_type(INDEX_TYPE_IS_NOT); + table_schema.set_def_type(TABLE_DEF_TYPE_INTERNAL); + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_table_name(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TNAME))) { + LOG_ERROR("fail to set table_name", K(ret)); + } + } + + if (OB_SUCC(ret)) { + if (OB_FAIL(table_schema.set_compress_func_name(OB_DEFAULT_COMPRESS_FUNC_NAME))) { + LOG_ERROR("fail to set compress_func_name", K(ret)); + } + } + table_schema.set_part_level(PARTITION_LEVEL_ZERO); + table_schema.set_charset_type(ObCharset::get_default_charset()); + table_schema.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("piece_id", //column_name + ++column_id, //column_id + 1, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt64Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint64_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("data_len", //column_name + ++column_id, //column_id + 0, //rowkey_id + 0, //index_id + 0, //part_key_pos + ObUInt32Type, //column_type + CS_TYPE_INVALID, //column_collation_type + sizeof(uint32_t), //column_length + -1, //column_precision + -1, //column_scale + false, //is_nullable + false); //is_autoincrement + } + + if (OB_SUCC(ret)) { + ADD_COLUMN_SCHEMA("lob_data", //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 + 32, //column_length + -1, //column_precision + -1, //column_scale + false, //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); + table_schema.set_progressive_merge_round(1); + table_schema.set_storage_format_version(3); + table_schema.set_tablet_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TID); + table_schema.set_data_table_id(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID); + + table_schema.set_max_used_column_id(column_id); + return ret; +} + int ObInnerTableSchema::all_mview_dep_aux_lob_piece_schema(ObTableSchema &table_schema) { int ret = OB_SUCCESS; diff --git a/src/share/inner_table/ob_inner_table_schema.h b/src/share/inner_table/ob_inner_table_schema.h index c2977509d9..dce4838ed2 100644 --- a/src/share/inner_table/ob_inner_table_schema.h +++ b/src/share/inner_table/ob_inner_table_schema.h @@ -585,6 +585,10 @@ public: static int all_column_privilege_schema(share::schema::ObTableSchema &table_schema); static int all_column_privilege_history_schema(share::schema::ObTableSchema &table_schema); static int all_tenant_snapshot_ls_replica_history_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_info_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_info_history_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_role_info_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_role_info_history_schema(share::schema::ObTableSchema &table_schema); static int all_mview_dep_schema(share::schema::ObTableSchema &table_schema); static int tenant_virtual_all_table_schema(share::schema::ObTableSchema &table_schema); static int tenant_virtual_table_column_schema(share::schema::ObTableSchema &table_schema); @@ -1029,6 +1033,11 @@ public: static int all_virtual_tenant_snapshot_ls_replica_history_schema(share::schema::ObTableSchema &table_schema); static int enabled_roles_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_tracepoint_info_schema(share::schema::ObTableSchema &table_schema); + static int all_virtual_compatibility_control_schema(share::schema::ObTableSchema &table_schema); + static int all_virtual_user_proxy_info_schema(share::schema::ObTableSchema &table_schema); + static int all_virtual_user_proxy_info_history_schema(share::schema::ObTableSchema &table_schema); + static int all_virtual_user_proxy_role_info_schema(share::schema::ObTableSchema &table_schema); + static int all_virtual_user_proxy_role_info_history_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_tenant_resource_limit_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_tenant_resource_limit_detail_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_nic_info_schema(share::schema::ObTableSchema &table_schema); @@ -1298,6 +1307,8 @@ public: static int all_virtual_ls_snapshot_ora_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_index_usage_info_real_agent_ora_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_tracepoint_info_ora_schema(share::schema::ObTableSchema &table_schema); + static int all_virtual_user_proxy_info_real_agent_ora_schema(share::schema::ObTableSchema &table_schema); + static int all_virtual_user_proxy_role_info_real_agent_ora_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_tenant_resource_limit_ora_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_tenant_resource_limit_detail_ora_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_nic_info_ora_schema(share::schema::ObTableSchema &table_schema); @@ -1315,6 +1326,7 @@ public: static int key_column_usage_schema(share::schema::ObTableSchema &table_schema); static int engines_schema(share::schema::ObTableSchema &table_schema); static int routines_schema(share::schema::ObTableSchema &table_schema); + static int profiling_schema(share::schema::ObTableSchema &table_schema); static int gv_session_event_schema(share::schema::ObTableSchema &table_schema); static int gv_session_wait_schema(share::schema::ObTableSchema &table_schema); static int gv_session_wait_history_schema(share::schema::ObTableSchema &table_schema); @@ -1710,6 +1722,7 @@ public: static int dba_mvref_stmt_stats_schema(share::schema::ObTableSchema &table_schema); static int gv_ob_tracepoint_info_schema(share::schema::ObTableSchema &table_schema); static int v_ob_tracepoint_info_schema(share::schema::ObTableSchema &table_schema); + static int v_ob_compatibility_control_schema(share::schema::ObTableSchema &table_schema); static int gv_ob_tenant_resource_limit_schema(share::schema::ObTableSchema &table_schema); static int v_ob_tenant_resource_limit_schema(share::schema::ObTableSchema &table_schema); static int gv_ob_tenant_resource_limit_detail_schema(share::schema::ObTableSchema &table_schema); @@ -1991,6 +2004,7 @@ public: static int user_mvref_change_stats_ora_schema(share::schema::ObTableSchema &table_schema); static int dba_mvref_stmt_stats_ora_schema(share::schema::ObTableSchema &table_schema); static int user_mvref_stmt_stats_ora_schema(share::schema::ObTableSchema &table_schema); + static int proxy_users_schema(share::schema::ObTableSchema &table_schema); static int gv_ob_sql_audit_ora_schema(share::schema::ObTableSchema &table_schema); static int v_ob_sql_audit_ora_schema(share::schema::ObTableSchema &table_schema); static int gv_instance_schema(share::schema::ObTableSchema &table_schema); @@ -2470,6 +2484,10 @@ public: static int all_column_privilege_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema); static int all_column_privilege_history_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema); static int all_tenant_snapshot_ls_replica_history_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_info_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_info_history_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_role_info_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_role_info_history_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema); static int all_mview_dep_aux_lob_meta_schema(share::schema::ObTableSchema &table_schema); static int all_table_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); static int all_column_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); @@ -2764,6 +2782,10 @@ public: static int all_column_privilege_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); static int all_column_privilege_history_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); static int all_tenant_snapshot_ls_replica_history_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_info_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_info_history_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_role_info_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_role_info_history_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); static int all_mview_dep_aux_lob_piece_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_ash_all_virtual_ash_i1_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_sql_plan_monitor_all_virtual_sql_plan_monitor_i1_schema(share::schema::ObTableSchema &table_schema); @@ -2847,6 +2869,7 @@ public: static int all_virtual_rls_context_real_agent_ora_idx_rls_context_table_id_real_agent_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_dbms_lock_allocated_real_agent_ora_idx_dbms_lock_allocated_lockhandle_real_agent_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_dbms_lock_allocated_real_agent_ora_idx_dbms_lock_allocated_expiration_real_agent_schema(share::schema::ObTableSchema &table_schema); + static int all_virtual_user_proxy_info_real_agent_ora_idx_user_proxy_info_proxy_user_id_real_agent_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_ash_ora_all_virtual_ash_i1_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_sql_plan_monitor_ora_all_virtual_sql_plan_monitor_i1_schema(share::schema::ObTableSchema &table_schema); static int all_virtual_system_event_ora_all_virtual_system_event_i1_schema(share::schema::ObTableSchema &table_schema); @@ -2961,6 +2984,9 @@ public: static int all_transfer_partition_task_idx_transfer_partition_key_schema(share::schema::ObTableSchema &table_schema); static int all_client_to_server_session_info_idx_client_to_server_session_info_client_session_id_schema(share::schema::ObTableSchema &table_schema); static int all_column_privilege_idx_column_privilege_name_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_info_idx_user_proxy_info_proxy_user_id_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_info_history_idx_user_proxy_info_proxy_user_id_history_schema(share::schema::ObTableSchema &table_schema); + static int all_user_proxy_role_info_history_idx_user_proxy_role_info_proxy_user_id_history_schema(share::schema::ObTableSchema &table_schema); private: DISALLOW_COPY_AND_ASSIGN(ObInnerTableSchema); @@ -3269,6 +3295,10 @@ const schema_create_func sys_table_schema_creators [] = { ObInnerTableSchema::all_column_privilege_schema, ObInnerTableSchema::all_column_privilege_history_schema, ObInnerTableSchema::all_tenant_snapshot_ls_replica_history_schema, + ObInnerTableSchema::all_user_proxy_info_schema, + ObInnerTableSchema::all_user_proxy_info_history_schema, + ObInnerTableSchema::all_user_proxy_role_info_schema, + ObInnerTableSchema::all_user_proxy_role_info_history_schema, ObInnerTableSchema::all_mview_dep_schema, NULL,}; @@ -3716,6 +3746,11 @@ const schema_create_func virtual_table_schema_creators [] = { ObInnerTableSchema::all_virtual_tenant_snapshot_ls_replica_history_schema, ObInnerTableSchema::enabled_roles_schema, ObInnerTableSchema::all_virtual_tracepoint_info_schema, + ObInnerTableSchema::all_virtual_compatibility_control_schema, + ObInnerTableSchema::all_virtual_user_proxy_info_schema, + ObInnerTableSchema::all_virtual_user_proxy_info_history_schema, + ObInnerTableSchema::all_virtual_user_proxy_role_info_schema, + ObInnerTableSchema::all_virtual_user_proxy_role_info_history_schema, ObInnerTableSchema::all_virtual_tenant_resource_limit_schema, ObInnerTableSchema::all_virtual_tenant_resource_limit_detail_schema, ObInnerTableSchema::all_virtual_nic_info_schema, @@ -3995,6 +4030,8 @@ const schema_create_func virtual_table_schema_creators [] = { ObInnerTableSchema::all_virtual_ls_snapshot_ora_schema, ObInnerTableSchema::all_virtual_index_usage_info_real_agent_ora_schema, ObInnerTableSchema::all_virtual_tracepoint_info_ora_schema, + ObInnerTableSchema::all_virtual_user_proxy_info_real_agent_ora_schema, + ObInnerTableSchema::all_virtual_user_proxy_role_info_real_agent_ora_schema, ObInnerTableSchema::all_virtual_tenant_resource_limit_ora_schema, ObInnerTableSchema::all_virtual_tenant_resource_limit_detail_ora_schema, ObInnerTableSchema::all_virtual_nic_info_ora_schema, @@ -4070,6 +4107,7 @@ const schema_create_func virtual_table_schema_creators [] = { ObInnerTableSchema::all_virtual_rls_context_real_agent_ora_idx_rls_context_table_id_real_agent_schema, ObInnerTableSchema::all_virtual_dbms_lock_allocated_real_agent_ora_idx_dbms_lock_allocated_lockhandle_real_agent_schema, ObInnerTableSchema::all_virtual_dbms_lock_allocated_real_agent_ora_idx_dbms_lock_allocated_expiration_real_agent_schema, + ObInnerTableSchema::all_virtual_user_proxy_info_real_agent_ora_idx_user_proxy_info_proxy_user_id_real_agent_schema, ObInnerTableSchema::all_virtual_ash_ora_all_virtual_ash_i1_schema, ObInnerTableSchema::all_virtual_sql_plan_monitor_ora_all_virtual_sql_plan_monitor_i1_schema, ObInnerTableSchema::all_virtual_system_event_ora_all_virtual_system_event_i1_schema, @@ -4096,6 +4134,7 @@ const schema_create_func sys_view_schema_creators [] = { ObInnerTableSchema::key_column_usage_schema, ObInnerTableSchema::engines_schema, ObInnerTableSchema::routines_schema, + ObInnerTableSchema::profiling_schema, ObInnerTableSchema::gv_session_event_schema, ObInnerTableSchema::gv_session_wait_schema, ObInnerTableSchema::gv_session_wait_history_schema, @@ -4491,6 +4530,7 @@ const schema_create_func sys_view_schema_creators [] = { ObInnerTableSchema::dba_mvref_stmt_stats_schema, ObInnerTableSchema::gv_ob_tracepoint_info_schema, ObInnerTableSchema::v_ob_tracepoint_info_schema, + ObInnerTableSchema::v_ob_compatibility_control_schema, ObInnerTableSchema::gv_ob_tenant_resource_limit_schema, ObInnerTableSchema::v_ob_tenant_resource_limit_schema, ObInnerTableSchema::gv_ob_tenant_resource_limit_detail_schema, @@ -4772,6 +4812,7 @@ const schema_create_func sys_view_schema_creators [] = { ObInnerTableSchema::user_mvref_change_stats_ora_schema, ObInnerTableSchema::dba_mvref_stmt_stats_ora_schema, ObInnerTableSchema::user_mvref_stmt_stats_ora_schema, + ObInnerTableSchema::proxy_users_schema, ObInnerTableSchema::gv_ob_sql_audit_ora_schema, ObInnerTableSchema::v_ob_sql_audit_ora_schema, ObInnerTableSchema::gv_instance_schema, @@ -5069,6 +5110,9 @@ const schema_create_func sys_index_table_schema_creators [] = { ObInnerTableSchema::all_transfer_partition_task_idx_transfer_partition_key_schema, ObInnerTableSchema::all_client_to_server_session_info_idx_client_to_server_session_info_client_session_id_schema, ObInnerTableSchema::all_column_privilege_idx_column_privilege_name_schema, + ObInnerTableSchema::all_user_proxy_info_idx_user_proxy_info_proxy_user_id_schema, + ObInnerTableSchema::all_user_proxy_info_history_idx_user_proxy_info_proxy_user_id_history_schema, + ObInnerTableSchema::all_user_proxy_role_info_history_idx_user_proxy_role_info_proxy_user_id_history_schema, NULL,}; const schema_create_func information_schema_table_schema_creators[] = { @@ -5348,6 +5392,10 @@ const uint64_t tenant_space_tables [] = { OB_ALL_COLUMN_PRIVILEGE_TID, OB_ALL_COLUMN_PRIVILEGE_HISTORY_TID, OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_TID, + OB_ALL_USER_PROXY_INFO_TID, + OB_ALL_USER_PROXY_INFO_HISTORY_TID, + OB_ALL_USER_PROXY_ROLE_INFO_TID, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID, OB_ALL_MVIEW_DEP_TID, OB_TENANT_VIRTUAL_ALL_TABLE_TID, OB_TENANT_VIRTUAL_TABLE_COLUMN_TID, @@ -5577,6 +5625,7 @@ const uint64_t tenant_space_tables [] = { OB_ALL_VIRTUAL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_TID, OB_ENABLED_ROLES_TID, OB_ALL_VIRTUAL_TRACEPOINT_INFO_TID, + OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_TID, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_TID, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_TID, OB_ALL_VIRTUAL_NIC_INFO_TID, @@ -5855,6 +5904,8 @@ const uint64_t tenant_space_tables [] = { OB_ALL_VIRTUAL_LS_SNAPSHOT_ORA_TID, OB_ALL_VIRTUAL_INDEX_USAGE_INFO_REAL_AGENT_ORA_TID, OB_ALL_VIRTUAL_TRACEPOINT_INFO_ORA_TID, + OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TID, + OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA_TID, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_ORA_TID, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_ORA_TID, OB_ALL_VIRTUAL_NIC_INFO_ORA_TID, @@ -5872,6 +5923,7 @@ const uint64_t tenant_space_tables [] = { OB_KEY_COLUMN_USAGE_TID, OB_ENGINES_TID, OB_ROUTINES_TID, + OB_PROFILING_TID, OB_GV_SESSION_EVENT_TID, OB_GV_SESSION_WAIT_TID, OB_GV_SESSION_WAIT_HISTORY_TID, @@ -6148,6 +6200,7 @@ const uint64_t tenant_space_tables [] = { OB_DBA_MVREF_STMT_STATS_TID, OB_GV_OB_TRACEPOINT_INFO_TID, OB_V_OB_TRACEPOINT_INFO_TID, + OB_V_OB_COMPATIBILITY_CONTROL_TID, OB_GV_OB_TENANT_RESOURCE_LIMIT_TID, OB_V_OB_TENANT_RESOURCE_LIMIT_TID, OB_GV_OB_TENANT_RESOURCE_LIMIT_DETAIL_TID, @@ -6429,6 +6482,7 @@ const uint64_t tenant_space_tables [] = { OB_USER_MVREF_CHANGE_STATS_ORA_TID, OB_DBA_MVREF_STMT_STATS_ORA_TID, OB_USER_MVREF_STMT_STATS_ORA_TID, + OB_PROXY_USERS_TID, OB_GV_OB_SQL_AUDIT_ORA_TID, OB_V_OB_SQL_AUDIT_ORA_TID, OB_GV_INSTANCE_TID, @@ -6714,6 +6768,9 @@ const uint64_t tenant_space_tables [] = { OB_ALL_TRANSFER_PARTITION_TASK_IDX_TRANSFER_PARTITION_KEY_TID, OB_ALL_CLIENT_TO_SERVER_SESSION_INFO_IDX_CLIENT_TO_SERVER_SESSION_INFO_CLIENT_SESSION_ID_TID, OB_ALL_COLUMN_PRIVILEGE_IDX_COLUMN_PRIVILEGE_NAME_TID, + OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TID, + OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TID, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TID, OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_DATA_TABLE_ID_REAL_AGENT_TID, OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_DB_TB_NAME_REAL_AGENT_TID, OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_TB_NAME_REAL_AGENT_TID, @@ -6786,6 +6843,7 @@ const uint64_t tenant_space_tables [] = { OB_ALL_VIRTUAL_RLS_CONTEXT_REAL_AGENT_ORA_IDX_RLS_CONTEXT_TABLE_ID_REAL_AGENT_TID, OB_ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA_IDX_DBMS_LOCK_ALLOCATED_LOCKHANDLE_REAL_AGENT_TID, OB_ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA_IDX_DBMS_LOCK_ALLOCATED_EXPIRATION_REAL_AGENT_TID, + OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_IDX_USER_PROXY_INFO_PROXY_USER_ID_REAL_AGENT_TID, OB_ALL_TABLE_AUX_LOB_META_TID, OB_ALL_COLUMN_AUX_LOB_META_TID, OB_ALL_DDL_OPERATION_AUX_LOB_META_TID, @@ -7055,6 +7113,10 @@ const uint64_t tenant_space_tables [] = { OB_ALL_COLUMN_PRIVILEGE_AUX_LOB_META_TID, OB_ALL_COLUMN_PRIVILEGE_HISTORY_AUX_LOB_META_TID, OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_AUX_LOB_META_TID, + OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TID, + OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TID, + OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TID, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TID, OB_ALL_MVIEW_DEP_AUX_LOB_META_TID, OB_ALL_TABLE_AUX_LOB_PIECE_TID, OB_ALL_COLUMN_AUX_LOB_PIECE_TID, @@ -7325,6 +7387,10 @@ const uint64_t tenant_space_tables [] = { OB_ALL_COLUMN_PRIVILEGE_AUX_LOB_PIECE_TID, OB_ALL_COLUMN_PRIVILEGE_HISTORY_AUX_LOB_PIECE_TID, OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_AUX_LOB_PIECE_TID, + OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TID, + OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TID, + OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TID, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TID, OB_ALL_MVIEW_DEP_AUX_LOB_PIECE_TID, }; const uint64_t all_ora_mapping_virtual_table_org_tables [] = { @@ -7903,6 +7969,10 @@ const char* const tenant_space_table_names [] = { OB_ALL_COLUMN_PRIVILEGE_TNAME, OB_ALL_COLUMN_PRIVILEGE_HISTORY_TNAME, OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_TNAME, + OB_ALL_USER_PROXY_INFO_TNAME, + OB_ALL_USER_PROXY_INFO_HISTORY_TNAME, + OB_ALL_USER_PROXY_ROLE_INFO_TNAME, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TNAME, OB_ALL_MVIEW_DEP_TNAME, OB_TENANT_VIRTUAL_ALL_TABLE_TNAME, OB_TENANT_VIRTUAL_TABLE_COLUMN_TNAME, @@ -8132,6 +8202,7 @@ const char* const tenant_space_table_names [] = { OB_ALL_VIRTUAL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_TNAME, OB_ENABLED_ROLES_TNAME, OB_ALL_VIRTUAL_TRACEPOINT_INFO_TNAME, + OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_TNAME, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_TNAME, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_TNAME, OB_ALL_VIRTUAL_NIC_INFO_TNAME, @@ -8410,6 +8481,8 @@ const char* const tenant_space_table_names [] = { OB_ALL_VIRTUAL_LS_SNAPSHOT_ORA_TNAME, OB_ALL_VIRTUAL_INDEX_USAGE_INFO_REAL_AGENT_ORA_TNAME, OB_ALL_VIRTUAL_TRACEPOINT_INFO_ORA_TNAME, + OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TNAME, + OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA_TNAME, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_ORA_TNAME, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_ORA_TNAME, OB_ALL_VIRTUAL_NIC_INFO_ORA_TNAME, @@ -8427,6 +8500,7 @@ const char* const tenant_space_table_names [] = { OB_KEY_COLUMN_USAGE_TNAME, OB_ENGINES_TNAME, OB_ROUTINES_TNAME, + OB_PROFILING_TNAME, OB_GV_SESSION_EVENT_TNAME, OB_GV_SESSION_WAIT_TNAME, OB_GV_SESSION_WAIT_HISTORY_TNAME, @@ -8703,6 +8777,7 @@ const char* const tenant_space_table_names [] = { OB_DBA_MVREF_STMT_STATS_TNAME, OB_GV_OB_TRACEPOINT_INFO_TNAME, OB_V_OB_TRACEPOINT_INFO_TNAME, + OB_V_OB_COMPATIBILITY_CONTROL_TNAME, OB_GV_OB_TENANT_RESOURCE_LIMIT_TNAME, OB_V_OB_TENANT_RESOURCE_LIMIT_TNAME, OB_GV_OB_TENANT_RESOURCE_LIMIT_DETAIL_TNAME, @@ -8984,6 +9059,7 @@ const char* const tenant_space_table_names [] = { OB_USER_MVREF_CHANGE_STATS_ORA_TNAME, OB_DBA_MVREF_STMT_STATS_ORA_TNAME, OB_USER_MVREF_STMT_STATS_ORA_TNAME, + OB_PROXY_USERS_TNAME, OB_GV_OB_SQL_AUDIT_ORA_TNAME, OB_V_OB_SQL_AUDIT_ORA_TNAME, OB_GV_INSTANCE_TNAME, @@ -9269,6 +9345,9 @@ const char* const tenant_space_table_names [] = { OB_ALL_TRANSFER_PARTITION_TASK_IDX_TRANSFER_PARTITION_KEY_TNAME, OB_ALL_CLIENT_TO_SERVER_SESSION_INFO_IDX_CLIENT_TO_SERVER_SESSION_INFO_CLIENT_SESSION_ID_TNAME, OB_ALL_COLUMN_PRIVILEGE_IDX_COLUMN_PRIVILEGE_NAME_TNAME, + OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TNAME, + OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TNAME, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TNAME, OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_DATA_TABLE_ID_REAL_AGENT_TNAME, OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_DB_TB_NAME_REAL_AGENT_TNAME, OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_TB_NAME_REAL_AGENT_TNAME, @@ -9341,6 +9420,7 @@ const char* const tenant_space_table_names [] = { OB_ALL_VIRTUAL_RLS_CONTEXT_REAL_AGENT_ORA_IDX_RLS_CONTEXT_TABLE_ID_REAL_AGENT_TNAME, OB_ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA_IDX_DBMS_LOCK_ALLOCATED_LOCKHANDLE_REAL_AGENT_TNAME, OB_ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA_IDX_DBMS_LOCK_ALLOCATED_EXPIRATION_REAL_AGENT_TNAME, + OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_IDX_USER_PROXY_INFO_PROXY_USER_ID_REAL_AGENT_TNAME, OB_ALL_TABLE_AUX_LOB_META_TNAME, OB_ALL_COLUMN_AUX_LOB_META_TNAME, OB_ALL_DDL_OPERATION_AUX_LOB_META_TNAME, @@ -9610,6 +9690,10 @@ const char* const tenant_space_table_names [] = { OB_ALL_COLUMN_PRIVILEGE_AUX_LOB_META_TNAME, OB_ALL_COLUMN_PRIVILEGE_HISTORY_AUX_LOB_META_TNAME, OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_AUX_LOB_META_TNAME, + OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TNAME, + OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TNAME, + OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TNAME, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TNAME, OB_ALL_MVIEW_DEP_AUX_LOB_META_TNAME, OB_ALL_TABLE_AUX_LOB_PIECE_TNAME, OB_ALL_COLUMN_AUX_LOB_PIECE_TNAME, @@ -9880,6 +9964,10 @@ const char* const tenant_space_table_names [] = { OB_ALL_COLUMN_PRIVILEGE_AUX_LOB_PIECE_TNAME, OB_ALL_COLUMN_PRIVILEGE_HISTORY_AUX_LOB_PIECE_TNAME, OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_AUX_LOB_PIECE_TNAME, + OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TNAME, + OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TNAME, + OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TNAME, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TNAME, OB_ALL_MVIEW_DEP_AUX_LOB_PIECE_TNAME, }; const uint64_t only_rs_vtables [] = { @@ -10236,6 +10324,8 @@ const uint64_t restrict_access_virtual_tables[] = { OB_ALL_VIRTUAL_LS_SNAPSHOT_ORA_TID, OB_ALL_VIRTUAL_INDEX_USAGE_INFO_REAL_AGENT_ORA_TID, OB_ALL_VIRTUAL_TRACEPOINT_INFO_ORA_TID, + OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TID, + OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA_TID, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_ORA_TID, OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_ORA_TID, OB_ALL_VIRTUAL_NIC_INFO_ORA_TID }; @@ -12729,6 +12819,38 @@ LOBMapping const lob_aux_table_mappings [] = { ObInnerTableSchema::all_tenant_snapshot_ls_replica_history_aux_lob_piece_schema }, + { + OB_ALL_USER_PROXY_INFO_TID, + OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TID, + OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TID, + ObInnerTableSchema::all_user_proxy_info_aux_lob_meta_schema, + ObInnerTableSchema::all_user_proxy_info_aux_lob_piece_schema + }, + + { + OB_ALL_USER_PROXY_INFO_HISTORY_TID, + OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TID, + OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TID, + ObInnerTableSchema::all_user_proxy_info_history_aux_lob_meta_schema, + ObInnerTableSchema::all_user_proxy_info_history_aux_lob_piece_schema + }, + + { + OB_ALL_USER_PROXY_ROLE_INFO_TID, + OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TID, + OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TID, + ObInnerTableSchema::all_user_proxy_role_info_aux_lob_meta_schema, + ObInnerTableSchema::all_user_proxy_role_info_aux_lob_piece_schema + }, + + { + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TID, + OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TID, + ObInnerTableSchema::all_user_proxy_role_info_history_aux_lob_meta_schema, + ObInnerTableSchema::all_user_proxy_role_info_history_aux_lob_piece_schema + }, + { OB_ALL_MVIEW_DEP_TID, OB_ALL_MVIEW_DEP_AUX_LOB_META_TID, @@ -12774,12 +12896,12 @@ static inline int get_sys_table_lob_aux_schema(const uint64_t tid, } const int64_t OB_CORE_TABLE_COUNT = 4; -const int64_t OB_SYS_TABLE_COUNT = 291; -const int64_t OB_VIRTUAL_TABLE_COUNT = 806; -const int64_t OB_SYS_VIEW_COUNT = 876; -const int64_t OB_SYS_TENANT_TABLE_COUNT = 1978; +const int64_t OB_SYS_TABLE_COUNT = 295; +const int64_t OB_VIRTUAL_TABLE_COUNT = 814; +const int64_t OB_SYS_VIEW_COUNT = 879; +const int64_t OB_SYS_TENANT_TABLE_COUNT = 1993; const int64_t OB_CORE_SCHEMA_VERSION = 1; -const int64_t OB_BOOTSTRAP_SCHEMA_VERSION = 1981; +const int64_t OB_BOOTSTRAP_SCHEMA_VERSION = 1996; } // end namespace share } // end namespace oceanbase diff --git a/src/share/inner_table/ob_inner_table_schema.lob.cpp b/src/share/inner_table/ob_inner_table_schema.lob.cpp index 406bcb1932..97364a9901 100644 --- a/src/share/inner_table/ob_inner_table_schema.lob.cpp +++ b/src/share/inner_table/ob_inner_table_schema.lob.cpp @@ -21,7 +21,7 @@ inner_lob_map_t inner_lob_map; bool lob_mapping_init() { int ret = OB_SUCCESS; - if (OB_FAIL(inner_lob_map.create(294, ObModIds::OB_INNER_LOB_HASH_SET))) { + if (OB_FAIL(inner_lob_map.create(298, ObModIds::OB_INNER_LOB_HASH_SET))) { SERVER_LOG(WARN, "fail to create inner lob map", K(ret)); } else { for (int64_t i = 0; OB_SUCC(ret) && i < ARRAYSIZEOF(lob_aux_table_mappings); ++i) { diff --git a/src/share/inner_table/ob_inner_table_schema.vt.cpp b/src/share/inner_table/ob_inner_table_schema.vt.cpp index 7c061cb1cd..0ec17ad729 100644 --- a/src/share/inner_table/ob_inner_table_schema.vt.cpp +++ b/src/share/inner_table/ob_inner_table_schema.vt.cpp @@ -1253,6 +1253,27 @@ bool vt_mapping_init() tmp_vt_mapping.is_real_vt_ = true; } + { + int64_t idx = OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TID - start_idx; + VTMapping &tmp_vt_mapping = vt_mappings[idx]; + tmp_vt_mapping.mapping_tid_ = OB_ALL_USER_PROXY_INFO_TID; + tmp_vt_mapping.is_real_vt_ = true; + } + + { + int64_t idx = OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_IDX_USER_PROXY_INFO_PROXY_USER_ID_REAL_AGENT_TID - start_idx; + VTMapping &tmp_vt_mapping = vt_mappings[idx]; + tmp_vt_mapping.mapping_tid_ = OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TID; + tmp_vt_mapping.is_real_vt_ = true; + } + + { + int64_t idx = OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA_TID - start_idx; + VTMapping &tmp_vt_mapping = vt_mappings[idx]; + tmp_vt_mapping.mapping_tid_ = OB_ALL_USER_PROXY_ROLE_INFO_TID; + tmp_vt_mapping.is_real_vt_ = true; + } + { int64_t idx = OB_ALL_VIRTUAL_USER_REAL_AGENT_ORA_TID - start_idx; VTMapping &tmp_vt_mapping = vt_mappings[idx]; diff --git a/src/share/inner_table/ob_inner_table_schema_constants.h b/src/share/inner_table/ob_inner_table_schema_constants.h index a926d56689..669b15c3b2 100644 --- a/src/share/inner_table/ob_inner_table_schema_constants.h +++ b/src/share/inner_table/ob_inner_table_schema_constants.h @@ -321,6 +321,10 @@ const uint64_t OB_ALL_TRUSTED_ROOT_CERTIFICATE_TID = 502; // "__all_trusted_root const uint64_t OB_ALL_COLUMN_PRIVILEGE_TID = 505; // "__all_column_privilege" const uint64_t OB_ALL_COLUMN_PRIVILEGE_HISTORY_TID = 506; // "__all_column_privilege_history" const uint64_t OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_TID = 507; // "__all_tenant_snapshot_ls_replica_history" +const uint64_t OB_ALL_USER_PROXY_INFO_TID = 512; // "__all_user_proxy_info" +const uint64_t OB_ALL_USER_PROXY_INFO_HISTORY_TID = 513; // "__all_user_proxy_info_history" +const uint64_t OB_ALL_USER_PROXY_ROLE_INFO_TID = 514; // "__all_user_proxy_role_info" +const uint64_t OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID = 515; // "__all_user_proxy_role_info_history" const uint64_t OB_ALL_MVIEW_DEP_TID = 518; // "__all_mview_dep" const uint64_t OB_TENANT_VIRTUAL_ALL_TABLE_TID = 10001; // "__tenant_virtual_all_table" const uint64_t OB_TENANT_VIRTUAL_TABLE_COLUMN_TID = 10002; // "__tenant_virtual_table_column" @@ -765,6 +769,11 @@ const uint64_t OB_ALL_VIRTUAL_COLUMN_PRIVILEGE_HISTORY_TID = 12463; // "__all_vi const uint64_t OB_ALL_VIRTUAL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_TID = 12464; // "__all_virtual_tenant_snapshot_ls_replica_history" const uint64_t OB_ENABLED_ROLES_TID = 12466; // "ENABLED_ROLES" const uint64_t OB_ALL_VIRTUAL_TRACEPOINT_INFO_TID = 12469; // "__all_virtual_tracepoint_info" +const uint64_t OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_TID = 12473; // "__all_virtual_compatibility_control" +const uint64_t OB_ALL_VIRTUAL_USER_PROXY_INFO_TID = 12474; // "__all_virtual_user_proxy_info" +const uint64_t OB_ALL_VIRTUAL_USER_PROXY_INFO_HISTORY_TID = 12475; // "__all_virtual_user_proxy_info_history" +const uint64_t OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_TID = 12476; // "__all_virtual_user_proxy_role_info" +const uint64_t OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_HISTORY_TID = 12477; // "__all_virtual_user_proxy_role_info_history" const uint64_t OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_TID = 12481; // "__all_virtual_tenant_resource_limit" const uint64_t OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_TID = 12482; // "__all_virtual_tenant_resource_limit_detail" const uint64_t OB_ALL_VIRTUAL_NIC_INFO_TID = 12487; // "__all_virtual_nic_info" @@ -1034,6 +1043,8 @@ const uint64_t OB_ALL_VIRTUAL_TRANSFER_PARTITION_TASK_HISTORY_REAL_AGENT_ORA_TID const uint64_t OB_ALL_VIRTUAL_LS_SNAPSHOT_ORA_TID = 15439; // "ALL_VIRTUAL_LS_SNAPSHOT_ORA" const uint64_t OB_ALL_VIRTUAL_INDEX_USAGE_INFO_REAL_AGENT_ORA_TID = 15440; // "ALL_VIRTUAL_INDEX_USAGE_INFO_REAL_AGENT_ORA" const uint64_t OB_ALL_VIRTUAL_TRACEPOINT_INFO_ORA_TID = 15445; // "ALL_VIRTUAL_TRACEPOINT_INFO_ORA" +const uint64_t OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TID = 15446; // "ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA" +const uint64_t OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA_TID = 15447; // "ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA" const uint64_t OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_ORA_TID = 15450; // "ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_ORA" const uint64_t OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_ORA_TID = 15451; // "ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_ORA" const uint64_t OB_ALL_VIRTUAL_NIC_INFO_ORA_TID = 15456; // "ALL_VIRTUAL_NIC_INFO_ORA" @@ -1051,6 +1062,7 @@ const uint64_t OB_PROCESSLIST_TID = 20011; // "PROCESSLIST" const uint64_t OB_KEY_COLUMN_USAGE_TID = 20012; // "KEY_COLUMN_USAGE" const uint64_t OB_ENGINES_TID = 20014; // "ENGINES" const uint64_t OB_ROUTINES_TID = 20015; // "ROUTINES" +const uint64_t OB_PROFILING_TID = 20016; // "PROFILING" const uint64_t OB_GV_SESSION_EVENT_TID = 21000; // "GV$SESSION_EVENT" const uint64_t OB_GV_SESSION_WAIT_TID = 21001; // "GV$SESSION_WAIT" const uint64_t OB_GV_SESSION_WAIT_HISTORY_TID = 21002; // "GV$SESSION_WAIT_HISTORY" @@ -1446,6 +1458,7 @@ const uint64_t OB_CDB_MVREF_STMT_STATS_TID = 21539; // "CDB_MVREF_STMT_STATS" const uint64_t OB_DBA_MVREF_STMT_STATS_TID = 21540; // "DBA_MVREF_STMT_STATS" const uint64_t OB_GV_OB_TRACEPOINT_INFO_TID = 21543; // "GV$OB_TRACEPOINT_INFO" const uint64_t OB_V_OB_TRACEPOINT_INFO_TID = 21544; // "V$OB_TRACEPOINT_INFO" +const uint64_t OB_V_OB_COMPATIBILITY_CONTROL_TID = 21545; // "V$OB_COMPATIBILITY_CONTROL" const uint64_t OB_GV_OB_TENANT_RESOURCE_LIMIT_TID = 21550; // "GV$OB_TENANT_RESOURCE_LIMIT" const uint64_t OB_V_OB_TENANT_RESOURCE_LIMIT_TID = 21551; // "V$OB_TENANT_RESOURCE_LIMIT" const uint64_t OB_GV_OB_TENANT_RESOURCE_LIMIT_DETAIL_TID = 21552; // "GV$OB_TENANT_RESOURCE_LIMIT_DETAIL" @@ -1727,6 +1740,7 @@ const uint64_t OB_DBA_MVREF_CHANGE_STATS_ORA_TID = 25297; // "DBA_MVREF_CHANGE_S const uint64_t OB_USER_MVREF_CHANGE_STATS_ORA_TID = 25298; // "USER_MVREF_CHANGE_STATS_ORA" const uint64_t OB_DBA_MVREF_STMT_STATS_ORA_TID = 25299; // "DBA_MVREF_STMT_STATS_ORA" const uint64_t OB_USER_MVREF_STMT_STATS_ORA_TID = 25300; // "USER_MVREF_STMT_STATS_ORA" +const uint64_t OB_PROXY_USERS_TID = 25301; // "PROXY_USERS" const uint64_t OB_GV_OB_SQL_AUDIT_ORA_TID = 28002; // "GV$OB_SQL_AUDIT_ORA" const uint64_t OB_V_OB_SQL_AUDIT_ORA_TID = 28003; // "V$OB_SQL_AUDIT_ORA" const uint64_t OB_GV_INSTANCE_TID = 28004; // "GV$INSTANCE" @@ -2206,6 +2220,10 @@ const uint64_t OB_ALL_TRUSTED_ROOT_CERTIFICATE_AUX_LOB_META_TID = 50502; // "__a const uint64_t OB_ALL_COLUMN_PRIVILEGE_AUX_LOB_META_TID = 50505; // "__all_column_privilege_aux_lob_meta" const uint64_t OB_ALL_COLUMN_PRIVILEGE_HISTORY_AUX_LOB_META_TID = 50506; // "__all_column_privilege_history_aux_lob_meta" const uint64_t OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_AUX_LOB_META_TID = 50507; // "__all_tenant_snapshot_ls_replica_history_aux_lob_meta" +const uint64_t OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TID = 50512; // "__all_user_proxy_info_aux_lob_meta" +const uint64_t OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TID = 50513; // "__all_user_proxy_info_history_aux_lob_meta" +const uint64_t OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TID = 50514; // "__all_user_proxy_role_info_aux_lob_meta" +const uint64_t OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TID = 50515; // "__all_user_proxy_role_info_history_aux_lob_meta" const uint64_t OB_ALL_MVIEW_DEP_AUX_LOB_META_TID = 50518; // "__all_mview_dep_aux_lob_meta" const uint64_t OB_ALL_TABLE_AUX_LOB_PIECE_TID = 60003; // "__all_table_aux_lob_piece" const uint64_t OB_ALL_COLUMN_AUX_LOB_PIECE_TID = 60004; // "__all_column_aux_lob_piece" @@ -2500,6 +2518,10 @@ const uint64_t OB_ALL_TRUSTED_ROOT_CERTIFICATE_AUX_LOB_PIECE_TID = 60502; // "__ const uint64_t OB_ALL_COLUMN_PRIVILEGE_AUX_LOB_PIECE_TID = 60505; // "__all_column_privilege_aux_lob_piece" const uint64_t OB_ALL_COLUMN_PRIVILEGE_HISTORY_AUX_LOB_PIECE_TID = 60506; // "__all_column_privilege_history_aux_lob_piece" const uint64_t OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_AUX_LOB_PIECE_TID = 60507; // "__all_tenant_snapshot_ls_replica_history_aux_lob_piece" +const uint64_t OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TID = 60512; // "__all_user_proxy_info_aux_lob_piece" +const uint64_t OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TID = 60513; // "__all_user_proxy_info_history_aux_lob_piece" +const uint64_t OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TID = 60514; // "__all_user_proxy_role_info_aux_lob_piece" +const uint64_t OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TID = 60515; // "__all_user_proxy_role_info_history_aux_lob_piece" const uint64_t OB_ALL_MVIEW_DEP_AUX_LOB_PIECE_TID = 60518; // "__all_mview_dep_aux_lob_piece" const uint64_t OB_ALL_VIRTUAL_PLAN_CACHE_STAT_ALL_VIRTUAL_PLAN_CACHE_STAT_I1_TID = 14999; // "__all_virtual_plan_cache_stat" const uint64_t OB_ALL_VIRTUAL_SESSION_EVENT_ALL_VIRTUAL_SESSION_EVENT_I1_TID = 14998; // "__all_virtual_session_event" @@ -2625,6 +2647,9 @@ const uint64_t OB_ALL_MVIEW_REFRESH_STATS_IDX_MVIEW_REFRESH_STATS_MVIEW_END_TIME const uint64_t OB_ALL_TRANSFER_PARTITION_TASK_IDX_TRANSFER_PARTITION_KEY_TID = 101098; // "__all_transfer_partition_task" const uint64_t OB_ALL_CLIENT_TO_SERVER_SESSION_INFO_IDX_CLIENT_TO_SERVER_SESSION_INFO_CLIENT_SESSION_ID_TID = 101099; // "__all_client_to_server_session_info" const uint64_t OB_ALL_COLUMN_PRIVILEGE_IDX_COLUMN_PRIVILEGE_NAME_TID = 101100; // "__all_column_privilege" +const uint64_t OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TID = 101101; // "__all_user_proxy_info" +const uint64_t OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TID = 101102; // "__all_user_proxy_info_history" +const uint64_t OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TID = 101103; // "__all_user_proxy_role_info_history" const uint64_t OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_DATA_TABLE_ID_REAL_AGENT_TID = 15306; // "ALL_VIRTUAL_TABLE_REAL_AGENT_ORA" const uint64_t OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_DB_TB_NAME_REAL_AGENT_TID = 15307; // "ALL_VIRTUAL_TABLE_REAL_AGENT_ORA" const uint64_t OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_TB_NAME_REAL_AGENT_TID = 15308; // "ALL_VIRTUAL_TABLE_REAL_AGENT_ORA" @@ -2697,6 +2722,7 @@ const uint64_t OB_ALL_VIRTUAL_RLS_GROUP_REAL_AGENT_ORA_IDX_RLS_GROUP_TABLE_ID_RE const uint64_t OB_ALL_VIRTUAL_RLS_CONTEXT_REAL_AGENT_ORA_IDX_RLS_CONTEXT_TABLE_ID_REAL_AGENT_TID = 15375; // "ALL_VIRTUAL_RLS_CONTEXT_REAL_AGENT_ORA" const uint64_t OB_ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA_IDX_DBMS_LOCK_ALLOCATED_LOCKHANDLE_REAL_AGENT_TID = 15415; // "ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA" const uint64_t OB_ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA_IDX_DBMS_LOCK_ALLOCATED_EXPIRATION_REAL_AGENT_TID = 15416; // "ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA" +const uint64_t OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_IDX_USER_PROXY_INFO_PROXY_USER_ID_REAL_AGENT_TID = 15448; // "ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA" const char *const OB_ALL_CORE_TABLE_TNAME = "__all_core_table"; const char *const OB_ALL_TABLE_TNAME = "__all_table"; @@ -2992,6 +3018,10 @@ const char *const OB_ALL_TRUSTED_ROOT_CERTIFICATE_TNAME = "__all_trusted_root_ce const char *const OB_ALL_COLUMN_PRIVILEGE_TNAME = "__all_column_privilege"; const char *const OB_ALL_COLUMN_PRIVILEGE_HISTORY_TNAME = "__all_column_privilege_history"; const char *const OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_TNAME = "__all_tenant_snapshot_ls_replica_history"; +const char *const OB_ALL_USER_PROXY_INFO_TNAME = "__all_user_proxy_info"; +const char *const OB_ALL_USER_PROXY_INFO_HISTORY_TNAME = "__all_user_proxy_info_history"; +const char *const OB_ALL_USER_PROXY_ROLE_INFO_TNAME = "__all_user_proxy_role_info"; +const char *const OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TNAME = "__all_user_proxy_role_info_history"; const char *const OB_ALL_MVIEW_DEP_TNAME = "__all_mview_dep"; const char *const OB_TENANT_VIRTUAL_ALL_TABLE_TNAME = "__tenant_virtual_all_table"; const char *const OB_TENANT_VIRTUAL_TABLE_COLUMN_TNAME = "__tenant_virtual_table_column"; @@ -3436,6 +3466,11 @@ const char *const OB_ALL_VIRTUAL_COLUMN_PRIVILEGE_HISTORY_TNAME = "__all_virtual const char *const OB_ALL_VIRTUAL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_TNAME = "__all_virtual_tenant_snapshot_ls_replica_history"; const char *const OB_ENABLED_ROLES_TNAME = "ENABLED_ROLES"; const char *const OB_ALL_VIRTUAL_TRACEPOINT_INFO_TNAME = "__all_virtual_tracepoint_info"; +const char *const OB_ALL_VIRTUAL_COMPATIBILITY_CONTROL_TNAME = "__all_virtual_compatibility_control"; +const char *const OB_ALL_VIRTUAL_USER_PROXY_INFO_TNAME = "__all_virtual_user_proxy_info"; +const char *const OB_ALL_VIRTUAL_USER_PROXY_INFO_HISTORY_TNAME = "__all_virtual_user_proxy_info_history"; +const char *const OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_TNAME = "__all_virtual_user_proxy_role_info"; +const char *const OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_HISTORY_TNAME = "__all_virtual_user_proxy_role_info_history"; const char *const OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_TNAME = "__all_virtual_tenant_resource_limit"; const char *const OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_TNAME = "__all_virtual_tenant_resource_limit_detail"; const char *const OB_ALL_VIRTUAL_NIC_INFO_TNAME = "__all_virtual_nic_info"; @@ -3705,6 +3740,8 @@ const char *const OB_ALL_VIRTUAL_TRANSFER_PARTITION_TASK_HISTORY_REAL_AGENT_ORA_ const char *const OB_ALL_VIRTUAL_LS_SNAPSHOT_ORA_TNAME = "ALL_VIRTUAL_LS_SNAPSHOT"; const char *const OB_ALL_VIRTUAL_INDEX_USAGE_INFO_REAL_AGENT_ORA_TNAME = "ALL_VIRTUAL_INDEX_USAGE_INFO_REAL_AGENT"; const char *const OB_ALL_VIRTUAL_TRACEPOINT_INFO_ORA_TNAME = "ALL_VIRTUAL_TRACEPOINT_INFO"; +const char *const OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_TNAME = "ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT"; +const char *const OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT_ORA_TNAME = "ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT"; const char *const OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_ORA_TNAME = "ALL_VIRTUAL_TENANT_RESOURCE_LIMIT"; const char *const OB_ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL_ORA_TNAME = "ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL"; const char *const OB_ALL_VIRTUAL_NIC_INFO_ORA_TNAME = "ALL_VIRTUAL_NIC_INFO"; @@ -3722,6 +3759,7 @@ const char *const OB_PROCESSLIST_TNAME = "PROCESSLIST"; const char *const OB_KEY_COLUMN_USAGE_TNAME = "KEY_COLUMN_USAGE"; const char *const OB_ENGINES_TNAME = "ENGINES"; const char *const OB_ROUTINES_TNAME = "ROUTINES"; +const char *const OB_PROFILING_TNAME = "PROFILING"; const char *const OB_GV_SESSION_EVENT_TNAME = "GV$SESSION_EVENT"; const char *const OB_GV_SESSION_WAIT_TNAME = "GV$SESSION_WAIT"; const char *const OB_GV_SESSION_WAIT_HISTORY_TNAME = "GV$SESSION_WAIT_HISTORY"; @@ -4117,6 +4155,7 @@ const char *const OB_CDB_MVREF_STMT_STATS_TNAME = "CDB_MVREF_STMT_STATS"; const char *const OB_DBA_MVREF_STMT_STATS_TNAME = "DBA_MVREF_STMT_STATS"; const char *const OB_GV_OB_TRACEPOINT_INFO_TNAME = "GV$OB_TRACEPOINT_INFO"; const char *const OB_V_OB_TRACEPOINT_INFO_TNAME = "V$OB_TRACEPOINT_INFO"; +const char *const OB_V_OB_COMPATIBILITY_CONTROL_TNAME = "V$OB_COMPATIBILITY_CONTROL"; const char *const OB_GV_OB_TENANT_RESOURCE_LIMIT_TNAME = "GV$OB_TENANT_RESOURCE_LIMIT"; const char *const OB_V_OB_TENANT_RESOURCE_LIMIT_TNAME = "V$OB_TENANT_RESOURCE_LIMIT"; const char *const OB_GV_OB_TENANT_RESOURCE_LIMIT_DETAIL_TNAME = "GV$OB_TENANT_RESOURCE_LIMIT_DETAIL"; @@ -4398,6 +4437,7 @@ const char *const OB_DBA_MVREF_CHANGE_STATS_ORA_TNAME = "DBA_MVREF_CHANGE_STATS" const char *const OB_USER_MVREF_CHANGE_STATS_ORA_TNAME = "USER_MVREF_CHANGE_STATS"; const char *const OB_DBA_MVREF_STMT_STATS_ORA_TNAME = "DBA_MVREF_STMT_STATS"; const char *const OB_USER_MVREF_STMT_STATS_ORA_TNAME = "USER_MVREF_STMT_STATS"; +const char *const OB_PROXY_USERS_TNAME = "PROXY_USERS"; const char *const OB_GV_OB_SQL_AUDIT_ORA_TNAME = "GV$OB_SQL_AUDIT"; const char *const OB_V_OB_SQL_AUDIT_ORA_TNAME = "V$OB_SQL_AUDIT"; const char *const OB_GV_INSTANCE_TNAME = "GV$INSTANCE"; @@ -4877,6 +4917,10 @@ const char *const OB_ALL_TRUSTED_ROOT_CERTIFICATE_AUX_LOB_META_TNAME = "__all_tr const char *const OB_ALL_COLUMN_PRIVILEGE_AUX_LOB_META_TNAME = "__all_column_privilege_aux_lob_meta"; const char *const OB_ALL_COLUMN_PRIVILEGE_HISTORY_AUX_LOB_META_TNAME = "__all_column_privilege_history_aux_lob_meta"; const char *const OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_AUX_LOB_META_TNAME = "__all_tenant_snapshot_ls_replica_history_aux_lob_meta"; +const char *const OB_ALL_USER_PROXY_INFO_AUX_LOB_META_TNAME = "__all_user_proxy_info_aux_lob_meta"; +const char *const OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_META_TNAME = "__all_user_proxy_info_history_aux_lob_meta"; +const char *const OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_META_TNAME = "__all_user_proxy_role_info_aux_lob_meta"; +const char *const OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_META_TNAME = "__all_user_proxy_role_info_history_aux_lob_meta"; const char *const OB_ALL_MVIEW_DEP_AUX_LOB_META_TNAME = "__all_mview_dep_aux_lob_meta"; const char *const OB_ALL_TABLE_AUX_LOB_PIECE_TNAME = "__all_table_aux_lob_piece"; const char *const OB_ALL_COLUMN_AUX_LOB_PIECE_TNAME = "__all_column_aux_lob_piece"; @@ -5171,6 +5215,10 @@ const char *const OB_ALL_TRUSTED_ROOT_CERTIFICATE_AUX_LOB_PIECE_TNAME = "__all_t const char *const OB_ALL_COLUMN_PRIVILEGE_AUX_LOB_PIECE_TNAME = "__all_column_privilege_aux_lob_piece"; const char *const OB_ALL_COLUMN_PRIVILEGE_HISTORY_AUX_LOB_PIECE_TNAME = "__all_column_privilege_history_aux_lob_piece"; const char *const OB_ALL_TENANT_SNAPSHOT_LS_REPLICA_HISTORY_AUX_LOB_PIECE_TNAME = "__all_tenant_snapshot_ls_replica_history_aux_lob_piece"; +const char *const OB_ALL_USER_PROXY_INFO_AUX_LOB_PIECE_TNAME = "__all_user_proxy_info_aux_lob_piece"; +const char *const OB_ALL_USER_PROXY_INFO_HISTORY_AUX_LOB_PIECE_TNAME = "__all_user_proxy_info_history_aux_lob_piece"; +const char *const OB_ALL_USER_PROXY_ROLE_INFO_AUX_LOB_PIECE_TNAME = "__all_user_proxy_role_info_aux_lob_piece"; +const char *const OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_AUX_LOB_PIECE_TNAME = "__all_user_proxy_role_info_history_aux_lob_piece"; const char *const OB_ALL_MVIEW_DEP_AUX_LOB_PIECE_TNAME = "__all_mview_dep_aux_lob_piece"; const char *const OB_ALL_VIRTUAL_PLAN_CACHE_STAT_ALL_VIRTUAL_PLAN_CACHE_STAT_I1_TNAME = "__idx_11003_all_virtual_plan_cache_stat_i1"; const char *const OB_ALL_VIRTUAL_SESSION_EVENT_ALL_VIRTUAL_SESSION_EVENT_I1_TNAME = "__idx_11013_all_virtual_session_event_i1"; @@ -5296,6 +5344,9 @@ const char *const OB_ALL_MVIEW_REFRESH_STATS_IDX_MVIEW_REFRESH_STATS_MVIEW_END_T const char *const OB_ALL_TRANSFER_PARTITION_TASK_IDX_TRANSFER_PARTITION_KEY_TNAME = "__idx_498_idx_transfer_partition_key"; const char *const OB_ALL_CLIENT_TO_SERVER_SESSION_INFO_IDX_CLIENT_TO_SERVER_SESSION_INFO_CLIENT_SESSION_ID_TNAME = "__idx_497_idx_client_to_server_session_info_client_session_id"; const char *const OB_ALL_COLUMN_PRIVILEGE_IDX_COLUMN_PRIVILEGE_NAME_TNAME = "__idx_505_idx_column_privilege_name"; +const char *const OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TNAME = "__idx_512_idx_user_proxy_info_proxy_user_id"; +const char *const OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TNAME = "__idx_513_idx_user_proxy_info_proxy_user_id_history"; +const char *const OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TNAME = "__idx_515_idx_user_proxy_role_info_proxy_user_id_history"; const char *const OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_DATA_TABLE_ID_REAL_AGENT_TNAME = "__idx_15120_idx_data_table_id_real_agent"; const char *const OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_DB_TB_NAME_REAL_AGENT_TNAME = "__idx_15120_idx_db_tb_name_real_agent"; const char *const OB_ALL_VIRTUAL_TABLE_REAL_AGENT_ORA_IDX_TB_NAME_REAL_AGENT_TNAME = "__idx_15120_idx_tb_name_real_agent"; @@ -5368,6 +5419,7 @@ const char *const OB_ALL_VIRTUAL_RLS_GROUP_REAL_AGENT_ORA_IDX_RLS_GROUP_TABLE_ID const char *const OB_ALL_VIRTUAL_RLS_CONTEXT_REAL_AGENT_ORA_IDX_RLS_CONTEXT_TABLE_ID_REAL_AGENT_TNAME = "__idx_15279_idx_rls_context_table_id_real_agent"; const char *const OB_ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA_IDX_DBMS_LOCK_ALLOCATED_LOCKHANDLE_REAL_AGENT_TNAME = "__idx_15397_idx_dbms_lock_allocated_lockhandle_real_agent"; const char *const OB_ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA_IDX_DBMS_LOCK_ALLOCATED_EXPIRATION_REAL_AGENT_TNAME = "__idx_15397_idx_dbms_lock_allocated_expiration_real_agent"; +const char *const OB_ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA_IDX_USER_PROXY_INFO_PROXY_USER_ID_REAL_AGENT_TNAME = "__idx_15446_idx_user_proxy_info_proxy_user_id_real_agent"; // initial data for __all_privilege struct PrivilegeRow { 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 e814e624ca..a6709686f1 100644 --- a/src/share/inner_table/ob_inner_table_schema_def.py +++ b/src/share/inner_table/ob_inner_table_schema_def.py @@ -7178,6 +7178,48 @@ all_tenant_snapshot_ls_replica_history_def = dict( ], ) def_table_schema(**all_tenant_snapshot_ls_replica_history_def) + +all_user_proxy_info_def = dict( + owner = 'mingye.swj', + table_name = '__all_user_proxy_info', + table_id = '512', + table_type = 'SYSTEM_TABLE', + gm_columns = ['gmt_create', 'gmt_modified'], + rowkey_columns = [ + ('tenant_id', 'int', 'false'), + ('client_user_id', 'int', 'false'), + ('proxy_user_id', 'int', 'false'), + ], + in_tenant_space = True, + + normal_columns = [ + ('credential_type', 'int', 'false', '0'), + ('flags', 'int', 'false', '0') + ], +) +def_table_schema(**all_user_proxy_info_def) +def_table_schema(**gen_history_table_def(513, all_user_proxy_info_def)) + +all_user_proxy_role_info_def = dict( + owner = 'mingye.swj', + table_name = '__all_user_proxy_role_info', + table_id = '514', + table_type = 'SYSTEM_TABLE', + gm_columns = ['gmt_create', 'gmt_modified'], + rowkey_columns = [ + ('tenant_id', 'int', 'false'), + ('client_user_id', 'int', 'false'), + ('proxy_user_id', 'int', 'false'), + ('role_id', 'int', 'false'), + ], + in_tenant_space = True, + + normal_columns = [ + ], +) +def_table_schema(**all_user_proxy_role_info_def) +def_table_schema(**gen_history_table_def(515, all_user_proxy_role_info_def)) + # # 508 : __all_ls_replica_task_history # 509 : __all_ls_compaction_status @@ -14300,11 +14342,44 @@ def_table_schema( # 12470: __all_virtual_ls_compaction_status # 12471: __all_virtual_tablet_compaction_status # 12472: __all_virtual_tablet_checksum_error_info -# 12473: __all_virtual_compatibility_control -# 12474: __all_virtual_user_proxy_info -# 12475: __all_virtual_user_proxy_info_history -# 12476: __all_virtual_user_proxy_role_info -# 12477: __all_virtual_user_proxy_role_info_history + +def_table_schema( + owner = 'sean.yyj', + table_name = '__all_virtual_compatibility_control', + table_id = '12473', + table_type = 'VIRTUAL_TABLE', + in_tenant_space = True, + gm_columns = [], + rowkey_columns = [], + normal_columns = [ + ('tenant_id', 'int'), + ('name', 'varchar:OB_MAX_CONFIG_NAME_LEN'), + ('description', 'varchar:OB_MAX_CONFIG_INFO_LEN'), + ('is_enable', 'bool'), + ('enable_versions', 'longtext'), + ], +) + +def_table_schema(**gen_iterate_virtual_table_def( + table_id = '12474', + table_name = '__all_virtual_user_proxy_info', + keywords = all_def_keywords['__all_user_proxy_info'])) + +def_table_schema(**gen_iterate_virtual_table_def( + table_id = '12475', + table_name = '__all_virtual_user_proxy_info_history', + keywords = all_def_keywords['__all_user_proxy_info_history'])) + +def_table_schema(**gen_iterate_virtual_table_def( + table_id = '12476', + table_name = '__all_virtual_user_proxy_role_info', + keywords = all_def_keywords['__all_user_proxy_role_info'])) + +def_table_schema(**gen_iterate_virtual_table_def( + table_id = '12477', + table_name = '__all_virtual_user_proxy_role_info_history', + keywords = all_def_keywords['__all_user_proxy_role_info_history'])) + # 12478: __all_virtual_tablet_reorganize_history # 12479: __all_virtual_res_mgr_directive # 12480: __all_virtual_service @@ -14357,11 +14432,11 @@ def_table_schema( vtable_route_policy = 'distributed', ) + # 12483: __all_virtual_group_io_stat # 12484: __all_virtual_res_mgr_consumer_group # 12485: __all_virtual_storage_io_usage # 12486: __all_zone_storage -# def_table_schema( owner = 'gengfu.zpc', @@ -14844,13 +14919,15 @@ def_table_schema(**no_direct_access(gen_oracle_mapping_real_virtual_table_def('1 def_table_schema(**no_direct_access(gen_oracle_mapping_virtual_table_def('15439', all_def_keywords['__all_virtual_ls_snapshot']))) def_table_schema(**no_direct_access(gen_oracle_mapping_real_virtual_table_def('15440', all_def_keywords['__all_index_usage_info']))) +# 余留位置 + # 15441: __all_virtual_shared_storage_quota # 15442: __all_virtual_column_group # 15443: __all_virtual_ls_replica_task_history # 15444: __all_virtual_session_ps_info def_table_schema(**no_direct_access(gen_oracle_mapping_virtual_table_def('15445', all_def_keywords['__all_virtual_tracepoint_info']))) -# 15446: __all_user_proxy_info -# 15447: __all_user_proxy_role_info +def_table_schema(**no_direct_access(gen_oracle_mapping_real_virtual_table_def('15446', all_def_keywords['__all_user_proxy_info']))) +def_table_schema(**no_direct_access(gen_oracle_mapping_real_virtual_table_def('15447', all_def_keywords['__all_user_proxy_role_info']))) # 15448: idx_user_proxy_info_proxy_user_id_real_agent # 15449: __all_virtual_service def_table_schema(**no_direct_access(gen_oracle_mapping_virtual_table_def('15450', all_def_keywords['__all_virtual_tenant_resource_limit']))) @@ -15709,6 +15786,40 @@ def_table_schema( # 20018: PLUGINS # 20019: INNODB_SYS_COLUMNS +def_table_schema( + owner = 'ailing.lcq', + tablegroup_id = 'OB_INVALID_ID', + database_id = 'OB_INFORMATION_SCHEMA_ID', + table_name = 'PROFILING', + table_id = '20016', + table_type = 'SYSTEM_VIEW', + rowkey_columns = [], + normal_columns = [], + gm_columns = [], + in_tenant_space = True, + view_definition = """ + SELECT CAST(00000000000000000000 as SIGNED) as QUERY_ID, + CAST(00000000000000000000 as SIGNED) as SEQ, + CAST('' as CHAR(30)) as STATE, + CAST(0.000000 as DECIMAL(9, 6)) as DURATION, + CAST(NULL as DECIMAL(9, 6)) as CPU_USER, + CAST(NULL as DECIMAL(9, 6)) as CPU_SYSTEM, + CAST(00000000000000000000 as SIGNED) as CONTEXT_VOLUNTARY, + CAST(00000000000000000000 as SIGNED) as CONTEXT_INVOLUNTARY, + CAST(00000000000000000000 as SIGNED) as BLOCK_OPS_IN, + CAST(00000000000000000000 as SIGNED) as BLOCK_OPS_OUT, + CAST(00000000000000000000 as SIGNED) as MESSAGES_SENT, + CAST(00000000000000000000 as SIGNED) as MESSAGES_RECEIVED, + CAST(00000000000000000000 as SIGNED) as PAGE_FAULTS_MAJOR, + CAST(00000000000000000000 as SIGNED) as PAGE_FAULTS_MINOR, + CAST(00000000000000000000 as SIGNED) as SWAPS, + CAST(NULL as CHAR(30)) as SOURCE_FUNCTION, + CAST(NULL as CHAR(20)) as SOURCE_FILE, + CAST(00000000000000000000 as SIGNED) as SOURCE_LINE + FROM DUAL limit 0; +""".replace("\n", " ") +) + def_table_schema( owner = 'yuzhong.zhao', tablegroup_id = 'OB_INVALID_ID', @@ -16217,7 +16328,8 @@ def_table_schema( pl_trace_id as PL_TRACE_ID, plsql_exec_time as PLSQL_EXEC_TIME, total_memstore_read_row_count as TOTAL_MEMSTORE_READ_ROW_COUNT, - total_ssstore_read_row_count as TOTAL_SSSTORE_READ_ROW_COUNT + total_ssstore_read_row_count as TOTAL_SSSTORE_READ_ROW_COUNT, + proxy_user as PROXY_USER from oceanbase.__all_virtual_sql_audit """.replace("\n", " "), @@ -16625,7 +16737,9 @@ def_table_schema( PL_TRACE_ID, PLSQL_EXEC_TIME, TOTAL_MEMSTORE_READ_ROW_COUNT, - TOTAL_SSSTORE_READ_ROW_COUNT FROM oceanbase.GV$OB_SQL_AUDIT WHERE svr_ip=HOST_IP() AND svr_port=RPC_PORT() + TOTAL_SSSTORE_READ_ROW_COUNT, + PROXY_USER + FROM oceanbase.GV$OB_SQL_AUDIT WHERE svr_ip=HOST_IP() AND svr_port=RPC_PORT() """.replace("\n", " "), normal_columns = [ @@ -23557,7 +23671,8 @@ SELECT IN_BYTES, OUT_BYTES, USER_CLIENT_PORT, - cast(total_cpu_time as SIGNED) as TOTAL_CPU_TIME + cast(total_cpu_time as SIGNED) as TOTAL_CPU_TIME, + PROXY_USER FROM oceanbase.__all_virtual_processlist """.replace("\n", " ") ) @@ -23607,7 +23722,8 @@ def_table_schema( IN_BYTES, OUT_BYTES, USER_CLIENT_PORT, - cast(total_cpu_time as SIGNED) as TOTAL_CPU_TIME + cast(total_cpu_time as SIGNED) as TOTAL_CPU_TIME, + PROXY_USER FROM oceanbase.GV$OB_PROCESSLIST WHERE SVR_IP = host_ip() AND SVR_PORT = rpc_port() """.replace("\n", " ") @@ -28299,7 +28415,10 @@ def_table_schema( (CASE WHEN PRIV_CREATE_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_DATABASE_LINK, (CASE WHEN (PRIV_OTHERS & (1 << 0)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_EXECUTE, (CASE WHEN (PRIV_OTHERS & (1 << 1)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_ALTER_ROUTINE, - (CASE WHEN (PRIV_OTHERS & (1 << 2)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_ROUTINE + (CASE WHEN (PRIV_OTHERS & (1 << 2)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_ROUTINE, + (CASE WHEN (PRIV_OTHERS & (1 << 3)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_TABLESPACE, + (CASE WHEN (PRIV_OTHERS & (1 << 4)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_SHUTDOWN, + (CASE WHEN (PRIV_OTHERS & (1 << 5)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_RELOAD FROM OCEANBASE.__all_user; """.replace("\n", " ") ) @@ -28356,7 +28475,10 @@ def_table_schema( (CASE WHEN PRIV_CREATE_DATABASE_LINK = 0 THEN 'NO' ELSE 'YES' END) AS PRIV_CREATE_DATABASE_LINK, (CASE WHEN (PRIV_OTHERS & (1 << 0)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_EXECUTE, (CASE WHEN (PRIV_OTHERS & (1 << 1)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_ALTER_ROUTINE, - (CASE WHEN (PRIV_OTHERS & (1 << 2)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_ROUTINE + (CASE WHEN (PRIV_OTHERS & (1 << 2)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_ROUTINE, + (CASE WHEN (PRIV_OTHERS & (1 << 3)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_CREATE_TABLESPACE, + (CASE WHEN (PRIV_OTHERS & (1 << 4)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_SHUTDOWN, + (CASE WHEN (PRIV_OTHERS & (1 << 5)) != 0 THEN 'YES' ELSE 'NO' END) AS PRIV_RELOAD FROM OCEANBASE.__all_virtual_user; """.replace("\n", " ") ) @@ -28932,6 +29054,8 @@ def_table_schema( AND U.PRIV_PROCESS = 1 THEN 'PROCESS' WHEN V1.C1 = 17 AND U.PRIV_CREATE_SYNONYM = 1 THEN 'CREATE SYNONYM' + WHEN V1.C1 = 23 + AND (U.PRIV_OTHERS & (1 << 0)) != 0 THEN 'EXECUTE' WHEN V1.C1 = 27 AND U.PRIV_FILE = 1 THEN 'FILE' WHEN V1.C1 = 28 @@ -28951,11 +29075,15 @@ def_table_schema( WHEN V1.C1 = 36 AND U.PRIV_CREATE_DATABASE_LINK = 1 THEN 'CREATE DATABASE LINK' WHEN V1.C1 = 37 - AND (U.PRIV_OTHERS & (1 << 0)) != 0 THEN 'EXECUTE' - WHEN V1.C1 = 38 AND (U.PRIV_OTHERS & (1 << 1)) != 0 THEN 'ALTER ROUTINE' - WHEN V1.C1 = 39 + WHEN V1.C1 = 38 AND (U.PRIV_OTHERS & (1 << 2)) != 0 THEN 'CREATE ROUTINE' + WHEN V1.C1 = 39 + AND (U.PRIV_OTHERS & (1 << 3)) != 0 THEN 'CREATE TABLESPACE' + WHEN V1.C1 = 40 + AND (U.PRIV_OTHERS & (1 << 4)) != 0 THEN 'SHUTDOWN' + WHEN V1.C1 = 41 + AND (U.PRIV_OTHERS & (1 << 5)) != 0 THEN 'RELOAD' WHEN V1.C1 = 0 AND U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 @@ -29029,6 +29157,7 @@ def_table_schema( UNION ALL SELECT 14 AS C1 UNION ALL SELECT 15 AS C1 UNION ALL SELECT 17 AS C1 + UNION ALL SELECT 23 AS C1 UNION ALL SELECT 27 AS C1 UNION ALL SELECT 28 AS C1 UNION ALL SELECT 29 AS C1 @@ -29040,7 +29169,9 @@ def_table_schema( UNION ALL SELECT 36 AS C1 UNION ALL SELECT 37 AS C1 UNION ALL SELECT 38 AS C1 - UNION ALL SELECT 39 AS C1) V1, + UNION ALL SELECT 39 AS C1 + UNION ALL SELECT 40 AS C1 + UNION ALL SELECT 41 AS C1) V1, (SELECT USER_ID FROM oceanbase.__all_user WHERE TENANT_ID = 0 @@ -34195,7 +34326,25 @@ def_table_schema( WHERE SVR_IP=HOST_IP() AND SVR_PORT=RPC_PORT() """.replace("\n", " ") ) -# 21545: V$OB_COMPATIBILITY_CONTROL + +def_table_schema( + owner = 'sean.yyj', + tablegroup_id = 'OB_INVALID_ID', + table_name = 'V$OB_COMPATIBILITY_CONTROL', + table_id = '21545', + gm_columns = [], + rowkey_columns = [], + table_type = 'SYSTEM_VIEW', + in_tenant_space = True, + view_definition = """SELECT + name as NAME, + description as DESCRIPTION, + CASE is_enable WHEN 1 THEN 'TRUE' ELSE 'FALSE' END AS IS_ENABLE, + enable_versions as ENABLE_VERSIONS + FROM oceanbase.__all_virtual_compatibility_control +""".replace("\n", " "), + normal_columns = [], +) # 21546: DBA_OB_RSRC_DIRECTIVES # 21547: CDB_OB_RSRC_DIRECTIVES # 21548: DBA_OB_SERVICES @@ -46183,19 +46332,61 @@ def_table_schema( normal_columns = [], gm_columns = [], in_tenant_space = True, - view_definition = """SELECT CAST(A.USER_NAME AS VARCHAR2(30)) GRANTEE,\ - CAST(B.USER_NAME AS VARCHAR2(30)) GRANTED_ROLE,\ - DECODE(R.ADMIN_OPTION, 0, 'NO', 1, 'YES', '') AS ADMIN_OPTION ,\ - DECODE(R.DISABLE_FLAG, 0, 'YES', 1, 'NO', '') AS DEFAULT_ROLE\ - FROM SYS.ALL_VIRTUAL_TENANT_ROLE_GRANTEE_MAP_REAL_AGENT R,\ - SYS.ALL_VIRTUAL_USER_REAL_AGENT A,\ - SYS.ALL_VIRTUAL_USER_REAL_AGENT B\ - WHERE R.GRANTEE_ID = A.USER_ID\ - AND R.ROLE_ID = B.USER_ID\ - AND B.TYPE = 1\ - AND A.TENANT_ID = EFFECTIVE_TENANT_ID()\ - AND B.TENANT_ID = EFFECTIVE_TENANT_ID()\ - AND A.USER_NAME = SYS_CONTEXT('USERENV','CURRENT_USER')""".replace("\n", " ") + view_definition = """ + WITH RV AS ( + SELECT R.ROLE_ID, + CAST(A.USER_NAME AS VARCHAR2(30)) GRANTEE, + CAST(B.USER_NAME AS VARCHAR2(30)) GRANTED_ROLE, + DECODE(R.ADMIN_OPTION, 0, 'NO', 1, 'YES', '') AS ADMIN_OPTION , + DECODE(R.DISABLE_FLAG, 0, 'YES', 1, 'NO', '') AS DEFAULT_ROLE + FROM SYS.ALL_VIRTUAL_TENANT_ROLE_GRANTEE_MAP_REAL_AGENT R, + SYS.ALL_VIRTUAL_USER_REAL_AGENT A, + SYS.ALL_VIRTUAL_USER_REAL_AGENT B + WHERE R.GRANTEE_ID = A.USER_ID + AND R.ROLE_ID = B.USER_ID + AND B.TYPE = 1 + AND A.TENANT_ID = EFFECTIVE_TENANT_ID() + AND B.TENANT_ID = EFFECTIVE_TENANT_ID() + AND A.USER_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') + ), + PRV AS ( + SELECT PR.ROLE_ID ROLE_ID + FROM SYS.ALL_VIRTUAL_USER_REAL_AGENT A, + SYS.ALL_VIRTUAL_USER_REAL_AGENT B, + SYS.ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT P LEFT JOIN + SYS.ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT PR + ON P.TENANT_ID = PR.TENANT_ID AND P.CLIENT_USER_ID = PR.CLIENT_USER_ID AND P.PROXY_USER_ID = PR.PROXY_USER_ID + WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID() + AND A.TENANT_ID = EFFECTIVE_TENANT_ID() + AND B.TENANT_ID = EFFECTIVE_TENANT_ID() + AND A.USER_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') + AND B.USER_NAME = SYS_CONTEXT('USERENV','PROXY_USER') + AND P.CLIENT_USER_ID = A.USER_ID + AND P.PROXY_USER_ID = B.USER_ID + ), + PRV_FLAG AS ( + SELECT P.FLAGS FLAGS + FROM SYS.ALL_VIRTUAL_USER_REAL_AGENT A, + SYS.ALL_VIRTUAL_USER_REAL_AGENT B, + SYS.ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT P + WHERE P.TENANT_ID = EFFECTIVE_TENANT_ID() + AND A.TENANT_ID = EFFECTIVE_TENANT_ID() + AND B.TENANT_ID = EFFECTIVE_TENANT_ID() + AND A.USER_NAME = SYS_CONTEXT('USERENV','CURRENT_USER') + AND B.USER_NAME = SYS_CONTEXT('USERENV','PROXY_USER') + AND P.CLIENT_USER_ID = A.USER_ID + AND P.PROXY_USER_ID = B.USER_ID + ) + SELECT RV.GRANTEE GRANTEE, + RV.GRANTED_ROLE GRANTED_ROLE, + RV.ADMIN_OPTION ADMIN_OPTION, + RV.DEFAULT_ROLE DEFAULT_ROLE + FROM RV LEFT JOIN PRV ON RV.ROLE_ID = PRV.ROLE_ID LEFT JOIN PRV_FLAG ON 1 = 1 + WHERE (0 = (SELECT COUNT(ROLE_ID) FROM PRV) AND (PRV_FLAG.FLAGS IS NULL OR PRV_FLAG.FLAGS != 2)) + OR (PRV_FLAG.FLAGS = 1) + OR (PRV_FLAG.FLAGS = 2 AND 1 = 0) + OR (PRV_FLAG.FLAGS = 4 AND RV.ROLE_ID = PRV.ROLE_ID) + OR (PRV_FLAG.FLAGS = 8 AND (RV.ROLE_ID != PRV.ROLE_ID OR PRV.ROLE_ID IS NULL))""".replace("\n", " ") ) def_table_schema( @@ -54348,6 +54539,49 @@ def_table_schema( # 25301: PROXY_USERS # 25302: DBA_OB_SERVICES # 25303: DBA_OB_STORAGE_IO_USAGE +def_table_schema( + owner = 'mingye.swj', + table_name = 'PROXY_USERS', + database_id = 'OB_ORA_SYS_DATABASE_ID', + table_id = '25301', + table_type = 'SYSTEM_VIEW', + rowkey_columns = [], + normal_columns = [], + gm_columns = [], + in_tenant_space = True, + view_definition = """ + select cast(U1.USER_NAME as VARCHAR2(128)) as PROXY, + cast(U2.USER_NAME as VARCHAR2(128)) as CLIENT, + cast(DECODE(P.CREDENTIAL_TYPE, 0, 'NO', 5, 'YES') as VARCHAR2(3)) as AUTHENTICATION, + cast(DECODE(case when V.CNT = 0 and P.FLAGS = 4 then 2 + when V.CNT = 0 and P.FlAGS = 8 then 1 + else P.FLAGS end, + 0, NULL, + 1, 'PROXY MAY ACTIVATE ALL CLIENT ROLES', + 2, 'NO CLIENT ROLES MAY BE ACTIVATED', + 4, 'PROXY MAY ACTIVATE ROLE', + 5, 'PROXY MAY ACTIVATE ALL CLIENT ROLES', + 8, 'PROXY MAY NOT ACTIVATE ROLE') as VARCHAR2(35)) as FLAGS +from SYS.ALL_VIRTUAL_USER_REAL_AGENT U1, SYS.ALL_VIRTUAL_USER_REAL_AGENT U2, SYS.ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT P, + (SELECT COUNT(B.ROLE_ID) CNT, A.TENANT_ID TENANT_ID, A.PROXY_USER_ID PROXY_USER_ID, A.CLIENT_USER_ID CLIENT_USER_ID + FROM SYS.ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT A LEFT JOIN + SYS.ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT B + ON A.TENANT_ID = B.TENANT_ID + AND A.CLIENT_USER_ID = B.CLIENT_USER_ID + AND A.PROXY_USER_ID = B.PROXY_USER_ID + GROUP BY A.TENANT_ID, A.PROXY_USER_ID, A.CLIENT_USER_ID + ) V +where U1.TENANT_ID = U2.TENANT_ID + and U2.TENANT_ID = P.TENANT_ID + and U1.TENANT_ID = EFFECTIVE_TENANT_ID() + and U1.USER_ID = P.PROXY_USER_ID + and U2.USER_ID = P.CLIENT_USER_ID + and V.TENANT_ID = U1.TENANT_ID + and V.PROXY_USER_ID = P.PROXY_USER_ID + and V.CLIENT_USER_ID = P.CLIENT_USER_ID +""".replace("\n", " ") +) + # # 余留位置(此行之前占位) @@ -54499,7 +54733,8 @@ def_table_schema( pl_trace_id as PL_TRACE_ID, plsql_exec_time as PLSQL_EXEC_TIME, total_memstore_read_row_count as TOTAL_MEMSTORE_READ_ROW_COUNT, - total_ssstore_read_row_count as TOTAL_SSSTORE_READ_ROW_COUNT + total_ssstore_read_row_count as TOTAL_SSSTORE_READ_ROW_COUNT, + proxy_user as PROXY_USER FROM SYS.ALL_VIRTUAL_SQL_AUDIT """.replace("\n", " ") ) @@ -54611,7 +54846,8 @@ FLT_TRACE_ID, PL_TRACE_ID, PLSQL_EXEC_TIME, TOTAL_MEMSTORE_READ_ROW_COUNT, -TOTAL_SSSTORE_READ_ROW_COUNT FROM SYS.GV$OB_SQL_AUDIT WHERE SVR_IP=HOST_IP() AND SVR_PORT=RPC_PORT() +TOTAL_SSSTORE_READ_ROW_COUNT, +PROXY_USER FROM SYS.GV$OB_SQL_AUDIT WHERE SVR_IP=HOST_IP() AND SVR_PORT=RPC_PORT() """.replace("\n", " ") ) @@ -59002,7 +59238,8 @@ SELECT LB_VPORT, IN_BYTES, OUT_BYTES, - USER_CLIENT_PORT + USER_CLIENT_PORT, + PROXY_USER FROM SYS.ALL_VIRTUAL_PROCESSLIST """.replace("\n", " ") ) @@ -59053,7 +59290,8 @@ def_table_schema( LB_VPORT, IN_BYTES, OUT_BYTES, - USER_CLIENT_PORT + USER_CLIENT_PORT, + PROXY_USER FROM SYS.GV$OB_PROCESSLIST WHERE SVR_IP = host_ip() AND SVR_PORT = rpc_port() """.replace("\n", " ") @@ -62861,6 +63099,30 @@ def_sys_index_table( # 101104: __all_tablet_reorganize_history # 101105: __all_scheduler_job_run_detail_v2 # +def_sys_index_table( + index_name = 'idx_user_proxy_info_proxy_user_id', + index_table_id = 101101, + index_columns = ['tenant_id', 'proxy_user_id'], + index_using_type = 'USING_BTREE', + index_type = 'INDEX_TYPE_NORMAL_LOCAL', + keywords = all_def_keywords['__all_user_proxy_info']) + +def_sys_index_table( + index_name = 'idx_user_proxy_info_proxy_user_id_history', + index_table_id = 101102, + index_columns = ['tenant_id', 'proxy_user_id'], + index_using_type = 'USING_BTREE', + index_type = 'INDEX_TYPE_NORMAL_LOCAL', + keywords = all_def_keywords['__all_user_proxy_info_history']) + +def_sys_index_table( + index_name = 'idx_user_proxy_role_info_proxy_user_id_history', + index_table_id = 101103, + index_columns = ['tenant_id', 'proxy_user_id'], + index_using_type = 'USING_BTREE', + index_type = 'INDEX_TYPE_NORMAL_LOCAL', + keywords = all_def_keywords['__all_user_proxy_role_info_history']) + # 余留位置(此行之前占位) # 索引表占位建议:基于基表(数据表)表名来占位,其他方式包括:索引名(index_name)、索引表表名 ################################################################################ @@ -63628,5 +63890,16 @@ def_agent_index_table( real_index_name = 'idx_dbms_lock_allocated_expiration', keywords = all_def_keywords['ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT_ORA']) +def_agent_index_table( + index_name = 'idx_user_proxy_info_proxy_user_id_real_agent', + index_table_id = 15448, + index_columns = ['tenant_id', 'proxy_user_id'], + index_using_type = 'USING_BTREE', + index_type = 'INDEX_TYPE_NORMAL_LOCAL', + real_table_name = '__all_user_proxy_info' , + real_index_name = 'idx_user_proxy_info_proxy_user_id', + keywords = all_def_keywords['ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT_ORA']) + + # End Oracle Agent table Index ################################################################################ diff --git a/src/share/inner_table/ob_inner_table_schema_misc.ipp b/src/share/inner_table/ob_inner_table_schema_misc.ipp index 555d39bb19..77ad3819d7 100644 --- a/src/share/inner_table/ob_inner_table_schema_misc.ipp +++ b/src/share/inner_table/ob_inner_table_schema_misc.ipp @@ -1928,6 +1928,10 @@ case OB_ALL_VIRTUAL_TYPE_ATTR_HISTORY_TID: case OB_ALL_VIRTUAL_TYPE_HISTORY_TID: case OB_ALL_VIRTUAL_USER_TID: case OB_ALL_VIRTUAL_USER_HISTORY_TID: +case OB_ALL_VIRTUAL_USER_PROXY_INFO_TID: +case OB_ALL_VIRTUAL_USER_PROXY_INFO_HISTORY_TID: +case OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_TID: +case OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_HISTORY_TID: #endif @@ -4545,6 +4549,66 @@ case OB_ALL_VIRTUAL_USER_HISTORY_TID: } break; } + + case OB_ALL_VIRTUAL_USER_PROXY_INFO_TID: { + ObIterateVirtualTable *iter = NULL; + if (OB_FAIL(NEW_VIRTUAL_TABLE(ObIterateVirtualTable, iter))) { + SERVER_LOG(WARN, "create virtual table iterator failed", K(ret)); + } else if (OB_FAIL(iter->init(OB_ALL_USER_PROXY_INFO_TID, index_schema, params))) { + SERVER_LOG(WARN, "virtual table iter init failed", K(ret)); + iter->~ObIterateVirtualTable(); + allocator.free(iter); + iter = NULL; + } else { + vt_iter = iter; + } + break; + } + + case OB_ALL_VIRTUAL_USER_PROXY_INFO_HISTORY_TID: { + ObIterateVirtualTable *iter = NULL; + if (OB_FAIL(NEW_VIRTUAL_TABLE(ObIterateVirtualTable, iter))) { + SERVER_LOG(WARN, "create virtual table iterator failed", K(ret)); + } else if (OB_FAIL(iter->init(OB_ALL_USER_PROXY_INFO_HISTORY_TID, index_schema, params))) { + SERVER_LOG(WARN, "virtual table iter init failed", K(ret)); + iter->~ObIterateVirtualTable(); + allocator.free(iter); + iter = NULL; + } else { + vt_iter = iter; + } + break; + } + + case OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_TID: { + ObIterateVirtualTable *iter = NULL; + if (OB_FAIL(NEW_VIRTUAL_TABLE(ObIterateVirtualTable, iter))) { + SERVER_LOG(WARN, "create virtual table iterator failed", K(ret)); + } else if (OB_FAIL(iter->init(OB_ALL_USER_PROXY_ROLE_INFO_TID, index_schema, params))) { + SERVER_LOG(WARN, "virtual table iter init failed", K(ret)); + iter->~ObIterateVirtualTable(); + allocator.free(iter); + iter = NULL; + } else { + vt_iter = iter; + } + break; + } + + case OB_ALL_VIRTUAL_USER_PROXY_ROLE_INFO_HISTORY_TID: { + ObIterateVirtualTable *iter = NULL; + if (OB_FAIL(NEW_VIRTUAL_TABLE(ObIterateVirtualTable, iter))) { + SERVER_LOG(WARN, "create virtual table iterator failed", K(ret)); + } else if (OB_FAIL(iter->init(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID, index_schema, params))) { + SERVER_LOG(WARN, "virtual table iter init failed", K(ret)); + iter->~ObIterateVirtualTable(); + allocator.free(iter); + iter = NULL; + } else { + vt_iter = iter; + } + break; + } END_CREATE_VT_ITER_SWITCH_LAMBDA #endif // ITERATE_VIRTUAL_TABLE_CREATE_ITER @@ -4912,6 +4976,9 @@ case OB_ALL_MVIEW_REFRESH_STATS_IDX_MVIEW_REFRESH_STATS_MVIEW_END_TIME_TID: case OB_ALL_TRANSFER_PARTITION_TASK_IDX_TRANSFER_PARTITION_KEY_TID: case OB_ALL_CLIENT_TO_SERVER_SESSION_INFO_IDX_CLIENT_TO_SERVER_SESSION_INFO_CLIENT_SESSION_ID_TID: case OB_ALL_COLUMN_PRIVILEGE_IDX_COLUMN_PRIVILEGE_NAME_TID: +case OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TID: +case OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TID: +case OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TID: #endif @@ -4932,6 +4999,7 @@ case OB_ALL_CONTEXT_TID: case OB_ALL_TABLE_PRIVILEGE_TID: case OB_ALL_DDL_CHECKSUM_TID: case OB_ALL_RLS_POLICY_TID: +case OB_ALL_USER_PROXY_INFO_HISTORY_TID: case OB_ALL_TENANT_OBJAUTH_TID: case OB_ALL_PACKAGE_TID: case OB_ALL_ROOTSERVICE_EVENT_HISTORY_TID: @@ -4945,6 +5013,7 @@ case OB_ALL_ROUTINE_PARAM_TID: case OB_ALL_DATABASE_PRIVILEGE_TID: case OB_ALL_TENANT_OLS_LABEL_TID: case OB_ALL_TENANT_KEYSTORE_TID: +case OB_ALL_USER_PROXY_INFO_TID: case OB_ALL_COLUMN_TID: case OB_ALL_CLIENT_TO_SERVER_SESSION_INFO_TID: case OB_ALL_MVIEW_REFRESH_RUN_STATS_TID: @@ -4977,6 +5046,7 @@ case OB_ALL_TRANSFER_PARTITION_TASK_TID: case OB_ALL_SUB_PART_TID: case OB_ALL_ROUTINE_TID: case OB_ALL_TENANT_DIRECTORY_TID: +case OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID: case OB_ALL_TENANT_SNAPSHOT_TID: case OB_ALL_DDL_ERROR_MESSAGE_TID: case OB_ALL_TENANT_TRIGGER_HISTORY_TID: @@ -5098,6 +5168,12 @@ case OB_ALL_RLS_POLICY_TID: { } break; } +case OB_ALL_USER_PROXY_INFO_HISTORY_TID: { + if (FAILEDx(index_tids.push_back(OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TID))) { + LOG_WARN("fail to push back index tid", KR(ret)); + } + break; +} case OB_ALL_TENANT_OBJAUTH_TID: { if (FAILEDx(index_tids.push_back(OB_ALL_TENANT_OBJAUTH_IDX_OBJAUTH_GRANTOR_TID))) { LOG_WARN("fail to push back index tid", KR(ret)); @@ -5206,6 +5282,12 @@ case OB_ALL_TENANT_KEYSTORE_TID: { } break; } +case OB_ALL_USER_PROXY_INFO_TID: { + if (FAILEDx(index_tids.push_back(OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TID))) { + LOG_WARN("fail to push back index tid", KR(ret)); + } + break; +} case OB_ALL_COLUMN_TID: { if (FAILEDx(index_tids.push_back(OB_ALL_COLUMN_IDX_TB_COLUMN_NAME_TID))) { LOG_WARN("fail to push back index tid", KR(ret)); @@ -5428,6 +5510,12 @@ case OB_ALL_TENANT_DIRECTORY_TID: { } break; } +case OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID: { + if (FAILEDx(index_tids.push_back(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TID))) { + LOG_WARN("fail to push back index tid", KR(ret)); + } + break; +} case OB_ALL_TENANT_SNAPSHOT_TID: { if (FAILEDx(index_tids.push_back(OB_ALL_TENANT_SNAPSHOT_IDX_TENANT_SNAPSHOT_NAME_TID))) { LOG_WARN("fail to push back index tid", KR(ret)); @@ -5701,6 +5789,15 @@ case OB_ALL_RLS_POLICY_TID: { } break; } +case OB_ALL_USER_PROXY_INFO_HISTORY_TID: { + index_schema.reset(); + if (FAILEDx(ObInnerTableSchema::all_user_proxy_info_history_idx_user_proxy_info_proxy_user_id_history_schema(index_schema))) { + LOG_WARN("fail to create index schema", KR(ret), K(tenant_id), K(data_table_id)); + } else if (OB_FAIL(append_table_(tenant_id, index_schema, tables))) { + LOG_WARN("fail to append", KR(ret), K(tenant_id), K(data_table_id)); + } + break; +} case OB_ALL_TENANT_OBJAUTH_TID: { index_schema.reset(); if (FAILEDx(ObInnerTableSchema::all_tenant_objauth_idx_objauth_grantor_schema(index_schema))) { @@ -5878,6 +5975,15 @@ case OB_ALL_TENANT_KEYSTORE_TID: { } break; } +case OB_ALL_USER_PROXY_INFO_TID: { + index_schema.reset(); + if (FAILEDx(ObInnerTableSchema::all_user_proxy_info_idx_user_proxy_info_proxy_user_id_schema(index_schema))) { + LOG_WARN("fail to create index schema", KR(ret), K(tenant_id), K(data_table_id)); + } else if (OB_FAIL(append_table_(tenant_id, index_schema, tables))) { + LOG_WARN("fail to append", KR(ret), K(tenant_id), K(data_table_id)); + } + break; +} case OB_ALL_COLUMN_TID: { index_schema.reset(); if (FAILEDx(ObInnerTableSchema::all_column_idx_tb_column_name_schema(index_schema))) { @@ -6226,6 +6332,15 @@ case OB_ALL_TENANT_DIRECTORY_TID: { } break; } +case OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TID: { + index_schema.reset(); + if (FAILEDx(ObInnerTableSchema::all_user_proxy_role_info_history_idx_user_proxy_role_info_proxy_user_id_history_schema(index_schema))) { + LOG_WARN("fail to create index schema", KR(ret), K(tenant_id), K(data_table_id)); + } else if (OB_FAIL(append_table_(tenant_id, index_schema, tables))) { + LOG_WARN("fail to append", KR(ret), K(tenant_id), K(data_table_id)); + } + break; +} case OB_ALL_TENANT_SNAPSHOT_TID: { index_schema.reset(); if (FAILEDx(ObInnerTableSchema::all_tenant_snapshot_idx_tenant_snapshot_name_schema(index_schema))) { @@ -6616,5 +6731,11 @@ case OB_ALL_FOREIGN_KEY_TID: { LOG_WARN("add index id failed", KR(ret), K(tenant_id)); } else if (OB_FAIL(table_ids.push_back(OB_ALL_COLUMN_PRIVILEGE_IDX_COLUMN_PRIVILEGE_NAME_TID))) { LOG_WARN("add index id failed", KR(ret), K(tenant_id)); + } else if (OB_FAIL(table_ids.push_back(OB_ALL_USER_PROXY_INFO_IDX_USER_PROXY_INFO_PROXY_USER_ID_TID))) { + LOG_WARN("add index id failed", KR(ret), K(tenant_id)); + } else if (OB_FAIL(table_ids.push_back(OB_ALL_USER_PROXY_INFO_HISTORY_IDX_USER_PROXY_INFO_PROXY_USER_ID_HISTORY_TID))) { + LOG_WARN("add index id failed", KR(ret), K(tenant_id)); + } else if (OB_FAIL(table_ids.push_back(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_IDX_USER_PROXY_ROLE_INFO_PROXY_USER_ID_HISTORY_TID))) { + LOG_WARN("add index id failed", KR(ret), K(tenant_id)); #endif diff --git a/src/share/inner_table/table_id_to_name b/src/share/inner_table/table_id_to_name index 4a374d8a4d..d01563e5a5 100644 --- a/src/share/inner_table/table_id_to_name +++ b/src/share/inner_table/table_id_to_name @@ -348,6 +348,12 @@ # 506: __all_column_privilege_history # 506: __all_column_privilege # BASE_TABLE_NAME # 507: __all_tenant_snapshot_ls_replica_history +# 512: __all_user_proxy_info +# 513: __all_user_proxy_info_history +# 513: __all_user_proxy_info # BASE_TABLE_NAME +# 514: __all_user_proxy_role_info +# 515: __all_user_proxy_role_info_history +# 515: __all_user_proxy_role_info # BASE_TABLE_NAME # 518: __all_mview_dep # 10001: __tenant_virtual_all_table # 10002: __tenant_virtual_table_column @@ -1098,6 +1104,17 @@ # 12464: __all_tenant_snapshot_ls_replica_history # BASE_TABLE_NAME # 12466: ENABLED_ROLES # 12469: __all_virtual_tracepoint_info +# 12473: __all_virtual_compatibility_control +# 12474: __all_virtual_user_proxy_info +# 12474: __all_user_proxy_info # BASE_TABLE_NAME +# 12475: __all_virtual_user_proxy_info_history +# 12475: __all_user_proxy_info # BASE_TABLE_NAME +# 12475: __all_user_proxy_info_history # BASE_TABLE_NAME1 +# 12476: __all_virtual_user_proxy_role_info +# 12476: __all_user_proxy_role_info # BASE_TABLE_NAME +# 12477: __all_virtual_user_proxy_role_info_history +# 12477: __all_user_proxy_role_info # BASE_TABLE_NAME +# 12477: __all_user_proxy_role_info_history # BASE_TABLE_NAME1 # 12481: __all_virtual_tenant_resource_limit # 12482: __all_virtual_tenant_resource_limit_detail # 12487: __all_virtual_nic_info @@ -1690,6 +1707,10 @@ # 15440: __all_index_usage_info # BASE_TABLE_NAME # 15445: ALL_VIRTUAL_TRACEPOINT_INFO # 15445: __all_virtual_tracepoint_info # BASE_TABLE_NAME +# 15446: ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT +# 15446: __all_user_proxy_info # BASE_TABLE_NAME +# 15447: ALL_VIRTUAL_USER_PROXY_ROLE_INFO_REAL_AGENT +# 15447: __all_user_proxy_role_info # BASE_TABLE_NAME # 15450: ALL_VIRTUAL_TENANT_RESOURCE_LIMIT # 15450: __all_virtual_tenant_resource_limit # BASE_TABLE_NAME # 15451: ALL_VIRTUAL_TENANT_RESOURCE_LIMIT_DETAIL @@ -1710,6 +1731,7 @@ # 20012: KEY_COLUMN_USAGE # 20014: ENGINES # 20015: ROUTINES +# 20016: PROFILING # 21000: GV$SESSION_EVENT # 21001: GV$SESSION_WAIT # 21002: GV$SESSION_WAIT_HISTORY @@ -2105,6 +2127,7 @@ # 21540: DBA_MVREF_STMT_STATS # 21543: GV$OB_TRACEPOINT_INFO # 21544: V$OB_TRACEPOINT_INFO +# 21545: V$OB_COMPATIBILITY_CONTROL # 21550: GV$OB_TENANT_RESOURCE_LIMIT # 21551: V$OB_TENANT_RESOURCE_LIMIT # 21552: GV$OB_TENANT_RESOURCE_LIMIT_DETAIL @@ -2386,6 +2409,7 @@ # 25298: USER_MVREF_CHANGE_STATS # 25299: DBA_MVREF_STMT_STATS # 25300: USER_MVREF_STMT_STATS +# 25301: PROXY_USERS # 28002: GV$OB_SQL_AUDIT # 28003: V$OB_SQL_AUDIT # 28004: GV$INSTANCE @@ -2963,6 +2987,17 @@ # 101100: __idx_505_idx_column_privilege_name # 101100: idx_column_privilege_name # INDEX_NAME # 101100: __all_column_privilege # DATA_BASE_TABLE_NAME +# 101101: __idx_512_idx_user_proxy_info_proxy_user_id +# 101101: idx_user_proxy_info_proxy_user_id # INDEX_NAME +# 101101: __all_user_proxy_info # DATA_BASE_TABLE_NAME +# 101102: __idx_513_idx_user_proxy_info_proxy_user_id_history +# 101102: idx_user_proxy_info_proxy_user_id_history # INDEX_NAME +# 101102: __all_user_proxy_info # DATA_BASE_TABLE_NAME +# 101102: __all_user_proxy_info_history # DATA_BASE_TABLE_NAME1 +# 101103: __idx_515_idx_user_proxy_role_info_proxy_user_id_history +# 101103: idx_user_proxy_role_info_proxy_user_id_history # INDEX_NAME +# 101103: __all_user_proxy_role_info # DATA_BASE_TABLE_NAME +# 101103: __all_user_proxy_role_info_history # DATA_BASE_TABLE_NAME1 # 15306: __idx_15120_idx_data_table_id_real_agent # 15306: idx_data_table_id_real_agent # INDEX_NAME # 15306: __all_table # DATA_BASE_TABLE_NAME @@ -3251,3 +3286,7 @@ # 15416: idx_dbms_lock_allocated_expiration_real_agent # INDEX_NAME # 15416: __all_dbms_lock_allocated # DATA_BASE_TABLE_NAME # 15416: ALL_VIRTUAL_DBMS_LOCK_ALLOCATED_REAL_AGENT # DATA_BASE_TABLE_NAME1 +# 15448: __idx_15446_idx_user_proxy_info_proxy_user_id_real_agent +# 15448: idx_user_proxy_info_proxy_user_id_real_agent # INDEX_NAME +# 15448: __all_user_proxy_info # DATA_BASE_TABLE_NAME +# 15448: ALL_VIRTUAL_USER_PROXY_INFO_REAL_AGENT # DATA_BASE_TABLE_NAME1 diff --git a/src/share/ob_cluster_version.h b/src/share/ob_cluster_version.h index 22d96967a5..228739e9c0 100644 --- a/src/share/ob_cluster_version.h +++ b/src/share/ob_cluster_version.h @@ -174,6 +174,7 @@ cal_version(const uint64_t major, const uint64_t minor, const uint64_t major_pat #define CLUSTER_VERSION_4_2_1_2 (oceanbase::common::cal_version(4, 2, 1, 2)) #define MOCK_CLUSTER_VERSION_4_2_1_3 (oceanbase::common::cal_version(4, 2, 1, 3)) #define MOCK_CLUSTER_VERSION_4_2_1_4 (oceanbase::common::cal_version(4, 2, 1, 4)) +#define MOCK_CLUSTER_VERSION_4_2_1_6 (oceanbase::common::cal_version(4, 2, 1, 6)) #define MOCK_CLUSTER_VERSION_4_2_1_7 (oceanbase::common::cal_version(4, 2, 1, 7)) #define CLUSTER_VERSION_4_2_2_0 (oceanbase::common::cal_version(4, 2, 2, 0)) #define MOCK_CLUSTER_VERSION_4_2_2_1 (oceanbase::common::cal_version(4, 2, 2, 1)) diff --git a/src/share/ob_common_rpc_proxy.h b/src/share/ob_common_rpc_proxy.h index bbac8be1c4..5e577cd804 100644 --- a/src/share/ob_common_rpc_proxy.h +++ b/src/share/ob_common_rpc_proxy.h @@ -322,6 +322,7 @@ public: RPC_S(PR5 get_root_key, obrpc::OB_GET_ROOT_KEY, (obrpc::ObRootKeyArg), obrpc::ObRootKeyResult); RPC_S(PR5 reload_master_key, obrpc::OB_RELOAD_MASTER_KEY, (obrpc::ObReloadMasterKeyArg), obrpc::ObReloadMasterKeyResult); #endif + RPC_S(PRD alter_user_proxy, obrpc::OB_ALTER_USER_PROXY, (ObAlterUserProxyArg), obrpc::ObAlterUserProxyRes); public: void set_rs_mgr(share::ObRsMgr &rs_mgr) { diff --git a/src/share/ob_compatibility_control.cpp b/src/share/ob_compatibility_control.cpp new file mode 100644 index 0000000000..7c263bdfed --- /dev/null +++ b/src/share/ob_compatibility_control.cpp @@ -0,0 +1,187 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SHARE +#include "share/ob_compatibility_control.h" +#include "share/ob_cluster_version.h" +#include "share/ob_upgrade_utils.h" +#include "lib/container/ob_se_array.h" +#include "lib/oblog/ob_log.h" +#include "lib/file/ob_string_util.h" + +namespace oceanbase +{ +namespace share +{ +using namespace oceanbase::common; + +#define DEF_COMPAT_CONTROL_FEATURE(type, description, args...) \ +const ObCompatInfo ObCompatControl::COMPAT_##type = \ + ObCompatInfo(ObCompatFeatureType::type, #type, description, args); +#include "share/ob_compatibility_control_feature_def.h" +#include "share/ob_compatibility_security_feature_def.h" +#undef DEF_COMPAT_CONTROL_FEATURE + +const ObICompatInfo* ObCompatControl::infos_[] = +{ +#define DEF_COMPAT_CONTROL_FEATURE(type, args...) \ + &COMPAT_##type, +#include "share/ob_compatibility_control_feature_def.h" + NULL, // COMPAT_FEATURE_END +#include "share/ob_compatibility_security_feature_def.h" +#undef DEF_COMPAT_CONTROL_FEATURE +}; + +#define DEF_COMPAT_CONTROL_FEATURE(type, description, args...) \ +static_assert(1 == ARGS_NUM(args) % 2, "num of versions must be odd"); +#include "share/ob_compatibility_control_feature_def.h" +#include "share/ob_compatibility_security_feature_def.h" +#undef DEF_COMPAT_CONTROL_FEATURE + +bool ObICompatInfo::is_valid_version(uint64_t version) const +{ + bool bret = false; + const uint64_t *versions = NULL; + int64_t version_num = 0; + int64_t i = 0; + get_versions(versions, version_num); + if (OB_ISNULL(versions) || OB_UNLIKELY(version_num <= 0)) { + bret = false; + } + for (; !bret && i + 1 < version_num; i += 2) { + bret = version >= versions[i] && version < versions[i + 1]; + } + if (!bret) { + bret = version >= versions[i]; + } + return bret; +} + +int ObICompatInfo::print_version_range(common::ObString &range_str, ObIAllocator &allocator) const +{ + int ret = OB_SUCCESS; + const uint64_t *versions = NULL; + int64_t version_num = 0; + int64_t i = 0; + ObSqlString str; + char buf[OB_CLUSTER_VERSION_LENGTH] = {0}; + int64_t len = 0; + get_versions(versions, version_num); + if (OB_ISNULL(versions) || OB_UNLIKELY(version_num <= 0)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } + for (; OB_SUCC(ret) && i + 1 < version_num; i += 2) { + if (i != 0) { + if (OB_FAIL(str.append(", "))) { + LOG_WARN("failed to append", K(ret)); + } + } + if (OB_FAIL(ret)) { + } else if (OB_FAIL(str.append("["))) { + LOG_WARN("failed to append", K(ret)); + } else if (OB_UNLIKELY(OB_INVALID_INDEX == (len = ObClusterVersion::print_version_str( + buf, OB_CLUSTER_VERSION_LENGTH, versions[i])))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to print version", KR(ret), K(versions[i])); + } else if (OB_FAIL(str.append(buf, len))) { + LOG_WARN("failed to append start version", K(ret), K(versions[i])); + } else if (OB_UNLIKELY(OB_INVALID_INDEX == (len = ObClusterVersion::print_version_str( + buf, OB_CLUSTER_VERSION_LENGTH, versions[i + 1])))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to print version", KR(ret), K(versions[i])); + } else if (OB_FAIL(str.append_fmt(", %.*s)", static_cast(len), buf))) { + LOG_WARN("failed to append end version", K(ret), K(versions[i])); + } + } + if (OB_SUCC(ret)) { + if (i != 0) { + if (OB_FAIL(str.append(", "))) { + LOG_WARN("failed to append", K(ret)); + } + } + if (OB_FAIL(ret)) { + } else if (OB_UNLIKELY(OB_INVALID_INDEX == (len = ObClusterVersion::print_version_str( + buf, OB_CLUSTER_VERSION_LENGTH, versions[i])))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to print version", KR(ret), K(versions[i])); + } else if (OB_FAIL(str.append_fmt("[%.*s, )", static_cast(len), buf))) { + LOG_WARN("failed to append last version", K(ret), K(versions[i])); + } else if (OB_FAIL(ob_write_string(allocator, str.string(), range_str))) { + LOG_WARN("failed to deep copy str", K(ret)); + } + } + return ret; +} + +int ObCompatControl::get_compat_version(const ObString &str, uint64_t &version) +{ + int ret = OB_SUCCESS; + if (OB_FAIL(ObClusterVersion::get_version(str, version))) { + LOG_WARN("failed to get version", K(ret), K(str)); + } + return ret; +} + +int ObCompatControl::check_compat_version(const uint64_t tenant_id, const uint64_t compat_version) +{ + int ret = OB_SUCCESS; + uint64_t data_version = 0; + uint64_t min_data_version = 0; + if (OB_UNLIKELY(compat_version > GET_MIN_CLUSTER_VERSION())) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("compat version must less than min cluster version", K(ret), K(compat_version)); + } else if (OB_FAIL(ObUpgradeChecker::get_data_version_by_cluster_version(compat_version, + data_version))) { + LOG_WARN("failed to get data version", K(ret)); + } else if (OB_INVALID_ID == tenant_id) { + // tenant_id is invalid when create tenant, there is no need to check min data version + } else if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, min_data_version))) { + LOG_WARN("failed to get min data version", K(ret)); + } else if (OB_UNLIKELY(data_version > min_data_version)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid data version", K(ret), K(compat_version), K(tenant_id), K(min_data_version)); + } + return ret; +} + +int ObCompatControl::get_version_str(uint64_t version, ObString &str, ObIAllocator &allocator) +{ + int ret = OB_SUCCESS; + char buf[OB_CLUSTER_VERSION_LENGTH] = {0}; + int64_t len = ObClusterVersion::print_version_str(buf, OB_CLUSTER_VERSION_LENGTH, version); + if (OB_UNLIKELY(OB_INVALID_INDEX == len)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to print version", KR(ret), K(version)); + } else if (OB_FAIL(ob_write_string(allocator, ObString(len, buf), str))) { + LOG_WARN("failed to write version str", K(ret), K(version)); + } + return ret; +} + +int ObCompatControl::check_feature_enable(const uint64_t compat_version, + const ObCompatFeatureType feature_type, + bool &is_enable) +{ + int ret = OB_SUCCESS; + int64_t i = feature_type; + if (OB_UNLIKELY(i < 0 || i >= ObCompatFeatureType::MAX_TYPE) || OB_ISNULL(infos_[i])) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected compat feature type", K(ret), K(feature_type)); + } else { + is_enable = infos_[i]->is_valid_version(compat_version); + } + return ret; +} + +} // end of namespace share +} // end of namespace oceanbase diff --git a/src/share/ob_compatibility_control.h b/src/share/ob_compatibility_control.h new file mode 100644 index 0000000000..633cf8895b --- /dev/null +++ b/src/share/ob_compatibility_control.h @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEABASE_SHARE_OB_COMPATIBILITY_CONTROL_H_ +#define OCEABASE_SHARE_OB_COMPATIBILITY_CONTROL_H_ + +#include "lib/container/ob_se_array.h" +#include "lib/utility/ob_macro_utils.h" + +namespace oceanbase +{ +namespace share +{ + +enum ObCompatType +{ + COMPAT_MYSQL57, + COMPAT_MYSQL8, +}; + +enum ObCompatFeatureType +{ +#define DEF_COMPAT_CONTROL_FEATURE(type, args...) type, +#include "share/ob_compatibility_control_feature_def.h" + COMPAT_FEATURE_END, +#include "share/ob_compatibility_security_feature_def.h" +#undef DEF_COMPAT_CONTROL_FEATURE + MAX_TYPE +}; + +class ObICompatInfo +{ +public: + ObICompatInfo(ObCompatFeatureType type, const char *name, const char *description) + : type_(type), name_(name), description_(description) + {} + virtual bool is_valid_version(uint64_t version) const; + virtual int print_version_range(common::ObString &range_str, ObIAllocator &allocator) const; +protected: + virtual void get_versions(const uint64_t *&versions, int64_t &version_num) const = 0; +public: + ObCompatFeatureType type_; + const char *name_; + const char *description_; +}; + +template +class ObCompatInfo : public ObICompatInfo +{ +public: + template + ObCompatInfo(ObCompatFeatureType type, const char *name, const char *description, Args... args) + : ObICompatInfo(type, name, description), + versions_{ args... } + { + } +protected: + virtual void get_versions(const uint64_t *&versions, int64_t &version_num) const override + { + versions = versions_; + version_num = ARRAYSIZEOF(versions_); + } +private: + uint64_t versions_[N]; +}; + +class ObCompatControl +{ +public: + static int get_compat_version(const common::ObString &str, uint64_t &version); + static int check_compat_version(const uint64_t tenant_id, const uint64_t compat_version); + static int get_version_str(uint64_t version, common::ObString &str, ObIAllocator &allocator); + static void get_compat_feature_infos(const ObICompatInfo **&infos, int64_t &len) + { infos = infos_; len = ObCompatFeatureType::MAX_TYPE; } + static int check_feature_enable(const uint64_t compat_version, + const ObCompatFeatureType feature_type, + bool &is_enable); +private: +#define DEF_COMPAT_CONTROL_FEATURE(type, description, args...) \ + static const ObCompatInfo COMPAT_##type; +#include "share/ob_compatibility_control_feature_def.h" +#include "share/ob_compatibility_security_feature_def.h" +#undef DEF_COMPAT_CONTROL_FEATURE + static const ObICompatInfo* infos_[]; +}; + +} // end of namespace share +} // end of namespace oceanbase + +#endif /* OCEABASE_SHARE_OB_COMPATIBILITY_CONTROL_H_*/ diff --git a/src/share/ob_compatibility_control_feature_def.h b/src/share/ob_compatibility_control_feature_def.h new file mode 100644 index 0000000000..ff8f818db6 --- /dev/null +++ b/src/share/ob_compatibility_control_feature_def.h @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +// define the feature list here whose behavior is different in MySQL5.7, MySQL8.0 or OB +// DEF_COMPAT_CONTROL_FEATURE(type, id, is_dynanmic, description, lastest_version, patch_versions ...) + +#ifdef DEF_COMPAT_CONTROL_FEATURE +DEF_COMPAT_CONTROL_FEATURE(FUNC_REPLACE_NULL, + "The result of REPLACE('abd', '', null) is different in MySQL 5.7 and 8.0", + MOCK_CLUSTER_VERSION_4_2_3_0, CLUSTER_VERSION_4_3_0_0, + CLUSTER_VERSION_4_3_2_0) + +DEF_COMPAT_CONTROL_FEATURE(UPD_LIMIT_OFFSET, + "MySQL do not support the use of OFFSET in the LIMIT clause of UPDATE/DELETE statement", + MOCK_CLUSTER_VERSION_4_2_3_0, CLUSTER_VERSION_4_3_0_0, + CLUSTER_VERSION_4_3_2_0) + +DEF_COMPAT_CONTROL_FEATURE(PROJECT_NULL, + "MySQL will rename the projection item names with pure null values to `NULL`", + MOCK_CLUSTER_VERSION_4_2_3_0, CLUSTER_VERSION_4_3_0_0, + CLUSTER_VERSION_4_3_2_0) + +DEF_COMPAT_CONTROL_FEATURE(VAR_NAME_LENGTH, + "MySQL will limit the length of user-defined variable names to within 64 characters", + MOCK_CLUSTER_VERSION_4_2_3_0, CLUSTER_VERSION_4_3_0_0, + CLUSTER_VERSION_4_3_2_0) +#endif diff --git a/src/share/ob_compatibility_security_feature_def.h b/src/share/ob_compatibility_security_feature_def.h new file mode 100644 index 0000000000..006079bc5d --- /dev/null +++ b/src/share/ob_compatibility_security_feature_def.h @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +// define the feature list here whose behavior is different in MySQL5.7, MySQL8.0 or OB +// DEF_COMPAT_CONTROL_FEATURE(type, id, is_dynanmic, description, lastest_version, patch_versions ...) + +#ifdef DEF_COMPAT_CONTROL_FEATURE +DEF_COMPAT_CONTROL_FEATURE(MYSQL_PRIV_ENHANCE, "add privilege check to some command", + MOCK_CLUSTER_VERSION_4_2_3_0, CLUSTER_VERSION_4_3_0_0, + CLUSTER_VERSION_4_3_2_0) +#endif diff --git a/src/share/ob_rpc_struct.cpp b/src/share/ob_rpc_struct.cpp index 88cfbaecfd..ee6ee3f7b6 100755 --- a/src/share/ob_rpc_struct.cpp +++ b/src/share/ob_rpc_struct.cpp @@ -4832,6 +4832,42 @@ OB_SERIALIZE_MEMBER((ObAlterUserProfileArg, ObDDLArg), role_id_array_, user_ids_); +bool ObAlterUserProxyArg::is_valid() const +{ + return is_valid_tenant_id(tenant_id_) + && !client_user_ids_.empty() + && !proxy_user_ids_.empty() + && flags_ != 0; +} + +int ObAlterUserProxyArg::assign(const ObAlterUserProxyArg &other) +{ + int ret = OB_SUCCESS; + tenant_id_ = other.tenant_id_; + credential_type_ = other.credential_type_; + is_grant_ = other.is_grant_; + flags_ = other.flags_; + if (OB_FAIL(ObDDLArg::assign(other))) { + LOG_WARN("fail to assign ddl arg", KR(ret)); + } else if (OB_FAIL(client_user_ids_.assign(other.client_user_ids_))) { + LOG_WARN("fail to assign role_id_array", KR(ret)); + } else if (OB_FAIL(proxy_user_ids_.assign(other.proxy_user_ids_))) { + LOG_WARN("fail to assign role_id_array", KR(ret)); + } else if (OB_FAIL(role_ids_.assign(other.role_ids_))) { + LOG_WARN("fail to assign role_id_array", KR(ret)); + } + return ret; +} + +OB_SERIALIZE_MEMBER((ObAlterUserProxyArg, ObDDLArg), + tenant_id_, + client_user_ids_, + proxy_user_ids_, + credential_type_, + flags_, + is_grant_, + role_ids_); + bool ObGrantArg::is_valid() const { return OB_INVALID_ID != tenant_id_ @@ -8165,6 +8201,17 @@ int ObPhysicalRestoreResult::assign(const ObPhysicalRestoreResult &other) return ret; } +OB_SERIALIZE_MEMBER(ObAlterUserProxyRes, ret_); +int ObAlterUserProxyRes::assign(const ObAlterUserProxyRes &other) +{ + int ret = OB_SUCCESS; + if (this != &other) { + reset(); + ret_ = other.ret_; + } + return ret; +} + OB_SERIALIZE_MEMBER(ObRefreshTimezoneArg, tenant_id_); OB_SERIALIZE_MEMBER(ObCreateRestorePointArg, tenant_id_, diff --git a/src/share/ob_rpc_struct.h b/src/share/ob_rpc_struct.h index cb120911fd..e19e836000 100755 --- a/src/share/ob_rpc_struct.h +++ b/src/share/ob_rpc_struct.h @@ -4569,7 +4569,6 @@ public: private: AdminDRTaskType type_; }; - struct ObAdminCommandArg { public: @@ -5323,6 +5322,28 @@ public: common::ObSEArray user_ids_; //for set default role to multiple users }; +struct ObAlterUserProxyArg : public ObDDLArg +{ + OB_UNIS_VERSION(1); +public: + ObAlterUserProxyArg() : ObDDLArg(), tenant_id_(common::OB_INVALID_TENANT_ID), + client_user_ids_(), proxy_user_ids_(), + credential_type_(0), flags_(0), role_ids_() + {} + virtual ~ObAlterUserProxyArg() {} + int assign(const ObAlterUserProxyArg &other); + bool is_valid() const; + TO_STRING_KV(K_(tenant_id), K_(client_user_ids), K_(proxy_user_ids), K_(role_ids), K_(flags)); + + uint64_t tenant_id_; + ObSEArray client_user_ids_; + ObSEArray proxy_user_ids_; + uint64_t credential_type_; + uint64_t flags_; + bool is_grant_; + common::ObSEArray role_ids_; +}; + struct ObCreateDirectoryArg : public ObDDLArg { OB_UNIS_VERSION(1); @@ -9477,6 +9498,23 @@ public: }; #endif +struct ObAlterUserProxyRes +{ + OB_UNIS_VERSION(1); +public: + ObAlterUserProxyRes() + : ret_(OB_SUCCESS) + {} + ~ObAlterUserProxyRes() {} + int assign(const ObAlterUserProxyRes &other); + void set_ret(int ret) { ret_ = ret; } + int64_t get_ret() const { return ret_; } + void reset() { ret_ = OB_SUCCESS; }; + TO_STRING_KV(K_(ret)); +private: + int ret_; +}; + struct TenantServerUnitConfig { public: @@ -11606,7 +11644,6 @@ public: uint64_t tenant_id_; int64_t log_disk_size_; }; - struct ObDumpServerUsageRequest final { OB_UNIS_VERSION(1); @@ -11615,7 +11652,6 @@ public: ~ObDumpServerUsageRequest() { tenant_id_ = OB_INVALID_TENANT_ID; } uint64_t tenant_id_; }; - struct ObDumpServerUsageResult final { OB_UNIS_VERSION(1); diff --git a/src/share/ob_upgrade_utils.cpp b/src/share/ob_upgrade_utils.cpp index a624bf570d..6c3c67f509 100755 --- a/src/share/ob_upgrade_utils.cpp +++ b/src/share/ob_upgrade_utils.cpp @@ -1296,6 +1296,66 @@ int ObUpgradeFor4310Processor::post_upgrade_for_create_replication_role_in_oracl } return ret; } + +int ObUpgradeFor4320Processor::post_upgrade() +{ + int ret = OB_SUCCESS; + if (OB_FAIL(check_inner_stat())) { + LOG_WARN("fail to check inner stat", KR(ret)); + } else if (OB_FAIL(post_upgrade_for_reset_compat_version())) { + LOG_WARN("fail to reset compat version", KR(ret)); + } + return ret; +} + +int ObUpgradeFor4320Processor::post_upgrade_for_reset_compat_version() +{ + int ret = OB_SUCCESS; + int64_t start = ObTimeUtility::current_time(); + if (!is_user_tenant(tenant_id_)) { + LOG_INFO("meta and sys tenant no need to reset system variable", K_(tenant_id)); + } else if (OB_FAIL(try_reset_version(tenant_id_, OB_SV_COMPATIBILITY_VERSION))) { + LOG_WARN("failed to try reset ob_compatibility_version", K(ret)); + } else if (OB_FAIL(try_reset_version(tenant_id_, OB_SV_SECURITY_VERSION))) { + LOG_WARN("failed to try reset ob_security_version", K(ret)); + } + LOG_INFO("[UPGRADE] finish reset compat version", K(ret), K(tenant_id_), + "cost", ObTimeUtility::current_time() - start); + return ret; +} + +int ObUpgradeFor4320Processor::try_reset_version(const uint64_t tenant_id, const char *var_name) +{ + int ret = OB_SUCCESS; + ObSchemaGetterGuard schema_guard; + const ObSysVarSchema *var_schema = NULL; + ObObj val_obj; + uint64_t version = 0; + if (OB_ISNULL(schema_service_) || OB_ISNULL(sql_proxy_) || OB_ISNULL(var_name)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null ptr", K(ret)); + } else if (OB_FAIL(schema_service_->get_tenant_schema_guard(tenant_id_, schema_guard))) { + LOG_WARN("failed to get schema guard", K(ret)); + } else if (OB_FAIL(schema_guard.get_tenant_system_variable(tenant_id_, var_name, var_schema))) { + LOG_WARN("failed to get system variable", K(ret)); + } else if (OB_ISNULL(var_schema)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("var_schema is null", K(ret)); + } else if (OB_FAIL(var_schema->get_value(NULL, NULL, val_obj))) { + LOG_WARN("failed to get value from var_schema", K(ret), KPC(var_schema)); + } else if (OB_FAIL(val_obj.get_uint64(version))) { + LOG_WARN("fail to get uint", K(val_obj), K(ret)); + } else if (CLUSTER_VERSION_4_2_1_0 != version) { + ObSqlString set_sql; + int64_t affected_rows = 0; + if (OB_FAIL(set_sql.assign_fmt("set global %s = %ld", var_name, CLUSTER_VERSION_4_2_1_0))) { + LOG_WARN("failed to assign sql", K(ret)); + } else if (OB_FAIL(sql_proxy_->write(tenant_id_, set_sql.ptr(), affected_rows))) { + LOG_WARN("failed to write sql", K(ret), K(set_sql)); + } + } + return ret; +} /* =========== 4310 upgrade processor end ============= */ /* =========== special upgrade processor end ============= */ diff --git a/src/share/ob_upgrade_utils.h b/src/share/ob_upgrade_utils.h index 97232b8df2..63a2d0ad36 100755 --- a/src/share/ob_upgrade_utils.h +++ b/src/share/ob_upgrade_utils.h @@ -244,7 +244,17 @@ private: int post_upgrade_for_create_replication_role_in_oracle(); }; -DEF_SIMPLE_UPGRARD_PROCESSER(4, 3, 2, 0) +class ObUpgradeFor4320Processor : public ObBaseUpgradeProcessor +{ +public: + ObUpgradeFor4320Processor() : ObBaseUpgradeProcessor() {} + virtual ~ObUpgradeFor4320Processor() {} + virtual int pre_upgrade() override { return common::OB_SUCCESS; } + virtual int post_upgrade() override; +private: + int post_upgrade_for_reset_compat_version(); + int try_reset_version(const uint64_t tenant_id, const char *var_name); +}; /* =========== special upgrade processor end ============= */ diff --git a/src/share/ob_virtual_table_iterator.cpp b/src/share/ob_virtual_table_iterator.cpp index 81a03da50b..18de78a895 100644 --- a/src/share/ob_virtual_table_iterator.cpp +++ b/src/share/ob_virtual_table_iterator.cpp @@ -544,7 +544,7 @@ int ObVirtualTableIterator::check_priv(const ObString &level_str, int ret = OB_SUCCESS; share::schema::ObSessionPrivInfo session_priv; CK (OB_NOT_NULL(session_) && OB_NOT_NULL(schema_guard_)); - OX (session_->get_session_priv_info(session_priv)); + OZ (session_->get_session_priv_info(session_priv)); // bool allow_show = true; if (OB_SUCC(ret)) { //tenant_id in table is static casted to int64_t, diff --git a/src/share/schema/ob_priv_sql_service.cpp b/src/share/schema/ob_priv_sql_service.cpp index 93567e416c..3c918b7976 100644 --- a/src/share/schema/ob_priv_sql_service.cpp +++ b/src/share/schema/ob_priv_sql_service.cpp @@ -982,7 +982,7 @@ int ObPrivSqlService::gen_routine_priv_dml( int ObPrivSqlService::gen_db_priv_dml( const uint64_t exec_tenant_id, const ObOriginalDBKey &db_priv_key, - const ObPrivSet &priv_set, + const ObPrivSet &priv_set, ObDMLSqlSplicer &dml) { int ret = OB_SUCCESS; @@ -1368,6 +1368,112 @@ int ObPrivSqlService::grant_sys_priv_to_ur( return ret; } +int ObPrivSqlService::grant_proxy(const uint64_t tenant_id, + const uint64_t client_user_id, + const uint64_t proxy_user_id, + const uint64_t flags, + const int64_t new_schema_version, + ObISQLClient &sql_client, + const bool is_grant) +{ + int ret = OB_SUCCESS; + const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id); + int64_t affected_rows = 0; + const bool is_deleted = is_grant ? false : true; + ObDMLExecHelper exec(sql_client, exec_tenant_id); + ObDMLSqlSplicer dml; + uint64_t tenant_data_version = 0; + if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, tenant_data_version))) { + LOG_WARN("get tenant data version failed", K(ret)); + } else if (!ObSQLUtils::is_data_version_ge_423_or_432(tenant_data_version)) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "alter user grant connect through is not supported when data version is below 4.2.3 or 4.3.2"); + } else if (OB_FAIL(dml.add_pk_column("tenant_id", 0)) + || OB_FAIL(dml.add_pk_column("client_user_id", client_user_id)) + || OB_FAIL(dml.add_pk_column("proxy_user_id", proxy_user_id)) + || OB_FAIL(dml.add_column("flags", flags)) + || OB_FAIL(dml.add_column("credential_type", 0))) { + LOG_WARN("add column failed", K(ret)); + } else if (is_grant) { + if (OB_FAIL(exec.exec_replace(OB_ALL_USER_PROXY_INFO_TNAME, dml, affected_rows))) { + LOG_WARN("exec replace failed", K(ret)); + } + } else { + if (OB_FAIL(exec.exec_delete(OB_ALL_USER_PROXY_INFO_TNAME, dml, affected_rows))) { + LOG_WARN("exec delete failed", K(ret)); + } else if (!is_single_row(affected_rows)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expeccted to be one", K(affected_rows), K(ret)); + } + } + + if (OB_FAIL(ret)) { + } else if (OB_FAIL(dml.add_pk_column("schema_version", new_schema_version)) + || OB_FAIL(dml.add_column("is_deleted", is_deleted))) { + LOG_WARN("add column failed", K(ret)); + } else if (OB_FAIL(exec.exec_insert(OB_ALL_USER_PROXY_INFO_HISTORY_TNAME, dml, affected_rows))) { + LOG_WARN("exec_replace failed", K(ret)); + } else if (!is_single_row(affected_rows)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expeccted to be one", K(affected_rows), K(ret)); + } + return ret; +} + +int ObPrivSqlService::grant_proxy_role(const uint64_t tenant_id, + const uint64_t client_user_id, + const uint64_t proxy_user_id, + const uint64_t role_id, + const int64_t new_schema_version, + ObISQLClient &sql_client, + const bool is_grant) +{ + int ret = OB_SUCCESS; + const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id); + int64_t affected_rows = 0; + ObDMLExecHelper exec(sql_client, exec_tenant_id); + ObDMLSqlSplicer dml; + uint64_t tenant_data_version = 0; + if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, tenant_data_version))) { + LOG_WARN("get tenant data version failed", K(ret)); + } else if (!ObSQLUtils::is_data_version_ge_423_or_432(tenant_data_version)) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "alter user grant connect through is not supported when data version is below 4.2.3 or 4.3.2"); + } else if (OB_FAIL(dml.add_pk_column("tenant_id", 0)) + || OB_FAIL(dml.add_pk_column("client_user_id", client_user_id)) + || OB_FAIL(dml.add_pk_column("proxy_user_id", proxy_user_id)) + || OB_FAIL(dml.add_pk_column("role_id", role_id))) { + LOG_WARN("add column failed", K(ret)); + } else if (is_grant) { + if (OB_FAIL(exec.exec_replace(OB_ALL_USER_PROXY_ROLE_INFO_TNAME, dml, affected_rows))) { + LOG_WARN("exec replace failed", K(ret)); + } else if (!is_single_row(affected_rows)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expeccted to be one", K(affected_rows), K(ret)); + } + } else { + if (OB_FAIL(exec.exec_delete(OB_ALL_USER_PROXY_ROLE_INFO_TNAME, dml, affected_rows))) { + LOG_WARN("exec delete failed", K(ret)); + } else if (!is_single_row(affected_rows)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expeccted to be one", K(affected_rows), K(ret)); + } + } + + if (OB_FAIL(ret)) { + } else if (OB_FAIL(dml.add_pk_column("schema_version", new_schema_version)) + || OB_FAIL(dml.add_column("is_deleted", !is_grant))) { + LOG_WARN("add column failed", K(ret)); + } else if (OB_FAIL(exec.exec_insert(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TNAME, dml, affected_rows))) { + LOG_WARN("exec_replace failed", K(ret)); + } else if (!is_single_row(affected_rows)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expeccted to be one", K(affected_rows), K(ret)); + } + return ret; +} + + } //end of schema } //end of share } //end of oceanbase diff --git a/src/share/schema/ob_priv_sql_service.h b/src/share/schema/ob_priv_sql_service.h index dbd5478e0c..9a1a5abe9b 100644 --- a/src/share/schema/ob_priv_sql_service.h +++ b/src/share/schema/ob_priv_sql_service.h @@ -165,6 +165,22 @@ public: const int64_t new_schema_version, ObISQLClient &sql_client); + virtual int grant_proxy(const uint64_t tenant_id, + const uint64_t client_user_id, + const uint64_t proxy_user_id, + const uint64_t flags, + const int64_t new_schema_version, + ObISQLClient &sql_client, + const bool is_grant); + + virtual int grant_proxy_role(const uint64_t tenant_id, + const uint64_t client_user_id, + const uint64_t proxy_user_id, + const uint64_t role_id, + const int64_t new_schema_version, + ObISQLClient &sql_client, + const bool is_grant); + private: int log_obj_priv_operation( const ObObjPrivSortKey &obj_priv_key, diff --git a/src/share/schema/ob_priv_type.h b/src/share/schema/ob_priv_type.h index 5c10a46bc7..27d78fe1bc 100644 --- a/src/share/schema/ob_priv_type.h +++ b/src/share/schema/ob_priv_type.h @@ -119,6 +119,9 @@ enum OB_PRIV_SHIFT #define OB_PRIV_EXECUTE OB_PRIV_GET_TYPE(OB_PRIV_EXECUTE_SHIFT) #define OB_PRIV_ALTER_ROUTINE OB_PRIV_GET_TYPE(OB_PRIV_ALTER_ROUTINE_SHIFT) #define OB_PRIV_CREATE_ROUTINE OB_PRIV_GET_TYPE(OB_PRIV_CREATE_ROUTINE_SHIFT) +#define OB_PRIV_CREATE_TABLESPACE OB_PRIV_GET_TYPE(OB_PRIV_CREATE_TABLESPACE_SHIFT) +#define OB_PRIV_SHUTDOWN OB_PRIV_GET_TYPE(OB_PRIV_SHUTDOWN_SHIFT) +#define OB_PRIV_RELOAD OB_PRIV_GET_TYPE(OB_PRIV_RELOAD_SHIFT) #define OB_PRIV_ALL \ (OB_PRIV_ALTER | OB_PRIV_CREATE | OB_PRIV_CREATE_USER | OB_PRIV_DELETE | \ @@ -129,7 +132,8 @@ enum OB_PRIV_SHIFT OB_PRIV_CREATE_RESOURCE_POOL | OB_PRIV_CREATE_RESOURCE_UNIT| \ OB_PRIV_REPL_SLAVE | OB_PRIV_REPL_CLIENT | \ OB_PRIV_DROP_DATABASE_LINK | OB_PRIV_CREATE_DATABASE_LINK | \ - OB_PRIV_EXECUTE | OB_PRIV_ALTER_ROUTINE | OB_PRIV_CREATE_ROUTINE) + OB_PRIV_EXECUTE | OB_PRIV_ALTER_ROUTINE | OB_PRIV_CREATE_ROUTINE | \ + OB_PRIV_CREATE_TABLESPACE | OB_PRIV_SHUTDOWN | OB_PRIV_RELOAD) #define OB_PRIV_DB_ACC \ (OB_PRIV_ALTER | OB_PRIV_CREATE | OB_PRIV_DELETE | \ diff --git a/src/share/schema/ob_schema_getter_guard.cpp b/src/share/schema/ob_schema_getter_guard.cpp index f1d9fdb31f..3658de6659 100644 --- a/src/share/schema/ob_schema_getter_guard.cpp +++ b/src/share/schema/ob_schema_getter_guard.cpp @@ -2980,18 +2980,77 @@ int ObSchemaGetterGuard::check_user_access( "client_ip_", login_info.client_ip_, KR(ret)); } } + const ObUserInfo *proxied_user_info = NULL; + uint64_t proxied_info_idx = OB_INVALID_INDEX; + if (OB_SUCC(ret) && compat_mode == lib::Worker::CompatMode::ORACLE) { + if (!login_info.proxied_user_name_.empty()) { + users_info.reuse(); + if (OB_FAIL(get_user_info(s_priv.tenant_id_, login_info.proxied_user_name_, users_info))) { + LOG_WARN("get user info failed", KR(ret), K(s_priv.tenant_id_), K(login_info)); + } else if (users_info.count() <= 0) { + ret = OB_PASSWORD_WRONG; + LOG_WARN("proxy user not existed", K(ret)); + } else if (OB_ISNULL(proxied_user_info = users_info.at(0))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else { + is_found = false; + for (int64_t i = 0; OB_SUCC(ret) && !is_found && i < proxied_user_info->get_proxied_user_info_cnt(); i++) { + const ObProxyInfo *proxied_info = proxied_user_info->get_proxied_user_info_by_idx(i); + if (OB_ISNULL(proxied_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (proxied_info->user_id_ == user_info->get_user_id()) { + is_found = true; + proxied_info_idx = i; + } + } + if (OB_FAIL(ret)) { + } else if (!is_found) { + ret = OB_PASSWORD_WRONG; + LOG_WARN("proxy user not existed", KR(ret), K(user_info->get_user_id()), KPC(proxied_user_info)); + proxied_user_info = NULL; + } else { + s_priv.proxy_user_name_ = user_info->get_user_name_str(); + s_priv.proxy_host_name_ = user_info->get_host_name_str(); + } + } + } + } + + if (OB_SUCC(ret) && proxied_user_info!= NULL) { + if (proxied_user_info->get_is_locked() + && !sql::ObOraSysChecker::is_super_user(proxied_user_info->get_user_id())) { + ret = OB_ERR_USER_IS_LOCKED; + LOG_WARN("User is locked", KR(ret)); + } + } if (OB_SUCC(ret)) { s_priv.tenant_id_ = user_info->get_tenant_id(); - s_priv.user_id_ = user_info->get_user_id(); - s_priv.user_name_ = user_info->get_user_name_str(); - s_priv.host_name_ = user_info->get_host_name_str(); - s_priv.user_priv_set_ = user_info->get_priv_set(); + if (proxied_user_info != NULL) { + s_priv.user_id_ = proxied_user_info->get_user_id(); + s_priv.proxy_user_id_ = user_info->get_user_id(); + s_priv.user_name_ = proxied_user_info->get_user_name_str(); + s_priv.host_name_ = proxied_user_info->get_host_name_str(); + s_priv.proxy_user_name_ = user_info->get_user_name_str(); + s_priv.proxy_host_name_ = user_info->get_host_name_str(); + s_priv.user_priv_set_ = proxied_user_info->get_priv_set(); + sel_user_info = proxied_user_info; + } else { + s_priv.user_id_ = user_info->get_user_id(); + s_priv.proxy_user_id_ = OB_INVALID_ID; + s_priv.user_id_ = user_info->get_user_id(); + s_priv.user_name_ = user_info->get_user_name_str(); + s_priv.host_name_ = user_info->get_host_name_str(); + s_priv.proxy_user_name_ = ObString(); + s_priv.proxy_host_name_ = ObString(); + s_priv.user_priv_set_ = user_info->get_priv_set(); + sel_user_info = user_info; + } s_priv.db_ = login_info.db_; - sel_user_info = user_info; - // load role priv + // load role privx if (OB_SUCC(ret)) { - const ObSEArray &role_id_array = user_info->get_role_id_array(); bool activate_all_role = false; CK (user_info->get_role_id_array().count() == user_info->get_role_id_option_array().count()); @@ -3002,6 +3061,57 @@ int ObSchemaGetterGuard::check_user_access( } } + ObSEArray role_id_array; + ObSEArray role_id_option_array; + if (proxied_user_info != NULL) { + CK (proxied_user_info->get_role_id_array().count() == + proxied_user_info->get_role_id_option_array().count()); + OZ (role_id_array.assign(proxied_user_info->get_role_id_array())); + OZ (role_id_option_array.assign(proxied_user_info->get_role_id_option_array())); + } else { + CK (user_info->get_role_id_array().count() == + user_info->get_role_id_option_array().count()); + OZ (role_id_array.assign(user_info->get_role_id_array())); + OZ (role_id_option_array.assign(user_info->get_role_id_option_array())); + } + if (OB_SUCC(ret) && compat_mode == lib::Worker::CompatMode::ORACLE && proxied_user_info != NULL) { + const ObProxyInfo *proxied_info = NULL; + if (OB_UNLIKELY(proxied_info_idx < 0 || proxied_info_idx >= proxied_user_info->get_proxied_user_info_cnt())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_ISNULL(proxied_info = proxied_user_info->get_proxied_user_info_by_idx(proxied_info_idx)) + || OB_UNLIKELY(proxied_info->user_id_ != user_info->get_user_id())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else { + ObArray new_role_id_array; + ObArray new_role_id_option_array; + if (OB_FAIL(sql::ObSQLUtils::get_proxy_can_activate_role(role_id_array, + role_id_option_array, + *proxied_info, + new_role_id_array, + new_role_id_option_array))) { + LOG_WARN("get proxy can activate role failed", K(ret)); + } else { + role_id_array.reuse(); + role_id_option_array.reuse(); + for (int64_t i = 0; OB_SUCC(ret) && i < new_role_id_array.count(); i++) { + const ObUserInfo *role_info = NULL; + if (OB_FAIL(get_user_info(s_priv.tenant_id_, new_role_id_array.at(i), role_info))) { + LOG_WARN("failed to get role ids", KR(ret), K(new_role_id_array.at(i))); + } else if (NULL == role_info) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("role info is null", KR(ret), K(new_role_id_array.at(i))); + } else if (!role_info->get_passwd_str().empty()) { + //do nothing + } else { + OZ (role_id_array.push_back(new_role_id_array.at(i))); + OZ (role_id_option_array.push_back(new_role_id_option_array.at(i))); + } + } + } + } + } for (int i = 0; OB_SUCC(ret) && i < role_id_array.count(); ++i) { const ObUserInfo *role_info = NULL; if (OB_FAIL(get_user_info(s_priv.tenant_id_, role_id_array.at(i), role_info))) { @@ -3011,9 +3121,8 @@ int ObSchemaGetterGuard::check_user_access( LOG_WARN("role info is null", KR(ret), K(role_id_array.at(i))); } else if (lib::Worker::CompatMode::ORACLE == compat_mode) { s_priv.user_priv_set_ |= role_info->get_priv_set(); - if (user_info->get_disable_option( - user_info->get_role_id_option_array().at(i)) == 0) { - OZ (add_role_id_recursively(user_info->get_tenant_id(), + if (user_info->get_disable_option(role_id_option_array.at(i)) == 0) { + OZ (add_role_id_recursively(s_priv.tenant_id_, role_id_array.at(i), s_priv)); } diff --git a/src/share/schema/ob_schema_retrieve_utils.h b/src/share/schema/ob_schema_retrieve_utils.h index d8c12039bf..51e9f1901d 100644 --- a/src/share/schema/ob_schema_retrieve_utils.h +++ b/src/share/schema/ob_schema_retrieve_utils.h @@ -417,6 +417,8 @@ public: RETRIEVE_SCHEMA_FUNC_DECLARE(rls_policy); RETRIEVE_SCHEMA_FUNC_DECLARE(rls_group); RETRIEVE_SCHEMA_FUNC_DECLARE(rls_context); + //RETRIEVE_SCHEMA_FUNC_DECLARE(proxy); + //RETRIEVE_SCHEMA_FUNC_DECLARE(proxy_role); template static int retrieve_object_list(const uint64_t tenant_id, T &result, common::ObIArray &trigger_list); template @@ -623,6 +625,17 @@ public: T &result, const bool is_fetch_role, ObArray &user_array); + template + static int retrieve_proxy_info_schema(const uint64_t tenant_id, + T &result, + const bool is_fetch_proxy, + ObArray &user_array); + + template + static int retrieve_proxy_role_info_schema(const uint64_t tenant_id, + T &result, + const bool is_fetch_proxy, + ObArray &user_array); static inline int find_user_info(const uint64_t user_id, ObArray &user_array, ObUserInfo *&user_info); @@ -642,6 +655,8 @@ public: static int fill_object_id(const uint64_t tenant_id, T &result, uint64_t &object_id, bool &is_deleted); + // template + // static bool compare_proxy_id(const T *proxy_schema, const uint64_t proxy_id); //=========================================================================== template diff --git a/src/share/schema/ob_schema_retrieve_utils.ipp b/src/share/schema/ob_schema_retrieve_utils.ipp index 5633fb615f..548c2c1a9d 100644 --- a/src/share/schema/ob_schema_retrieve_utils.ipp +++ b/src/share/schema/ob_schema_retrieve_utils.ipp @@ -1912,6 +1912,17 @@ int ObSchemaRetrieveUtils::fill_user_schema( user_info.set_priv((priv_others & 1) != 0 ? OB_PRIV_EXECUTE : 0); user_info.set_priv((priv_others & 2) != 0 ? OB_PRIV_ALTER_ROUTINE : 0); user_info.set_priv((priv_others & 4) != 0 ? OB_PRIV_CREATE_ROUTINE : 0); + user_info.set_priv((priv_others & 8) != 0 ? OB_PRIV_CREATE_TABLESPACE : 0); + user_info.set_priv((priv_others & 16) != 0 ? OB_PRIV_SHUTDOWN : 0); + user_info.set_priv((priv_others & 32) != 0 ? OB_PRIV_RELOAD : 0); + + if (OB_SUCC(ret)) { + int64_t default_flags = 0; + //In user schema def, flag is a int column. + //int is int64_t, not uint64_t. So only 63 bit can be used. + EXTRACT_INT_FIELD_TO_CLASS_MYSQL_WITH_DEFAULT_VALUE(result, flags, user_info, int64_t, + true/* skip null error*/, ignore_column_error, default_flags); + } } return ret; } @@ -2000,6 +2011,145 @@ int ObSchemaRetrieveUtils::retrieve_role_grantee_map_schema( return ret; } +template +int ObSchemaRetrieveUtils::retrieve_proxy_info_schema( + const uint64_t tenant_id, + T &result, + const bool is_fetch_proxy, + ObArray &user_array) +{ + int ret = common::OB_SUCCESS; + uint64_t prev_key_id = common::OB_INVALID_ID; + uint64_t prev_value_id = common::OB_INVALID_ID; + ObArenaAllocator allocator(ObModIds::OB_TEMP_VARIABLES); + while (OB_SUCC(ret) && OB_SUCC(result.next())) { + allocator.reset(); + uint64_t proxy_user_id = common::OB_INVALID_ID; + uint64_t client_user_id = common::OB_INVALID_ID; + bool is_deleted = false; + uint64_t flags = 0; + uint64_t credential_type = 0; + EXTRACT_INT_FIELD_MYSQL(result, "proxy_user_id", proxy_user_id, uint64_t); + EXTRACT_INT_FIELD_MYSQL(result, "client_user_id", client_user_id, uint64_t); + EXTRACT_INT_FIELD_MYSQL(result, "is_deleted", is_deleted, bool); + + ObUserInfo *user_info = NULL; + if (OB_FAIL(ret)) { + } else if (is_deleted) { + SHARE_SCHEMA_LOG(INFO, "proxy is deleted", K(proxy_user_id), K(client_user_id)); + } else if (prev_key_id == (is_fetch_proxy ? proxy_user_id : client_user_id) + && prev_value_id == (is_fetch_proxy ? client_user_id : proxy_user_id)) { + ret = common::OB_SUCCESS; + } else { + EXTRACT_INT_FIELD_MYSQL(result, "flags", flags, uint64_t); + EXTRACT_INT_FIELD_MYSQL(result, "credential_type", credential_type, uint64_t); + if (OB_FAIL(ret)) { + } else if (OB_FAIL(ObSchemaRetrieveUtils::find_user_info(is_fetch_proxy ? proxy_user_id : client_user_id, + user_array, user_info))) { + SHARE_SCHEMA_LOG(WARN, "failed to find user info", K(ret), K(client_user_id), K(proxy_user_id)); + } else if (NULL == user_info) { + SHARE_SCHEMA_LOG(INFO, "user info is null", K(ret), K(is_fetch_proxy), K(proxy_user_id), K(client_user_id)); + } else { + ObProxyInfo proxy_info(&allocator); + proxy_info.user_id_ = is_fetch_proxy ? client_user_id : proxy_user_id; + proxy_info.proxy_flags_ = flags; + proxy_info.credential_type_ = credential_type; + if (is_fetch_proxy) { + OZ (user_info->add_proxy_user_info(proxy_info)); + } else { + OZ (user_info->add_proxied_user_info(proxy_info)); + } + } + } + // iterate next + prev_key_id = is_fetch_proxy ? proxy_user_id : client_user_id; + prev_value_id = is_fetch_proxy ? client_user_id : proxy_user_id; + } + if (ret != common::OB_ITER_END) { + SHARE_SCHEMA_LOG(WARN, "fail to get role grantee map. iter quit. ", K(ret)); + } else { + ret = common::OB_SUCCESS; + } + return ret; +} + +template +int ObSchemaRetrieveUtils::retrieve_proxy_role_info_schema( + const uint64_t tenant_id, + T &result, + const bool is_fetch_proxy, + ObArray &user_array) +{ + int ret = common::OB_SUCCESS; + uint64_t prev_key_id = common::OB_INVALID_ID; + uint64_t prev_value_id = common::OB_INVALID_ID; + uint64_t prev_role_id = common::OB_INVALID_ID; + while (OB_SUCC(ret) && OB_SUCC(result.next())) { + uint64_t client_user_id = common::OB_INVALID_ID; + uint64_t proxy_user_id = common::OB_INVALID_ID; + uint64_t role_id = common::OB_INVALID_ID; + bool is_deleted = false; + uint64_t flags = 0; + EXTRACT_INT_FIELD_MYSQL(result, "proxy_user_id", proxy_user_id, uint64_t); + EXTRACT_INT_FIELD_MYSQL(result, "client_user_id", client_user_id, uint64_t); + EXTRACT_INT_FIELD_MYSQL(result, "role_id", role_id, uint64_t); + EXTRACT_INT_FIELD_MYSQL(result, "is_deleted", is_deleted, bool); + + ObUserInfo *user_info = NULL; + if (OB_FAIL(ret)) { + } else if (is_deleted) { + SHARE_SCHEMA_LOG(INFO, "proxy is deleted", K(proxy_user_id), K(client_user_id), K(role_id)); + } else if (prev_key_id == (is_fetch_proxy ? proxy_user_id : client_user_id) + && prev_value_id == (is_fetch_proxy ? client_user_id : proxy_user_id) + && prev_role_id == role_id) { + ret = common::OB_SUCCESS; + } else { + if (OB_FAIL(ObSchemaRetrieveUtils::find_user_info(is_fetch_proxy ? proxy_user_id : client_user_id, + user_array, user_info))) { + SHARE_SCHEMA_LOG(WARN, "failed to find user info", K(ret), K(client_user_id), K(proxy_user_id)); + } else if (NULL == user_info) { + SHARE_SCHEMA_LOG(INFO, "user info is null", K(ret), K(is_fetch_proxy), K(proxy_user_id), K(client_user_id)); + } else { + if (is_fetch_proxy) { + for (int64_t i = 0; OB_SUCC(ret) && i < user_info->get_proxy_user_info_cnt(); i++) { + ObProxyInfo *proxy_info = user_info->get_proxy_user_info_by_idx_for_update(i); + if (OB_ISNULL(proxy_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (proxy_info->user_id_ == client_user_id) { + if (OB_FAIL(proxy_info->add_role_id(role_id))) { + LOG_WARN("add role id failed", K(ret)); + } + } + } + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < user_info->get_proxied_user_info_cnt(); i++) { + ObProxyInfo *proxied_info = user_info->get_proxied_user_info_by_idx_for_update(i); + if (OB_ISNULL(proxied_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (proxied_info->user_id_ == proxy_user_id) { + if (OB_FAIL(proxied_info->add_role_id(role_id))) { + LOG_WARN("add role id failed", K(ret)); + } + } + } + } + } + } + // iterate next + prev_key_id = is_fetch_proxy ? proxy_user_id : client_user_id; + prev_value_id = is_fetch_proxy ? client_user_id : proxy_user_id; + prev_role_id = role_id; + } + if (ret != common::OB_ITER_END) { + SHARE_SCHEMA_LOG(WARN, "fail to get role grantee map. iter quit. ", K(ret)); + } else { + ret = common::OB_SUCCESS; + } + return ret; +} + int ObSchemaRetrieveUtils::find_user_info( const uint64_t user_id, ObArray &user_array, diff --git a/src/share/schema/ob_schema_service.h b/src/share/schema/ob_schema_service.h index 935fe2ddfd..0bd727f7bd 100755 --- a/src/share/schema/ob_schema_service.h +++ b/src/share/schema/ob_schema_service.h @@ -404,10 +404,12 @@ public: union { uint64_t user_id_; uint64_t grantee_id_; + uint64_t client_user_id_; }; union { uint64_t database_id_; uint64_t grantor_id_; + uint64_t proxy_user_id_; }; common::ObString database_name_; uint64_t tablegroup_id_; diff --git a/src/share/schema/ob_schema_service_sql_impl.cpp b/src/share/schema/ob_schema_service_sql_impl.cpp index f21552c2f2..25e06be7d3 100644 --- a/src/share/schema/ob_schema_service_sql_impl.cpp +++ b/src/share/schema/ob_schema_service_sql_impl.cpp @@ -133,6 +133,8 @@ #define FETCH_ALL_RLS_GROUP_HISTORY_SQL COMMON_SQL_WITH_TENANT #define FETCH_ALL_RLS_CONTEXT_HISTORY_SQL COMMON_SQL_WITH_TENANT #define FETCH_ALL_RLS_SEC_COLUMN_HISTORY_SQL COMMON_SQL_WITH_TENANT +#define FETCH_ALL_PROXY_INFO_HISTORY_SQL COMMON_SQL_WITH_TENANT +#define FETCH_ALL_PROXY_ROLE_INFO_HISTORY_SQL COMMON_SQL_WITH_TENANT #define FETCH_ALL_CASCADE_OBJECT_ID_HISTORY_SQL "SELECT %s object_id, is_deleted FROM %s " \ "WHERE tenant_id = %lu AND %s = %lu AND schema_version <= %lu " \ "ORDER BY object_id desc, schema_version desc" @@ -2719,6 +2721,29 @@ int ObSchemaServiceSQLImpl::fetch_all_tenant_info( ret; \ }) +#define SQL_APPEND_PROXY_USERS_ID(schema_keys, tenant_id, schema_key_size, sql) \ +({ \ + int ret = OB_SUCCESS; \ + if (OB_FAIL(sql.append("("))) { \ + LOG_WARN("append sql failed", K(ret)); \ + } else { \ + for (int64_t i = 0; OB_SUCC(ret) && i < schema_key_size; ++i) { \ + if (OB_FAIL(sql.append_fmt("%s(%lu, %lu, %lu)", 0 == i ? "" : ", ", \ + fill_extract_tenant_id(schema_status, tenant_id), \ + schema_keys[i].client_user_id_, \ + schema_keys[i].proxy_user_id_))) { \ + LOG_WARN("append sql failed", K(ret)); \ + } \ + } \ + if (OB_SUCC(ret)) { \ + if (OB_FAIL(sql.append(")"))) { \ + LOG_WARN("append sql failed", K(ret)); \ + } \ + } \ + } \ + ret; \ + }) + #define SQL_APPEND_OBJ_PRIV_ID(schema_keys, tenant_id, schema_key_size, sql) \ ({ \ int ret = OB_SUCCESS; \ @@ -4593,6 +4618,24 @@ int ObSchemaServiceSQLImpl::fetch_all_user_info( user_keys, users_size))) { LOG_WARN("failed to fetch_role_grantee_map_info", K(ret)); + } else if (OB_FAIL(fetch_proxy_user_info(schema_status, + schema_version, + tenant_id, + sql_client, + user_array, + true, /*get proxy info*/ + user_keys, + users_size))) { + LOG_WARN("fetch proxy user info failed", K(ret)); + } else if (OB_FAIL(fetch_proxy_user_info(schema_status, + schema_version, + tenant_id, + sql_client, + user_array, + false, /*get proxied info*/ + user_keys, + users_size))) { + LOG_WARN("fetch proxy user info failed", K(ret)); } } } @@ -4816,6 +4859,199 @@ int ObSchemaServiceSQLImpl::fetch_role_grantee_map_info( return ret; } + +// fill ObUserInfo +// 1. If user info is a user, get the users info which the user can proxy and be proxied. +// 2. If user info is a role, do nothing +int ObSchemaServiceSQLImpl::fetch_proxy_user_info( + const ObRefreshSchemaStatus &schema_status, + const int64_t schema_version, + const uint64_t tenant_id, + ObISQLClient &sql_client, + ObArray &user_array, + const bool is_fetch_proxy, + const uint64_t *user_keys, + const int64_t users_size) +{ + int ret = OB_SUCCESS; + ObSqlString sql; + SMART_VAR(ObMySQLProxy::MySQLResult, res) { + ObMySQLResult *result = NULL; + const bool is_full_schema = (NULL != user_keys && users_size > 0) ? false : true; + const int64_t snapshot_timestamp = schema_status.snapshot_timestamp_; + const uint64_t exec_tenant_id = fill_exec_tenant_id(schema_status); + bool printed = false; + if (OB_FAIL(sql.append_fmt(FETCH_ALL_PROXY_INFO_HISTORY_SQL, OB_ALL_USER_PROXY_INFO_HISTORY_TNAME, 0UL))) { + LOG_WARN("append sql failed", K(ret)); + } else if (!is_full_schema) { + for (int64_t i = 0; OB_SUCC(ret) && i < users_size; ++i) { + const uint64_t user_id = user_keys[i]; + ObUserInfo *user_info = NULL; + if (OB_FAIL(ObSchemaRetrieveUtils::find_user_info(user_id, user_array, user_info))) { + LOG_WARN("find user info failed", K(user_id), K(ret)); + } else if (OB_ISNULL(user_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(user_id), K(ret)); + } else if (user_info->is_role()) { + //do nothing + } else if (user_info->get_proxy_activated_flag() == ObProxyActivatedFlag::PROXY_NERVER_BEEN_ACTIVATED) { + //skip + } else { + if (!printed) { + printed = true; + if (is_fetch_proxy) { + if (OB_FAIL(sql.append_fmt(" AND proxy_user_id IN (%lu", user_id))) { + LOG_WARN("append sql failed", K(ret), K(user_id)); + } + } else { + if (OB_FAIL(sql.append_fmt(" AND client_user_id IN (%lu", user_id))) { + LOG_WARN("append sql failed", K(ret), K(user_id)); + } + } + } else if (OB_FAIL(sql.append_fmt(", %lu", user_id))) { + LOG_WARN("append sql failed", K(ret), K(i), K(user_id)); + } + } + } + if (OB_SUCC(ret)) { + if (printed) { + if (OB_FAIL(sql.append(")"))) { + LOG_WARN("append sql failed", K(ret)); + } + } else { + // reset sql if no schema objects need to be fetched from inner table. + sql.reset(); + } + } + } + + if (OB_SUCC(ret) && !sql.empty()) { + if (OB_FAIL(sql.append_fmt(" AND SCHEMA_VERSION <= %ld", schema_version))) { + LOG_WARN("append failed", K(ret)); + } else if (OB_FAIL(sql.append(is_fetch_proxy ? + " ORDER BY TENANT_ID DESC, PROXY_USER_ID DESC, CLIENT_USER_ID DESC, SCHEMA_VERSION DESC" : + " ORDER BY TENANT_ID DESC, CLIENT_USER_ID DESC, PROXY_USER_ID DESC, SCHEMA_VERSION DESC"))) { + LOG_WARN("sql append failed", K(ret)); + } + } + + if (OB_SUCC(ret) && !sql.empty()) { + DEFINE_SQL_CLIENT_RETRY_WEAK_WITH_SNAPSHOT(sql_client, snapshot_timestamp); + if (OB_FAIL(sql_client_retry_weak.read(res, exec_tenant_id, sql.ptr()))) { + LOG_WARN("execute sql failed", K(ret), K(tenant_id), K(sql)); + } else if (OB_UNLIKELY(NULL == (result = res.get_result()))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("Fail to get result", K(ret)); + } else if (OB_FAIL(ObSchemaRetrieveUtils::retrieve_proxy_info_schema(tenant_id, *result, is_fetch_proxy, user_array))) { + LOG_WARN("Failed to retrieve user infos", K(ret)); + } + } + } + if (OB_SUCC(ret) && !sql.empty()) { //may existed proxy user + if (OB_FAIL(fetch_proxy_role_info(schema_status, + schema_version, + tenant_id, + sql_client, + user_array, + is_fetch_proxy, + user_keys, + users_size))) { + LOG_WARN("fetch proxy role info failed", K(ret)); + } + } + return ret; +} + +// fill ObUserInfo +// 1. If user info is a user, get the users info which the user can proxy and be proxied. +// 2. If user info is a role, do nothing +int ObSchemaServiceSQLImpl::fetch_proxy_role_info( + const ObRefreshSchemaStatus &schema_status, + const int64_t schema_version, + const uint64_t tenant_id, + ObISQLClient &sql_client, + ObArray &user_array, + const bool is_fetch_proxy, + const uint64_t *user_keys /* = NULL */, + const int64_t users_size /* = 0 */) +{ + int ret = OB_SUCCESS; + SMART_VAR(ObMySQLProxy::MySQLResult, res) { + ObMySQLResult *result = NULL; + ObSqlString sql; + const bool is_full_schema = (NULL != user_keys && users_size > 0) ? false : true; + const int64_t snapshot_timestamp = schema_status.snapshot_timestamp_; + const uint64_t exec_tenant_id = fill_exec_tenant_id(schema_status); + bool printed = false; + if (OB_FAIL(sql.append_fmt(FETCH_ALL_PROXY_ROLE_INFO_HISTORY_SQL, OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TNAME, 0UL))) { + LOG_WARN("append sql failed", K(ret)); + } else if (!is_full_schema) { + for (int64_t i = 0; OB_SUCC(ret) && i < users_size; ++i) { + const uint64_t user_id = user_keys[i]; + ObUserInfo *user_info = NULL; + if (OB_FAIL(ObSchemaRetrieveUtils::find_user_info(user_id, user_array, user_info))) { + LOG_WARN("find user info failed", K(user_id), K(ret)); + } else if (OB_ISNULL(user_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(user_id), K(ret)); + } else if (user_info->is_role()) { + //do nothing + } else if (user_info->get_proxy_activated_flag() == ObProxyActivatedFlag::PROXY_NERVER_BEEN_ACTIVATED) { + //skip + } else { + if (!printed) { + printed = true; + if (is_fetch_proxy) { + if (OB_FAIL(sql.append_fmt(" AND proxy_user_id IN (%lu", user_id))) { + LOG_WARN("append sql failed", K(ret), K(user_id)); + } + } else { + if (OB_FAIL(sql.append_fmt(" AND client_user_id IN (%lu", user_id))) { + LOG_WARN("append sql failed", K(ret), K(user_id)); + } + } + } else if (OB_FAIL(sql.append_fmt(", %lu", user_id))) { + LOG_WARN("append sql failed", K(ret), K(i), K(user_id)); + } + } + } + if (OB_SUCC(ret)) { + if (printed) { + if (OB_FAIL(sql.append(")"))) { + LOG_WARN("append sql failed", K(ret)); + } + } else { + // reset sql if no schema objects need to be fetched from inner table. + sql.reset(); + } + } + } + + if (OB_SUCC(ret) && !sql.empty()) { + if (OB_FAIL(sql.append_fmt(" AND SCHEMA_VERSION <= %ld", schema_version))) { + LOG_WARN("append failed", K(ret)); + } else if (OB_FAIL(sql.append(is_fetch_proxy ? + " ORDER BY TENANT_ID DESC, PROXY_USER_ID DESC, CLIENT_USER_ID DESC, ROLE_ID DESC, SCHEMA_VERSION DESC" : + " ORDER BY TENANT_ID DESC, CLIENT_USER_ID DESC, PROXY_USER_ID DESC, ROLE_ID DESC, SCHEMA_VERSION DESC"))) { + LOG_WARN("sql append failed", K(ret)); + } + } + + if (OB_SUCC(ret) && !sql.empty()) { + DEFINE_SQL_CLIENT_RETRY_WEAK_WITH_SNAPSHOT(sql_client, snapshot_timestamp); + if (OB_FAIL(sql_client_retry_weak.read(res, exec_tenant_id, sql.ptr()))) { + LOG_WARN("execute sql failed", K(ret), K(tenant_id), K(sql)); + } else if (OB_UNLIKELY(NULL == (result = res.get_result()))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("Fail to get result", K(ret)); + } else if (OB_FAIL(ObSchemaRetrieveUtils::retrieve_proxy_role_info_schema(tenant_id, *result, is_fetch_proxy, user_array))) { + LOG_WARN("Failed to retrieve user infos", K(ret)); + } + } + } + return ret; +} + //FIXME@xiyu: to add fetch_tenants int ObSchemaServiceSQLImpl::fetch_tenants( ObISQLClient &sql_client, @@ -5818,7 +6054,6 @@ int ObSchemaServiceSQLImpl::fetch_rls_columns(const ObRefreshSchemaStatus &schem } return ret; } - /* new schema_cache related */ diff --git a/src/share/schema/ob_schema_service_sql_impl.h b/src/share/schema/ob_schema_service_sql_impl.h index 462b02d4a5..e95ce1cd41 100644 --- a/src/share/schema/ob_schema_service_sql_impl.h +++ b/src/share/schema/ob_schema_service_sql_impl.h @@ -537,6 +537,26 @@ public: const uint64_t *user_keys /* = NULL */, const int64_t users_size /* = 0 */); + int fetch_proxy_user_info( + const ObRefreshSchemaStatus &schema_status, + const int64_t schema_version, + const uint64_t tenant_id, + ObISQLClient &sql_client, + ObArray &user_array, + const bool is_fetch_proxy, + const uint64_t *user_keys /* = NULL */, + const int64_t users_size /* = 0 */); + + int fetch_proxy_role_info( + const ObRefreshSchemaStatus &schema_status, + const int64_t schema_version, + const uint64_t tenant_id, + ObISQLClient &sql_client, + ObArray &user_array, + const bool is_fetch_proxy, + const uint64_t *user_keys /* = NULL */, + const int64_t users_size /* = 0 */); + virtual int get_core_version(common::ObISQLClient &sql_client, const ObRefreshSchemaStatus &schema_status, int64_t &core_schema_version); diff --git a/src/share/schema/ob_schema_struct.cpp b/src/share/schema/ob_schema_struct.cpp index 6a05954dc5..9d55d734d8 100644 --- a/src/share/schema/ob_schema_struct.cpp +++ b/src/share/schema/ob_schema_struct.cpp @@ -8370,6 +8370,15 @@ DEF_TO_STRING(ObPrintPrivSet) if ((priv_set_ & OB_PRIV_CREATE_ROUTINE) && OB_SUCCESS == ret) { ret = BUF_PRINTF(" CREATE ROUTINE,"); } + if ((priv_set_ & OB_PRIV_CREATE_TABLESPACE) && OB_SUCCESS == ret) { + ret = BUF_PRINTF(" CREATE TABLESPACE,"); + } + if ((priv_set_ & OB_PRIV_SHUTDOWN) && OB_SUCCESS == ret) { + ret = BUF_PRINTF(" SHUTDOWN,"); + } + if ((priv_set_ & OB_PRIV_RELOAD) && OB_SUCCESS == ret) { + ret = BUF_PRINTF(" RELOAD,"); + } if (OB_SUCCESS == ret && pos > 1) { pos--; //Delete last ',' } @@ -8496,6 +8505,42 @@ int ObProxyInfo::assign(const ObProxyInfo &other) return ret; } +int ObProxyInfo::add_role_id(const uint64_t role_id) +{ + int ret = OB_SUCCESS; + if (OB_ISNULL(allocator_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + }else if (0 == role_id_capacity_) { + if (NULL == (role_ids_ = static_cast( + allocator_->alloc(sizeof(uint64_t) * DEFAULT_ARRAY_CAPACITY)))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("Fail to allocate memory for array_.", K(ret)); + } else { + role_id_capacity_ = DEFAULT_ARRAY_CAPACITY; + MEMSET(role_ids_, 0, sizeof(uint64_t*) * DEFAULT_ARRAY_CAPACITY); + } + } else if (role_id_cnt_ >= role_id_capacity_) { + int64_t tmp_size = 2 * role_id_capacity_; + uint64_t *tmp = NULL; + if (NULL == (tmp = static_cast( + allocator_->alloc(sizeof(uint64_t) * tmp_size)))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("Fail to allocate memory for array_, ", K(tmp_size), K(ret)); + } else { + MEMCPY(tmp, role_ids_, sizeof(uint64_t) * role_id_capacity_); + free(role_ids_); + role_ids_ = tmp; + role_id_capacity_ = tmp_size; + } + } + + if (OB_SUCC(ret)) { + role_ids_[role_id_cnt_++] = role_id; + } + return ret; +} + uint64_t ObProxyInfo::get_role_id_by_idx(const int64_t idx) const { uint64_t role_id = OB_INVALID_ID; @@ -8744,6 +8789,101 @@ bool ObUserInfo::is_valid() const return ObSchema::is_valid() && ObPriv::is_valid(); } +int ObUserInfo::add_proxy_info_(ObProxyInfo **&arr, uint64_t &capacity, uint64_t &cnt, const ObProxyInfo &proxy_info) +{ + int ret = OB_SUCCESS; + if (0 == capacity) { + if (NULL == (arr = static_cast( + alloc(sizeof(ObProxyInfo*) * DEFAULT_ARRAY_CAPACITY)))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_ERROR("Fail to allocate memory for array_.", KR(ret)); + } else { + capacity = DEFAULT_ARRAY_CAPACITY; + MEMSET(arr, 0, sizeof(ObProxyInfo*) * DEFAULT_ARRAY_CAPACITY); + } + } else if (cnt >= capacity) { + int64_t tmp_size = 2 * capacity; + ObProxyInfo **tmp = NULL; + if (NULL == (tmp = static_cast( + alloc(sizeof(ObProxyInfo*) * tmp_size)))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_ERROR("Fail to allocate memory for array_, ", K(tmp_size), KR(ret)); + } else { + MEMCPY(tmp, arr, sizeof(ObProxyInfo*) * capacity); + free(arr); + arr = tmp; + capacity = tmp_size; + } + } + + if (OB_SUCC(ret)) { + ObProxyInfo *info = OB_NEWx(ObProxyInfo, get_allocator(), get_allocator()); + if (NULL == info) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("failed to allocate memory", K(ret), K(get_allocator())); + } else if (OB_FAIL(info->assign(proxy_info))) { + LOG_WARN("failed to assign proxy info", K(ret)); + } else { + arr[cnt++] = info; + } + } + return ret; +} + +int ObUserInfo::add_proxied_user_info(const ObProxyInfo& proxy_info) +{ + return add_proxy_info_(proxied_user_info_, proxied_user_info_capacity_, proxied_user_info_cnt_, proxy_info); +} + +int ObUserInfo::add_proxy_user_info(const ObProxyInfo& proxy_info) +{ + return add_proxy_info_(proxy_user_info_, proxy_user_info_capacity_, proxy_user_info_cnt_, proxy_info); +} + +const ObProxyInfo* ObUserInfo::get_proxied_user_info_by_idx(uint64_t idx) const +{ + const ObProxyInfo *proxy_info = NULL; + if (idx < 0 || idx >= proxied_user_info_cnt_) { + proxy_info = NULL; + } else { + proxy_info = proxied_user_info_[idx]; + } + return proxy_info; +} + +ObProxyInfo* ObUserInfo::get_proxied_user_info_by_idx_for_update(uint64_t idx) +{ + ObProxyInfo *proxy_info = NULL; + if (idx < 0 || idx >= proxied_user_info_cnt_) { + proxy_info = NULL; + } else { + proxy_info = proxied_user_info_[idx]; + } + return proxy_info; +} + +const ObProxyInfo* ObUserInfo::get_proxy_user_info_by_idx(uint64_t idx) const +{ + const ObProxyInfo *proxy_info = NULL; + if (idx < 0 || idx >= proxy_user_info_cnt_) { + proxy_info = NULL; + } else { + proxy_info = proxy_user_info_[idx]; + } + return proxy_info; +} + +ObProxyInfo* ObUserInfo::get_proxy_user_info_by_idx_for_update(uint64_t idx) +{ + ObProxyInfo *proxy_info = NULL; + if (idx < 0 || idx >= proxy_user_info_cnt_) { + proxy_info = NULL; + } else { + proxy_info = proxy_user_info_[idx]; + } + return proxy_info; +} + void ObUserInfo::reset() { user_name_.reset(); @@ -8758,6 +8898,12 @@ void ObUserInfo::reset() grantee_id_array_.reset(); role_id_array_.reset(); role_id_option_array_.reset(); + proxied_user_info_ = NULL; + proxied_user_info_cnt_ = 0; + proxied_user_info_capacity_ = 0; + proxy_user_info_ = NULL; + proxy_user_info_cnt_ = 0; + proxy_user_info_capacity_ = 0; profile_id_ = OB_INVALID_ID; password_last_changed_timestamp_ = OB_INVALID_TIMESTAMP; max_connections_ = 0; @@ -8953,6 +9099,19 @@ OB_DEF_DESERIALIZE(ObUserInfo) LST_DO_CODE(OB_UNIS_DECODE, user_flags_); } } + if (OB_SUCC(ret)) { + if (OB_FAIL(deserialize_proxy_info_array_(proxied_user_info_, proxied_user_info_cnt_, proxied_user_info_capacity_, + buf, data_len, pos))) { + LOG_WARN("deserialize proxi info array failed", K(ret)); + } else if (OB_FAIL(deserialize_proxy_info_array_(proxy_user_info_, proxy_user_info_cnt_, proxy_user_info_capacity_, + buf, data_len, pos))) { + LOG_WARN("deserialize proxi info array failed", K(ret)); + } + } + + if (OB_SUCC(ret)) { + LST_DO_CODE(OB_UNIS_DECODE, user_flags_); + } return ret; } diff --git a/src/share/schema/ob_schema_struct.h b/src/share/schema/ob_schema_struct.h index 4e8d8d3580..758318ad28 100755 --- a/src/share/schema/ob_schema_struct.h +++ b/src/share/schema/ob_schema_struct.h @@ -4243,6 +4243,11 @@ enum ObUserType OB_TYPE_MAX, }; +#define PROXY_USER_ACTIVATE_ALL_ROLES 1 +#define PROXY_USER_NO_ROLES_BE_ACTIVATED 2 +#define PROXY_USER_MAY_ACTIVATE_ROLE 4 +#define PROXY_USER_ROLE_CAN_NOT_BE_ACTIVATED 8 + struct ObProxyInfo { OB_UNIS_VERSION(1); @@ -4259,6 +4264,7 @@ public: } void reset(); int assign(const ObProxyInfo &other); + int add_role_id(const uint64_t role_id); uint64_t get_role_id_by_idx(const int64_t idx) const; TO_STRING_KV(K_(user_id), K_(proxy_flags), K(ObArrayWrap(role_ids_, role_id_cnt_)), K_(role_id_cnt)); @@ -4388,6 +4394,14 @@ public: const common::ObSEArray& get_grantee_id_array() const { return grantee_id_array_; } const common::ObSEArray& get_role_id_array() const { return role_id_array_; } const common::ObSEArray& get_role_id_option_array() const { return role_id_option_array_; } + uint64_t get_proxied_user_info_cnt() const { return proxied_user_info_cnt_; } + uint64_t get_proxy_user_info_cnt() const { return proxy_user_info_cnt_; } + const ObProxyInfo* get_proxied_user_info_by_idx(uint64_t idx) const; + ObProxyInfo* get_proxied_user_info_by_idx_for_update(uint64_t idx); + const ObProxyInfo* get_proxy_user_info_by_idx(uint64_t idx) const; + ObProxyInfo* get_proxy_user_info_by_idx_for_update(uint64_t idx); + int add_proxied_user_info(const ObProxyInfo &proxied_info); + int add_proxy_user_info(const ObProxyInfo &proxy_info); int add_grantee_id(const uint64_t id) { return grantee_id_array_.push_back(id); } int add_role_id(const uint64_t id, const uint64_t admin_option = NO_OPTION, @@ -4416,7 +4430,16 @@ public: ); bool role_exists(const uint64_t role_id, const uint64_t option) const; int get_seq_by_role_id(uint64_t role_id, uint64_t &seq) const; + inline void set_flags(const int64_t flags) { user_flags_.flags_ = flags; } + inline int64_t get_flags() const { return user_flags_.flags_; } + inline void set_proxy_activated_flag(const ObProxyActivatedFlag flag) { + static_assert(ObProxyActivatedFlag::PROXY_ACTIVATED_MAX == 2, "proxy activated flag not valid"); + user_flags_.proxy_activated_flag_ = flag; + } + inline ObProxyActivatedFlag get_proxy_activated_flag() { return (ObProxyActivatedFlag)(user_flags_.proxy_activated_flag_); } + private: + int add_proxy_info_(ObProxyInfo **&arr, uint64_t &capacity, uint64_t &cnt, const ObProxyInfo &proxy_info); int assign_proxy_info_array_(ObProxyInfo **src_arr, const uint64_t src_cnt, const uint64_t src_capacity, @@ -5502,7 +5525,11 @@ struct ObSessionPrivInfo user_priv_set_(0), db_priv_set_(0), effective_tenant_id_(common::OB_INVALID_ID), - enable_role_id_array_() + enable_role_id_array_(), + security_version_(0), + proxy_user_id_(), + proxy_user_name_(), + proxy_host_name_() {} ObSessionPrivInfo(const uint64_t tenant_id, const uint64_t effective_tenant_id, @@ -5518,11 +5545,22 @@ struct ObSessionPrivInfo user_priv_set_(user_priv_set), db_priv_set_(db_priv_set), effective_tenant_id_(effective_tenant_id), - enable_role_id_array_() + enable_role_id_array_(), + security_version_(0), + proxy_user_id_(), + proxy_user_name_(), + proxy_host_name_() {} virtual ~ObSessionPrivInfo() {} + bool is_valid() const + { + return (tenant_id_ != common::OB_INVALID_ID) && (user_id_ != common::OB_INVALID_ID); + } + + bool is_tenant_changed() const { return common::OB_INVALID_ID != effective_tenant_id_ + && tenant_id_ != effective_tenant_id_; } void reset() { tenant_id_ = common::OB_INVALID_ID; @@ -5534,17 +5572,16 @@ struct ObSessionPrivInfo user_priv_set_ = 0; db_priv_set_ = 0; enable_role_id_array_.reset(); + security_version_ = 0; + proxy_user_id_ = common::OB_INVALID_ID; + proxy_user_name_.reset(); + proxy_host_name_.reset(); } - bool is_valid() const - { - return (tenant_id_ != common::OB_INVALID_ID) && (user_id_ != common::OB_INVALID_ID); - } - bool is_tenant_changed() const { return common::OB_INVALID_ID != effective_tenant_id_ - && tenant_id_ != effective_tenant_id_; } void set_effective_tenant_id(uint64_t effective_tenant_id) { effective_tenant_id_ = effective_tenant_id; } uint64_t get_effective_tenant_id() { return effective_tenant_id_; } virtual TO_STRING_KV(K_(tenant_id), K_(effective_tenant_id), K_(user_id), K_(user_name), K_(host_name), - K_(db), K_(user_priv_set), K_(db_priv_set)); + K_(db), K_(user_priv_set), K_(db_priv_set), K_(security_version), K_(proxy_user_id), K_(proxy_user_name), + K_(proxy_host_name)); uint64_t tenant_id_; //for privilege.Current login tenant. if normal tenant access //sys tenant's object should use other method for priv checking. @@ -5557,6 +5594,10 @@ struct ObSessionPrivInfo // Only used for privilege check to determine whether there are currently tenants, otherwise the value is illegal uint64_t effective_tenant_id_; common::ObSEArray enable_role_id_array_; + uint64_t security_version_; + uint64_t proxy_user_id_; + common::ObString proxy_user_name_; + common::ObString proxy_host_name_; }; struct ObUserLoginInfo @@ -5567,7 +5608,7 @@ struct ObUserLoginInfo const common::ObString &client_ip, const common::ObString &passwd, const common::ObString &db) - : tenant_name_(tenant_name), user_name_(user_name), client_ip_(client_ip), + : tenant_name_(tenant_name), user_name_(user_name), proxied_user_name_(), client_ip_(client_ip), passwd_(passwd), db_(db), scramble_str_() {} @@ -5577,13 +5618,25 @@ struct ObUserLoginInfo const common::ObString &passwd, const common::ObString &db, const common::ObString &scramble_str) - : tenant_name_(tenant_name), user_name_(user_name), client_ip_(client_ip), + : tenant_name_(tenant_name), user_name_(user_name), proxied_user_name_(), client_ip_(client_ip), passwd_(passwd), db_(db), scramble_str_(scramble_str) {} - TO_STRING_KV(K_(tenant_name), K_(user_name), K_(client_ip), K_(db), K_(scramble_str)); + ObUserLoginInfo(const common::ObString &tenant_name, + const common::ObString &user_name, + const common::ObString &proxied_user_name, + const common::ObString &client_ip, + const common::ObString &passwd, + const common::ObString &db, + const common::ObString &scramble_str) + : tenant_name_(tenant_name), user_name_(user_name), proxied_user_name_(proxied_user_name), client_ip_(client_ip), + passwd_(passwd), db_(db), scramble_str_(scramble_str) + {} + + TO_STRING_KV(K_(tenant_name), K_(user_name), K_(proxied_user_name), K_(client_ip), K_(db), K_(scramble_str)); common::ObString tenant_name_; common::ObString user_name_; + common::ObString proxied_user_name_; common::ObString client_ip_;//client ip for current user common::ObString passwd_; common::ObString db_; diff --git a/src/share/schema/ob_server_schema_service.h b/src/share/schema/ob_server_schema_service.h index ed7a2f673f..7f09832a46 100644 --- a/src/share/schema/ob_server_schema_service.h +++ b/src/share/schema/ob_server_schema_service.h @@ -71,10 +71,12 @@ struct SchemaKey union { uint64_t user_id_; uint64_t grantee_id_; + uint64_t client_user_id_; }; union { uint64_t database_id_; uint64_t grantor_id_; + uint64_t proxy_user_id_; }; common::ObString database_name_; uint64_t tablegroup_id_; @@ -159,7 +161,9 @@ struct SchemaKey K_(rls_group_id), K_(rls_context_id), K_(routine_type), - K_(column_priv_id)); + K_(column_priv_id), + K_(client_user_id), + K_(proxy_user_id)); SchemaKey() : tenant_id_(common::OB_INVALID_ID), @@ -750,6 +754,7 @@ public: SCHEMA_KEYS_DEF(rls_policy, RlsPolicyKeys); SCHEMA_KEYS_DEF(rls_group, RlsGroupKeys); SCHEMA_KEYS_DEF(rls_context, RlsContextKeys); + #undef SCHEMA_KEYS_DEF typedef common::hash::ObHashSet DBPrivKeys; diff --git a/src/share/schema/ob_user_sql_service.cpp b/src/share/schema/ob_user_sql_service.cpp index 56ef17f01f..b236818f6c 100644 --- a/src/share/schema/ob_user_sql_service.cpp +++ b/src/share/schema/ob_user_sql_service.cpp @@ -20,6 +20,7 @@ #include "share/schema/ob_priv_type.h" #include "share/schema/ob_schema_struct.h" #include "share/schema/ob_schema_getter_guard.h" +#include "sql/ob_sql_utils.h" namespace oceanbase { @@ -87,7 +88,6 @@ int ObUserSqlService::replace_user( if (OB_FAIL(gen_user_dml(exec_tenant_id, user, dml, false))) { LOG_WARN("gen_user_dml failed", K(ret)); } - // insert into __all_user if (FAILEDx(exec.exec_replace(OB_ALL_USER_TNAME, dml, affected_rows))) { LOG_WARN("execute insert failed", K(ret)); @@ -193,7 +193,8 @@ int ObUserSqlService::drop_user_delete_role_grantee_map( } } const int64_t is_deleted = 1; - if (OB_FAIL(insert_sql.append_fmt("(now(6), now(6), %lu, %lu, %lu, %ld, %ld, %lu, %lu)", + if (OB_FAIL(ret)) { + } else if (OB_FAIL(insert_sql.append_fmt("(now(6), now(6), %lu, %lu, %lu, %ld, %ld, %lu, %lu)", ObSchemaUtils::get_extract_tenant_id(exec_tenant_id, tenant_id), ObSchemaUtils::get_extract_schema_id(exec_tenant_id, is_role ? id : user_id), ObSchemaUtils::get_extract_schema_id(exec_tenant_id, is_role ? user_id : id), @@ -237,6 +238,194 @@ int ObUserSqlService::drop_user_delete_role_grantee_map( return ret; } +int ObUserSqlService::drop_proxy_info(ObISQLClient &sql_client, + const uint64_t tenant_id, + const uint64_t client_user_id, + const uint64_t proxy_user_id, + const uint64_t new_schema_version) +{ + int ret = OB_SUCCESS; + ObDMLSqlSplicer dml; + const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id); + ObDMLExecHelper exec(sql_client, exec_tenant_id); + int64_t affected_rows = 0; + if (OB_FAIL(dml.add_pk_column("tenant_id", 0)) + || OB_FAIL(dml.add_pk_column("client_user_id", client_user_id)) + || OB_FAIL(dml.add_pk_column("proxy_user_id", proxy_user_id))) { + LOG_WARN("add pk column failed", K(ret)); + } else if (OB_FAIL(exec.exec_delete(OB_ALL_USER_PROXY_INFO_TNAME, dml, affected_rows))) { + LOG_WARN("exec delete failed", K(ret)); + } else if (OB_UNLIKELY(affected_rows > 1)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expected to be less than 2", K(affected_rows), K(ret)); + } else if (OB_FAIL(dml.add_pk_column("schema_version", new_schema_version)) + || OB_FAIL(dml.add_column("is_deleted", 1))) { + LOG_WARN("add column failed", K(ret)); + } else if (OB_FAIL(exec.exec_insert(OB_ALL_USER_PROXY_INFO_HISTORY_TNAME, dml, affected_rows))) { + LOG_WARN("exec insert failed", K(ret)); + } else if (!is_single_row(affected_rows)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expected to be one", K(affected_rows), K(ret)); + } + return ret; +} + +int ObUserSqlService::drop_proxy_role_info(ObISQLClient &sql_client, + const uint64_t tenant_id, + const uint64_t client_user_id, + const uint64_t proxy_user_id, + const uint64_t role_id, + const uint64_t new_schema_version) +{ + int ret = OB_SUCCESS; + ObDMLSqlSplicer dml; + const uint64_t exec_tenant_id = ObSchemaUtils::get_exec_tenant_id(tenant_id); + ObDMLExecHelper exec(sql_client, exec_tenant_id); + int64_t affected_rows = 0; + if (OB_FAIL(dml.add_pk_column("tenant_id", 0)) + || OB_FAIL(dml.add_pk_column("client_user_id", client_user_id)) + || OB_FAIL(dml.add_pk_column("proxy_user_id", proxy_user_id)) + || OB_FAIL(dml.add_pk_column("role_id", role_id))) { + LOG_WARN("add pk column failed", K(ret)); + } else if (OB_FAIL(exec.exec_delete(OB_ALL_USER_PROXY_ROLE_INFO_TNAME, dml, affected_rows))) { + LOG_WARN("exec delete failed", K(ret)); + } else if (OB_UNLIKELY(affected_rows > 1)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expected to be less than 2", K(affected_rows), K(ret)); + } else if (OB_FAIL(dml.add_pk_column("schema_version", new_schema_version)) + || OB_FAIL(dml.add_column("is_deleted", 1))) { + LOG_WARN("add column failed", K(ret)); + } else if (OB_FAIL(exec.exec_insert(OB_ALL_USER_PROXY_ROLE_INFO_HISTORY_TNAME, dml, affected_rows))) { + LOG_WARN("exec insert failed", K(ret)); + } else if (!is_single_row(affected_rows)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("affected_rows expected to be one", K(affected_rows), K(ret)); + } + return ret; +} + +int ObUserSqlService::drop_user_delete_proxy_user_info(const uint64_t tenant_id, + const bool is_role, + const uint64_t new_schema_version, + const ObUserInfo &user, + const ObString *ddl_stmt_str, + ObISQLClient &sql_client, + ObSchemaGetterGuard &schema_guard) +{ + int ret = OB_SUCCESS; + common::ObArray user_infos_to_update; + if (is_role) { //drop role + common::ObSEArray schema_id_array = user.get_grantee_id_array(); + for (int64_t i = 0; OB_SUCC(ret) && i < schema_id_array.count(); i++) { + const ObUserInfo *grantee = NULL; + if (OB_FAIL(schema_guard.get_user_info(tenant_id, schema_id_array.at(i), grantee))) { + LOG_WARN("get user info failed", K(ret)); + } else if (OB_ISNULL(grantee)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (grantee->is_role()) { + //do nothing + } else { + for (int64_t j = 0; OB_SUCC(ret) && j < grantee->get_proxied_user_info_cnt(); j++) { + const ObProxyInfo *proxy_info = grantee->get_proxied_user_info_by_idx(j); + bool found = false; + if (OB_ISNULL(proxy_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } + for (int64_t k = 0; OB_SUCC(ret) && !found && k < proxy_info->role_id_cnt_; k++) { + uint64_t role_id = proxy_info->get_role_id_by_idx(k); + if (user.get_user_id() == proxy_info->get_role_id_by_idx(k)) { + found = true; + OZ (drop_proxy_role_info(sql_client, tenant_id, grantee->get_user_id(), + proxy_info->user_id_, user.get_user_id(), new_schema_version)); + } + if (OB_SUCC(ret) && found) { + const ObUserInfo *user_info = NULL; + if (OB_FAIL(schema_guard.get_user_info(tenant_id, proxy_info->user_id_, user_info))) { + LOG_WARN("get user info failed", K(ret)); + } else if (OB_ISNULL(user_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_FAIL(user_infos_to_update.push_back(*user_info))) { + LOG_WARN("push back failed", K(ret)); + } + } + } + } + } + } + } else { //drop user + for (int64_t i = 0; OB_SUCC(ret) && i < user.get_proxy_user_info_cnt(); i++) { + const ObProxyInfo *proxy_info = user.get_proxy_user_info_by_idx(i); + if (OB_ISNULL(proxy_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_FAIL(drop_proxy_info(sql_client, tenant_id, proxy_info->user_id_, + user.get_user_id(), new_schema_version))) { + LOG_WARN("drop proxy info failed", K(ret)); + } else { + const ObUserInfo *user_info = NULL; + if (proxy_info->user_id_ == user.get_user_id()) { //u1 proxy u1, when droping u1, do not update u1 + //do nothing + } else if (OB_FAIL(schema_guard.get_user_info(tenant_id, proxy_info->user_id_, user_info))) { + LOG_WARN("get user info failed", K(ret)); + } else if (OB_ISNULL(user_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_FAIL(user_infos_to_update.push_back(*user_info))) { + LOG_WARN("push back failed", K(ret)); + } + for (int64_t j = 0; OB_SUCC(ret) && j < proxy_info->role_id_cnt_; j++) { + if (OB_FAIL(drop_proxy_role_info(sql_client, tenant_id, proxy_info->user_id_, user.get_user_id(), + proxy_info->get_role_id_by_idx(j), new_schema_version))) { + LOG_WARN("drop proxy role info failed", K(ret)); + } + } + } + } + for (int64_t i = 0; OB_SUCC(ret) && i < user.get_proxied_user_info_cnt(); i++) { + const ObProxyInfo *proxy_info = user.get_proxied_user_info_by_idx(i); + if (OB_ISNULL(proxy_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (user.get_user_id() == proxy_info->user_id_) { + //alread dropped before + } else if (OB_FAIL(drop_proxy_info(sql_client, tenant_id, user.get_user_id(), proxy_info->user_id_, + new_schema_version))) { + LOG_WARN("drop proxy info failed", K(ret)); + } else { + const ObUserInfo *user_info = NULL; + if (proxy_info->user_id_ == user.get_user_id()) { //u1 proxy u1, when droping u1, do not update u1 + //do nothing + } else if (OB_FAIL(schema_guard.get_user_info(tenant_id, proxy_info->user_id_, user_info))) { + LOG_WARN("get user info failed", K(ret)); + } else if (OB_ISNULL(user_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_FAIL(user_infos_to_update.push_back(*user_info))) { + LOG_WARN("push back failed", K(ret)); + } + for (int64_t j = 0; OB_SUCC(ret) && j < proxy_info->role_id_cnt_; j++) { + if (OB_FAIL(drop_proxy_role_info(sql_client, tenant_id, user.get_user_id(), proxy_info->user_id_, + proxy_info->get_role_id_by_idx(j), new_schema_version))) { + LOG_WARN("drop proxy role info failed", K(ret)); + } + } + } + } + } + if (OB_FAIL(ret)) { + } else if (user_infos_to_update.empty()) { + } else if (OB_FAIL(update_user_proxy_info(tenant_id, + user_infos_to_update, + NULL, + sql_client))) { + LOG_WARN("Failed to grant or revoke user", K(ret)); + } + return ret; +} + int ObUserSqlService::drop_user( const uint64_t tenant_id, const uint64_t user_id, @@ -323,6 +512,9 @@ int ObUserSqlService::drop_user( OZ (drop_user_delete_role_grantee_map(tenant_id, false, new_schema_version, user, ddl_stmt_str, sql_client, schema_guard)); } + + OZ (drop_user_delete_proxy_user_info(tenant_id, is_role, new_schema_version, + *user, NULL, sql_client, schema_guard)); } return ret; @@ -881,6 +1073,9 @@ int ObUserSqlService::gen_user_dml( if ((user.get_priv_set() & OB_PRIV_EXECUTE) != 0) { priv_others |= 1; } if ((user.get_priv_set() & OB_PRIV_ALTER_ROUTINE) != 0) { priv_others |= 2; } if ((user.get_priv_set() & OB_PRIV_CREATE_ROUTINE) != 0) { priv_others |= 4; } + if ((user.get_priv_set() & OB_PRIV_CREATE_TABLESPACE) != 0) { priv_others |= 8; } + if ((user.get_priv_set() & OB_PRIV_SHUTDOWN) != 0) { priv_others |= 16; } + if ((user.get_priv_set() & OB_PRIV_RELOAD) != 0) { priv_others |= 32; } } if (OB_FAIL(ret)) { } else if (!sql::ObSQLUtils::is_data_version_ge_422_or_431(compat_version)) { @@ -891,6 +1086,42 @@ int ObUserSqlService::gen_user_dml( } else if (OB_FAIL(dml.add_column("PRIV_OTHERS", priv_others))) { LOG_WARN("add PRIV_OTHERS column failed", K(priv_others), K(ret)); } + + if (OB_FAIL(ret)) { + } else if (!sql::ObSQLUtils::is_data_version_ge_423_or_432(compat_version)) { + if (user.get_flags() != 0) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("some column of user info is not empty when MIN_DATA_VERSION is below DATA_VERSION_4_2_3_0 or 4_3_2_0", K(ret), K(user.get_flags())); + } + } else if (OB_FAIL(dml.add_column("flags", user.get_flags()))) { + LOG_WARN("add flags column failed", K(user.get_flags()), K(ret)); + } + return ret; +} + +int ObUserSqlService::update_user_proxy_info(const uint64_t tenant_id, + const common::ObArray &user_infos, + const ObString *ddl_stmt_str, + ObISQLClient &sql_client) +{ + int ret = OB_SUCCESS; + int64_t new_schema_version = OB_INVALID_VERSION; + if (OB_INVALID_ID == tenant_id) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Invalid arguments", K(tenant_id), K(ret)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < user_infos.count(); i++) { + const ObUserInfo &user_info = user_infos.at(i); + if (OB_FAIL(schema_service_.gen_new_schema_version(tenant_id, OB_INVALID_VERSION, new_schema_version))) { + LOG_WARN("fail to gen new schema_version", K(ret), K(tenant_id)); + } else if (OB_FAIL(replace_user(user_info, new_schema_version, ddl_stmt_str, sql_client, OB_DDL_GRANT_REVOKE_USER))) { + LOG_WARN("update user failed failed", K(user_info), K(new_schema_version), K(ret)); + } else { + ddl_stmt_str = NULL; + } + } + } + return ret; } diff --git a/src/share/schema/ob_user_sql_service.h b/src/share/schema/ob_user_sql_service.h index 65784a490f..c622c37c2a 100644 --- a/src/share/schema/ob_user_sql_service.h +++ b/src/share/schema/ob_user_sql_service.h @@ -110,6 +110,11 @@ public: common::ObISQLClient &sql_client, const ObSchemaOperationType type); + virtual int update_user_proxy_info(const uint64_t tenant_id, + const common::ObArray &user_infos, + const ObString *ddl_stmt_str, + ObISQLClient &sql_client); + private: int drop_user_delete_role_grantee_map( const uint64_t tenant_id, @@ -119,6 +124,27 @@ private: const ObString *ddl_stmt_str, ObISQLClient &sql_client, share::schema::ObSchemaGetterGuard &schema_guard); + + int drop_user_delete_proxy_user_info(const uint64_t tenant_id, + const bool is_role, + const uint64_t new_schema_version, + const ObUserInfo &user, + const ObString *ddl_stmt_str, + ObISQLClient &sql_client, + ObSchemaGetterGuard &schema_guard); + + int drop_proxy_role_info(ObISQLClient &sql_client, + const uint64_t tenant_id, + const uint64_t client_user_id, + const uint64_t proxy_user_id, + const uint64_t role_id, + const uint64_t new_schema_version); + + int drop_proxy_info(ObISQLClient &sql_client, + const uint64_t tenant_id, + const uint64_t client_user_id, + const uint64_t proxy_user_id, + const uint64_t new_schema_version); private: DISALLOW_COPY_AND_ASSIGN(ObUserSqlService); }; diff --git a/src/share/system_variable/ob_system_variable.cpp b/src/share/system_variable/ob_system_variable.cpp index c92034a7f8..7b564a6b61 100644 --- a/src/share/system_variable/ob_system_variable.cpp +++ b/src/share/system_variable/ob_system_variable.cpp @@ -36,6 +36,7 @@ #include "share/resource_manager/ob_resource_manager_proxy.h" #include "sql/engine/expr/ob_expr_uuid.h" #include "lib/locale/ob_locale_type.h" +#include "share/ob_compatibility_control.h" #ifdef OB_BUILD_ORACLE_PL #include "pl/ob_pl_warning.h" #endif @@ -1068,6 +1069,67 @@ int ObCharsetSysVar::do_check_and_convert(ObExecContext &ctx, return ret; } +int ObVersionSysVar::do_check_and_convert(ObExecContext &ctx, + const ObSetVar &set_var, + const ObObj &in_val, ObObj &out_val) +{ + int ret = OB_SUCCESS; + ObSQLSessionInfo *session = ctx.get_my_session(); + const ObDataTypeCastParams dtc_params = ObBasicSessionInfo::create_dtc_params(session); + if (OB_ISNULL(session)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("session is NULL", K(ret), K(*this)); + } else if (true == set_var.is_set_default_) { + ret = OB_ERR_NO_DEFAULT; + LOG_USER_ERROR(OB_ERR_NO_DEFAULT, set_var.var_name_.length(), set_var.var_name_.ptr()); + } else if (ObNullType == in_val.get_type()) { + if (0 != (flags_ & ObSysVarFlag::NULLABLE)) { + // do nothing + } else { + ret = OB_ERR_WRONG_VALUE_FOR_VAR; + LOG_USER_ERROR(OB_ERR_WRONG_VALUE_FOR_VAR, set_var.var_name_.length(), + set_var.var_name_.ptr(), (int)strlen("NULL"), "NULL"); + } + } else if (true == ob_is_string_type(in_val.get_type())) { + ObCastCtx cast_ctx(&ctx.get_allocator(), &dtc_params, CM_NONE, ObCharset::get_system_collation()); + ObObj buf_obj; + const ObObj *res_obj_ptr = NULL; + if (OB_FAIL(ObObjCaster::to_type(ObVarcharType, cast_ctx, in_val, buf_obj, res_obj_ptr))) { + LOG_WARN("failed to cast object to ObVarcharType ", K(ret), K(in_val)); + } else if (OB_ISNULL(res_obj_ptr)) { + ret = OB_ERR_UNEXPECTED; + LOG_ERROR("succ to cast obj, but res_obj_ptr is NULL", K(ret)); + } else { + out_val = *res_obj_ptr; + } + } else if (true == ob_is_integer_type(in_val.get_type())) { + ObCastCtx cast_ctx(&ctx.get_allocator(), &dtc_params, CM_NONE, ObCharset::get_system_collation()); + ObObj buf_obj; + const ObObj *res_obj_ptr = NULL; + if (OB_FAIL(ObObjCaster::to_type(ObUInt64Type, cast_ctx, in_val, buf_obj, res_obj_ptr))) { + LOG_WARN("failed to cast object to ObUInt64Type ", K(ret), K(in_val)); + } else if (OB_ISNULL(res_obj_ptr)) { + ret = OB_ERR_UNEXPECTED; + LOG_ERROR("succ to cast obj, but res_obj_ptr is NULL", K(ret)); + } else { + out_val = *res_obj_ptr; + } + } else if (is_oracle_mode() && (ObNumberType == in_val.get_type())) { + number::ObNumber num = in_val.get_number(); + uint64_t uint_val = 0; + if (num.is_valid_uint64(uint_val)) { + out_val.set_uint64(uint_val); + } else { + ret = OB_ERR_WRONG_TYPE_FOR_VAR; + LOG_WARN("not valid int value for var on oracle mode", K(in_val)); + } + } else { + ret = OB_ERR_WRONG_TYPE_FOR_VAR; + LOG_WARN("invalid type ", K(ret), K(in_val)); + } + return ret; +} + int ObTinyintSysVar::check_update_type(const ObSetVar &set_var, const ObObj &val) { int ret = OB_SUCCESS; @@ -2543,6 +2605,93 @@ int ObSysVarOnCheckFuncs::check_locale_type_is_valid( return ret; } +int ObSysVarOnCheckFuncs::check_and_convert_compat_version(sql::ObExecContext &ctx, + const ObSetVar &set_var, + const ObBasicSysVar &sys_var, + const common::ObObj &in_val, + common::ObObj &out_val) +{ + int ret = OB_SUCCESS; + uint64_t compat_version = 0; + if (true == set_var.is_set_default_) { + // do nothing + } else if (OB_FAIL(check_and_convert_version(ctx, sys_var, in_val, + set_var.actual_tenant_id_, compat_version))) { + LOG_WARN("failed to check and convert version", K(ret)); + } else { + out_val.set_uint64(compat_version); + } + return ret; +} + +int ObSysVarOnCheckFuncs::check_and_convert_security_version(sql::ObExecContext &ctx, + const ObSetVar &set_var, + const ObBasicSysVar &sys_var, + const common::ObObj &in_val, + common::ObObj &out_val) +{ + int ret = OB_SUCCESS; + uint64_t security_version = 0; + uint64_t old_version = 0; + ObSQLSessionInfo *session = GET_MY_SESSION(ctx); + if (OB_ISNULL(session)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("fail to get session info", K(ret)); + } else if (true == set_var.is_set_default_) { + // do nothing + } else if (OB_FAIL(check_and_convert_version(ctx, sys_var, in_val, + set_var.actual_tenant_id_, security_version))) { + LOG_WARN("failed to check and convert version", K(ret)); + } else if (OB_FAIL(session->get_security_version(old_version))) { + LOG_WARN("failed to get security version", K(ret)); + } else if (OB_UNLIKELY(set_var.actual_tenant_id_ != OB_INVALID_ID && + security_version < old_version)) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "decrease security version"); + } else { + out_val.set_uint64(security_version); + } + return ret; +} + +int ObSysVarOnCheckFuncs::check_and_convert_version(sql::ObExecContext &ctx, + const ObBasicSysVar &sys_var, + const common::ObObj &in_val, + const uint64_t tenant_id, + uint64_t &version) +{ + int ret = OB_SUCCESS; + version = 0; + if (ObVarcharType == in_val.get_type()) { + const ObString &val = in_val.get_string(); + if (OB_FAIL(ObCompatControl::get_compat_version(val, version))) { + if (OB_INVALID_ARGUMENT == ret) { + ret = OB_ERR_WRONG_VALUE_FOR_VAR; + LOG_USER_ERROR(OB_ERR_WRONG_VALUE_FOR_VAR, sys_var.get_name().length(), + sys_var.get_name().ptr(), + val.length(), val.ptr()); + } else { + LOG_WARN("failed to get compat version", K(ret), K(val)); + } + } + } else if (ObUInt64Type == in_val.get_type()) { + version = in_val.get_uint64(); + } else { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid type", K(ret), K(in_val)); + } + if (OB_FAIL(ret)) { + } else if (OB_FAIL(ObCompatControl::check_compat_version(tenant_id, version))) { + if (OB_INVALID_ARGUMENT == ret) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "target version"); + } else { + LOG_WARN("failed to check version", K(ret), K(version)); + } + } + return ret; +} + int ObSysVarOnUpdateFuncs::update_tx_isolation(ObExecContext &ctx, const ObSetVar &set_var, const ObBasicSysVar &sys_var, @@ -2770,6 +2919,23 @@ int ObSysVarToObjFuncs::to_obj_sql_mode(ObIAllocator &allocator, return ret; } +int ObSysVarToObjFuncs::to_obj_version(ObIAllocator &allocator, + const ObBasicSessionInfo &session, + const ObBasicSysVar &sys_var, + ObObj &result_obj) +{ + int ret = OB_SUCCESS; + ObString result_str; + if (OB_FAIL(ObSysVarToStrFuncs::to_str_version(allocator, session, sys_var, result_str))) { + LOG_WARN("fail to convert to str version", K(ret), K(sys_var)); + } else { + result_obj.set_varchar(result_str); + result_obj.set_collation_type(ObCharset::get_system_collation()); + result_obj.set_collation_level(sys_var.get_value().get_collation_level()); + } + return ret; +} + int ObSysVarToStrFuncs::to_str_charset(ObIAllocator &allocator, const ObBasicSessionInfo &session, const ObBasicSysVar &sys_var, @@ -2837,6 +3003,24 @@ int ObSysVarToStrFuncs::to_str_sql_mode(ObIAllocator &allocator, return ret; } +int ObSysVarToStrFuncs::to_str_version(ObIAllocator &allocator, + const ObBasicSessionInfo &session, + const ObBasicSysVar &sys_var, + ObString &result_str) +{ + UNUSED(allocator); + UNUSED(session); + int ret = OB_SUCCESS; + uint64_t version = 0; + if (OB_FAIL(sys_var.get_value().get_uint64(version))) { + ret = OB_ERR_UNEXPECTED; + LOG_ERROR("invalid value", K(ret), K(sys_var), K(sys_var.get_value())); + } else if (OB_FAIL(ObCompatControl::get_version_str(version, result_str, allocator))) { + LOG_WARN("fail to get version str", K(ret), K(version)); + } + return ret; +} + int ObSysVarSessionSpecialUpdateFuncs::update_identity(ObExecContext &ctx, const ObSetVar &set_var, const ObObj &val) diff --git a/src/share/system_variable/ob_system_variable.h b/src/share/system_variable/ob_system_variable.h index 79cf3c50e1..9af52da558 100644 --- a/src/share/system_variable/ob_system_variable.h +++ b/src/share/system_variable/ob_system_variable.h @@ -487,6 +487,31 @@ private: DISALLOW_COPY_AND_ASSIGN(ObCharsetSysVar); }; +class ObVersionSysVar : public ObBasicSysVar +{ +public: + ObVersionSysVar(OnCheckAndConvertFunc on_check_and_convert = NULL, + OnUpdateFunc on_update = NULL, + ToObjFunc to_select_obj = NULL, + ToStrFunc to_show_str = NULL, + GetMetaTypeFunc get_meta_type = NULL) + : ObBasicSysVar(on_check_and_convert, + on_update, + to_select_obj, + to_show_str, + get_meta_type) + { + } + virtual ~ObVersionSysVar() {} +private: + virtual int do_check_and_convert(sql::ObExecContext &ctx, + const ObSetVar &set_var, + const common::ObObj &in_val, + common::ObObj &out_val); +private: + DISALLOW_COPY_AND_ASSIGN(ObVersionSysVar); +}; + ///////////////////////////// class ObTinyintSysVar : public ObBasicSysVar { @@ -910,6 +935,21 @@ public: const ObBasicSysVar &sys_var, const common::ObObj &in_val, common::ObObj &out_val); + static int check_and_convert_compat_version(sql::ObExecContext &ctx, + const ObSetVar &set_var, + const ObBasicSysVar &sys_var, + const common::ObObj &in_val, + common::ObObj &out_val); + static int check_and_convert_security_version(sql::ObExecContext &ctx, + const ObSetVar &set_var, + const ObBasicSysVar &sys_var, + const common::ObObj &in_val, + common::ObObj &out_val); + static int check_and_convert_version(sql::ObExecContext &ctx, + const ObBasicSysVar &sys_var, + const common::ObObj &in_val, + const uint64_t tenant_id, + uint64_t &version); private: static int check_session_readonly(sql::ObExecContext &ctx, const ObSetVar &set_var, @@ -964,6 +1004,8 @@ public: const ObBasicSysVar &sys_var, common::ObObj &result_obj); static int to_obj_sql_mode(common::ObIAllocator &allocator, const sql::ObBasicSessionInfo &session, const ObBasicSysVar &sys_var, common::ObObj &result_obj); + static int to_obj_version(common::ObIAllocator &allocator, const sql::ObBasicSessionInfo &session, + const ObBasicSysVar &sys_var, common::ObObj &result_obj); private: DISALLOW_COPY_AND_ASSIGN(ObSysVarToObjFuncs); }; @@ -980,6 +1022,8 @@ public: const ObBasicSysVar &sys_var, common::ObString &result_str); static int to_str_sql_mode(common::ObIAllocator &allocator, const sql::ObBasicSessionInfo &session, const ObBasicSysVar &sys_var, common::ObString &result_str); + static int to_str_version(common::ObIAllocator &allocator, const sql::ObBasicSessionInfo &session, + const ObBasicSysVar &sys_var, common::ObString &result_str); private: DISALLOW_COPY_AND_ASSIGN(ObSysVarToStrFuncs); }; diff --git a/src/share/system_variable/ob_system_variable_factory.h b/src/share/system_variable/ob_system_variable_factory.h index 697ca3a47b..0854011e95 100644 --- a/src/share/system_variable/ob_system_variable_factory.h +++ b/src/share/system_variable/ob_system_variable_factory.h @@ -1881,17 +1881,17 @@ public: inline virtual ObSysVarClassType get_type() const { return SYS_VAR_OB_COMPATIBILITY_CONTROL; } inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(259); } }; -class ObSysVarObCompatibilityVersion : public ObIntSysVar +class ObSysVarObCompatibilityVersion : public ObVersionSysVar { public: - ObSysVarObCompatibilityVersion() : ObIntSysVar(NULL, NULL, NULL, NULL, NULL) {} + ObSysVarObCompatibilityVersion() : ObVersionSysVar(ObSysVarOnCheckFuncs::check_and_convert_compat_version, NULL, ObSysVarToObjFuncs::to_obj_version, ObSysVarToStrFuncs::to_str_version, ObSysVarGetMetaTypeFuncs::get_meta_type_varchar) {} inline virtual ObSysVarClassType get_type() const { return SYS_VAR_OB_COMPATIBILITY_VERSION; } inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(260); } }; -class ObSysVarObSecurityVersion : public ObIntSysVar +class ObSysVarObSecurityVersion : public ObVersionSysVar { public: - ObSysVarObSecurityVersion() : ObIntSysVar(NULL, NULL, NULL, NULL, NULL) {} + ObSysVarObSecurityVersion() : ObVersionSysVar(ObSysVarOnCheckFuncs::check_and_convert_security_version, NULL, ObSysVarToObjFuncs::to_obj_version, ObSysVarToStrFuncs::to_str_version, ObSysVarGetMetaTypeFuncs::get_meta_type_varchar) {} inline virtual ObSysVarClassType get_type() const { return SYS_VAR_OB_SECURITY_VERSION; } inline virtual const common::ObObj &get_global_default_value() const { return ObSysVariables::get_default_value(261); } }; diff --git a/src/share/system_variable/ob_system_variable_init.cpp b/src/share/system_variable/ob_system_variable_init.cpp index 20c94f6254..cdaee28dcf 100644 --- a/src/share/system_variable/ob_system_variable_init.cpp +++ b/src/share/system_variable/ob_system_variable_init.cpp @@ -3673,10 +3673,15 @@ static struct VarsInit{ ObSysVars[260].info_ = "specifies the compatible verision when the behaviors of different release version are different" ; ObSysVars[260].name_ = "ob_compatibility_version" ; ObSysVars[260].data_type_ = ObUInt64Type ; + ObSysVars[260].to_show_str_func_ = "ObSysVarToStrFuncs::to_str_version" ; ObSysVars[260].flags_ = ObSysVarFlag::GLOBAL_SCOPE | ObSysVarFlag::NEED_SERIALIZE | ObSysVarFlag::INFLUENCE_PLAN ; + ObSysVars[260].base_class_ = "ObVersionSysVar" ; + ObSysVars[260].to_select_obj_func_ = "ObSysVarToObjFuncs::to_obj_version" ; + ObSysVars[260].on_check_and_convert_func_ = "ObSysVarOnCheckFuncs::check_and_convert_compat_version" ; ObSysVars[260].id_ = SYS_VAR_OB_COMPATIBILITY_VERSION ; cur_max_var_id = MAX(cur_max_var_id, static_cast(SYS_VAR_OB_COMPATIBILITY_VERSION)) ; ObSysVarsIdToArrayIdx[SYS_VAR_OB_COMPATIBILITY_VERSION] = 260 ; + ObSysVars[260].get_meta_type_func_ = "ObSysVarGetMetaTypeFuncs::get_meta_type_varchar" ; ObSysVars[260].base_value_ = "17180000512" ; ObSysVars[260].alias_ = "OB_SV_COMPATIBILITY_VERSION" ; }(); @@ -3686,10 +3691,15 @@ static struct VarsInit{ ObSysVars[261].info_ = "specifies the security verision when the behaviors of different release version are different" ; ObSysVars[261].name_ = "ob_security_version" ; ObSysVars[261].data_type_ = ObUInt64Type ; + ObSysVars[261].to_show_str_func_ = "ObSysVarToStrFuncs::to_str_version" ; ObSysVars[261].flags_ = ObSysVarFlag::GLOBAL_SCOPE | ObSysVarFlag::NEED_SERIALIZE | ObSysVarFlag::INFLUENCE_PLAN ; + ObSysVars[261].base_class_ = "ObVersionSysVar" ; + ObSysVars[261].to_select_obj_func_ = "ObSysVarToObjFuncs::to_obj_version" ; + ObSysVars[261].on_check_and_convert_func_ = "ObSysVarOnCheckFuncs::check_and_convert_security_version" ; ObSysVars[261].id_ = SYS_VAR_OB_SECURITY_VERSION ; cur_max_var_id = MAX(cur_max_var_id, static_cast(SYS_VAR_OB_SECURITY_VERSION)) ; ObSysVarsIdToArrayIdx[SYS_VAR_OB_SECURITY_VERSION] = 261 ; + ObSysVars[261].get_meta_type_func_ = "ObSysVarGetMetaTypeFuncs::get_meta_type_varchar" ; ObSysVars[261].base_value_ = "17180000512" ; ObSysVars[261].alias_ = "OB_SV_SECURITY_VERSION" ; }(); diff --git a/src/share/system_variable/ob_system_variable_init.json b/src/share/system_variable/ob_system_variable_init.json index a4117ac860..4c4e24ca84 100644 --- a/src/share/system_variable/ob_system_variable_init.json +++ b/src/share/system_variable/ob_system_variable_init.json @@ -3719,8 +3719,13 @@ "default_value": "17180000512", "base_value": "17180000512", "data_type": "uint", + "on_check_and_convert_func": "ObSysVarOnCheckFuncs::check_and_convert_compat_version", + "get_meta_type_func": "ObSysVarGetMetaTypeFuncs::get_meta_type_varchar", + "to_select_obj_func": "ObSysVarToObjFuncs::to_obj_version", + "to_show_str_func": "ObSysVarToStrFuncs::to_str_version", "info": "specifies the compatible verision when the behaviors of different release version are different", "flags": "GLOBAL | NEED_SERIALIZE | INFLUENCE_PLAN", + "base_class": "ObVersionSysVar", "publish_version": "423", "info_cn": "", "background_cn": "", @@ -3732,8 +3737,13 @@ "default_value": "17180000512", "base_value": "17180000512", "data_type": "uint", + "on_check_and_convert_func": "ObSysVarOnCheckFuncs::check_and_convert_security_version", + "get_meta_type_func": "ObSysVarGetMetaTypeFuncs::get_meta_type_varchar", + "to_select_obj_func": "ObSysVarToObjFuncs::to_obj_version", + "to_show_str_func": "ObSysVarToStrFuncs::to_str_version", "info": "specifies the security verision when the behaviors of different release version are different", "flags": "GLOBAL | NEED_SERIALIZE | INFLUENCE_PLAN", + "base_class": "ObVersionSysVar", "publish_version": "423", "info_cn": "", "background_cn": "", diff --git a/src/sql/CMakeLists.txt b/src/sql/CMakeLists.txt index 301aeb9f8b..602891b34d 100644 --- a/src/sql/CMakeLists.txt +++ b/src/sql/CMakeLists.txt @@ -257,6 +257,7 @@ ob_set_subtarget(ob_sql engine_cmd engine/cmd/ob_table_direct_insert_ctx.cpp engine/cmd/ob_table_direct_insert_service.cpp engine/cmd/ob_tenant_snapshot_executor.cpp + engine/cmd/ob_mock_executor.cpp ) ob_set_subtarget(ob_sql engine_dml @@ -509,6 +510,7 @@ ob_set_subtarget(ob_sql engine_expr engine/expr/ob_expr_pad.cpp engine/expr/ob_expr_part_id.cpp engine/expr/ob_expr_part_id_pseudo_column.cpp + engine/expr/ob_expr_password.cpp engine/expr/ob_expr_period_diff.cpp engine/expr/ob_expr_pi.cpp engine/expr/ob_expr_pl_associative_index.cpp @@ -734,6 +736,7 @@ ob_set_subtarget(ob_sql engine_expr engine/expr/ob_expr_inner_row_cmp_val.cpp engine/expr/ob_expr_last_refresh_scn.cpp engine/expr/ob_expr_json_utils.cpp + engine/expr/ob_expr_inner_table_option_printer.cpp ) ob_set_subtarget(ob_sql engine_join @@ -1065,6 +1068,7 @@ ob_set_subtarget(ob_sql resolver_cmd resolver/cmd/ob_help_resolver.cpp resolver/cmd/ob_help_stmt.cpp resolver/cmd/ob_kill_resolver.cpp + resolver/cmd/ob_mock_resolver.cpp resolver/cmd/ob_load_data_resolver.cpp resolver/cmd/ob_load_data_stmt.cpp resolver/cmd/ob_resource_resolver.cpp @@ -1085,6 +1089,8 @@ ob_set_subtarget(ob_sql resolver_dcl resolver/dcl/ob_alter_user_primary_zone_stmt.cpp resolver/dcl/ob_alter_user_profile_resolver.cpp resolver/dcl/ob_alter_user_profile_stmt.cpp + resolver/dcl/ob_alter_user_proxy_resolver.cpp + resolver/dcl/ob_alter_user_proxy_stmt.cpp resolver/dcl/ob_create_role_resolver.cpp resolver/dcl/ob_create_role_stmt.cpp resolver/dcl/ob_create_user_resolver.cpp diff --git a/src/sql/engine/cmd/ob_alter_system_executor.cpp b/src/sql/engine/cmd/ob_alter_system_executor.cpp index b5aadd10fb..575f924487 100644 --- a/src/sql/engine/cmd/ob_alter_system_executor.cpp +++ b/src/sql/engine/cmd/ob_alter_system_executor.cpp @@ -1955,7 +1955,8 @@ int ObChangeTenantExecutor::execute(ObExecContext &ctx, ObChangeTenantStmt &stmt LOG_WARN("ptr is null", KR(ret)); } else if (FALSE_IT(pre_effective_tenant_id = session_info->get_effective_tenant_id())) { } else if (FALSE_IT(login_tenant_id = session_info->get_login_tenant_id())) { - } else if (FALSE_IT(session_info->get_session_priv_info(session_priv))) { + } else if (OB_FAIL(session_info->get_session_priv_info(session_priv))) { + LOG_WARN("fail to get session priv info", K(ret)); } else if (effective_tenant_id == pre_effective_tenant_id) { // do nothing } else if (OB_SYS_TENANT_ID != login_tenant_id) { //case 1 diff --git a/src/sql/engine/cmd/ob_kill_executor.cpp b/src/sql/engine/cmd/ob_kill_executor.cpp index 7e03928d17..fd7abf4f3d 100644 --- a/src/sql/engine/cmd/ob_kill_executor.cpp +++ b/src/sql/engine/cmd/ob_kill_executor.cpp @@ -37,7 +37,6 @@ int ObKillExecutor::execute(ObExecContext &ctx, ObKillStmt &stmt) ObKillSessionArg arg; ObAddr addr; ObSQLSessionMgr &session_mgr = OBSERVER.get_sql_session_mgr(); - if (OB_FAIL(arg.init(ctx, stmt))) { LOG_WARN("fail to init kill_session arg", K(ret), K(arg), K(ctx), K(stmt)); } else { diff --git a/src/sql/engine/cmd/ob_mock_executor.cpp b/src/sql/engine/cmd/ob_mock_executor.cpp new file mode 100644 index 0000000000..3ff7d1f766 --- /dev/null +++ b/src/sql/engine/cmd/ob_mock_executor.cpp @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SQL_ENG +#include "sql/engine/cmd/ob_mock_executor.h" +#include "sql/resolver/cmd/ob_mock_stmt.h" +namespace oceanbase +{ +using namespace common; +namespace sql +{ +int ObMockExecutor::execute(ObExecContext &exec_ctx, ObMockStmt &stmt) +{ + int ret = OB_SUCCESS; + if (stmt::T_FLUSH_PRIVILEGES == stmt.get_stmt_type()) { + LOG_USER_WARN(OB_NOT_SUPPORTED, "After executing the GRANT and REVOKE statements, " + "the permissions will be automatically applied and take effect. " + "There is no need to execute the FLUSH PRIVILEGES command. FLUSH PRIVILEGES"); + } + return ret; +} + +} +} diff --git a/src/sql/engine/cmd/ob_mock_executor.h b/src/sql/engine/cmd/ob_mock_executor.h new file mode 100644 index 0000000000..3aea227425 --- /dev/null +++ b/src/sql/engine/cmd/ob_mock_executor.h @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_SQL_ENGINE_MOCK_EXECUTOR_H_ +#define OCEANBASE_SQL_ENGINE_MOCK_EXECUTOR_H_ + +#include "share/ob_define.h" +#include "sql/engine/ob_exec_context.h" +#include "sql/resolver/cmd/ob_mock_stmt.h" + +namespace oceanbase +{ +namespace sql +{ +class ObMockExecutor +{ +public: + ObMockExecutor() = default; + virtual ~ObMockExecutor() = default; + int execute(ObExecContext &exec_ctx, ObMockStmt &stmt); +private: + DISALLOW_COPY_AND_ASSIGN(ObMockExecutor); +}; + +} +} + +#endif diff --git a/src/sql/engine/cmd/ob_role_cmd_executor.cpp b/src/sql/engine/cmd/ob_role_cmd_executor.cpp index 41b2e8eaea..cc55a81fbd 100644 --- a/src/sql/engine/cmd/ob_role_cmd_executor.cpp +++ b/src/sql/engine/cmd/ob_role_cmd_executor.cpp @@ -147,7 +147,7 @@ int ObDropRoleExecutor::execute(ObExecContext &ctx, ObDropRoleStmt &stmt) OZ (arg.users_.push_back(stmt.get_user_names().at(i))); OZ (arg.hosts_.push_back(stmt.get_host_names().at(i))); } - OZ (ObDropUserExecutor::drop_user(common_rpc_proxy, arg)); + OZ (ObDropUserExecutor::drop_user(common_rpc_proxy, arg, false)); } return ret; diff --git a/src/sql/engine/cmd/ob_table_executor.cpp b/src/sql/engine/cmd/ob_table_executor.cpp index 6eb6242957..2ddf4f7612 100644 --- a/src/sql/engine/cmd/ob_table_executor.cpp +++ b/src/sql/engine/cmd/ob_table_executor.cpp @@ -104,23 +104,67 @@ int ObCreateTableExecutor::ObInsSQLPrinter::inner_print(char *buf, int64_t buf_l const char sep_char = lib::is_oracle_mode()? '"': '`'; const ObSelectStmt *select_stmt = NULL; int64_t pos1 = 0; + uint64_t insert_mode = 0; if (OB_ISNULL(stmt_) || OB_ISNULL(select_stmt= stmt_->get_sub_select())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("null stmt", K(ret)); - } else if (OB_FAIL(databuff_printf(buf, buf_len, pos1, - do_osg_ - ? "insert /*+ ENABLE_PARALLEL_DML PARALLEL(%lu) GATHER_OPTIMIZER_STATISTICS*/ into %c%.*s%c.%c%.*s%c" - : "insert /*+ ENABLE_PARALLEL_DML PARALLEL(%lu) NO_GATHER_OPTIMIZER_STATISTICS*/ into %c%.*s%c.%c%.*s%c", - stmt_->get_parallelism(), - sep_char, - stmt_->get_database_name().length(), - stmt_->get_database_name().ptr(), - sep_char, - sep_char, - stmt_->get_table_name().length(), - stmt_->get_table_name().ptr(), - sep_char))) { - LOG_WARN("fail to print insert into string", K(ret)); + } else { + insert_mode = stmt_->get_insert_mode(); + if (insert_mode != 0 && + insert_mode != 1 && + insert_mode != 2 ) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected insert_mode", K(insert_mode), K(ret)); + } else if (insert_mode == 1 /*ignore*/) { + if (OB_FAIL(databuff_printf(buf, buf_len, pos1, + do_osg_ + ? "insert ignore /*+ ENABLE_PARALLEL_DML PARALLEL(%lu) GATHER_OPTIMIZER_STATISTICS*/ into %c%.*s%c.%c%.*s%c" + : "insert ignore /*+ ENABLE_PARALLEL_DML PARALLEL(%lu) NO_GATHER_OPTIMIZER_STATISTICS*/ into %c%.*s%c.%c%.*s%c", + stmt_->get_parallelism(), + sep_char, + stmt_->get_database_name().length(), + stmt_->get_database_name().ptr(), + sep_char, + sep_char, + stmt_->get_table_name().length(), + stmt_->get_table_name().ptr(), + sep_char))) { + LOG_WARN("fail to print insert into string", K(ret)); + } + } else if (insert_mode == 2 /*replace*/) { + if (OB_FAIL(databuff_printf(buf, buf_len, pos1, + do_osg_ + ? "replace /*+ ENABLE_PARALLEL_DML PARALLEL(%lu) GATHER_OPTIMIZER_STATISTICS*/ into %c%.*s%c.%c%.*s%c" + : "replace /*+ ENABLE_PARALLEL_DML PARALLEL(%lu) NO_GATHER_OPTIMIZER_STATISTICS*/ into %c%.*s%c.%c%.*s%c", + stmt_->get_parallelism(), + sep_char, + stmt_->get_database_name().length(), + stmt_->get_database_name().ptr(), + sep_char, + sep_char, + stmt_->get_table_name().length(), + stmt_->get_table_name().ptr(), + sep_char))) { + LOG_WARN("fail to print insert into string", K(ret)); + } + } else if (OB_FAIL(databuff_printf(buf, buf_len, pos1, + do_osg_ + ? "insert /*+ ENABLE_PARALLEL_DML PARALLEL(%lu) GATHER_OPTIMIZER_STATISTICS*/ into %c%.*s%c.%c%.*s%c" + : "insert /*+ ENABLE_PARALLEL_DML PARALLEL(%lu) NO_GATHER_OPTIMIZER_STATISTICS*/ into %c%.*s%c.%c%.*s%c", + stmt_->get_parallelism(), + sep_char, + stmt_->get_database_name().length(), + stmt_->get_database_name().ptr(), + sep_char, + sep_char, + stmt_->get_table_name().length(), + stmt_->get_table_name().ptr(), + sep_char))) { + LOG_WARN("fail to print insert into string", K(ret)); + } + } + if (OB_FAIL(ret)) { + //do nothing } else if (lib::is_oracle_mode()) { const ObTableSchema &table_schema = stmt_->get_create_table_arg().schema_; int64_t used_column_count = 0; diff --git a/src/sql/engine/cmd/ob_user_cmd_executor.cpp b/src/sql/engine/cmd/ob_user_cmd_executor.cpp index ab79410d70..da7fac73c2 100644 --- a/src/sql/engine/cmd/ob_user_cmd_executor.cpp +++ b/src/sql/engine/cmd/ob_user_cmd_executor.cpp @@ -23,6 +23,7 @@ #include "sql/resolver/dcl/ob_lock_user_stmt.h" #include "sql/resolver/dcl/ob_rename_user_stmt.h" #include "sql/resolver/dcl/ob_alter_user_profile_stmt.h" +#include "sql/resolver/dcl/ob_alter_user_proxy_stmt.h" #include "sql/resolver/dcl/ob_alter_user_primary_zone_stmt.h" #include "sql/engine/ob_exec_context.h" @@ -268,6 +269,16 @@ int ObCreateUserExecutor::create_user(obrpc::ObCommonRpcProxy *rpc_proxy, return ret; } +int ObDropUserExecutor::build_fail_msg_for_one(const ObString &user, const ObString &host, + common::ObSqlString &msg) { + int ret = OB_SUCCESS; + if (OB_FAIL(msg.append_fmt("'%.*s'@'%.*s'", + user.length(), user.ptr(), + host.length(), host.ptr()))) { + LOG_WARN("Build msg fail", K(user), K(host), K(ret)); + } + return ret; +} int ObDropUserExecutor::build_fail_msg(const common::ObIArray &users, const common::ObIArray &hosts, common::ObSqlString &msg) @@ -284,10 +295,8 @@ int ObDropUserExecutor::build_fail_msg(const common::ObIArray if (OB_SUCC(ret)) { const ObString &user = users.at(i); const ObString &host = hosts.at(i); - if (OB_FAIL(msg.append_fmt("'%.*s'@'%.*s'", - user.length(), user.ptr(), - host.length(), host.ptr()))) { - LOG_WARN("Build msg fail", K(user), K(host), K(ret)); + if (OB_FAIL(build_fail_msg_for_one(user, host, msg))) { + LOG_WARN("Build fail msg fail", K(user), K(host), K(ret)); } } } @@ -373,7 +382,7 @@ int ObDropUserExecutor::execute(ObExecContext &ctx, ObDropUserStmt &stmt) } } if (OB_SUCC(ret)) { - if (OB_FAIL(drop_user(common_rpc_proxy, arg))) { + if (OB_FAIL(drop_user(common_rpc_proxy, arg, stmt.get_if_exists()))) { LOG_WARN("Drop user completely failed", K(ret)); } else { //do nothing @@ -384,7 +393,8 @@ int ObDropUserExecutor::execute(ObExecContext &ctx, ObDropUserStmt &stmt) } int ObDropUserExecutor::drop_user(obrpc::ObCommonRpcProxy *rpc_proxy, - const obrpc::ObDropUserArg &arg) + const obrpc::ObDropUserArg &arg, + bool if_exist_stmt) { int ret = OB_SUCCESS; if (OB_UNLIKELY(!arg.is_valid())) { @@ -409,12 +419,28 @@ int ObDropUserExecutor::drop_user(obrpc::ObCommonRpcProxy *rpc_proxy, failed_index, failed_users, failed_hosts))) { LOG_WARN("Failed to extract user name", K(arg), K(ret)); - } else if (OB_FAIL(ObDropUserExecutor::build_fail_msg(failed_users, failed_hosts, fail_msg))) { - LOG_WARN("Build fail msg error", K(arg), K(ret)); - } else { - const char *ERR_CMD = (arg.is_role_ && lib::is_mysql_mode()) ? "DROP ROLE" : "DROP USER"; - ret = OB_CANNOT_USER; - LOG_USER_ERROR(OB_CANNOT_USER, (int)strlen(ERR_CMD), ERR_CMD, (int)fail_msg.length(), fail_msg.ptr()); + } else if (if_exist_stmt) { + if (OB_UNLIKELY(failed_users.count() < 1) || OB_UNLIKELY(failed_users.count() != failed_users.count())) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid argument", K(failed_users.count()), K(failed_users.count()), K(ret)); + } else { + for (int i = 0; OB_SUCC(ret) && i < failed_users.count(); ++i) { + ObSqlString fail_msg_one; + if (OB_FAIL(ObDropUserExecutor::build_fail_msg_for_one(failed_users.at(i), failed_hosts.at(i), fail_msg_one))) { + LOG_WARN("Build fail msg error", K(arg), K(ret)); + } else { + LOG_USER_WARN(OB_CANNOT_USER_IF_EXISTS, (int)fail_msg_one.length(), fail_msg_one.ptr()); + } + } + } + } else if (!if_exist_stmt) { + if (OB_FAIL(ObDropUserExecutor::build_fail_msg(failed_users, failed_hosts, fail_msg))) { + LOG_WARN("Build fail msg error", K(arg), K(ret)); + } else { + const char *ERR_CMD = (arg.is_role_ && lib::is_mysql_mode()) ? "DROP ROLE" : "DROP USER"; + ret = OB_CANNOT_USER; + LOG_USER_ERROR(OB_CANNOT_USER, (int)strlen(ERR_CMD), ERR_CMD, (int)fail_msg.length(), fail_msg.ptr()); + } } } } @@ -608,6 +634,28 @@ int ObAlterUserProfileExecutor::execute(ObExecContext &ctx, ObAlterUserProfileSt return ret; } +int ObAlterUserProxyExecutor::execute(ObExecContext &ctx, ObAlterUserProxyStmt &stmt) +{ + int ret = OB_SUCCESS; + ObTaskExecutorCtx *task_exec_ctx = NULL; + obrpc::ObCommonRpcProxy *common_rpc_proxy = NULL; + obrpc::ObAlterUserProxyRes res; + if (OB_ISNULL(stmt.get_query_ctx())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_FALSE_IT(stmt.get_ddl_arg().ddl_stmt_str_ = stmt.get_query_ctx()->get_sql_stmt())) { + } else if (OB_ISNULL(task_exec_ctx = GET_TASK_EXECUTOR_CTX(ctx))) { + ret = OB_NOT_INIT; + LOG_WARN("get task executor context failed", K(ret)); + } else if (OB_ISNULL(common_rpc_proxy = task_exec_ctx->get_common_rpc())) { + ret = OB_NOT_INIT; + LOG_WARN("get common rpc proxy failed", K(ret)); + } else if (OB_FAIL(common_rpc_proxy->alter_user_proxy(stmt.get_ddl_arg(), res))) { + LOG_WARN("alter user proxy failed", K(stmt.get_ddl_arg()), K(ret)); + } + return ret; +} + int ObRenameUserExecutor::execute(ObExecContext &ctx, ObRenameUserStmt &stmt) { int ret = OB_SUCCESS; diff --git a/src/sql/engine/cmd/ob_user_cmd_executor.h b/src/sql/engine/cmd/ob_user_cmd_executor.h index faccf81a7f..586a26dd7a 100644 --- a/src/sql/engine/cmd/ob_user_cmd_executor.h +++ b/src/sql/engine/cmd/ob_user_cmd_executor.h @@ -75,8 +75,13 @@ public: const common::ObIArray &index, common::ObIArray &dst_users, common::ObIArray &dst_hosts); + + static int build_fail_msg_for_one(const ObString &user, + const ObString &host, + common::ObSqlString &msg); static int drop_user(obrpc::ObCommonRpcProxy *rpc_proxy, - const obrpc::ObDropUserArg &arg); + const obrpc::ObDropUserArg &arg, + bool if_exists); int execute(ObExecContext &ctx, ObDropUserStmt &stmt); private: @@ -110,6 +115,18 @@ public: DISALLOW_COPY_AND_ASSIGN(ObAlterUserProfileExecutor); }; +class ObAlterUserProxyStmt; +class ObAlterUserProxyExecutor +{ +private: +public: + ObAlterUserProxyExecutor() {} + virtual ~ObAlterUserProxyExecutor() {} + int execute(ObExecContext &ctx, ObAlterUserProxyStmt &stmt); + + DISALLOW_COPY_AND_ASSIGN(ObAlterUserProxyExecutor); +}; + class ObRenameUserStmt; class ObRenameUserExecutor { diff --git a/src/sql/engine/expr/ob_expr_eval_functions.cpp b/src/sql/engine/expr/ob_expr_eval_functions.cpp index 8b45feb1f5..4f564a4f6a 100644 --- a/src/sql/engine/expr/ob_expr_eval_functions.cpp +++ b/src/sql/engine/expr/ob_expr_eval_functions.cpp @@ -375,6 +375,9 @@ #include "ob_expr_st_symdifference.h" #include "ob_expr_priv_st_asmvtgeom.h" #include "ob_expr_priv_st_makevalid.h" +#include "ob_expr_inner_table_option_printer.h" +#include "ob_expr_password.h" + namespace oceanbase { @@ -1141,14 +1144,14 @@ static ObExpr::EvalFunc g_expr_eval_functions[] = { NULL, //ObExprXmlConcat::eval_xml_concat, /* 662 */ NULL, //ObExprXmlForest::eval_xml_forest, /* 663 */ NULL, //ObExprExistsNodeXml::eval_existsnode_xml, /* 664 */ - NULL, //ObExprPassword::eval_password, /* 665 */ + ObExprPassword::eval_password, /* 665 */ ObExprDocID::generate_doc_id, /* 666 */ ObExprWordSegment::generate_fulltext_column, /* 667 */ ObExprWordCount::generate_word_count, /* 668 */ ObExprBM25::eval_bm25_relevance_expr, /* 669 */ ObExprTransactionId::eval_transaction_id, /* 670 */ - NULL, //ObExprInnerTableOptionPrinter::eval_inner_table_option_printer, /* 671 */ - NULL, //ObExprInnerTableSequenceGetter::eval_inner_table_sequence_getter, /* 672 */ + ObExprInnerTableOptionPrinter::eval_inner_table_option_printer, /* 671 */ + ObExprInnerTableSequenceGetter::eval_inner_table_sequence_getter, /* 672 */ NULL, //ObExprDecodeTraceId::calc_decode_trace_id_expr, /* 673 */ ObExprInnerRowCmpVal::eval_inner_row_cmp_val, /* 674 */ ObExprIs::json_is_true, /* 675 */ diff --git a/src/sql/engine/expr/ob_expr_inner_table_option_printer.cpp b/src/sql/engine/expr/ob_expr_inner_table_option_printer.cpp new file mode 100644 index 0000000000..685ea0456b --- /dev/null +++ b/src/sql/engine/expr/ob_expr_inner_table_option_printer.cpp @@ -0,0 +1,212 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SQL_ENG +#include "sql/engine/expr/ob_expr_inner_table_option_printer.h" +#include +#include "share/object/ob_obj_cast.h" +#include "objit/common/ob_item_type.h" +#include "sql/engine/ob_exec_context.h" +#include "sql/session/ob_sql_session_info.h" +#include "share/schema/ob_schema_struct.h" +#include "share/schema/ob_schema_printer.h" +//#include "sql/engine/expr/ob_expr_promotion_util.h" + + +namespace oceanbase +{ +using namespace common; +namespace sql +{ + +ObExprInnerTableOptionPrinter::ObExprInnerTableOptionPrinter(ObIAllocator &alloc) + : ObStringExprOperator(alloc, T_FUN_SYS_INNER_TABLE_OPTION_PRINTER, N_INNER_TABLE_OPTION_PRINTER, 3, + VALID_FOR_GENERATED_COL, INTERNAL_IN_MYSQL_MODE, INTERNAL_IN_ORACLE_MODE) +{ + need_charset_convert_ = false; +} + +ObExprInnerTableOptionPrinter::~ObExprInnerTableOptionPrinter() +{ +} + +inline int ObExprInnerTableOptionPrinter::calc_result_type3(ObExprResType &type, + ObExprResType &type1, + ObExprResType &type2, + ObExprResType &type3, + common::ObExprTypeCtx &type_ctx) const +{ + int ret = OB_SUCCESS; + UNUSED(type_ctx); + type1.set_calc_type(ObIntType); + type2.set_calc_type(ObIntType); + type3.set_calc_type(ObIntType); + type.set_type(ObVarcharType); + type.set_collation_type(ObCharset::get_default_collation(ObCharset::get_default_charset())); + type.set_collation_level(common::CS_LEVEL_IMPLICIT); + return ret; +} + +int ObExprInnerTableOptionPrinter::cg_expr(ObExprCGCtx &, const ObRawExpr &, ObExpr &rt_expr) const +{ + int ret = OB_SUCCESS; + CK(3 == rt_expr.arg_cnt_); + rt_expr.eval_func_ = &ObExprInnerTableOptionPrinter::eval_inner_table_option_printer; + return ret; +} + +int ObExprInnerTableOptionPrinter::eval_inner_table_option_printer(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum) +{ + int ret = OB_SUCCESS; + share::schema::ObSchemaGetterGuard schema_guard; + const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session(); + ObDatum *tenant_id = nullptr; + ObDatum *database_id = nullptr; + ObDatum *table_id = nullptr; + const ObTableSchema *table_schema = nullptr; + if (OB_ISNULL(session)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to get my session", K(ret)); + } else if (OB_ISNULL(GCTX.schema_service_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to get schema_service", K(ret)); + } else if (OB_FAIL(expr.eval_param_value(ctx, tenant_id, database_id, table_id))) { + LOG_WARN("failed to eval table id", K(ret)); + } else if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(session->get_effective_tenant_id(), schema_guard))) { + LOG_WARN("failed to get schema guard", K(ret)); + } else if (OB_FAIL(schema_guard.get_table_schema(tenant_id->get_int(), table_id->get_int(), table_schema))) { + LOG_WARN("failed to get table schema", K(ret), K(table_id->get_int())); + } else if (nullptr == table_schema) { + expr_datum.set_null(); + } else { + ObSchemaPrinter schema_printer(schema_guard); + int64_t pos = 0; + char *buf = expr.get_str_res_mem(ctx, MAX_TABLE_STATUS_CREATE_OPTION_LENGTH); + if (OB_ISNULL(buf)) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("failed to alloc buf", K(ret)); + } else if (FALSE_IT(MEMSET(buf, 0, MAX_TABLE_STATUS_CREATE_OPTION_LENGTH))) { + } else if (OB_FAIL(schema_printer.print_table_definition_table_options(*table_schema, + buf, + MAX_TABLE_STATUS_CREATE_OPTION_LENGTH, + pos, + true))) { + LOG_WARN("print table definition table options failed", K(ret)); + } else { + int64_t len = strlen(buf); + if (len > 0) { + expr_datum.set_string(ObString(len, buf)); + } else { + expr_datum.set_null(); + } + } + } + return ret; +} + +DEF_SET_LOCAL_SESSION_VARS(ObExprInnerTableOptionPrinter, raw_expr) { + int ret = OB_SUCCESS; + if (lib::is_mysql_mode()) { + SET_LOCAL_SYSVAR_CAPACITY(1); + EXPR_ADD_LOCAL_SYSVAR(SYS_VAR_COLLATION_CONNECTION); + } + return ret; +} + +ObExprInnerTableSequenceGetter::ObExprInnerTableSequenceGetter(ObIAllocator &alloc) + : ObExprOperator(alloc, T_FUN_SYS_INNER_TABLE_SEQUENCE_GETTER, N_INNER_TABLE_SEQUENCE_GETTER, 3, + VALID_FOR_GENERATED_COL, INTERNAL_IN_MYSQL_MODE, INTERNAL_IN_ORACLE_MODE) +{ +} + +ObExprInnerTableSequenceGetter::~ObExprInnerTableSequenceGetter() +{ +} + +inline int ObExprInnerTableSequenceGetter::calc_result_type3(ObExprResType &type, + ObExprResType &type1, + ObExprResType &type2, + ObExprResType &type3, + common::ObExprTypeCtx &type_ctx) const +{ + int ret = OB_SUCCESS; + UNUSED(type_ctx); + type1.set_calc_type(ObIntType); + type2.set_calc_type(ObIntType); + type3.set_calc_type(ObIntType); + type.set_type(ObUInt64Type); + return ret; +} + +int ObExprInnerTableSequenceGetter::cg_expr(ObExprCGCtx &, const ObRawExpr &, ObExpr &rt_expr) const +{ + int ret = OB_SUCCESS; + CK(3 == rt_expr.arg_cnt_); + rt_expr.eval_func_ = &ObExprInnerTableSequenceGetter::eval_inner_table_sequence_getter; + return ret; +} + +int ObExprInnerTableSequenceGetter::eval_inner_table_sequence_getter(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum) +{ + int ret = OB_SUCCESS; + share::schema::ObSchemaGetterGuard schema_guard; + const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session(); + ObDatum *tenant_id = nullptr; + ObDatum *table_id = nullptr; + ObDatum *auto_inc_col_id = nullptr; + const ObTableSchema *table_schema = nullptr; + if (OB_ISNULL(session)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to get my session", K(ret)); + } else if (OB_ISNULL(GCTX.schema_service_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to get schema_service", K(ret)); + } else if (OB_FAIL(expr.eval_param_value(ctx, tenant_id, table_id, auto_inc_col_id))) { + LOG_WARN("failed to eval table id", K(ret)); + } else if (auto_inc_col_id->is_null() || 0 == auto_inc_col_id->get_int()) { + expr_datum.set_null(); + } else if (OB_FAIL(GCTX.schema_service_->get_tenant_schema_guard(session->get_effective_tenant_id(), schema_guard))) { + LOG_WARN("failed to get schema guard", K(ret)); + } else if (OB_FAIL(schema_guard.get_table_schema(tenant_id->get_int(), table_id->get_int(), table_schema))) { + LOG_WARN("failed to get table schema", K(ret), K(table_id->get_int())); + } else if (nullptr == table_schema) { + expr_datum.set_null(); + } else { + uint64_t auto_increment = 0; + if (OB_FAIL(share::ObAutoincrementService::get_instance().get_sequence_value( + table_schema->get_tenant_id(), table_schema->get_table_id(), + table_schema->get_autoinc_column_id(), table_schema->is_order_auto_increment_mode(), + table_schema->get_truncate_version(), auto_increment))) { + SHARE_SCHEMA_LOG(WARN, "fail to get auto_increment value", K(ret)); + } else if (auto_increment > 0) { + if (table_schema->get_auto_increment() > auto_increment) { + auto_increment = table_schema->get_auto_increment(); + } + expr_datum.set_uint(auto_increment); + } else { + expr_datum.set_null(); + } + } + return ret; +} + +DEF_SET_LOCAL_SESSION_VARS(ObExprInnerTableSequenceGetter, raw_expr) { + int ret = OB_SUCCESS; + if (lib::is_mysql_mode()) { + SET_LOCAL_SYSVAR_CAPACITY(1); + EXPR_ADD_LOCAL_SYSVAR(share::SYS_VAR_COLLATION_CONNECTION); + } + return ret; +} + +} +} \ No newline at end of file diff --git a/src/sql/engine/expr/ob_expr_inner_table_option_printer.h b/src/sql/engine/expr/ob_expr_inner_table_option_printer.h new file mode 100644 index 0000000000..370df9422b --- /dev/null +++ b/src/sql/engine/expr/ob_expr_inner_table_option_printer.h @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef _OB_SQL_EXPR_INNER_TABLE_OPTION_PRINTER_H_ +#define _OB_SQL_EXPR_INNER_TABLE_OPTION_PRINTER_H_ + +#include "sql/engine/expr/ob_expr_operator.h" + +namespace oceanbase +{ +namespace sql +{ + +class ObExprInnerTableOptionPrinter : public ObStringExprOperator +{ +public: + explicit ObExprInnerTableOptionPrinter(common::ObIAllocator &alloc); + virtual ~ObExprInnerTableOptionPrinter(); + virtual int calc_result_type3(ObExprResType &type, + ObExprResType &type1, + ObExprResType &type2, + ObExprResType &type3, + common::ObExprTypeCtx &type_ctx) const; + virtual int cg_expr(ObExprCGCtx &op_cg_ctx, + const ObRawExpr &raw_expr, + ObExpr &rt_expr) const override; + static int eval_inner_table_option_printer(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum); + DECLARE_SET_LOCAL_SESSION_VARS; +private: + // disallow copy + DISALLOW_COPY_AND_ASSIGN(ObExprInnerTableOptionPrinter); +}; + +class ObExprInnerTableSequenceGetter : public ObExprOperator +{ +public: + explicit ObExprInnerTableSequenceGetter(common::ObIAllocator &alloc); + virtual ~ObExprInnerTableSequenceGetter(); + virtual int calc_result_type3(ObExprResType &type, + ObExprResType &type1, + ObExprResType &type2, + ObExprResType &type3, + common::ObExprTypeCtx &type_ctx) const; + virtual int cg_expr(ObExprCGCtx &op_cg_ctx, + const ObRawExpr &raw_expr, + ObExpr &rt_expr) const override; + static int eval_inner_table_sequence_getter(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum); + DECLARE_SET_LOCAL_SESSION_VARS; +private: + // disallow copy + DISALLOW_COPY_AND_ASSIGN(ObExprInnerTableSequenceGetter); +}; + +} +} +#endif /* _OB_SQL_EXPR_INNER_TABLE_OPTION_PRINTER_H_ */ diff --git a/src/sql/engine/expr/ob_expr_operator_factory.cpp b/src/sql/engine/expr/ob_expr_operator_factory.cpp index 89b1647157..1e5d4438b2 100644 --- a/src/sql/engine/expr/ob_expr_operator_factory.cpp +++ b/src/sql/engine/expr/ob_expr_operator_factory.cpp @@ -64,6 +64,7 @@ #include "sql/engine/expr/ob_expr_agg_param_list.h" #include "sql/engine/expr/ob_expr_is_serving_tenant.h" #include "sql/engine/expr/ob_expr_hex.h" +#include "sql/engine/expr/ob_expr_password.h" #include "sql/engine/expr/ob_expr_in.h" #include "sql/engine/expr/ob_expr_not_in.h" #include "sql/engine/expr/ob_expr_int2ip.h" @@ -438,6 +439,7 @@ #include "sql/engine/expr/ob_expr_st_symdifference.h" #include "sql/engine/expr/ob_expr_priv_st_asmvtgeom.h" #include "sql/engine/expr/ob_expr_priv_st_makevalid.h" +#include "sql/engine/expr/ob_expr_inner_table_option_printer.h" #include "sql/engine/expr/ob_expr_lock_func.h" @@ -675,6 +677,7 @@ void ObExprOperatorFactory::register_expr_operators() REG_OP(ObExprGreaterThan); REG_OP(ObExprGreatest); REG_OP(ObExprHex); + REG_OP(ObExprPassword); REG_OP(ObExprIn); REG_OP(ObExprNotIn); REG_OP(ObExprInt2ip); @@ -1077,6 +1080,8 @@ void ObExprOperatorFactory::register_expr_operators() REG_OP(ObExprPrivSTAsMVTGeom); REG_OP(ObExprPrivSTMakeValid); REG_OP(ObExprCurrentRole); + REG_OP(ObExprInnerTableOptionPrinter); + REG_OP(ObExprInnerTableSequenceGetter); }(); // 注册oracle系统函数 REG_OP_ORCL(ObExprSysConnectByPath); @@ -1398,6 +1403,8 @@ void ObExprOperatorFactory::register_expr_operators() REG_OP_ORCL(ObExprTransactionId); REG_OP_ORCL(ObExprInnerRowCmpVal); REG_OP_ORCL(ObExprLastRefreshScn); + REG_OP_ORCL(ObExprInnerTableOptionPrinter); + REG_OP_ORCL(ObExprInnerTableSequenceGetter); // REG_OP_ORCL(ObExprTopNFilter); // REG_OP_ORCL(ObExprSdoRelate); } diff --git a/src/sql/engine/expr/ob_expr_password.cpp b/src/sql/engine/expr/ob_expr_password.cpp new file mode 100644 index 0000000000..3cf43357fe --- /dev/null +++ b/src/sql/engine/expr/ob_expr_password.cpp @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SQL_ENG +#include "sql/engine/expr/ob_expr_password.h" +#include "sql/engine/expr/ob_expr_util.h" +#include "lib/encrypt/ob_encrypted_helper.h" + +using namespace oceanbase::common; + +namespace oceanbase +{ +namespace sql +{ + +ObExprPassword::ObExprPassword(ObIAllocator &alloc) + : ObStringExprOperator(alloc, T_FUN_SYS_PASSWORD, N_PASSWORD, 1, VALID_FOR_GENERATED_COL) +{ +} + +ObExprPassword::~ObExprPassword() +{ +} + +# define SHA_PASSWORD_CHAR_LENGTH (SHA_DIGEST_LENGTH * 2 + 2) + +int ObExprPassword::calc_result_type1(ObExprResType &type, ObExprResType &text, + common::ObExprTypeCtx &type_ctx) const +{ + int ret = OB_SUCCESS; + + type.set_type(ObVarcharType); + type.set_length(SHA_PASSWORD_CHAR_LENGTH); + type.set_collation_type(type_ctx.get_coll_type()); + type.set_collation_level(CS_LEVEL_COERCIBLE); + + text.set_calc_type(ObVarcharType); + ObExprResType tmp_type; + OZ(ObExprOperator::aggregate_charsets_for_string_result(tmp_type, &text, 1, + type_ctx.get_coll_type())); + OX(text.set_calc_collation_type(tmp_type.get_collation_type())); + OX(text.set_calc_collation_level(tmp_type.get_collation_level())); + return ret; +} + +int ObExprPassword::cg_expr(ObExprCGCtx &, const ObRawExpr &, ObExpr &rt_expr) const +{ + int ret = OB_SUCCESS; + rt_expr.eval_func_ = eval_password; + return ret; +} + +int ObExprPassword::eval_password(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_datum) +{ + int ret = OB_SUCCESS; + ObDatum *arg = NULL; + if (OB_FAIL(expr.eval_param_value(ctx, arg))) { + LOG_ERROR("evaluate parameter value failed", K(ret), K(arg)); + } else if (arg->is_null()) { + expr_datum.set_string("", 0); + } else if (arg->get_string().empty()) { + expr_datum.set_string("", 0); + } else { + ObEvalCtx::TempAllocGuard alloc_guard(ctx); + char *enc_buf = static_cast(alloc_guard.get_allocator().alloc(SHA_PASSWORD_CHAR_LENGTH)); + if (enc_buf == NULL) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_ERROR("alloc memory failed", K(ret)); + } else { + ObString tmp_str; + ObString upp_str; + ObString res_str; + ObString str_in_ctx; + tmp_str.assign_ptr(enc_buf, SHA_PASSWORD_CHAR_LENGTH); + if (OB_FAIL(ObEncryptedHelper::encrypt_passwd_to_stage2(arg->get_string(), tmp_str))) { + LOG_WARN("encrypt password failed", K(ret)); + } else if (OB_FAIL(ObCharset::toupper(ObCollationType::CS_TYPE_UTF8MB4_GENERAL_CI, + tmp_str, + upp_str, + alloc_guard.get_allocator()))) { + LOG_WARN("convert string to upper failed", K(ret), K(tmp_str)); + } else if (OB_FAIL(ObExprUtil::convert_string_collation(upp_str, + ObCollationType::CS_TYPE_UTF8MB4_GENERAL_CI, + res_str, + expr.datum_meta_.cs_type_, + alloc_guard.get_allocator()))) { + LOG_WARN("convert string collation failed", K(ret), K(upp_str)); + } else if (OB_FAIL(ObExprUtil::deep_copy_str(res_str, str_in_ctx, ctx.get_expr_res_alloc()))) { + LOG_WARN("failed to cpoy str to context", K(ret)); + } else { + expr_datum.set_string(str_in_ctx); + LOG_USER_WARN(OB_ERR_DEPRECATED_SYNTAX_NO_REP, "\'PASSWORD\'"); + } + } + } + return ret; +} + +DEF_SET_LOCAL_SESSION_VARS(ObExprPassword, raw_expr) { + int ret = OB_SUCCESS; + if (lib::is_mysql_mode()) { + SET_LOCAL_SYSVAR_CAPACITY(1); + EXPR_ADD_LOCAL_SYSVAR(share::SYS_VAR_COLLATION_SERVER); + } + return ret; +} + +} +} diff --git a/src/sql/engine/expr/ob_expr_password.h b/src/sql/engine/expr/ob_expr_password.h new file mode 100644 index 0000000000..916d607774 --- /dev/null +++ b/src/sql/engine/expr/ob_expr_password.h @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_PASSWORD_ +#define OCEANBASE_SQL_ENGINE_EXPR_OB_EXPR_PASSWORD_ + +#include "sql/engine/expr/ob_expr_operator.h" + +namespace oceanbase +{ +namespace sql +{ +class ObExprPassword : public ObStringExprOperator +{ +public: + explicit ObExprPassword(common::ObIAllocator &alloc); + virtual ~ObExprPassword(); + virtual int calc_result_type1(ObExprResType &type, + ObExprResType &text, + common::ObExprTypeCtx &type_ctx) const; + + virtual int cg_expr(ObExprCGCtx &expr_cg_ctx, + const ObRawExpr &raw_expr, + ObExpr &rt_expr) const override; + + static int eval_password(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &datum); + + DECLARE_SET_LOCAL_SESSION_VARS; +private: + DISALLOW_COPY_AND_ASSIGN(ObExprPassword); +}; + +} +} +#endif diff --git a/src/sql/engine/expr/ob_expr_replace.cpp b/src/sql/engine/expr/ob_expr_replace.cpp index aed5ee2399..8d0181b839 100644 --- a/src/sql/engine/expr/ob_expr_replace.cpp +++ b/src/sql/engine/expr/ob_expr_replace.cpp @@ -19,9 +19,11 @@ #include "lib/oblog/ob_log.h" #include "share/object/ob_obj_cast.h" +#include "share/ob_compatibility_control.h" #include "sql/session/ob_sql_session_info.h" #include "sql/engine/expr/ob_expr_result_type_util.h" #include "sql/engine/expr/ob_expr_lob_utils.h" +#include "sql/engine/ob_exec_context.h" namespace oceanbase { @@ -234,7 +236,30 @@ int ObExprReplace::eval_replace(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &exp } else if (text->is_null() || (is_mysql && from->is_null()) || (is_mysql && NULL != to && to->is_null())) { - expr_datum.set_null(); + if (is_mysql && !from->is_null() && 0 == from->len_) { + ObSolidifiedVarsGetter helper(expr, ctx, ctx.exec_ctx_.get_my_session()); + const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session(); + uint64_t compat_version = 0; + ObCompatType compat_type = COMPAT_MYSQL57; + bool is_enable = false; + if (OB_ISNULL(session)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("session info is null", K(ret)); + } else if (OB_FAIL(helper.get_compat_version(compat_version))) { + LOG_WARN("failed to get compat version", K(ret)); + } else if (OB_FAIL(ObCompatControl::check_feature_enable(compat_version, + ObCompatFeatureType::FUNC_REPLACE_NULL, is_enable))) { + LOG_WARN("failed to check feature enable", K(ret)); + } else if (OB_FAIL(session->get_compatibility_control(compat_type))) { + LOG_WARN("failed to get compat type", K(ret)); + } else if (is_enable && COMPAT_MYSQL57 == compat_type) { + expr_datum.set_datum(*text); + } else { + expr_datum.set_null(); + } + } else { + expr_datum.set_null(); + } } else if (is_clob && (0 == text->len_)) { expr_datum.set_datum(*text); } else if (!is_lob_res) { // non text tc inputs @@ -288,8 +313,9 @@ int ObExprReplace::eval_replace(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &exp DEF_SET_LOCAL_SESSION_VARS(ObExprReplace, raw_expr) { int ret = OB_SUCCESS; - SET_LOCAL_SYSVAR_CAPACITY(1); + SET_LOCAL_SYSVAR_CAPACITY(2); EXPR_ADD_LOCAL_SYSVAR(share::SYS_VAR_COLLATION_CONNECTION); + EXPR_ADD_LOCAL_SYSVAR(share::SYS_VAR_OB_COMPATIBILITY_VERSION); return ret; } diff --git a/src/sql/engine/expr/ob_expr_sys_context.cpp b/src/sql/engine/expr/ob_expr_sys_context.cpp index dbe79283fd..174664acf8 100644 --- a/src/sql/engine/expr/ob_expr_sys_context.cpp +++ b/src/sql/engine/expr/ob_expr_sys_context.cpp @@ -101,6 +101,9 @@ ObExprSysContext::UserEnvParameter ObExprSysContext::userenv_parameters_[] = {"CLIENT_INFO", eval_client_info}, {"MODULE", eval_module}, {"CLIENT_IDENTIFIER", eval_client_identifier}, + {"PROXY_USER", eval_proxy_user}, + {"PROXY_USERID", eval_proxy_user_id}, + {"AUTHENTICATED_IDENTITY", eval_auth_identity}, }; ObExprSysContext::NLS_Lang ObExprSysContext::lang_map_[] = { @@ -876,5 +879,80 @@ int ObExprSysContext::get_schema_guard(share::schema::ObSchemaGetterGuard &schem return ret; } +int ObExprSysContext::eval_proxy_user(const ObExpr &expr, ObDatum &res, const ObDatum &arg1, + const ObDatum &arg2, ObEvalCtx &ctx) +{ + int ret = OB_SUCCESS; + UNUSED(arg1); + UNUSED(arg2); + + const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session(); + CK(OB_NOT_NULL(session)); + if (OB_SUCC(ret)) { + const ObString &user_name = session->get_proxy_user_name(); + ObString out_user_name; + ObExprStrResAlloc res_alloc(expr, ctx); + ObEvalCtx::TempAllocGuard alloc_guard(ctx); + ObIAllocator &calc_alloc = alloc_guard.get_allocator(); + OZ(ObExprUtil::convert_string_collation(user_name, ObCharset::get_system_collation(), + out_user_name, expr.datum_meta_.cs_type_, + calc_alloc)); + OZ(deep_copy_ob_string(res_alloc, out_user_name, out_user_name)); + OX(res.set_string(out_user_name)); + } + return ret; +} + +int ObExprSysContext::eval_proxy_user_id(const ObExpr &expr, ObDatum &res, + const ObDatum &arg1, const ObDatum &arg2, + ObEvalCtx &ctx) +{ + int ret = OB_SUCCESS; + UNUSED(arg1); + UNUSED(arg2); + + const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session(); + CK(OB_NOT_NULL(session)); + if (OB_SUCC(ret)) { + uint64_t id = session->get_proxy_user_id(); + char out_id[256]; + sprintf(out_id, "%lu", id); + ObString out_id_str(strlen(out_id), out_id); + ObExprStrResAlloc res_alloc(expr, ctx); + ObEvalCtx::TempAllocGuard alloc_guard(ctx); + ObIAllocator &calc_alloc = alloc_guard.get_allocator(); + OZ(ObExprUtil::convert_string_collation(out_id_str, ObCharset::get_system_collation(), + out_id_str, expr.datum_meta_.cs_type_, + calc_alloc)); + OZ(deep_copy_ob_string(res_alloc, out_id_str, out_id_str)); + OX(res.set_string(out_id_str)); + } + return ret; +} + +int ObExprSysContext::eval_auth_identity(const ObExpr &expr, ObDatum &res, const ObDatum &arg1, + const ObDatum &arg2, ObEvalCtx &ctx) +{ + int ret = OB_SUCCESS; + UNUSED(arg1); + UNUSED(arg2); + + const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session(); + CK(OB_NOT_NULL(session)); + if (OB_SUCC(ret)) { + const ObString user_name = session->get_user_name(); + ObString out_user_name; + ObExprStrResAlloc res_alloc(expr, ctx); + ObEvalCtx::TempAllocGuard alloc_guard(ctx); + ObIAllocator &calc_alloc = alloc_guard.get_allocator(); + OZ(ObExprUtil::convert_string_collation(user_name, ObCharset::get_system_collation(), + out_user_name, expr.datum_meta_.cs_type_, + calc_alloc)); + OZ(deep_copy_ob_string(res_alloc, out_user_name, out_user_name)); + OX(res.set_string(out_user_name)); + } + return ret; +} + } // namespace sql } // namespace oceanbase diff --git a/src/sql/engine/expr/ob_expr_sys_context.h b/src/sql/engine/expr/ob_expr_sys_context.h index 5525b1cf64..f0b69f2a9d 100644 --- a/src/sql/engine/expr/ob_expr_sys_context.h +++ b/src/sql/engine/expr/ob_expr_sys_context.h @@ -99,6 +99,15 @@ public: static int eval_application_context(const ObExpr &expr, common::ObDatum &res, const common::ObString &arg1, const common::ObString &arg2, ObEvalCtx &ctx); + static int eval_proxy_user(const ObExpr &expr, ObDatum &res, const ObDatum &arg1, + const ObDatum &arg2, ObEvalCtx &ctx); + + static int eval_proxy_user_id(const ObExpr &expr, ObDatum &res, + const ObDatum &arg1, const ObDatum &arg2, + ObEvalCtx &ctx); + + static int eval_auth_identity(const ObExpr &expr, ObDatum &res, const ObDatum &arg1, + const ObDatum &arg2, ObEvalCtx &ctx); typedef int (*eval_fun)(const ObExpr &expr, common::ObDatum &res, const common::ObDatum &arg1, const common::ObDatum &arg2, ObEvalCtx &ctx); diff --git a/src/sql/engine/expr/ob_expr_sys_privilege_check.cpp b/src/sql/engine/expr/ob_expr_sys_privilege_check.cpp index 89ba8c2e75..9a6b866fd3 100644 --- a/src/sql/engine/expr/ob_expr_sys_privilege_check.cpp +++ b/src/sql/engine/expr/ob_expr_sys_privilege_check.cpp @@ -74,13 +74,14 @@ int ObExprSysPrivilegeCheck::check_show_priv(bool &allow_show, if (OB_UNLIKELY(NULL == schema_guard)) { ret = OB_SCHEMA_ERROR; } - exec_ctx.get_my_session()->get_session_priv_info(session_priv); allow_show = true; if (OB_SUCC(ret)) { //tenant_id in table is static casted to int64_t, //and use statis_cast for retrieving(same with schema_service) // schema拆分后,普通租户schema表的tenant_id为0,此时鉴权取session_priv.tenant_id_ - if (session_priv.tenant_id_ != static_cast(tenant_id) + if (OB_FAIL(exec_ctx.get_my_session()->get_session_priv_info(session_priv))) { + LOG_WARN("fail to get session priv info", K(ret)); + } else if (session_priv.tenant_id_ != static_cast(tenant_id) && OB_INVALID_TENANT_ID != tenant_id) { //not current tenant's row } else if (0 == level_str.case_compare("db_acc")) { diff --git a/src/sql/engine/expr/ob_expr_trim.cpp b/src/sql/engine/expr/ob_expr_trim.cpp index 5d3154d042..537f2069cb 100644 --- a/src/sql/engine/expr/ob_expr_trim.cpp +++ b/src/sql/engine/expr/ob_expr_trim.cpp @@ -884,7 +884,7 @@ DEF_SET_LOCAL_SESSION_VARS(ObExprTrim, raw_expr) { int ret = OB_SUCCESS; if (lib::is_mysql_mode()) { SET_LOCAL_SYSVAR_CAPACITY(1); - EXPR_ADD_LOCAL_SYSVAR(SYS_VAR_COLLATION_CONNECTION); + EXPR_ADD_LOCAL_SYSVAR(share::SYS_VAR_COLLATION_CONNECTION); } return ret; } diff --git a/src/sql/engine/expr/ob_expr_util.cpp b/src/sql/engine/expr/ob_expr_util.cpp index 1872c5bf66..db1cddf2e3 100644 --- a/src/sql/engine/expr/ob_expr_util.cpp +++ b/src/sql/engine/expr/ob_expr_util.cpp @@ -949,3 +949,19 @@ int ObSolidifiedVarsGetter::get_max_allowed_packet(int64_t &max_size) } return ret; } + +int ObSolidifiedVarsGetter::get_compat_version(uint64_t &compat_version) +{ + int ret = OB_SUCCESS; + if (OB_ISNULL(session_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_FAIL(session_->get_compatibility_version(compat_version))) { + LOG_WARN("failed to get compat version", K(ret)); + } else if (NULL != local_session_var_ + && OB_FAIL(ObSQLUtils::merge_solidified_var_into_compat_version(local_session_var_->get_local_vars(), + compat_version))) { + LOG_WARN("try get local compat version failed", K(ret)); + } + return ret; +} diff --git a/src/sql/engine/expr/ob_expr_util.h b/src/sql/engine/expr/ob_expr_util.h index 296686001a..7656561c5f 100644 --- a/src/sql/engine/expr/ob_expr_util.h +++ b/src/sql/engine/expr/ob_expr_util.h @@ -277,6 +277,7 @@ public: int get_local_nls_timestamp_tz_format(ObString &format); int get_local_nls_format_by_type(const ObObjType type, ObString &format_str); int get_max_allowed_packet(int64_t &max_size); + int get_compat_version(uint64_t &compat_version); //get the specified solidified var int get_local_var(share::ObSysVarClassType var_type, share::schema::ObSessionSysVar *&sys_var); private: diff --git a/src/sql/executor/ob_cmd_executor.cpp b/src/sql/executor/ob_cmd_executor.cpp index 24a4951196..1581c31c0f 100644 --- a/src/sql/executor/ob_cmd_executor.cpp +++ b/src/sql/executor/ob_cmd_executor.cpp @@ -65,6 +65,7 @@ #include "sql/resolver/dcl/ob_create_role_stmt.h" #include "sql/resolver/dcl/ob_drop_role_stmt.h" #include "sql/resolver/dcl/ob_alter_user_profile_stmt.h" +#include "sql/resolver/dcl/ob_alter_user_proxy_stmt.h" #include "sql/resolver/dcl/ob_alter_user_primary_zone_stmt.h" #include "sql/resolver/tcl/ob_start_trans_stmt.h" #include "sql/resolver/tcl/ob_end_trans_stmt.h" @@ -79,6 +80,7 @@ #include "sql/resolver/cmd/ob_clear_balance_task_stmt.h" #include "sql/resolver/cmd/ob_call_procedure_stmt.h" #include "sql/resolver/cmd/ob_anonymous_block_stmt.h" +#include "sql/resolver/cmd/ob_mock_stmt.h" #include "sql/resolver/prepare/ob_prepare_stmt.h" #include "sql/resolver/prepare/ob_execute_stmt.h" #include "sql/resolver/prepare/ob_deallocate_stmt.h" @@ -136,6 +138,7 @@ #include "sql/engine/cmd/ob_profile_cmd_executor.h" #include "sql/engine/cmd/ob_get_diagnostics_executor.h" #include "sql/engine/cmd/ob_lock_table_executor.h" +#include "sql/engine/cmd/ob_mock_executor.h" #include "sql/engine/prepare/ob_prepare_executor.h" #include "sql/engine/prepare/ob_execute_executor.h" #include "sql/engine/prepare/ob_deallocate_executor.h" @@ -473,6 +476,10 @@ int ObCmdExecutor::execute(ObExecContext &ctx, ObICmd &cmd) DEFINE_EXECUTE_CMD(ObAlterUserProfileStmt, ObAlterUserProfileExecutor); break; } + case stmt::T_ALTER_USER_PROXY: { + DEFINE_EXECUTE_CMD(ObAlterUserProxyStmt, ObAlterUserProxyExecutor); + break; + } case stmt::T_ALTER_USER_PRIMARY_ZONE: { DEFINE_EXECUTE_CMD(ObAlterUserPrimaryZoneStmt, ObAlterUserPrimaryZoneExecutor); break; @@ -563,6 +570,10 @@ int ObCmdExecutor::execute(ObExecContext &ctx, ObICmd &cmd) DEFINE_EXECUTE_CMD(ObFlushDagWarningsStmt, ObFlushDagWarningsExecutor); break; } + case stmt::T_FLUSH_PRIVILEGES: { + DEFINE_EXECUTE_CMD(ObMockStmt, ObMockExecutor); + break; + } case stmt::T_SWITCH_REPLICA_ROLE: { DEFINE_EXECUTE_CMD(ObSwitchReplicaRoleStmt, ObSwitchReplicaRoleExecutor); break; diff --git a/src/sql/monitor/ob_exec_stat.h b/src/sql/monitor/ob_exec_stat.h index d2f37e5e70..da64ecab0e 100644 --- a/src/sql/monitor/ob_exec_stat.h +++ b/src/sql/monitor/ob_exec_stat.h @@ -363,6 +363,9 @@ struct ObAuditRecordData { int64_t user_id_; char *user_name_; int64_t user_name_len_; + int64_t proxy_user_id_; + char *proxy_user_name_; + int64_t proxy_user_name_len_; int user_group_; // user 所属 cgroup id,仅主线程展示 uint64_t db_id_; char *db_name_; diff --git a/src/sql/ob_result_set.cpp b/src/sql/ob_result_set.cpp index 1e77936774..82f2242bcd 100644 --- a/src/sql/ob_result_set.cpp +++ b/src/sql/ob_result_set.cpp @@ -1159,7 +1159,9 @@ int ObResultSet::from_plan(const ObPhysicalPlan &phy_plan, const ObIArrayget_orig_question_mark_cnt(); @@ -1592,11 +1594,15 @@ int ObResultSet::copy_field_columns(const ObPhysicalPlan &plan) } int ObResultSet::construct_field_name(const common::ObIArray &raw_params, - const bool is_first_parse) + const bool is_first_parse, + const ObSQLSessionInfo &session_info) { int ret = OB_SUCCESS; for (int64_t i = 0; OB_SUCC(ret) && i < field_columns_.count(); i++) { - if (OB_FAIL(construct_display_field_name(field_columns_.at(i), raw_params, is_first_parse))) { + if (OB_FAIL(construct_display_field_name(field_columns_.at(i), + raw_params, + is_first_parse, + session_info))) { LOG_WARN("failed to construct display name", K(ret), K(field_columns_.at(i))); } else { // do nothing @@ -1607,7 +1613,8 @@ int ObResultSet::construct_field_name(const common::ObIArray &raw_p int ObResultSet::construct_display_field_name(common::ObField &field, const ObIArray &raw_params, - const bool is_first_parse) + const bool is_first_parse, + const ObSQLSessionInfo &session_info) { int ret = OB_SUCCESS; char *buf = nullptr; @@ -1617,7 +1624,7 @@ int ObResultSet::construct_display_field_name(common::ObField &field, int32_t buf_len = MAX_COLUMN_CHAR_LENGTH * 2; int32_t pos = 0; int32_t name_pos = 0; - + bool enable_modify_null_name = false; if (!field.is_paramed_select_item_ || NULL == field.paramed_ctx_) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(field.is_paramed_select_item_), K(field.paramed_ctx_)); @@ -1625,6 +1632,9 @@ int ObResultSet::construct_display_field_name(common::ObField &field, // 1. 参数化的cname长度为0,说明指定了列名 // 2. 指定了别名,别名存在cname_里,直接使用即可 // do nothing + } else if (OB_FAIL(my_session_.check_feature_enable(ObCompatFeatureType::PROJECT_NULL, + enable_modify_null_name))) { + LOG_WARN("failed to check feature enable", K(ret)); } else if (OB_ISNULL(buf = static_cast(get_mem_pool().alloc(buf_len)))) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_WARN("failed to allocate memory", K(ret), K(buf_len)); @@ -1697,6 +1707,14 @@ int ObResultSet::construct_display_field_name(common::ObField &field, buf[pos++] = '\''; } } + } else if (lib::is_mysql_mode() && + 0 == field.paramed_ctx_->paramed_cname_.compare("?") && + 1 == PARAM_CTX->param_idxs_.count() && + T_NULL == raw_params.at(idx)->node_->type_ && + enable_modify_null_name) { + // MySQL sets the alias of standalone null value("\N","null"...) to "NULL" during projection. + copy_str_len = strlen("NULL"); + copy_str = "NULL"; } else { copy_str_len = raw_params.at(idx)->node_->text_len_; copy_str = raw_params.at(idx)->node_->raw_text_; diff --git a/src/sql/ob_result_set.h b/src/sql/ob_result_set.h index af4ad7a941..a1ddc4ccd6 100644 --- a/src/sql/ob_result_set.h +++ b/src/sql/ob_result_set.h @@ -298,11 +298,14 @@ public: // 往带?的field name填充参数信息 // 要注意的是,除了cname_以外,其余的string都是从计划里面浅拷出来的, // cname_的内存是由result_set的分配器分配出来的 - int construct_field_name(const common::ObIArray &raw_params, const bool is_first_parse); + int construct_field_name(const common::ObIArray &raw_params, + const bool is_first_parse, + const ObSQLSessionInfo &session_info); int construct_display_field_name(common::ObField &field, const ObIArray &raw_params, - const bool is_first_parse); + const bool is_first_parse, + const ObSQLSessionInfo &session_info); // 深拷计划中的field columns,存放在field_columns_成员中 int copy_field_columns(const ObPhysicalPlan &plan); diff --git a/src/sql/ob_sql.cpp b/src/sql/ob_sql.cpp index 97f8225b99..b59bf28b9b 100644 --- a/src/sql/ob_sql.cpp +++ b/src/sql/ob_sql.cpp @@ -2049,6 +2049,7 @@ int ObSql::clac_fixed_param_store(const stmt::StmtType stmt_type, const bool is_paramlize = false; int64_t server_collation = CS_TYPE_INVALID; bool enable_decimal_int = false; + ObCompatType compat_type = COMPAT_MYSQL57; if (raw_params.empty()) { // do nothing } else if (raw_params_idx.count() != raw_params.count()) { @@ -2057,6 +2058,8 @@ int ObSql::clac_fixed_param_store(const stmt::StmtType stmt_type, K(raw_params_idx.count()), K(raw_params.count())); } else if (OB_FAIL(fixed_param_store.reserve(raw_params_idx.count()))) { LOG_WARN("failed to reserve array", K(ret), K(raw_params_idx.count())); + } else if (OB_FAIL(session.get_compatibility_control(compat_type))) { + LOG_WARN("failed to get compat type", K(ret)); } else if (lib::is_oracle_mode() && OB_FAIL( session.get_sys_variable(share::SYS_VAR_COLLATION_SERVER, server_collation))) { LOG_WARN("get sys variable failed", K(ret)); @@ -2073,18 +2076,19 @@ int ObSql::clac_fixed_param_store(const stmt::StmtType stmt_type, ret = OB_ERR_UNEXPECTED; LOG_WARN("node is null", K(ret)); } else if (OB_FAIL(ObResolverUtils::resolve_const(raw_param, - stmt_type, - allocator, - collation_connection, - session.get_nls_collation_nation(), - session.get_timezone_info(), - value, - is_paramlize, - literal_prefix, - session.get_actual_nls_length_semantics(), - static_cast(server_collation), - NULL, session.get_sql_mode(), - enable_decimal_int))) { + stmt_type, + allocator, + collation_connection, + session.get_nls_collation_nation(), + session.get_timezone_info(), + value, + is_paramlize, + literal_prefix, + session.get_actual_nls_length_semantics(), + static_cast(server_collation), + NULL, session.get_sql_mode(), + enable_decimal_int, + compat_type))) { SQL_PC_LOG(WARN, "fail to resolve const", K(ret)); } else if (OB_FAIL(add_param_to_param_store(value, fixed_param_store))) { LOG_WARN("failed to add param to param store", K(ret), K(value), K(fixed_param_store)); @@ -2884,6 +2888,9 @@ int ObSql::generate_stmt(ParseResult &parse_result, result.get_exec_context().get_stmt_factory()->get_query_ctx())) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_ERROR("allocate query context failed", K(ret)); + } else if (OB_FAIL(resolver_ctx.session_info_->get_optimizer_features_enable_version( + resolver_ctx.query_ctx_->optimizer_features_enable_version_))) { + LOG_WARN("failed to get_optimizer_features_enable_version", K(ret)); } else { resolver_ctx.query_ctx_->sql_schema_guard_.set_schema_guard(context.schema_guard_); if (OB_FAIL(resolver_ctx.schema_checker_->init(resolver_ctx.query_ctx_->sql_schema_guard_, session_id))) { diff --git a/src/sql/ob_sql_utils.cpp b/src/sql/ob_sql_utils.cpp index 5ab03ae6f6..0df546e583 100644 --- a/src/sql/ob_sql_utils.cpp +++ b/src/sql/ob_sql_utils.cpp @@ -1422,6 +1422,54 @@ int ObSQLUtils::check_ident_name(const ObCollationType cs_type, ObString &name, return ret; } +int ObSQLUtils::get_proxy_can_activate_role(const ObIArray &role_id_array, + const ObIArray &role_id_option_array, + const ObProxyInfo &proxied_info, + ObIArray &new_role_id_array, + ObIArray &new_role_id_option_array) +{ + int ret = OB_SUCCESS; + if (OB_UNLIKELY(role_id_array.count() != role_id_option_array.count())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (proxied_info.proxy_flags_ == PROXY_USER_NO_ROLES_BE_ACTIVATED) { + new_role_id_array.reuse(); + new_role_id_option_array.reuse(); + } else if (proxied_info.proxy_flags_ == PROXY_USER_ACTIVATE_ALL_ROLES) { + OZ (new_role_id_array.assign(role_id_array)); + OZ (new_role_id_option_array.assign(role_id_option_array)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < role_id_array.count(); i++) { + bool found = false; + for (int j = 0; OB_SUCC(ret) && !found && j < proxied_info.role_id_cnt_; j++) { + uint64_t role_id = proxied_info.get_role_id_by_idx(j); + if (role_id == OB_INVALID_ID) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (role_id_array.at(i) == role_id) { + found = true; + } + } + if (OB_FAIL(ret)) { + } else if (proxied_info.proxy_flags_ == PROXY_USER_MAY_ACTIVATE_ROLE) { + if (found) { + OZ (new_role_id_array.push_back(role_id_array.at(i))); + OZ (new_role_id_option_array.push_back(role_id_option_array.at(i))); + } + } else if (proxied_info.proxy_flags_ == PROXY_USER_ROLE_CAN_NOT_BE_ACTIVATED) { + if (!found) { + OZ (new_role_id_array.push_back(role_id_array.at(i))); + OZ (new_role_id_option_array.push_back(role_id_option_array.at(i))); + } + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } + } + } + return ret; +} + bool ObSQLUtils::check_mysql50_prefix(ObString &db_name) { bool ret = false; @@ -1596,6 +1644,7 @@ bool ObSQLUtils::is_readonly_stmt(ParseResult &result) || T_SET_NAMES == type //read only not restrict it || T_SET_CHARSET == type //read only not restrict it || T_SHOW_RECYCLEBIN == type + || T_SHOW_PROFILE == type || T_SHOW_TENANT == type || T_SHOW_RESTORE_PREVIEW == type || T_SHOW_SEQUENCES == type @@ -3364,6 +3413,26 @@ int ObSQLUtils::merge_solidified_var_into_max_allowed_packet(const share::schema return ret; } +int ObSQLUtils::merge_solidified_var_into_compat_version(const share::schema::ObLocalSessionVar *local_vars, + uint64_t &compat_version) +{ + int ret = OB_SUCCESS; + ObSessionSysVar *local_var = NULL; + if (NULL == local_vars) { + //do nothing + } else if (OB_FAIL(local_vars->get_local_var(SYS_VAR_OB_COMPATIBILITY_VERSION, local_var))) { + LOG_WARN("get local session var failed", K(ret)); + } else if (NULL != local_var) { + if (ObUInt64Type == local_var->val_.get_type()) { + compat_version = local_var->val_.get_uint64(); + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("invalid compat version val type", K(ret), K(local_var->val_)); + } + } + return ret; +} + void ObSQLUtils::init_type_ctx(const ObSQLSessionInfo *session, ObExprTypeCtx &type_ctx) { if (NULL != session) { @@ -5820,3 +5889,8 @@ bool ObSQLUtils::is_data_version_ge_423_or_431(uint64_t data_version) { return ((MOCK_DATA_VERSION_4_2_3_0 <= data_version && data_version < DATA_VERSION_4_3_0_0) || data_version >= DATA_VERSION_4_3_1_0); } + +bool ObSQLUtils::is_data_version_ge_423_or_432(uint64_t data_version) +{ + return ((MOCK_DATA_VERSION_4_2_3_0 <= data_version && data_version < DATA_VERSION_4_3_0_0) || data_version >= DATA_VERSION_4_3_2_0); +} \ No newline at end of file diff --git a/src/sql/ob_sql_utils.h b/src/sql/ob_sql_utils.h index bf5be4f926..a26f39a021 100644 --- a/src/sql/ob_sql_utils.h +++ b/src/sql/ob_sql_utils.h @@ -30,6 +30,7 @@ #include "sql/optimizer/ob_phy_table_location_info.h" #include "sql/engine/expr/ob_expr_frame_info.h" #include "sql/monitor/flt/ob_flt_span_mgr.h" +#include "share/ob_compatibility_control.h" namespace oceanbase { namespace share { @@ -529,6 +530,8 @@ public: ObCollationType &cs_type); static int merge_solidified_var_into_max_allowed_packet(const share::schema::ObLocalSessionVar *local_vars, int64_t &max_allowed_packet); + static int merge_solidified_var_into_compat_version(const share::schema::ObLocalSessionVar *local_vars, + uint64_t &compat_version); static bool is_oracle_sys_view(const ObString &table_name); @@ -710,6 +713,13 @@ public: static int compatibility_check_for_mysql_role_and_column_priv(uint64_t tenant_id); static bool is_data_version_ge_422_or_431(uint64_t data_version); static bool is_data_version_ge_423_or_431(uint64_t data_version); + static bool is_data_version_ge_423_or_432(uint64_t data_version); + + static int get_proxy_can_activate_role(const ObIArray &role_id_array, + const ObIArray &role_id_option_array, + const ObProxyInfo &proxied_info, + ObIArray &new_role_id_array, + ObIArray &new_role_id_option_array); private: static bool check_mysql50_prefix(common::ObString &db_name); static bool part_expr_has_virtual_column(const ObExpr *part_expr); diff --git a/src/sql/optimizer/ob_log_for_update.cpp b/src/sql/optimizer/ob_log_for_update.cpp index c5987d6771..c97035ad78 100644 --- a/src/sql/optimizer/ob_log_for_update.cpp +++ b/src/sql/optimizer/ob_log_for_update.cpp @@ -63,11 +63,51 @@ int ObLogForUpdate::get_plan_item_info(PlanText &plan_text, OB_ISNULL(table = stmt->get_table_item_by_id(index_dml_info_.at(i)->table_id_))) { ret = OB_ERR_UNEXPECTED; LOG_WARN("index dml info is null", K(ret), K(index_dml_info_.at(i)), K(table)); - } else if (OB_FAIL(BUF_PRINTF("%c%.*s%c", - i == 0 ? '(' : ' ', - table->get_table_name().length(), - table->get_table_name().ptr(), - i == index_dml_info_.count() - 1 ? ')' : ','))) { + } else if (table->is_generated_table()) { + // For hierarchical query, we only lock table in right view which is mocked by transform preprocess, + // the name of right view is meaningless, hence we only print the base table name here. + if (OB_ISNULL(table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("ref query is NULL", K(ret)); + } else if (stmt->is_hierarchical_query()) { + if (OB_ISNULL(table = table->ref_query_->get_table_item_by_id(index_dml_info_.at(i)->loc_table_id_))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table item is NULL", K(ret)); + } + } else if (table->ref_query_->is_hierarchical_query()) { + // for split hierarchical query + TableItem *base_table = NULL; + for (int j = 0; OB_SUCC(ret) && j < table->ref_query_->get_table_size(); ++j) { + TableItem *mocked_join_table = table->ref_query_->get_table_item(j); + if(OB_ISNULL(mocked_join_table) + || OB_UNLIKELY(!mocked_join_table->is_generated_table()) + || OB_ISNULL(mocked_join_table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected mocked join table", K(ret), KPC(mocked_join_table)); + } else { + base_table = mocked_join_table->ref_query_->get_table_item_by_id(index_dml_info_.at(i)->loc_table_id_); + if (base_table != NULL) { + break; + } + } + } + if (OB_FAIL(ret)) { + } else if (OB_ISNULL(base_table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("base table is not find", K(ret)); + } else { + table = base_table; + } + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("not a hierarchical query", K(ret), KPC(stmt)); + } + } + if (OB_SUCC(ret) && OB_FAIL(BUF_PRINTF("%c%.*s%c", + i == 0 ? '(' : ' ', + table->get_table_name().length(), + table->get_table_name().ptr(), + i == index_dml_info_.count() - 1 ? ')' : ','))) { LOG_WARN("failed to print lock table name", K(ret)); } } @@ -158,17 +198,14 @@ int ObLogForUpdate::generate_multi_part_partition_id_expr() LOG_WARN("get unexpected null", K(get_stmt()), K(ret)); } for (int64_t i = 0; OB_SUCC(ret) && i < index_dml_info_.count(); ++i) { - const TableItem *table_item = NULL; ObRawExpr *part_expr = NULL; - if (OB_ISNULL(index_dml_info_.at(i)) || - OB_ISNULL(table_item = get_stmt()->get_table_item_by_id( - index_dml_info_.at(i)->table_id_))) { + if (OB_ISNULL(index_dml_info_.at(i))) { ret = OB_ERR_UNEXPECTED; - LOG_WARN("get unexpected null", K(ret), K(index_dml_info_.at(i)), K(table_item)); - } else if (OB_FAIL(get_plan()->gen_calc_part_id_expr(table_item->table_id_, - table_item->ref_id_, - CALC_PARTITION_TABLET_ID, - part_expr))) { + LOG_WARN("get unexpected null", K(ret)); + } else if (OB_FAIL(get_plan()->gen_calc_part_id_expr(index_dml_info_.at(i)->loc_table_id_, + index_dml_info_.at(i)->ref_table_id_, + CALC_PARTITION_TABLET_ID, + part_expr))) { LOG_WARN("failed to gen calc part id expr", K(ret)); } else if (OB_ISNULL(part_expr)) { ret = OB_ERR_UNEXPECTED; diff --git a/src/sql/optimizer/ob_log_plan.cpp b/src/sql/optimizer/ob_log_plan.cpp index 6a216801a4..3d2d146b36 100644 --- a/src/sql/optimizer/ob_log_plan.cpp +++ b/src/sql/optimizer/ob_log_plan.cpp @@ -11843,6 +11843,10 @@ int ObLogPlan::allocate_for_update_as_top(ObLogicalOperator *&top, ObIArray &sfu_table_list) { int ret = OB_SUCCESS; + if (OB_ISNULL(get_stmt())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected null", K(ret)); + } for (int64_t i = 0; OB_SUCC(ret) && i < sfu_table_list.count(); ++i) { ObSEArray need_alloc_list; if (table_is_allocated_for_update(sfu_table_list.at(i))) { @@ -11861,11 +11865,21 @@ int ObLogPlan::allocate_for_update_as_top(ObLogicalOperator *&top, ObSEArray index_dml_infos; for (int64_t j = 0; OB_SUCC(ret) && j < need_alloc_list.count(); ++j) { IndexDMLInfo *index_dml_info = NULL; - if (OB_FAIL(get_table_for_update_info(need_alloc_list.at(j), - index_dml_info, - wait_ts, - skip_locked))) { - LOG_WARN("failed to get for update info", K(ret)); + bool is_hierarchical = false; + if (OB_FAIL(is_hierarchical_for_update(is_hierarchical))) { + LOG_WARN("failed to check hierarchical query", K(ret)); + } else if (is_hierarchical) { + if (OB_FAIL(get_table_for_update_info_for_hierarchical(need_alloc_list.at(j), + index_dml_infos, + wait_ts, + skip_locked))) { + LOG_WARN("failed to get table for update info for hierarchical", K(ret), KPC(get_stmt())); + } + } else if (OB_FAIL(get_table_for_update_info(need_alloc_list.at(j), + index_dml_info, + wait_ts, + skip_locked))) { + LOG_WARN("failed to get for update info", K(ret), KPC(get_stmt())); } else if (OB_ISNULL(index_dml_info)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("get unexpected null", K(ret), K(index_dml_info)); @@ -11904,6 +11918,37 @@ int ObLogPlan::allocate_for_update_as_top(ObLogicalOperator *&top, return ret; } +int ObLogPlan::is_hierarchical_for_update(bool &is_hierarchical) +{ + int ret = OB_SUCCESS; + is_hierarchical = false; + const TableItem *table = NULL; + const ObSelectStmt *ref_view = NULL; + if (OB_ISNULL(get_stmt())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("stmt is NULL", K(ret)); + } else if (get_stmt()->is_hierarchical_query()) { + is_hierarchical = true; + } else if (get_stmt()->get_table_size() != 1) { + is_hierarchical = false; + } else if (OB_ISNULL(table = get_stmt()->get_table_item(0))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table item is NULL", K(ret)); + } else if (!table->for_update_ || !table->is_generated_table()) { + is_hierarchical = false; + } else if (OB_UNLIKELY(static_cast(get_stmt())->get_for_update_dml_infos().count() == 0)) { + // For "select * from (select c1 from t1 connect by xxx) view1 where xxx for update;" + ret = OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT; + LOG_WARN("for update dml info is null", K(ret), KPC(static_cast(get_stmt()))); + } else if (OB_ISNULL(ref_view = table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("ref query is NULL", K(ret)); + } else if (ref_view->is_hierarchical_query()) { + is_hierarchical = true; + } + return ret; +} + int ObLogPlan::merge_same_sfu_table_list(uint64_t target_id, int64_t begin_idx, ObIArray &src_table_list, @@ -12045,6 +12090,148 @@ int ObLogPlan::get_table_for_update_info(const uint64_t table_id, return ret; } +int ObLogPlan::get_table_for_update_info_for_hierarchical(const uint64_t table_id, + ObIArray &index_dml_infos, + int64_t &wait_ts, + bool &skip_locked) +{ + int ret = OB_SUCCESS; + const ObSelectStmt *select_stmt = NULL; + const TableItem *table = NULL; + skip_locked = false; + wait_ts = 0; + if (OB_ISNULL(get_stmt()) || + OB_ISNULL(table = get_stmt()->get_table_item_by_id(table_id)) || + OB_UNLIKELY(!table->for_update_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected error", K(ret), K(get_stmt()), KPC(table)); + } else if (OB_UNLIKELY(!get_stmt()->is_select_stmt())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("stmt is not a select stmt", K(ret), KPC(get_stmt())); + } else if (OB_FALSE_IT(select_stmt = static_cast(get_stmt()))) { + } else if (table->is_generated_table()) { + for (int64_t i = 0; OB_SUCC(ret) && i < select_stmt->get_for_update_dml_infos().count(); ++i) { + const ForUpdateDMLInfo *for_update_info = NULL; + IndexDMLInfo *index_dml_info = NULL; + const TableItem *base_table = NULL; + if (OB_ISNULL(for_update_info = select_stmt->get_for_update_dml_infos().at(i))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("for update info is null", K(ret), KPC(select_stmt)); + } else if (table_id != for_update_info->table_id_) { + // do nothing + } else if (OB_ISNULL(index_dml_info = static_cast( + get_optimizer_context().get_allocator().alloc(sizeof(IndexDMLInfo))))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("failed to allocate memory for index dml info", K(ret)); + } else if (OB_ISNULL(table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("ref query is null", K(ret), KPC(table)); + } else if (OB_FAIL(check_hierarchical_for_update(table, for_update_info->base_table_id_))) { + LOG_WARN("failed to check hierarchical for update", K(ret), KPC(for_update_info)); + } else { + index_dml_info = new (index_dml_info) IndexDMLInfo(); + index_dml_info->table_id_ = for_update_info->table_id_; + index_dml_info->loc_table_id_ = for_update_info->base_table_id_; + index_dml_info->ref_table_id_ = for_update_info->ref_table_id_; + index_dml_info->distinct_algo_ = T_DISTINCT_NONE; + index_dml_info->rowkey_cnt_ = for_update_info->rowkey_cnt_; + index_dml_info->need_filter_null_ = for_update_info->is_nullable_; + index_dml_info->is_primary_index_ = true; + skip_locked = for_update_info->skip_locked_; + wait_ts = for_update_info->for_update_wait_us_; + for (int64_t j = 0; OB_SUCC(ret) && j < for_update_info->unique_column_ids_.count(); ++j) { + ObColumnRefRawExpr *col_expr = select_stmt->get_column_expr_by_id(for_update_info->table_id_, + for_update_info->unique_column_ids_.at(j)); + if (OB_ISNULL(col_expr)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("column expr is null", K(ret)); + } else if (OB_FAIL(index_dml_info->column_exprs_.push_back(col_expr))) { + LOG_WARN("failed to push back column expr", K(ret)); + } else { + col_expr->set_explicited_reference(); + } + } + + if (OB_FAIL(ret)){ + // do nothing + } else if (OB_SUCC(ret) && OB_FAIL(index_dml_infos.push_back(index_dml_info))) { + LOG_WARN("failed to push back", K(ret)); + } else { + LOG_TRACE("Succeed to get table for update info for hierarchical", K(table_id), K(for_update_info), + KPC(index_dml_info), K(wait_ts), K(skip_locked)); + } + } + } + } else if (table->is_basic_table()) { + IndexDMLInfo *index_dml_info = NULL; + if (OB_FAIL(get_table_for_update_info(table_id, + index_dml_info, + wait_ts, + skip_locked))) { + LOG_WARN("failed to get for update info", K(ret)); + } else if (OB_ISNULL(index_dml_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected null", K(ret), K(index_dml_info)); + } else if (OB_FAIL(index_dml_infos.push_back(index_dml_info))) { + LOG_WARN("failed to push back", K(ret)); + } + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected table table type", K(ret), KPC(table)); + } + return ret; +} + +int ObLogPlan::check_hierarchical_for_update(const TableItem *table, + uint64_t base_tid) +{ + int ret = OB_SUCCESS; + TableItem *base_table = NULL; + if (OB_ISNULL(get_stmt()) || OB_ISNULL(table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected null", K(ret), K(get_stmt()), K(table)); + } else if (OB_UNLIKELY(!table->is_generated_table())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table is not a generated table", K(ret), KPC(table)); + } else if (OB_ISNULL(table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("ref query is NULL", K(ret)); + } else if (get_stmt()->is_hierarchical_query()) { + base_table = table->ref_query_->get_table_item_by_id(base_tid); + } else if (table->ref_query_->is_hierarchical_query()) { + for (int i = 0; OB_SUCC(ret) && i < table->ref_query_->get_table_size(); ++i) { + TableItem *mocked_join_table = table->ref_query_->get_table_item(i); + if(OB_ISNULL(mocked_join_table) + || OB_UNLIKELY(!mocked_join_table->is_generated_table()) + || OB_ISNULL(mocked_join_table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected mocked join table", K(ret), KPC(mocked_join_table)); + } else { + base_table = mocked_join_table->ref_query_->get_table_item_by_id(base_tid); + if (base_table != NULL) { + break; + } + } + } + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("not a hierarchical query", K(ret), KPC(get_stmt())); + } + // check base table + if (OB_FAIL(ret)) { + } else if (OB_ISNULL(base_table)) { + // base table is not in hierarchical query mocked view, maybe in the + // inner generated table which not be merged. + ret = OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT; + LOG_WARN("base table is not in hierarchical query mocked view", K(ret), KPC(table->ref_query_), K(base_tid)); + } else if (OB_UNLIKELY(!base_table->is_basic_table() || is_virtual_table(base_table->ref_id_))) { + // invalid usage + ret = OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT; + LOG_WARN("base table is not basic table", K(ret), KPC(base_table)); + } + return ret; +} + int ObLogPlan::create_for_update_plan(ObLogicalOperator *&top, const ObIArray &index_dml_infos, int64_t wait_ts, diff --git a/src/sql/optimizer/ob_log_plan.h b/src/sql/optimizer/ob_log_plan.h index cb882c0406..74f9606f7b 100644 --- a/src/sql/optimizer/ob_log_plan.h +++ b/src/sql/optimizer/ob_log_plan.h @@ -1311,6 +1311,12 @@ public: IndexDMLInfo *&index_dml_info, int64_t &wait_ts, bool &skip_locked); + int get_table_for_update_info_for_hierarchical(const uint64_t table_id, + ObIArray &index_dml_infos, + int64_t &wait_ts, + bool &skip_locked); + int is_hierarchical_for_update(bool &is_hierarchical); + int check_hierarchical_for_update(const TableItem *table, uint64_t base_tid); int get_part_column_exprs(const uint64_t table_id, const uint64_t ref_table_id, diff --git a/src/sql/parser/ob_fast_parser.cpp b/src/sql/parser/ob_fast_parser.cpp index 8c44108a0d..78cee15f82 100644 --- a/src/sql/parser/ob_fast_parser.cpp +++ b/src/sql/parser/ob_fast_parser.cpp @@ -2518,6 +2518,20 @@ int ObFastParserMysql::process_identifier_begin_with_n() return ret; } +int ObFastParserMysql::process_identifier_begin_with_backslash() +{ + int ret = OB_SUCCESS; + if (raw_sql_.char_at(raw_sql_.cur_pos_) == 'N') { + raw_sql_.scan(1); + if (-1 == is_identifier_flags(raw_sql_.cur_pos_)) { + cur_token_type_ = PARAM_TOKEN; + OZ (add_null_type_node()); + } + } else { + } + return ret; +} + int ObFastParserMysql::process_values(const char *str) { int ret = OB_SUCCESS; @@ -2647,6 +2661,10 @@ int ObFastParserMysql::process_identifier(bool is_number_begin) } break; } + case '\\': { + OZ (process_identifier_begin_with_backslash()); + break; + } default: { break; } @@ -2805,6 +2823,11 @@ int ObFastParserMysql::parse_next_token() if (OB_LIKELY(process_idf_func_ != nullptr)) { OZ ((this->*process_idf_func_)(false)); } + } else if (is_mysql_mode() && raw_sql_.char_at(raw_sql_.cur_pos_) == '\\') { + raw_sql_.cur_pos_ += 1; + if (OB_LIKELY(process_idf_func_ != nullptr)) { + OZ ((this->*process_idf_func_)(false)); + } } else if (is_normal_char(ch)) { cur_token_type_ = NORMAL_TOKEN; raw_sql_.scan(); diff --git a/src/sql/parser/ob_fast_parser.h b/src/sql/parser/ob_fast_parser.h index 13244984b4..e611aea479 100644 --- a/src/sql/parser/ob_fast_parser.h +++ b/src/sql/parser/ob_fast_parser.h @@ -686,6 +686,7 @@ private: int process_string(const char quote); int process_zero_identifier(); int process_identifier_begin_with_n(); + int process_identifier_begin_with_backslash(); private: ObSEArray values_tokens_; DISALLOW_COPY_AND_ASSIGN(ObFastParserMysql); diff --git a/src/sql/parser/sql_parser_mysql_mode.l b/src/sql/parser/sql_parser_mysql_mode.l index 00962e184d..22cd79fb48 100644 --- a/src/sql/parser/sql_parser_mysql_mode.l +++ b/src/sql/parser/sql_parser_mysql_mode.l @@ -147,6 +147,21 @@ NULL { } } +\\N { + check_value(yylval); + ParseResult *p = (ParseResult *)yyextra; + malloc_new_node(yylval->node, p->malloc_pool_, T_NULL, 0); + COPY_STRING(p->input_sql_ + yylloc->first_column - 1, yyleng, yylval->node->raw_text_); + yylval->node->text_len_ = yyleng; + yylval->node->value_ = 1; + if (IS_FAST_PARAMETERIZE) { + STORE_PARAM_NODE(); + } else { + yylval->node->sql_str_off_ = yylloc->first_column - 1; + return NULLX; + } +} + {int_num} { int32_t token_ret = INTNUM; ParseNode *node = NULL; diff --git a/src/sql/parser/sql_parser_mysql_mode.y b/src/sql/parser/sql_parser_mysql_mode.y index 2688a41584..b3f46ed0b9 100644 --- a/src/sql/parser/sql_parser_mysql_mode.y +++ b/src/sql/parser/sql_parser_mysql_mode.y @@ -131,7 +131,8 @@ extern void obsql_oracle_parse_fatal_error(int32_t errcode, yyscan_t yyscanner, %nonassoc LOWER_PARENS //%nonassoc STRING_VALUE %left '(' ')' -%nonassoc SQL_CACHE SQL_NO_CACHE CHARSET DATABASE_ID REPLICA_NUM/*for shift/reduce conflict between opt_query_expresion_option_list and SQL_CACHE*/ +%nonassoc SQL_CACHE SQL_NO_CACHE HIGH_PRIORITY SQL_SMALL_RESULT SQL_BIG_RESULT SQL_BUFFER_RESULT CHARSET DATABASE_ID REPLICA_NUM/*for shift/reduce conflict between opt_query_expresion_option_list and SQL_CACHE*/ +%nonassoc LOW_PRIORITY QUICK %nonassoc HIGHER_PARENS TRANSACTION SIZE AUTO SKEWONLY DEFAULT AS/*for simple_expr conflict*/ %nonassoc TENANT /*for opt_tenant conflict*/ %left '.' @@ -454,7 +455,8 @@ END_P SET_VAR DELIMITER %type opt_limit opt_for_grant_user opt_using_role %type parameterized_trim %type opt_with_consistent_snapshot opt_config_scope opt_index_keyname opt_full opt_mode_flag opt_extended opt_extended_or_full -%type opt_work begin_stmt commit_stmt rollback_stmt opt_ignore xa_begin_stmt xa_end_stmt xa_prepare_stmt xa_commit_stmt xa_rollback_stmt +%type opt_priority opt_low_priority delete_option delete_option_list opt_delete_option_list +%type opt_work begin_stmt commit_stmt rollback_stmt opt_ignore opt_ignore_or_replace ignore_or_replace xa_begin_stmt xa_end_stmt xa_prepare_stmt xa_commit_stmt xa_rollback_stmt %type alter_table_stmt alter_table_actions alter_table_action_list alter_table_action alter_column_option alter_index_option alter_constraint_option standalone_alter_action alter_partition_option opt_to alter_tablegroup_option opt_table opt_tablegroup_option_list alter_tg_partition_option alter_column_group_option %type tablegroup_option_list tablegroup_option alter_tablegroup_actions alter_tablegroup_action tablegroup_option_list_space_seperated %type opt_tg_partition_option tg_hash_partition_option tg_key_partition_option tg_range_partition_option tg_subpartition_option tg_list_partition_option @@ -507,7 +509,7 @@ END_P SET_VAR DELIMITER %type ret_type opt_agg %type opt_match_option %type match_action -%type opt_reference_option_list reference_option require_specification tls_option_list tls_option +%type opt_column_reference opt_reference_option_list reference_option require_specification tls_option_list tls_option %type opt_resource_option resource_option_list resource_option %type reference_action %type alter_foreign_key_action @@ -542,6 +544,7 @@ END_P SET_VAR DELIMITER %type create_tenant_snapshot_stmt snapshot_name drop_tenant_snapshot_stmt clone_tenant_stmt clone_snapshot_option clone_tenant_option clone_tenant_option_list %type transfer_partition_stmt transfer_partition_clause part_info cancel_transfer_partition_clause %type geometry_collection +%type mock_stmt %type ttl_definition ttl_expr ttl_unit %type id_dot_id id_dot_id_dot_id %start sql_stmt @@ -717,6 +720,7 @@ stmt: | drop_tenant_snapshot_stmt { $$ = $1; check_question_mark($$, result); } | clone_tenant_stmt { $$ = $1; check_question_mark($$, result); } | transfer_partition_stmt { $$ = $1; check_question_mark($$, result); } + | mock_stmt {$$ = $1; check_question_mark($$, result);} ; /***************************************************************************** @@ -3676,32 +3680,34 @@ delete_basic_stmt ; delete_basic_stmt: -delete_with_opt_hint FROM tbl_name opt_where opt_order_by opt_limit_clause +delete_with_opt_hint opt_delete_option_list FROM tbl_name opt_where opt_order_by opt_limit_clause { + (void)($2); ParseNode *from_list = NULL; ParseNode *delete_table_node = NULL; - merge_nodes(from_list, result, T_TABLE_REFERENCES, $3); + merge_nodes(from_list, result, T_TABLE_REFERENCES, $4); malloc_non_terminal_node(delete_table_node, result->malloc_pool_, T_DELETE_TABLE_NODE, 2, NULL, /*0. delete list*/ from_list); /*1. from list*/ malloc_non_terminal_node($$, result->malloc_pool_, T_DELETE, 9, NULL, /* 0. with clause*/ delete_table_node, /* 1. table_node */ - $4, /* 2. where */ - $5, /* 3. order by */ - $6, /* 4. limit */ + $5, /* 2. where */ + $6, /* 3. order by */ + $7, /* 4. limit */ NULL, /* 5. when */ $1, /* 6. hint */ NULL, /* 7. returning, unused in mysql */ NULL); /* 8. error logging, unused in mysql */ } -| delete_with_opt_hint multi_delete_table opt_where +| delete_with_opt_hint opt_delete_option_list multi_delete_table opt_where { + (void)($2); malloc_non_terminal_node($$, result->malloc_pool_, T_DELETE, 9, NULL, /* 0. with clause */ - $2, /* 1. table_node */ - $3, /* 2. where */ + $3, /* 1. table_node */ + $4, /* 2. where */ NULL, /* 3. order by */ NULL, /* 4. limit */ NULL, /* 5. when */ @@ -3711,6 +3717,42 @@ delete_with_opt_hint FROM tbl_name opt_where opt_order_by opt_limit_clause } ; +opt_delete_option_list: +delete_option_list %prec LOWER_PARENS +{ + $$ = $1; +} +| /*EMPTY*/ %prec LOWER_PARENS +{ + $$ = NULL; +} +; + +delete_option_list: +delete_option +{ + $$ = $1; +} +| delete_option_list delete_option +{ + (void)($1); + $$ = $2; +} +; + +delete_option: +QUICK +{ + // we only support it in parser, but actually do nothing. + $$ = NULL; +} +| LOW_PRIORITY +{ + // we only support it in parser, but actually do nothing. + $$ = NULL; +} +; + multi_delete_table: relation_with_star_list FROM table_references { @@ -3753,23 +3795,24 @@ update_basic_stmt ; update_basic_stmt: -update_with_opt_hint opt_ignore table_references SET update_asgn_list opt_where opt_order_by opt_limit_clause +update_with_opt_hint opt_low_priority opt_ignore table_references SET update_asgn_list opt_where opt_order_by opt_limit_clause { + (void)($2); ParseNode *from_list = NULL; ParseNode *assign_list = NULL; - merge_nodes(from_list, result, T_TABLE_REFERENCES, $3); - merge_nodes(assign_list, result, T_ASSIGN_LIST, $5); + merge_nodes(from_list, result, T_TABLE_REFERENCES, $4); + merge_nodes(assign_list, result, T_ASSIGN_LIST, $6); malloc_non_terminal_node($$, result->malloc_pool_, T_UPDATE, 11, NULL, /* 0. with clause*/ from_list, /* 1. table node */ assign_list, /* 2. update list */ - $6, /* 3. where node */ - $7, /* 4. order by node */ - $8, /* 5. limit node */ + $7, /* 3. where node */ + $8, /* 4. order by node */ + $9, /* 5. limit node */ NULL, /* 7. when node */ $1, /* 8. hint node */ - $2, /* 9. ignore */ + $3, /* 9. ignore */ NULL, /* 10. returning, unused in mysql */ NULL); /* 11. error logging caluse */ } @@ -4878,14 +4921,14 @@ opt_table_option_list opt_partition_option with_column_group $$->reserved_ = 0; } | create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor '(' table_element_list ')' - opt_table_option_list opt_partition_option select_stmt + opt_table_option_list opt_partition_option opt_ignore_or_replace opt_as select_stmt { - (void)($10); + (void)($12); ParseNode *table_elements = NULL; ParseNode *table_options = NULL; merge_nodes(table_elements, result, T_TABLE_ELEMENT_LIST, $7); merge_nodes(table_options, result, T_TABLE_OPTION_LIST, $9); - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -4894,40 +4937,20 @@ opt_table_option_list opt_partition_option with_column_group $10, /* partition optition */ NULL, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ - $11, /* select_stmt */ - $1); /* hints */ - $$->reserved_ = 0; -} -| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor '(' table_element_list ')' - opt_table_option_list opt_partition_option AS select_stmt -{ - (void)$11; - ParseNode *table_elements = NULL; - ParseNode *table_options = NULL; - merge_nodes(table_elements, result, T_TABLE_ELEMENT_LIST, $7); - merge_nodes(table_options, result, T_TABLE_OPTION_LIST, $9); - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, - $2, /* temporary option */ - $4, /* if not exists */ - $5, /* table name */ - table_elements, /* columns or primary key */ - table_options, /* table option(s) */ - $10, /* partition optition */ - NULL, /* column group */ - NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ - $12, /* select_stmt */ - $1); /* hints */ + $13, /* select_stmt */ + $1, /* hints */ + $11); /* opt_ignore_or_replace */ $$->reserved_ = 0; } | create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor '(' table_element_list ')' opt_table_option_list opt_partition_option with_column_group opt_as select_stmt { - (void)$12; + (void)($12); ParseNode *table_elements = NULL; ParseNode *table_options = NULL; merge_nodes(table_elements, result, T_TABLE_ELEMENT_LIST, $7); merge_nodes(table_options, result, T_TABLE_OPTION_LIST, $9); - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -4936,15 +4959,17 @@ opt_table_option_list opt_partition_option with_column_group $10, /* partition optition */ $11, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ - $13, /* select_stmt */ - $1); /* hints */ + $13, /* select_stmt */ + $1, /* hints */ + NULL); /* opt_ignore_or_replace */ $$->reserved_ = 0; } -| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor table_option_list opt_partition_option select_stmt +| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor table_option_list opt_partition_option opt_ignore_or_replace opt_as select_stmt { + (void)($9); ParseNode *table_options = NULL; merge_nodes(table_options, result, T_TABLE_OPTION_LIST, $6); - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -4953,34 +4978,17 @@ opt_table_option_list opt_partition_option with_column_group $7, /* partition optition */ NULL, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ - $8, /* select_stmt */ - $1); - $$->reserved_ = 0; -} -| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor table_option_list opt_partition_option AS select_stmt -{ - (void)$8; - ParseNode *table_options = NULL; - merge_nodes(table_options, result, T_TABLE_OPTION_LIST, $6); - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, - $2, /* temporary option */ - $4, /* if not exists */ - $5, /* table name */ - NULL, /* columns or primary key */ - table_options, /* table option(s) */ - $7, /* partition optition */ - NULL, /* column group */ - NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ - $9, /* select_stmt */ - $1); + $10, /* select_stmt */ + $1, /* hints */ + $8); /* opt_ignore_or_replace */ $$->reserved_ = 0; } | create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor table_option_list opt_partition_option with_column_group opt_as select_stmt { - (void)$9; + (void)($9); ParseNode *table_options = NULL; merge_nodes(table_options, result, T_TABLE_OPTION_LIST, $6); - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -4990,13 +4998,14 @@ opt_table_option_list opt_partition_option with_column_group $8, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ $10, /* select_stmt */ - $1); + $1, /* hints */ + NULL); /* opt_ignore_or_replace */ $$->reserved_ = 0; } -| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor partition_option select_stmt +| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor partition_option opt_ignore_or_replace opt_as select_stmt { - (void)($1); - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + (void)($8); + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -5005,30 +5014,15 @@ opt_table_option_list opt_partition_option with_column_group $6, /* partition optition */ NULL, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ - $7, /* select_stmt */ - $1); - $$->reserved_ = 1; /* mean partition optition is partition_option, not opt_partition_option*/ -} -| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor partition_option AS select_stmt -{ - (void)$7; - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, - $2, /* temporary option */ - $4, /* if not exists */ - $5, /* table name */ - NULL, /* columns or primary key */ - NULL, /* table option(s) */ - $6, /* partition optition */ - NULL, /* column group */ - NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ - $8, /* select_stmt */ - $1); + $9, /* select_stmt */ + $1, /* hints */ + $7); /* opt_ignore_or_replace */ $$->reserved_ = 1; /* mean partition optition is partition_option, not opt_partition_option*/ } | create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor partition_option with_column_group opt_as select_stmt { - (void)$8; - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + (void)($8); + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -5038,12 +5032,13 @@ opt_table_option_list opt_partition_option with_column_group $7, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ $9, /* select_stmt */ - $1); + $1, /* hints */ + NULL); /* opt_ignore_or_replace */ $$->reserved_ = 1; /* mean partition optition is partition_option, not opt_partition_option*/ } | create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor select_stmt { - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -5053,27 +5048,13 @@ opt_table_option_list opt_partition_option with_column_group NULL, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ $6, /* select_stmt */ - $1); /* hints */ + $1, /* hints */ + NULL); /* opt_ignore_or_replace */ $$->reserved_ = 0; } -| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor with_column_group select_stmt +| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor ignore_or_replace select_stmt { - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, - $2, /* temporary option */ - $4, /* if not exists */ - $5, /* table name */ - NULL, /* columns or primary key */ - NULL, /* table option(s) */ - NULL, /* partition optition */ - $6, /* column group */ - NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ - $7, /* select_stmt */ - $1); - $$->reserved_ = 0; -} -| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor AS select_stmt -{ - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -5083,12 +5064,45 @@ opt_table_option_list opt_partition_option with_column_group NULL, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ $7, /* select_stmt */ - $1); /* hints */ + $1, /* hints */ + $6); /* opt_ignore_or_replace */ + $$->reserved_ = 0; +} +| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor with_column_group select_stmt +{ + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, + $2, /* temporary option */ + $4, /* if not exists */ + $5, /* table name */ + NULL, /* columns or primary key */ + NULL, /* table option(s) */ + NULL, /* partition optition */ + $6, /* column group */ + NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ + $7, /* select_stmt */ + $1, /* hints */ + NULL); /* opt_ignore_or_replace */ + $$->reserved_ = 0; +} +| create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor opt_ignore_or_replace AS select_stmt +{ + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, + $2, /* temporary option */ + $4, /* if not exists */ + $5, /* table name */ + NULL, /* columns or primary key */ + NULL, /* table option(s) */ + NULL, /* partition optition */ + NULL, /* column group */ + NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ + $8, /* select_stmt */ + $1, /* hints */ + $6); /* opt_ignore_or_replace */ $$->reserved_ = 0; } | create_with_opt_hint special_table_type TABLE opt_if_not_exists relation_factor with_column_group AS select_stmt { - malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 10, + malloc_non_terminal_node($$, result->malloc_pool_, T_CREATE_TABLE, 11, $2, /* temporary option */ $4, /* if not exists */ $5, /* table name */ @@ -5098,11 +5112,31 @@ opt_table_option_list opt_partition_option with_column_group $6, /* column group */ NULL, /* oracle兼容模式下存放临时表的 on commit 选项 */ $8, /* select_stmt */ - $1); + $1, /* hints */ + NULL); /* opt_ignore_or_replace */ $$->reserved_ = 0; } ; +opt_ignore_or_replace: +ignore_or_replace +{ + $$ = $1; +} +| {$$ = NULL;}; +; + +ignore_or_replace: +IGNORE +{ + malloc_terminal_node($$, result->malloc_pool_, T_IGNORE); +} +| REPLACE +{ + malloc_terminal_node($$, result->malloc_pool_, T_REPLACE); +} +; + opt_agg: AGGREGATE { @@ -5324,7 +5358,20 @@ column_definition malloc_non_terminal_node($$, result->malloc_pool_, T_FOREIGN_KEY, 7, child_col_list, $8, parent_col_list, reference_option_list, NULL, $3, $12); } ; - +opt_column_reference: +REFERENCES relation_factor '(' column_name_list ')' opt_match_option opt_reference_option_list +{ + (void)($2); + (void)($4); + (void)($6); + (void)($7); + $$ = NULL; +} +| /*empty*/ +{ + $$ = NULL; +} +; opt_reference_option_list: opt_reference_option_list reference_option { @@ -5409,20 +5456,48 @@ SIMPLE ; column_definition: -column_definition_ref data_type opt_column_attribute_list opt_position_column +column_definition_ref data_type opt_column_attribute_list opt_column_reference opt_position_column { + (void)($4); ParseNode *attributes = NULL; merge_nodes(attributes, result, T_COLUMN_ATTRIBUTES, $3); set_data_type_collation($2, attributes, false, true); - malloc_non_terminal_node($$, result->malloc_pool_, T_COLUMN_DEFINITION, 4, $1, $2, attributes, $4); + malloc_non_terminal_node($$, result->malloc_pool_, T_COLUMN_DEFINITION, 4, $1, $2, attributes, $5); } -| column_definition_ref data_type opt_collation opt_generated_keyname AS '(' expr ')' opt_storage_type opt_generated_column_attribute_list opt_position_column +| column_definition_ref data_type opt_collation opt_generated_keyname AS '(' expr ')' opt_storage_type opt_generated_column_attribute_list opt_column_reference opt_position_column { + (void)($11); ParseNode *attributes = NULL; set_data_type_collation($2, $3, true, false); dup_expr_string($7, result, @7.first_column, @7.last_column); merge_nodes(attributes, result, T_COLUMN_ATTRIBUTES, $10); - malloc_non_terminal_node($$, result->malloc_pool_, T_COLUMN_DEFINITION, 7, $1, $2, attributes, $7, $9, $11, $4); + malloc_non_terminal_node($$, result->malloc_pool_, T_COLUMN_DEFINITION, 7, $1, $2, attributes, $7, $9, $12, $4); +} +| column_definition_ref SERIAL opt_column_attribute_list opt_position_column +{ + ParseNode *unsigned_bigint_type = NULL; + ParseNode *not_null_attr = NULL; + ParseNode *auto_increment_attr = NULL; + ParseNode *unique_attr = NULL; + ParseNode *attributes = NULL; + /* set datatype unsigned bigint */ + malloc_terminal_node(unsigned_bigint_type, result->malloc_pool_, T_UINT64); + unsigned_bigint_type->int16_values_[0] = -1; // precision, default value -1 + unsigned_bigint_type->int16_values_[1] = 0; // scale, set value 0 for int + unsigned_bigint_type->int16_values_[2] = 0; // zerofill always false for serial type + unsigned_bigint_type->int16_values_[3] = 1; // unsigned flag + unsigned_bigint_type->sql_str_off_ = @2.first_column; + set_data_type_collation(unsigned_bigint_type, attributes, false, true); + + /* set column attributes */ + malloc_terminal_node(not_null_attr, result->malloc_pool_, T_CONSTR_NOT_NULL); + malloc_terminal_node(auto_increment_attr, result->malloc_pool_, T_CONSTR_AUTO_INCREMENT); + malloc_terminal_node(unique_attr, result->malloc_pool_, T_CONSTR_UNIQUE_KEY); + malloc_non_terminal_node(attributes, result->malloc_pool_, T_LINK_NODE, 2, $3, not_null_attr); + malloc_non_terminal_node(attributes, result->malloc_pool_, T_LINK_NODE, 2, attributes, auto_increment_attr); + malloc_non_terminal_node(attributes, result->malloc_pool_, T_LINK_NODE, 2, attributes, unique_attr); + merge_nodes(attributes, result, T_COLUMN_ATTRIBUTES, attributes); + malloc_non_terminal_node($$, result->malloc_pool_, T_COLUMN_DEFINITION, 4, $1, unsigned_bigint_type, attributes, $4); } ; @@ -6858,6 +6933,12 @@ TABLE_MODE opt_equal_mark STRING_VALUE (void)($2) ; /* make bison mute */ malloc_non_terminal_node($$, result->malloc_pool_, T_BLOCK_SIZE, 1, $3); } +| KEY_BLOCK_SIZE opt_equal_mark INTNUM +{ + (void)($2); + (void)($3); + $$ = NULL; +} | TABLE_ID opt_equal_mark INTNUM { (void)($2) ; /* make bison mute */ @@ -8775,6 +8856,12 @@ GLOBAL (void)($2) ; /* make bison mute */ malloc_non_terminal_node($$, result->malloc_pool_, T_BLOCK_SIZE, 1, $3); } +| KEY_BLOCK_SIZE opt_equal_mark INTNUM +{ + (void)($2); + (void)($3); + $$ = NULL; +} | COMMENT STRING_VALUE { malloc_non_terminal_node($$, result->malloc_pool_, T_COMMENT, 1, $2); @@ -9137,28 +9224,30 @@ DROP INDEX relation_name ON relation_factor * *****************************************************************************/ insert_stmt: -insert_with_opt_hint opt_ignore opt_into single_table_insert opt_on_duplicate_key_clause +insert_with_opt_hint opt_priority opt_ignore opt_into single_table_insert opt_on_duplicate_key_clause { - (void)($3); - if (NULL == $4) { + (void)($2); + (void)($4); + if (NULL == $5) { yyerror(NULL, result, "invalid single table insert node\n"); YYABORT_UNEXPECTED; } - $4->children_[2] = $5; /*duplicate key node*/ + $5->children_[2] = $6; /*duplicate key node*/ malloc_non_terminal_node($$, result->malloc_pool_, T_INSERT, 4, - $4, /*single or multi table insert node*/ + $5, /*single or multi table insert node*/ $1->children_[0], /* is replacement */ $1->children_[1], /* hint */ - $2 /*ignore node*/); + $3 /*ignore node*/); } -| replace_with_opt_hint opt_ignore opt_into single_table_insert +| replace_with_opt_hint opt_low_priority opt_ignore opt_into single_table_insert { - (void)($3); + (void)($2); + (void)($4); malloc_non_terminal_node($$, result->malloc_pool_, T_INSERT, 4, - $4, /*single or multi table insert node*/ + $5, /*single or multi table insert node*/ $1->children_[0], /* is replacement */ $1->children_[1], /* hint */ - $2 /*ignore node*/); + $3 /*ignore node*/); } ; @@ -9311,6 +9400,35 @@ IGNORE } ; +opt_priority: +HIGH_PRIORITY +{ + // we only support it in parser, but actually do nothing. + $$ = NULL; +} +| LOW_PRIORITY +{ + // we only support it in parser, but actually do nothing. + $$ = NULL; +} +| /* empty */ +{ + $$ = NULL; +} +; + +opt_low_priority: +LOW_PRIORITY +{ + // we only support it in parser, but actually do nothing. + $$ = NULL; +} +| /* empty */ +{ + $$ = NULL; +} +; + opt_on_duplicate_key_clause: ON DUPLICATE KEY UPDATE update_asgn_list { @@ -11526,6 +11644,30 @@ ALL { $$=NULL; } +| HIGH_PRIORITY +{ + // we only support it in parser, but actually do nothing. + $$=NULL; +} +| SQL_SMALL_RESULT +{ + // we only support it in parser, but actually do nothing. + $$=NULL; +} +| SQL_BIG_RESULT +{ + // we only support it in parser, but actually do nothing. + $$=NULL; +} +| SQL_BUFFER_RESULT +{ + // we only support it in parser, but actually do nothing. + $$=NULL; +} +| STRAIGHT_JOIN +{ + malloc_terminal_node($$, result->malloc_pool_, T_STRAIGHT_JOIN); +} ; projection: @@ -12840,7 +12982,7 @@ JOIN } | STRAIGHT_JOIN { - malloc_terminal_node($$, result->malloc_pool_, T_JOIN_INNER); + malloc_terminal_node($$, result->malloc_pool_, T_STRAIGHT_JOIN); } ; @@ -13843,6 +13985,14 @@ SHOW opt_extended_or_full TABLES opt_from_or_in_database_clause opt_show_conditi { malloc_terminal_node($$, result->malloc_pool_, T_SHOW_PRIVILEGES); } +| SHOW PROFILE +{ + malloc_terminal_node($$, result->malloc_pool_, T_SHOW_PROFILE); +} +| SHOW PROFILES +{ + malloc_terminal_node($$, result->malloc_pool_, T_SHOW_PROFILE); +} | SHOW QUERY_RESPONSE_TIME { malloc_terminal_node($$, result->malloc_pool_, T_SHOW_QUERY_RESPONSE_TIME); @@ -14401,9 +14551,11 @@ STRING_VALUE * *****************************************************************************/ drop_user_stmt: -DROP USER user_list +DROP USER opt_if_exists user_list { - merge_nodes($$, result, T_DROP_USER, $3); + ParseNode* drop_user_list = NULL; + merge_nodes(drop_user_list, result, T_USERS, $4); + malloc_non_terminal_node($$, result->malloc_pool_, T_DROP_USER, 2, drop_user_list, $3); } ; @@ -15345,6 +15497,21 @@ role_with_host malloc_terminal_node($$, result->malloc_pool_, T_PRIV_TYPE); $$->value_ = OB_PRIV_CREATE_ROUTINE; } +| CREATE TABLESPACE +{ + malloc_terminal_node($$, result->malloc_pool_, T_PRIV_TYPE); + $$->value_ = OB_PRIV_CREATE_TABLESPACE; +} +| SHUTDOWN +{ + malloc_terminal_node($$, result->malloc_pool_, T_PRIV_TYPE); + $$->value_ = OB_PRIV_SHUTDOWN; +} +| RELOAD +{ + malloc_terminal_node($$, result->malloc_pool_, T_PRIV_TYPE); + $$->value_ = OB_PRIV_RELOAD; +} ; opt_privilege: @@ -19435,6 +19602,18 @@ BEGI } ; +/*=========================================================== + * + * mock stmt + * + *===========================================================*/ +mock_stmt: +FLUSH PRIVILEGES +{ + malloc_terminal_node($$, result->malloc_pool_, T_FLUSH_PRIVILEGES); +} +; + /***************************************************************************** METHOD_OPT grammar ==> used for GatherTableStats METHOD_OPT - The value controls column statistics collection and histogram creation. It accepts @@ -20096,6 +20275,10 @@ NAME_OB { make_name_node($$, result->malloc_pool_, "normal"); } +| PASSWORD +{ + make_name_node($$, result->malloc_pool_, "password"); +} ; @@ -21623,7 +21806,6 @@ ACCOUNT | SET_TP | SHARDING | SHARE -| SHUTDOWN | SIGNED | SIZE %prec LOWER_PARENS | SIMPLE @@ -21854,6 +22036,7 @@ unreserved_keyword_ambiguous_roles: | REPLICATION | RESOURCE | EXECUTE +| SHUTDOWN ; /*注释掉的关键字有规约冲突暂时注释了,都是一些sql中常用的关键字,后面按需打开,增加这块代码逻辑是为了支持在mysql中允许以 @@ -22053,7 +22236,7 @@ ACCESSIBLE | SSL | STARTING | STORED -| STRAIGHT_JOIN +//| STRAIGHT_JOIN | TABLE | TERMINATED | THEN diff --git a/src/sql/plan_cache/ob_sql_parameterization.cpp b/src/sql/plan_cache/ob_sql_parameterization.cpp index f1c9272738..5eef21e1a4 100644 --- a/src/sql/plan_cache/ob_sql_parameterization.cpp +++ b/src/sql/plan_cache/ob_sql_parameterization.cpp @@ -215,7 +215,8 @@ int ObSqlParameterization::transform_syntax_tree(ObIAllocator &allocator, } else if (0 == tmp_root->is_val_paramed_item_idx_ && OB_FAIL(get_select_item_param_info(*raw_params, tmp_root, - select_item_param_infos))) { + select_item_param_infos, + session))) { SQL_PC_LOG(WARN, "failed to get select item param info", K(ret)); } else { // do nothing @@ -477,6 +478,7 @@ int ObSqlParameterization::transform_tree(TransformTreeCtx &ctx, int ret = OB_SUCCESS; int64_t value_level = NO_VALUES; int64_t assign_level = NO_VALUES; + ObCompatType compat_type = COMPAT_MYSQL57; if (OB_ISNULL(ctx.top_node_) || OB_ISNULL(ctx.allocator_) || OB_ISNULL(ctx.sql_info_) @@ -490,6 +492,8 @@ int ObSqlParameterization::transform_tree(TransformTreeCtx &ctx, K(ctx.fixed_param_store_), K(ctx.params_), K(ret)); + } else if (OB_FAIL(session_info.get_compatibility_control(compat_type))) { + LOG_WARN("failed to get compat type", K(ret)); } else if (NULL == ctx.tree_) { // do nothing } else { @@ -559,7 +563,9 @@ int ObSqlParameterization::transform_tree(TransformTreeCtx &ctx, literal_prefix, ctx.default_length_semantics_, static_cast(server_collation), - NULL, session_info.get_sql_mode(), enable_decimal_int, + NULL, session_info.get_sql_mode(), + enable_decimal_int, + compat_type, ctx.is_from_pl_))) { SQL_PC_LOG(WARN, "fail to resolve const", K(ret)); } else { @@ -2059,7 +2065,8 @@ int ObSqlParameterization::get_related_user_vars(const ParseNode *tree, common:: int ObSqlParameterization::get_select_item_param_info(const common::ObIArray &raw_params, ParseNode *tree, - SelectItemParamInfoArray *select_item_param_infos) + SelectItemParamInfoArray *select_item_param_infos, + const ObSQLSessionInfo &session) { int ret = OB_SUCCESS; SelectItemParamInfo param_info; @@ -2067,6 +2074,7 @@ int ObSqlParameterization::get_select_item_param_info(const common::ObIArrayraw_sql_offset_; int64_t buf_len = SelectItemParamInfo::PARAMED_FIELD_BUF_LEN; ObSEArray stack_frames; + bool enable_modify_null_name = false; if (T_PROJECT_STRING != tree->type_ || OB_ISNULL(tree->children_) || tree->num_child_ <= 0) { ret = OB_INVALID_ARGUMENT; @@ -2177,6 +2185,29 @@ int ObSqlParameterization::get_select_item_param_info(const common::ObIArray= raw_params.count()) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid index", K(idx), K(raw_params.count())); + } else if (OB_ISNULL(raw_params.at(idx)) || OB_ISNULL(raw_params.at(idx)->node_)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid argument", K(raw_params.at(idx)), K(raw_params.at(idx)->node_)); + } else if (T_NULL == raw_params.at(idx)->node_->type_) { + tree->str_value_ = "NULL"; + tree->str_len_ = strlen("NULL"); + } + } + return ret; } diff --git a/src/sql/plan_cache/ob_sql_parameterization.h b/src/sql/plan_cache/ob_sql_parameterization.h index 4ef5be9534..2706130114 100644 --- a/src/sql/plan_cache/ob_sql_parameterization.h +++ b/src/sql/plan_cache/ob_sql_parameterization.h @@ -212,7 +212,8 @@ private: static int get_select_item_param_info(const common::ObIArray &raw_params, ParseNode *tree, - SelectItemParamInfoArray *select_item_param_infos); + SelectItemParamInfoArray *select_item_param_infos, + const ObSQLSessionInfo &session); static int parameterize_fields(SelectItemTraverseCtx &ctx); static int resolve_paramed_const(SelectItemTraverseCtx &ctx); diff --git a/src/sql/printer/ob_dml_stmt_printer.cpp b/src/sql/printer/ob_dml_stmt_printer.cpp index bf2aa9de5e..52c0edc1ba 100644 --- a/src/sql/printer/ob_dml_stmt_printer.cpp +++ b/src/sql/printer/ob_dml_stmt_printer.cpp @@ -356,7 +356,7 @@ int ObDMLStmtPrinter::print_table(const TableItem *table_item, break; } case INNER_JOIN: { - type_str = "join"; + type_str = join_table->is_straight_join_ ? "straight_join" : "join"; break; } case CONNECT_BY_JOIN: { diff --git a/src/sql/printer/ob_select_stmt_printer.cpp b/src/sql/printer/ob_select_stmt_printer.cpp index 4cf09df465..6b2156a711 100644 --- a/src/sql/printer/ob_select_stmt_printer.cpp +++ b/src/sql/printer/ob_select_stmt_printer.cpp @@ -425,6 +425,9 @@ int ObSelectStmtPrinter::print_select() } else if (select_stmt->is_unpivot_select()) { DATA_PRINTF(" * "); } else { + if (select_stmt->is_select_straight_join()) { // straight_join + DATA_PRINTF("straight_join "); + } if (select_stmt->has_distinct()) { // distinct DATA_PRINTF("distinct "); } diff --git a/src/sql/privilege_check/ob_ora_priv_check.cpp b/src/sql/privilege_check/ob_ora_priv_check.cpp index 99b48ae664..4805fc96db 100644 --- a/src/sql/privilege_check/ob_ora_priv_check.cpp +++ b/src/sql/privilege_check/ob_ora_priv_check.cpp @@ -2278,6 +2278,7 @@ int ObOraSysChecker::check_ora_ddl_priv( DEFINE_PUB_CHECK_CMD(PRIV_ID_CREATE_USER); break; } + case stmt::T_ALTER_USER_PROXY: case stmt::T_ALTER_USER_PROFILE: case stmt::T_ALTER_USER_PRIMARY_ZONE: case stmt::T_ALTER_USER: { diff --git a/src/sql/privilege_check/ob_privilege_check.cpp b/src/sql/privilege_check/ob_privilege_check.cpp index fe7d7ca95f..75675e25e7 100644 --- a/src/sql/privilege_check/ob_privilege_check.cpp +++ b/src/sql/privilege_check/ob_privilege_check.cpp @@ -23,6 +23,10 @@ #include "sql/resolver/ddl/ob_drop_mlog_stmt.h" #include "sql/resolver/ddl/ob_create_database_stmt.h" #include "sql/resolver/ddl/ob_alter_table_stmt.h" +#include "sql/resolver/ddl/ob_sequence_stmt.h" +#include "sql/resolver/ddl/ob_create_outline_stmt.h" +#include "sql/resolver/ddl/ob_alter_outline_stmt.h" +#include "sql/resolver/ddl/ob_drop_outline_stmt.h" #include "sql/resolver/ddl/ob_drop_database_stmt.h" #include "sql/resolver/ddl/ob_drop_index_stmt.h" #include "sql/resolver/ddl/ob_lock_tenant_stmt.h" @@ -584,7 +588,7 @@ int set_privs_by_table_item_recursively( bool need_check = true; if (is_sys_view(table_item->ref_id_)) { /* oracle的字典视图(dba_*)需要做检查,其他系统视图(all_*, user_*, 性能视图(v$)不做权限检查 */ - need_check = table_item->is_oracle_dba_sys_view(); + need_check = table_item->is_oracle_dba_sys_view() || (OB_PROXY_USERS_TID == table_item->ref_id_); } else { need_check = true; } @@ -1416,6 +1420,197 @@ int get_drop_table_stmt_need_privs( return ret; } +int get_create_sequence_stmt_need_privs( + const ObSessionPrivInfo &session_priv, + const ObStmt *basic_stmt, + ObIArray &need_privs) +{ + int ret = OB_SUCCESS; + ObNeedPriv need_priv; + bool need_check = false; + if (OB_ISNULL(basic_stmt)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Basic stmt should be not be NULL", K(ret)); + } else if (OB_UNLIKELY(stmt::T_CREATE_SEQUENCE != basic_stmt->get_stmt_type())) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Stmt type should be T_CREATE_SEQUENCE", K(ret), "stmt type", basic_stmt->get_stmt_type()); + } else if (OB_FAIL(ObPrivilegeCheck::get_priv_need_check(session_priv, + ObCompatFeatureType::MYSQL_PRIV_ENHANCE, need_check))) { + LOG_WARN("failed to get priv need check", K(ret)); + } else if (lib::is_mysql_mode() && need_check) { + const ObCreateSequenceStmt *stmt = static_cast(basic_stmt); + if (OB_FAIL(ObPrivilegeCheck::can_do_operation_on_db(session_priv, + stmt->get_arg().get_database_name()))) { + LOG_WARN("Can not create sequence in current database", K(session_priv), K(ret)); + } else { + need_priv.db_ = stmt->get_arg().get_database_name(); + need_priv.priv_set_ = OB_PRIV_CREATE; + need_priv.priv_level_ = OB_PRIV_DB_LEVEL; + ADD_NEED_PRIV(need_priv); + } + } + return ret; +} + +int get_alter_sequence_stmt_need_privs( + const ObSessionPrivInfo &session_priv, + const ObStmt *basic_stmt, + ObIArray &need_privs) +{ + int ret = OB_SUCCESS; + ObNeedPriv need_priv; + bool need_check = false; + if (OB_ISNULL(basic_stmt)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Basic stmt should be not be NULL", K(ret)); + } else if (OB_UNLIKELY(stmt::T_ALTER_SEQUENCE != basic_stmt->get_stmt_type())) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Stmt type should be T_ALTER_SEQUENCE", K(ret), "stmt type", basic_stmt->get_stmt_type()); + } else if (OB_FAIL(ObPrivilegeCheck::get_priv_need_check(session_priv, + ObCompatFeatureType::MYSQL_PRIV_ENHANCE, need_check))) { + LOG_WARN("failed to get priv need check", K(ret)); + } else if (lib::is_mysql_mode() && need_check) { + const ObAlterSequenceStmt *stmt = static_cast(basic_stmt); + if (OB_FAIL(ObPrivilegeCheck::can_do_operation_on_db(session_priv, + stmt->get_arg().get_database_name()))) { + LOG_WARN("Can not alter sequence in current database", K(session_priv), K(ret)); + } else { + need_priv.db_ = stmt->get_arg().get_database_name(); + need_priv.priv_set_ = OB_PRIV_ALTER; + need_priv.priv_level_ = OB_PRIV_DB_LEVEL; + ADD_NEED_PRIV(need_priv); + } + } + return ret; +} + +int get_drop_sequence_stmt_need_privs( + const ObSessionPrivInfo &session_priv, + const ObStmt *basic_stmt, + ObIArray &need_privs) +{ + int ret = OB_SUCCESS; + ObNeedPriv need_priv; + bool need_check = false; + if (OB_ISNULL(basic_stmt)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Basic stmt should be not be NULL", K(ret)); + } else if (OB_UNLIKELY(stmt::T_DROP_SEQUENCE != basic_stmt->get_stmt_type())) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Stmt type should be T_DROP_SEQUENCE", K(ret), "stmt type", basic_stmt->get_stmt_type()); + } else if (OB_FAIL(ObPrivilegeCheck::get_priv_need_check(session_priv, + ObCompatFeatureType::MYSQL_PRIV_ENHANCE, need_check))) { + LOG_WARN("failed to get priv need check", K(ret)); + } else if (lib::is_mysql_mode() && need_check) { + const ObDropSequenceStmt *stmt = static_cast(basic_stmt); + if (OB_FAIL(ObPrivilegeCheck::can_do_operation_on_db(session_priv, + stmt->get_arg().get_database_name()))) { + LOG_WARN("Can not drop sequence in current database", K(session_priv), K(ret)); + } else { + need_priv.db_ = stmt->get_arg().get_database_name(); + need_priv.priv_set_ = OB_PRIV_DROP; + need_priv.priv_level_ = OB_PRIV_DB_LEVEL; + ADD_NEED_PRIV(need_priv); + } + } + return ret; +} + +int get_create_outline_stmt_need_privs( + const ObSessionPrivInfo &session_priv, + const ObStmt *basic_stmt, + ObIArray &need_privs) +{ + int ret = OB_SUCCESS; + ObNeedPriv need_priv; + bool need_check = false; + if (OB_ISNULL(basic_stmt)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Basic stmt should be not be NULL", K(ret)); + } else if (OB_UNLIKELY(stmt::T_CREATE_OUTLINE != basic_stmt->get_stmt_type())) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Stmt type should be T_CREATE_OUTLINE", K(ret), "stmt type", basic_stmt->get_stmt_type()); + } else if (OB_FAIL(ObPrivilegeCheck::get_priv_need_check(session_priv, + ObCompatFeatureType::MYSQL_PRIV_ENHANCE, need_check))) { + LOG_WARN("failed to get priv need check", K(ret)); + } else if (lib::is_mysql_mode() && need_check) { + const ObCreateOutlineStmt *stmt = static_cast(basic_stmt); + if (OB_FAIL(ObPrivilegeCheck::can_do_operation_on_db(session_priv, + stmt->get_create_outline_arg().db_name_))) { + LOG_WARN("Can not create outline in current database", K(session_priv), K(ret)); + } else { + need_priv.db_ = stmt->get_create_outline_arg().db_name_; + need_priv.priv_set_ = OB_PRIV_CREATE; + need_priv.priv_level_ = OB_PRIV_DB_LEVEL; + ADD_NEED_PRIV(need_priv); + } + } + return ret; +} + +int get_alter_outline_stmt_need_privs( + const ObSessionPrivInfo &session_priv, + const ObStmt *basic_stmt, + ObIArray &need_privs) +{ + int ret = OB_SUCCESS; + ObNeedPriv need_priv; + bool need_check = false; + if (OB_ISNULL(basic_stmt)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Basic stmt should be not be NULL", K(ret)); + } else if (OB_UNLIKELY(stmt::T_ALTER_OUTLINE != basic_stmt->get_stmt_type())) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Stmt type should be T_ALTER_OUTLINE", K(ret), "stmt type", basic_stmt->get_stmt_type()); + } else if (OB_FAIL(ObPrivilegeCheck::get_priv_need_check(session_priv, + ObCompatFeatureType::MYSQL_PRIV_ENHANCE, need_check))) { + LOG_WARN("failed to get priv need check", K(ret)); + } else if (lib::is_mysql_mode() && need_check) { + const ObAlterOutlineStmt *stmt = static_cast(basic_stmt); + if (OB_FAIL(ObPrivilegeCheck::can_do_operation_on_db(session_priv, + stmt->get_alter_outline_arg().db_name_))) { + LOG_WARN("Can not alter outline in current database", K(session_priv), K(ret)); + } else { + need_priv.db_ = stmt->get_alter_outline_arg().db_name_; + need_priv.priv_set_ = OB_PRIV_ALTER; + need_priv.priv_level_ = OB_PRIV_DB_LEVEL; + ADD_NEED_PRIV(need_priv); + } + } + return ret; +} + +int get_drop_outline_stmt_need_privs( + const ObSessionPrivInfo &session_priv, + const ObStmt *basic_stmt, + ObIArray &need_privs) +{ + int ret = OB_SUCCESS; + ObNeedPriv need_priv; + bool need_check = false; + if (OB_ISNULL(basic_stmt)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Basic stmt should be not be NULL", K(ret)); + } else if (OB_UNLIKELY(stmt::T_DROP_OUTLINE != basic_stmt->get_stmt_type())) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Stmt type should be T_DROP_OUTLINE", K(ret), "stmt type", basic_stmt->get_stmt_type()); + } else if (OB_FAIL(ObPrivilegeCheck::get_priv_need_check(session_priv, + ObCompatFeatureType::MYSQL_PRIV_ENHANCE, need_check))) { + LOG_WARN("failed to get priv need check", K(ret)); + } else if (lib::is_mysql_mode() && need_check) { + const ObDropOutlineStmt *stmt = static_cast(basic_stmt); + if (OB_FAIL(ObPrivilegeCheck::can_do_operation_on_db(session_priv, + stmt->get_drop_outline_arg().db_name_))) { + LOG_WARN("Can not drop outline in current database", K(session_priv), K(ret)); + } else { + need_priv.db_ = stmt->get_drop_outline_arg().db_name_; + need_priv.priv_set_ = OB_PRIV_DROP; + need_priv.priv_level_ = OB_PRIV_DB_LEVEL; + ADD_NEED_PRIV(need_priv); + } + } + return ret; +} int get_create_synonym_priv( const ObSessionPrivInfo &session_priv, @@ -1442,6 +1637,33 @@ int get_create_synonym_priv( return ret; } +int get_create_tablespace_priv( + const ObSessionPrivInfo &session_priv, + const ObStmt *basic_stmt, + ObIArray &need_privs) +{ + int ret = OB_SUCCESS; + ObNeedPriv need_priv; + bool need_check = false; + if (OB_ISNULL(basic_stmt)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("Basic stmt should be not be NULL", K(ret)); + } else if (OB_UNLIKELY(stmt::T_CREATE_TABLESPACE != basic_stmt->get_stmt_type() + && stmt::T_DROP_TABLESPACE != basic_stmt->get_stmt_type() + && stmt::T_ALTER_TABLESPACE != basic_stmt->get_stmt_type())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected stmt type", K(basic_stmt->get_stmt_type()), K(ret)); + } else if (OB_FAIL(ObPrivilegeCheck::get_priv_need_check(session_priv, + ObCompatFeatureType::MYSQL_PRIV_ENHANCE, need_check))) { + LOG_WARN("failed to get priv need check", K(ret)); + } else if (lib::is_mysql_mode() && need_check) { + need_priv.priv_set_ = OB_PRIV_CREATE_TABLESPACE; + need_priv.priv_level_ = OB_PRIV_USER_LEVEL; + ADD_NEED_PRIV(need_priv); + } + return ret; +} + int get_create_dblink_priv( const ObSessionPrivInfo &session_priv, const ObStmt *basic_stmt, @@ -1806,6 +2028,7 @@ int get_create_user_privs( switch (stmt_type) {//TODO deleted switch case stmt::T_LOCK_USER : case stmt::T_ALTER_USER_PROFILE : + case stmt::T_ALTER_USER_PROXY : case stmt::T_ALTER_USER_PRIMARY_ZONE: case stmt::T_ALTER_USER: case stmt::T_SET_PASSWORD : @@ -2761,8 +2984,8 @@ int ObPrivilegeCheck::check_privilege_new( common::ObSEArray tmp_need_privs; common::ObSEArray tmp_ora_need_privs; ObSessionPrivInfo session_priv; - ctx.session_info_->get_session_priv_info(session_priv); - session_priv.set_effective_tenant_id(ctx.session_info_->get_effective_tenant_id()); + OZ (ctx.session_info_->get_session_priv_info(session_priv)); + OX (session_priv.set_effective_tenant_id(ctx.session_info_->get_effective_tenant_id())); OZ (get_stmt_need_privs(session_priv, basic_stmt, tmp_need_privs)); OZ (stmt_need_privs.need_privs_.assign(tmp_need_privs)); /* set user id=-1, means: use current user executing sql and can change @@ -2853,9 +3076,11 @@ int ObPrivilegeCheck::check_privilege( if (OB_SUCC(ret)) { common::ObSEArray tmp_need_privs; ObSessionPrivInfo session_priv; - ctx.session_info_->get_session_priv_info(session_priv); - session_priv.set_effective_tenant_id(ctx.session_info_->get_effective_tenant_id()); - if (OB_FAIL(get_stmt_need_privs(session_priv, basic_stmt, tmp_need_privs))) { + if (OB_FAIL(ctx.session_info_->get_session_priv_info(session_priv))) { + LOG_WARN("fail to get session priv info", K(ret)); + } else if (FALSE_IT(session_priv.set_effective_tenant_id( + ctx.session_info_->get_effective_tenant_id()))) { + } else if (OB_FAIL(get_stmt_need_privs(session_priv, basic_stmt, tmp_need_privs))) { LOG_WARN("Get stmt need privs error", K(ret)); } else if (OB_FAIL(stmt_need_privs.need_privs_.assign(tmp_need_privs))) { LOG_WARN("fail to assign need_privs", K(ret)); @@ -2908,8 +3133,9 @@ int ObPrivilegeCheck::check_privilege( ret = OB_INVALID_ARGUMENT; LOG_WARN("Session is NULL"); } else { - ctx.session_info_->get_session_priv_info(session_priv); - if (ctx.session_info_->get_user_id() != ctx.session_info_->get_priv_user_id() + if (OB_FAIL(ctx.session_info_->get_session_priv_info(session_priv))) { + LOG_WARN("fail to get session priv info", K(ret)); + } else if (ctx.session_info_->get_user_id() != ctx.session_info_->get_priv_user_id() && OB_FAIL(adjust_session_priv(*ctx.schema_guard_, session_priv))) { LOG_WARN("fail to assign enable role id array", K(ret)); } else if (OB_UNLIKELY(!session_priv.is_valid())) { @@ -3799,6 +4025,17 @@ int ObPrivilegeCheck::check_priv_in_roles( return ret; } +int ObPrivilegeCheck::get_priv_need_check(const ObSessionPrivInfo &session_priv, + const ObCompatFeatureType feature_type, + bool &need_check) +{ + int ret = OB_SUCCESS; + if (OB_FAIL(ObCompatControl::check_feature_enable(session_priv.security_version_, + feature_type, need_check))) { + LOG_WARN("failed to check feature enable", K(ret), K(feature_type)); + } + return ret; +} #undef ADD_NEED_PRIV diff --git a/src/sql/privilege_check/ob_privilege_check.h b/src/sql/privilege_check/ob_privilege_check.h index 40f4325286..9532630679 100644 --- a/src/sql/privilege_check/ob_privilege_check.h +++ b/src/sql/privilege_check/ob_privilege_check.h @@ -14,6 +14,7 @@ #define OCEANBASE_SQL_PRIVILEGE_CHECK_OB_PRIVILEGE_CHECK_ #include "share/schema/ob_schema_struct.h" +#include "share/ob_compatibility_control.h" #include "sql/resolver/ob_stmt_type.h" namespace oceanbase { namespace sql { @@ -86,7 +87,10 @@ public: static int get_stmt_need_privs(const share::schema::ObSessionPrivInfo &session_priv, const ObStmt *basic_stmt, common::ObIArray &stmt_need_priv); - + // check privilege version for upgrade compatibility + static int get_priv_need_check(const share::schema::ObSessionPrivInfo &session_priv, + const share::ObCompatFeatureType feature_type, + bool &need_check); static int check_priv_in_roles(const uint64_t tenant_id, const uint64_t user_id, diff --git a/src/sql/resolver/cmd/ob_mock_resolver.cpp b/src/sql/resolver/cmd/ob_mock_resolver.cpp new file mode 100644 index 0000000000..60f3a00345 --- /dev/null +++ b/src/sql/resolver/cmd/ob_mock_resolver.cpp @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ +#define USING_LOG_PREFIX SQL_RESV +#include "sql/resolver/cmd/ob_mock_resolver.h" +#include "sql/resolver/cmd/ob_mock_stmt.h" +#include "sql/resolver/ob_resolver_utils.h" + +namespace oceanbase +{ +using namespace oceanbase::common; +namespace sql +{ +int ObMockResolver::resolve(const ParseNode& parse_tree) +{ + int ret = OB_SUCCESS; + ObMockStmt *mock_stmt = NULL; + if (OB_UNLIKELY(parse_tree.type_ != T_FLUSH_PRIVILEGES)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected parse tree type", K(ret), K(parse_tree.type_)); + } else if (OB_UNLIKELY(NULL == (mock_stmt = create_stmt()))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("failed to create mock stmt"); + } else { + switch (parse_tree.type_) { + case T_FLUSH_PRIVILEGES: + mock_stmt->set_stmt_type(stmt::T_FLUSH_PRIVILEGES); + break; + default: + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected parse tree type", K(ret), K(parse_tree.type_)); + break; + } + } + return ret; +} +} +} diff --git a/src/sql/resolver/cmd/ob_mock_resolver.h b/src/sql/resolver/cmd/ob_mock_resolver.h new file mode 100644 index 0000000000..808f417487 --- /dev/null +++ b/src/sql/resolver/cmd/ob_mock_resolver.h @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OCEANBASE_SQL_RESOLVER_CMD_OB_MOCK_RESOLVER_H_ +#define OCEANBASE_SQL_RESOLVER_CMD_OB_MOCK_RESOLVER_H_ +#include "sql/resolver/cmd/ob_cmd_resolver.h" + +namespace oceanbase +{ +namespace sql +{ +class ObMockResolver : public ObCMDResolver +{ +public: + explicit ObMockResolver(ObResolverParams ¶ms) : + ObCMDResolver(params) + { + } + virtual ~ObMockResolver() + { + } + virtual int resolve(const ParseNode &parse_tree); +private: + DISALLOW_COPY_AND_ASSIGN(ObMockResolver); +}; + +} // namespace sql +} // namespace oceanbase +#endif \ No newline at end of file diff --git a/src/sql/resolver/cmd/ob_mock_stmt.h b/src/sql/resolver/cmd/ob_mock_stmt.h new file mode 100644 index 0000000000..7fcf6332c4 --- /dev/null +++ b/src/sql/resolver/cmd/ob_mock_stmt.h @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OB_MOCK_STMT_H_ +#define OB_MOCK_STMT_H_ + +#include "sql/resolver/cmd/ob_cmd_stmt.h" + +namespace oceanbase +{ +namespace sql +{ +class ObMockStmt : public ObCMDStmt +{ +public: + ObMockStmt() : ObCMDStmt(stmt::T_FLUSH_PRIVILEGES) + { + } + virtual ~ObMockStmt() {} + +private: + DISALLOW_COPY_AND_ASSIGN(ObMockStmt); +}; +} +} + +#endif diff --git a/src/sql/resolver/cmd/ob_show_resolver.cpp b/src/sql/resolver/cmd/ob_show_resolver.cpp index 5399012dbc..af495c3798 100644 --- a/src/sql/resolver/cmd/ob_show_resolver.cpp +++ b/src/sql/resolver/cmd/ob_show_resolver.cpp @@ -21,6 +21,7 @@ #include "lib/charset/ob_charset.h" #include "observer/ob_server_struct.h" #include "sql/resolver/dcl/ob_grant_resolver.h" +#include "observer/virtual_table/ob_tenant_all_tables.h" using namespace oceanbase::common; using namespace oceanbase::share; using namespace oceanbase::share::schema; @@ -103,7 +104,9 @@ int ObShowResolver::resolve(const ParseNode &parse_tree) K(session_info_), K(params_.allocator_), K(schema_checker_)); - } else if (OB_UNLIKELY(parse_tree.type_ < T_SHOW_TABLES || parse_tree.type_ > T_SHOW_GRANTS) && (parse_tree.type_ != T_SHOW_TRIGGERS)) { + } else if (OB_UNLIKELY(parse_tree.type_ < T_SHOW_TABLES || parse_tree.type_ > T_SHOW_GRANTS) && + (parse_tree.type_ != T_SHOW_TRIGGERS) && + (parse_tree.type_ != T_SHOW_PROFILE)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected parse tree type", K(ret), K(parse_tree.type_)); } else { @@ -116,7 +119,9 @@ int ObShowResolver::resolve(const ParseNode &parse_tree) host_name.assign_ptr(session_info_->get_host_name().ptr(), session_info_->get_host_name().length()); user_id = session_info_->get_user_id(); - session_info_->get_session_priv_info(session_priv); + if (OB_FAIL(session_info_->get_session_priv_info(session_priv))) { + LOG_WARN("faile to get session priv info", K(ret)); + } } if (OB_SUCC(ret)) { @@ -945,7 +950,26 @@ int ObShowResolver::resolve(const ParseNode &parse_tree) } else { show_resv_ctx.stmt_type_ = stmt::T_SHOW_TABLE_STATUS; GEN_SQL_STEP_1(ObShowSqlSet::SHOW_TABLE_STATUS); - GEN_SQL_STEP_2(ObShowSqlSet::SHOW_TABLE_STATUS, REAL_NAME(OB_SYS_DATABASE_NAME, OB_ORA_SYS_SCHEMA_NAME), REAL_NAME(OB_TENANT_VIRTUAL_ALL_TABLE_TNAME, OB_TENANT_VIRTUAL_ALL_TABLE_AGENT_TNAME), show_db_id); + if ((GET_MIN_CLUSTER_VERSION() >= MOCK_CLUSTER_VERSION_4_2_3_0 + && GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_4_3_0_0) + || (GET_MIN_CLUSTER_VERSION() >= MOCK_CLUSTER_VERSION_4_2_1_6 + && GET_MIN_CLUSTER_VERSION() < CLUSTER_VERSION_4_2_2_0) + || GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_3_2_0) { + if (lib::is_mysql_mode()) { + GEN_SQL_STEP_2(ObShowSqlSet::SHOW_TABLE_STATUS, NEW_TABLE_STATUS_SQL, show_db_id); + } else { + GEN_SQL_STEP_2(ObShowSqlSet::SHOW_TABLE_STATUS, NEW_TABLE_STATUS_SQL_ORA, show_db_id); + } + } else { + const char *db_name = REAL_NAME(OB_SYS_DATABASE_NAME, OB_ORA_SYS_SCHEMA_NAME); + const char *vt_table_name = REAL_NAME(OB_TENANT_VIRTUAL_ALL_TABLE_TNAME, OB_TENANT_VIRTUAL_ALL_TABLE_AGENT_TNAME); + char table_name[strlen(db_name) + strlen(vt_table_name) + 2]; + strcpy(table_name, db_name); + table_name[strlen(db_name)] = '.'; + strcpy(table_name + strlen(db_name) + 1, vt_table_name); + table_name[strlen(db_name) + strlen(vt_table_name) + 1] = '\0'; + GEN_SQL_STEP_2(ObShowSqlSet::SHOW_TABLE_STATUS, table_name, show_db_id); + } } } }(); @@ -1387,6 +1411,28 @@ int ObShowResolver::resolve(const ParseNode &parse_tree) }(); break; } + case T_SHOW_PROFILE: { + [&] { + ObWarningBuffer *wb = NULL; + wb = common::ob_get_tsi_warning_buffer(); + if (is_oracle_mode) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "show profile in oracle mode is"); + } else if (OB_ISNULL(wb)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexcepted null ptr", K(ret)); + } else if (OB_UNLIKELY(parse_tree.num_child_ != 0)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("parse tree is wrong", K(ret), K(parse_tree.num_child_)); + } else { + show_resv_ctx.stmt_type_ = stmt::T_SHOW_PROFILE; + GEN_SQL_STEP_1(ObShowSqlSet::SHOW_PROFILE); + GEN_SQL_STEP_2(ObShowSqlSet::SHOW_PROFILE, OB_INFORMATION_SCHEMA_NAME, OB_PROFILING_TNAME); + wb->append_warning("SHOW PROFILES Statement just mocks the syntax of MySQL without supporting specific realization", OB_NOT_SUPPORTED); + } + }(); + break; + } case T_SHOW_PRIVILEGES: { [&] { if (OB_UNLIKELY(parse_tree.num_child_ != 0)) { @@ -2904,6 +2950,12 @@ DEFINE_SHOW_CLAUSE_SET(SHOW_ENGINES, NULL, NULL); +DEFINE_SHOW_CLAUSE_SET(SHOW_PROFILE, + NULL, + "SELECT * FROM %s.%s ", + NULL, + NULL); + DEFINE_SHOW_CLAUSE_SET(SHOW_PRIVILEGES, NULL, "SELECT * FROM %s.%s ", @@ -2953,8 +3005,8 @@ DEFINE_SHOW_CLAUSE_SET(SHOW_SYS_FULL_PROCESSLIST, NULL); DEFINE_SHOW_CLAUSE_SET(SHOW_TABLE_STATUS, NULL, - "SELECT table_name AS `Name`, engine as `Engine`, version as `Version`, row_format as `Row_format`, `ROWS` as `Rows`, avg_row_length as `Avg_row_length`, data_length as `Data_length`, max_data_length as `Max_data_length`, index_length as `Index_length`, data_free as `Data_free`, auto_increment as `Auto_increment`, create_time as `Create_time`, update_time as `Update_time`, check_time as `Check_time`, collation as `Collation`, checksum as `Checksum`, create_options as `Create_options`, `COMMENT` as `Comment` FROM %s.%s WHERE database_id = %ld ORDER BY name COLLATE utf8mb4_bin ASC", - R"(SELECT "TABLE_NAME" AS "NAME", "ENGINE", "VERSION", "ROW_FORMAT", "ROWS" AS "ROWS", "AVG_ROW_LENGTH", "DATA_LENGTH", "MAX_DATA_LENGTH", "INDEX_LENGTH", "DATA_FREE", "AUTO_INCREMENT", "CREATE_TIME", "UPDATE_TIME", "CHECK_TIME", "COLLATION", "CHECKSUM", "CREATE_OPTIONS", "COMMENT" AS "COMMENT" FROM %s.%s WHERE DATABASE_ID = %ld ORDER BY NAME COLLATE UTF8MB4_BIN ASC)", + "SELECT table_name AS `Name`, engine as `Engine`, version as `Version`, row_format as `Row_format`, `ROWS` as `Rows`, avg_row_length as `Avg_row_length`, data_length as `Data_length`, max_data_length as `Max_data_length`, index_length as `Index_length`, data_free as `Data_free`, auto_increment as `Auto_increment`, create_time as `Create_time`, update_time as `Update_time`, check_time as `Check_time`, collation as `Collation`, checksum as `Checksum`, create_options as `Create_options`, `COMMENT` as `Comment` FROM (%s) WHERE database_id = %ld ORDER BY name COLLATE utf8mb4_bin ASC", + R"(SELECT "TABLE_NAME" AS "NAME", "ENGINE", "VERSION", "ROW_FORMAT", "ROWS" AS "ROWS", "AVG_ROW_LENGTH", "DATA_LENGTH", "MAX_DATA_LENGTH", "INDEX_LENGTH", "DATA_FREE", "AUTO_INCREMENT", "CREATE_TIME", "UPDATE_TIME", "CHECK_TIME", "COLLATION", "CHECKSUM", "CREATE_OPTIONS", "COMMENT" AS "COMMENT" FROM (%s) WHERE DATABASE_ID = %ld ORDER BY NAME COLLATE UTF8MB4_BIN ASC)", "name"); DEFINE_SHOW_CLAUSE_SET(SHOW_PROCEDURE_STATUS, NULL, diff --git a/src/sql/resolver/cmd/ob_show_resolver.h b/src/sql/resolver/cmd/ob_show_resolver.h index 8c242492ec..be45192ec7 100644 --- a/src/sql/resolver/cmd/ob_show_resolver.h +++ b/src/sql/resolver/cmd/ob_show_resolver.h @@ -149,6 +149,7 @@ struct ObShowResolver::ObShowSqlSet DECLARE_SHOW_CLAUSE_SET(SHOW_CREATE_PROCEDURE); DECLARE_SHOW_CLAUSE_SET(SHOW_CREATE_FUNCTION); DECLARE_SHOW_CLAUSE_SET(SHOW_RECYCLEBIN); + DECLARE_SHOW_CLAUSE_SET(SHOW_PROFILE); DECLARE_SHOW_CLAUSE_SET(SHOW_SYS_RECYCLEBIN); DECLARE_SHOW_CLAUSE_SET(SHOW_TRIGGERS); DECLARE_SHOW_CLAUSE_SET(SHOW_RESTORE_PREVIEW); diff --git a/src/sql/resolver/cmd/ob_variable_set_resolver.cpp b/src/sql/resolver/cmd/ob_variable_set_resolver.cpp index 05a1226d78..da52b02500 100644 --- a/src/sql/resolver/cmd/ob_variable_set_resolver.cpp +++ b/src/sql/resolver/cmd/ob_variable_set_resolver.cpp @@ -59,16 +59,21 @@ int ObVariableSetResolver::resolve(const ParseNode &parse_tree) { int ret = OB_SUCCESS; ObVariableSetStmt *variable_set_stmt = NULL; + bool check_var_name_length = false; if (OB_UNLIKELY(T_VARIABLE_SET != parse_tree.type_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("parse_tree.type_ must be T_VARIABLE_SET", K(ret), K(parse_tree.type_)); - } else if (OB_ISNULL(session_info_) || OB_ISNULL(allocator_) || OB_ISNULL(schema_checker_)) { + } else if (OB_ISNULL(session_info_) || OB_ISNULL(allocator_) || OB_ISNULL(schema_checker_) || + OB_ISNULL(params_.query_ctx_)) { ret = OB_ERR_UNEXPECTED; LOG_ERROR("session_info_ or allocator_ is NULL", K(ret), K(session_info_), K(allocator_), - K(schema_checker_)); + K(schema_checker_), K(params_.query_ctx_)); } else if (OB_ISNULL(variable_set_stmt = create_stmt())) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_ERROR("create variable set stmt failed", K(ret)); + } else if (OB_FAIL(session_info_->check_feature_enable(ObCompatFeatureType::VAR_NAME_LENGTH, + check_var_name_length))) { + LOG_WARN("failed to check feature enable", K(ret)); } else { stmt_ = variable_set_stmt; variable_set_stmt->set_actual_tenant_id(session_info_->get_effective_tenant_id()); @@ -205,13 +210,21 @@ int ObVariableSetResolver::resolve(const ParseNode &parse_tree) } } } else { - // use WARN_ON_FAIL cast_mode if set user_variable - const stmt::StmtType session_ori_stmt_type = session_info_->get_stmt_type(); - session_info_->set_stmt_type(stmt::T_SELECT); - if (OB_FAIL(resolve_value_expr(*set_node->children_[1], var_node.value_expr_))) { - LOG_WARN("failed to resolve value expr", K(ret)); + if (lib::is_mysql_mode() && check_var_name_length) { + if (OB_FAIL(ObResolverUtils::check_user_variable_length(var_node.variable_name_.ptr(), + var_node.variable_name_.length()))) { + LOG_WARN("check user variable length fail", K(ret)); + } + } + if (OB_SUCC(ret)) { + // use WARN_ON_FAIL cast_mode if set user_variable + const stmt::StmtType session_ori_stmt_type = session_info_->get_stmt_type(); + session_info_->set_stmt_type(stmt::T_SELECT); + if (OB_FAIL(resolve_value_expr(*set_node->children_[1], var_node.value_expr_))) { + LOG_WARN("failed to resolve value expr", K(ret)); + } + session_info_->set_stmt_type(session_ori_stmt_type); } - session_info_->set_stmt_type(session_ori_stmt_type); } if (OB_SUCC(ret)) { if (OB_NOT_NULL(var_node.value_expr_) && var_node.value_expr_->has_flag(CNT_AGG)) { diff --git a/src/sql/resolver/dcl/ob_alter_user_profile_resolver.cpp b/src/sql/resolver/dcl/ob_alter_user_profile_resolver.cpp index 69b7b860d8..c34bffeff6 100644 --- a/src/sql/resolver/dcl/ob_alter_user_profile_resolver.cpp +++ b/src/sql/resolver/dcl/ob_alter_user_profile_resolver.cpp @@ -20,6 +20,7 @@ #include "share/ob_rpc_struct.h" #include "lib/encrypt/ob_encrypted_helper.h" #include "sql/engine/ob_exec_context.h" +#include "sql/optimizer/ob_optimizer_util.h" using namespace oceanbase::sql; using namespace oceanbase::common; using oceanbase::share::schema::ObUserInfo; @@ -72,9 +73,30 @@ int ObAlterUserProfileResolver::resolve_set_role(const ParseNode &parse_tree) arg.tenant_id_ = params_.session_info_->get_effective_tenant_id(); stmt->set_set_role_flag(ObAlterUserProfileStmt::SET_ROLE); + ObSEArray role_id_array = user_info->get_role_id_array(); + if (params_.session_info_->get_proxy_user_id() != OB_INVALID_ID) { + for (int64_t i = 0; OB_SUCC(ret) && i < user_info->get_proxied_user_info_cnt(); i++) { + const ObProxyInfo *proxy_info = user_info->get_proxied_user_info_by_idx(i); + if (OB_ISNULL(proxy_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (proxy_info->user_id_ == params_.session_info_->get_proxy_user_id()) { + ObArray res_role_id_array; + ObArray res_role_id_option_array; + if (OB_FAIL(ObSQLUtils::get_proxy_can_activate_role(user_info->get_role_id_array(), + user_info->get_role_id_option_array(), + *proxy_info, + res_role_id_array, + res_role_id_option_array))) { + LOG_WARN("get proxy can activate role failed", K(ret)); + } else { + OZ (role_id_array.assign(res_role_id_array)); + } + } + } + } /* 1. resolve default role */ - OZ (resolve_default_role_clause(parse_tree.children_[0], arg, - user_info->get_role_id_array(), false)); + OZ (resolve_default_role_clause(parse_tree.children_[0], arg, role_id_array, false)); } } diff --git a/src/sql/resolver/dcl/ob_alter_user_proxy_resolver.cpp b/src/sql/resolver/dcl/ob_alter_user_proxy_resolver.cpp new file mode 100644 index 0000000000..fa9997f29e --- /dev/null +++ b/src/sql/resolver/dcl/ob_alter_user_proxy_resolver.cpp @@ -0,0 +1,261 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#define USING_LOG_PREFIX SQL_RESV + +#include "sql/resolver/dcl/ob_alter_user_proxy_resolver.h" + +#include "share/schema/ob_schema_struct.h" +#include "sql/session/ob_sql_session_info.h" +#include "sql/resolver/dcl/ob_grant_resolver.h" +#include "share/ob_rpc_struct.h" +#include "lib/encrypt/ob_encrypted_helper.h" +using namespace oceanbase::sql; +using namespace oceanbase::common; +using oceanbase::share::schema::ObUserInfo; + +ObAlterUserProxyResolver::ObAlterUserProxyResolver(ObResolverParams ¶ms) + : ObDCLResolver(params) +{ +} + +ObAlterUserProxyResolver::~ObAlterUserProxyResolver() +{ +} + +int ObAlterUserProxyResolver::resolve(const ParseNode &parse_tree) +{ + int ret = OB_SUCCESS; + ParseNode *client_user = NULL; + ParseNode *proxy_user = NULL; + ParseNode *with_role = NULL; + ParseNode *type_node = NULL; + ObAlterUserProxyStmt *alter_user_proxy_stmt = NULL; + uint64_t tenant_data_version = 0; + if (OB_ISNULL(params_.session_info_) || OB_ISNULL(params_.schema_checker_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("not init", K(ret)); + } else if (OB_UNLIKELY(parse_tree.type_ != T_ALTER_USER_PROXY)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected stmt type", K(ret), K(parse_tree.type_)); + } else if (OB_UNLIKELY(parse_tree.num_child_ != 4)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected stmt children", K(ret), K(parse_tree.num_child_)); + } else if (OB_FAIL(GET_MIN_DATA_VERSION(params_.session_info_->get_effective_tenant_id(), tenant_data_version))) { + LOG_WARN("get tenant data version failed", K(ret)); + } else if (!ObSQLUtils::is_data_version_ge_423_or_432(tenant_data_version)) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "alter user grant connect through is not supported when data version is below 4.2.3 or 4.3.2"); + } else if (OB_ISNULL(client_user = parse_tree.children_[0]) + || OB_ISNULL(proxy_user = parse_tree.children_[1]) + || OB_ISNULL(with_role = parse_tree.children_[2]) + || OB_ISNULL(type_node = parse_tree.children_[3])) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null error", K(ret)); + } else if (OB_UNLIKELY(with_role->type_ != T_DEFAULT_ROLE)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected type error", K(ret)); + } else if (OB_UNLIKELY(client_user->type_ != T_USERS + || proxy_user->type_ != T_USERS + || client_user->num_child_ <= 0 + || proxy_user->num_child_ <= 0)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_ISNULL(alter_user_proxy_stmt = create_stmt())) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("Failed to create stmt", K(ret)); + } else { + uint64_t tenant_id = params_.session_info_->get_effective_tenant_id(); + bool is_grant = type_node->value_ == 1 ? false : true; + alter_user_proxy_stmt->set_tenant_id(tenant_id); + alter_user_proxy_stmt->set_is_grant(is_grant); + ObArray client_user_infos; + for (int64_t i = 0; OB_SUCC(ret) && i < client_user->num_child_; i++) { + ObString user_name; + ObString user_host; + ParseNode *user = client_user->children_[i]; + if (OB_ISNULL(user) || OB_UNLIKELY(user->num_child_ != 2)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (NULL == user->children_[1]) { + user_host = ObString(OB_DEFAULT_HOST_NAME); + } else { + user_host = ObString(user->children_[1]->str_len_, user->children_[1]->str_value_); + } + if (OB_SUCC(ret)) { + user_name = ObString(user->children_[0]->str_len_, user->children_[0]->str_value_); + } + const ObUserInfo *client_user_info = NULL; + if (OB_SUCC(ret)) { + if (0 == user_name.case_compare(OB_ORA_SYS_USER_NAME)) { + if (params_.session_info_->get_user_id() != OB_ORA_SYS_USER_ID) { + ret = OB_ERR_NO_SYS_PRIVILEGE; + LOG_WARN("no sys privilege", K(ret)); + } else { + ret = OB_NOT_SUPPORTED; + LOG_WARN("proxy user act as client sys is not supported", K(ret)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "proxy user act as client 'SYS'"); + } + } else if (OB_FAIL(params_.schema_checker_->get_user_info(tenant_id, user_name, user_host, client_user_info))) { + LOG_WARN("get user info failed", K(ret), K(user_name), K(user_host)); + } else if (OB_UNLIKELY(client_user_info->is_role())) { + ret = ER_NO_SUCH_USER; + LOG_WARN("user not existed", K(ret)); + } else if (OB_FAIL(alter_user_proxy_stmt->add_client_user_id(client_user_info->get_user_id()))) { + LOG_WARN("add client user id failed", K(ret)); + } else if (OB_FAIL(client_user_infos.push_back(client_user_info))) { + LOG_WARN("push back failed", K(ret)); + } else if (OB_FAIL(alter_user_proxy_stmt->get_ddl_arg().based_schema_object_infos_. + push_back(ObBasedSchemaObjectInfo( + client_user_info->get_user_id(), + USER_SCHEMA, + client_user_info->get_schema_version())))) { + LOG_WARN("push back failed", K(ret)); + } + } + } + for (int64_t i = 0; OB_SUCC(ret) && i < proxy_user->num_child_; i++) { + ObString user_name; + ObString user_host; + ParseNode *user = proxy_user->children_[i]; + if (OB_ISNULL(user) || OB_UNLIKELY(user->num_child_ != 2)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (NULL == user->children_[1]) { + user_host = ObString(OB_DEFAULT_HOST_NAME); + } else { + user_host = ObString(user->children_[1]->str_len_, user->children_[1]->str_value_); + } + if (OB_SUCC(ret)) { + user_name = ObString(user->children_[0]->str_len_, user->children_[0]->str_value_); + } + const ObUserInfo *proxy_user_info = NULL; + if (OB_SUCC(ret)) { + if (0 == user_name.case_compare(OB_ORA_SYS_USER_NAME)) { + if (params_.session_info_->get_user_id() != OB_ORA_SYS_USER_ID) { + ret = OB_ERR_NO_SYS_PRIVILEGE; + LOG_WARN("no sys privilege", K(ret)); + } else { + ret = OB_NOT_SUPPORTED; + LOG_WARN("proxy user act as client sys is not supported", K(ret)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "proxy user act as client 'SYS'"); + } + } else if (OB_FAIL(params_.schema_checker_->get_user_info(tenant_id, user_name, user_host, proxy_user_info))) { + LOG_WARN("get user info failed", K(ret), K(user_name), K(user_host)); + } else if (OB_UNLIKELY(proxy_user_info->is_role())) { + ret = ER_NO_SUCH_USER; + LOG_WARN("user not existed", K(ret)); + } else if (OB_FAIL(alter_user_proxy_stmt->add_proxy_user_id(proxy_user_info->get_user_id()))) { + LOG_WARN("add client user id failed", K(ret)); + } else if (OB_FAIL(alter_user_proxy_stmt->get_ddl_arg().based_schema_object_infos_. + push_back(ObBasedSchemaObjectInfo( + proxy_user_info->get_user_id(), + USER_SCHEMA, + proxy_user_info->get_schema_version())))) { + LOG_WARN("push back failed", K(ret)); + } + } + } + + for (int64_t i = 0; OB_SUCC(ret) && i < alter_user_proxy_stmt->get_proxy_user_id().count(); i++) { + for (int64_t j = i + 1; OB_SUCC(ret) && j < alter_user_proxy_stmt->get_proxy_user_id().count(); j++) { + if (alter_user_proxy_stmt->get_proxy_user_id().at(i) == alter_user_proxy_stmt->get_proxy_user_id().at(j)) { + ret = OB_ERR_DUPLICATE_USERNAME_IN_LIST; + LOG_WARN("duplicate name in list", K(ret)); + } + } + } + + for (int64_t i = 0; OB_SUCC(ret) && i < alter_user_proxy_stmt->get_client_user_id().count(); i++) { + for (int64_t j = i + 1; OB_SUCC(ret) && j < alter_user_proxy_stmt->get_client_user_id().count(); j++) { + if (alter_user_proxy_stmt->get_client_user_id().at(i) == alter_user_proxy_stmt->get_client_user_id().at(j)) { + ret = OB_ERR_DUPLICATE_USERNAME_IN_LIST; + LOG_WARN("duplicate name in list", K(ret)); + } + } + } + + if (OB_SUCC(ret)) { + if (with_role->value_ == 1) { + alter_user_proxy_stmt->set_flags(PROXY_USER_MAY_ACTIVATE_ROLE); + } else if (with_role->value_ == 2) { + alter_user_proxy_stmt->set_flags(PROXY_USER_ROLE_CAN_NOT_BE_ACTIVATED); + } else if (with_role->value_ == 3) { + alter_user_proxy_stmt->set_flags(PROXY_USER_NO_ROLES_BE_ACTIVATED); + } else if (with_role->value_ == 4) { + alter_user_proxy_stmt->set_flags(PROXY_USER_ACTIVATE_ALL_ROLES); + } + + if (with_role->value_ == 1 || with_role->value_ == 2) { + ParseNode *role_list = NULL; + if (OB_UNLIKELY(with_role->num_child_ != 1) || OB_ISNULL(role_list = with_role->children_[0])) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } + for (int i = 0; OB_SUCC(ret) && i < role_list->num_child_; ++i) { + ParseNode *role = role_list->children_[i]; + if (OB_ISNULL(role)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("role node is null", K(ret)); + } else { + ObString role_name; + role_name.assign_ptr(const_cast(role->str_value_), + static_cast(role->str_len_)); + // check roles exists + const ObUserInfo *role_info = NULL; + if (OB_FAIL(params_.schema_checker_->get_user_info(tenant_id, + role_name, + // role has fixed host_name '%' + ObString::make_string(OB_DEFAULT_HOST_NAME), + role_info))) { + LOG_WARN("get user role info failed", K(ret)); + } else if (OB_ISNULL(role_info) || OB_UNLIKELY(!role_info->is_role())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } else if (OB_FAIL(alter_user_proxy_stmt->add_role_id(role_info->get_user_id()))) { + LOG_WARN("push back failed", K(ret)); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < client_user_infos.count(); i++) { + bool found = false; + const ObUserInfo *user_info = client_user_infos.at(i); + if (OB_ISNULL(user_info)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error", K(ret)); + } + for (int64_t j = 0; OB_SUCC(ret) && !found && j < user_info->get_role_id_array().count(); j++) { + if (role_info->get_user_id() == user_info->get_role_id_array().at(j)) { + found = true; + } + } + if (OB_SUCC(ret) && !found) { + ret = OB_ERR_ROLE_NOT_GRANTED_OR_DOES_NOT_EXIST; + LOG_WARN("role not granted", K(ret)); + LOG_USER_ERROR(OB_ERR_ROLE_NOT_GRANTED_OR_DOES_NOT_EXIST, + role_info->get_user_name_str().length(), role_info->get_user_name_str().ptr()); + } + } + } + } + } + } + } + } + if (OB_SUCC(ret) && ObSchemaChecker::is_ora_priv_check()) { + OZ (schema_checker_->check_ora_ddl_priv( + params_.session_info_->get_effective_tenant_id(), + params_.session_info_->get_priv_user_id(), + ObString(""), + stmt::T_ALTER_USER_PROXY, + params_.session_info_->get_enable_role_array())); + } + return ret; +} diff --git a/src/sql/resolver/dcl/ob_alter_user_proxy_resolver.h b/src/sql/resolver/dcl/ob_alter_user_proxy_resolver.h new file mode 100644 index 0000000000..4d4bf27700 --- /dev/null +++ b/src/sql/resolver/dcl/ob_alter_user_proxy_resolver.h @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OB_ALTER_USER_PROXY_RESOLVER_H +#define OB_ALTER_USER_PROXY_RESOLVER_H + +#include "sql/resolver/dcl/ob_alter_user_proxy_stmt.h" +#include "sql/resolver/dcl/ob_dcl_resolver.h" +#include "share/ob_rpc_struct.h" + +namespace oceanbase +{ +namespace sql +{ +class ObAlterUserProxyResolver: public ObDCLResolver +{ +public: + explicit ObAlterUserProxyResolver(ObResolverParams ¶ms); + virtual ~ObAlterUserProxyResolver(); + virtual int resolve(const ParseNode &parse_tree); +private: + // disallow copy + DISALLOW_COPY_AND_ASSIGN(ObAlterUserProxyResolver); +}; + +} // end namespace sql +} // end namespace oceanbase + + + +#endif // OB_ALTER_USER_PROFILE_RESOLVER_H diff --git a/src/sql/resolver/dcl/ob_alter_user_proxy_stmt.cpp b/src/sql/resolver/dcl/ob_alter_user_proxy_stmt.cpp new file mode 100644 index 0000000000..7c35292a71 --- /dev/null +++ b/src/sql/resolver/dcl/ob_alter_user_proxy_stmt.cpp @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2021 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#include "sql/resolver/dcl/ob_alter_user_proxy_stmt.h" +using namespace oceanbase::common; +using namespace oceanbase::sql; +ObAlterUserProxyStmt::ObAlterUserProxyStmt(common::ObIAllocator *name_pool) + : ObDDLStmt(name_pool, stmt::T_ALTER_USER_PROXY), arg_() +{ +} + +ObAlterUserProxyStmt::ObAlterUserProxyStmt() + : ObDDLStmt(NULL, stmt::T_ALTER_USER_PROXY), arg_() +{ +} + +ObAlterUserProxyStmt::~ObAlterUserProxyStmt() +{ +} diff --git a/src/sql/resolver/dcl/ob_alter_user_proxy_stmt.h b/src/sql/resolver/dcl/ob_alter_user_proxy_stmt.h new file mode 100644 index 0000000000..7c6bdb43bf --- /dev/null +++ b/src/sql/resolver/dcl/ob_alter_user_proxy_stmt.h @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2022 OceanBase + * OceanBase CE is licensed under Mulan PubL v2. + * You can use this software according to the terms and conditions of the Mulan PubL v2. + * You may obtain a copy of Mulan PubL v2 at: + * http://license.coscl.org.cn/MulanPubL-2.0 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PubL v2 for more details. + */ + +#ifndef OB_ALTER_USER_PROXY_STMT_H_ +#define OB_ALTER_USER_PROXY_STMT_H_ +#include "sql/resolver/ddl/ob_ddl_stmt.h" +#include "lib/string/ob_strings.h" +namespace oceanbase +{ +namespace sql +{ + + +class ObAlterUserProxyStmt: public ObDDLStmt +{ +public: + ObAlterUserProxyStmt(); + explicit ObAlterUserProxyStmt(common::ObIAllocator *name_pool); + virtual ~ObAlterUserProxyStmt(); + obrpc::ObAlterUserProxyArg &get_ddl_arg() { return arg_; } + inline int set_proxy_user_id(const ObIArray& proxy_id_array) { return arg_.proxy_user_ids_.assign(proxy_id_array); } + inline int set_client_user_id(const ObIArray& client_id_array) { return arg_.client_user_ids_.assign(client_id_array); } + inline void set_tenant_id(const uint64_t tenant_id) { arg_.tenant_id_ = tenant_id; } + inline void set_flags(const uint64_t flags) { arg_.flags_ = flags; } + inline void add_flag(const uint64_t flags) { arg_.flags_ |= flags; } + inline void set_is_grant(const uint64_t is_grant) { arg_.is_grant_ = is_grant; } + + int add_proxy_user_id(const uint64_t proxy_user_id) { return arg_.proxy_user_ids_.push_back(proxy_user_id); } + int add_client_user_id(const uint64_t client_user_id) { return arg_.client_user_ids_.push_back(client_user_id); } + int set_role_id_array(const ObIArray& role_id_array) { return arg_.role_ids_.assign(role_id_array); } + int add_role_id(const uint64_t role_id) { return arg_.role_ids_.push_back(role_id); } + + inline const ObIArray& get_proxy_user_id() const { return arg_.proxy_user_ids_; } + inline const ObIArray& get_client_user_id() const { return arg_.client_user_ids_; } + inline int get_tenant_id() const { return arg_.tenant_id_; } + inline int get_flags() const { return arg_.flags_; } + inline const ObIArray& get_role_ids() const { return arg_.role_ids_; } + + // function members + TO_STRING_KV(K_(stmt_type), K_(arg)); +private: + // data members + obrpc::ObAlterUserProxyArg arg_; +private: + DISALLOW_COPY_AND_ASSIGN(ObAlterUserProxyStmt); +}; +} // end namespace sql +} // end namespace oceanbase + +#endif //OB_ALTER_USER_PROXY_STMT_H_ diff --git a/src/sql/resolver/dcl/ob_drop_user_resolver.cpp b/src/sql/resolver/dcl/ob_drop_user_resolver.cpp index aa1935ff6f..8439705ed9 100644 --- a/src/sql/resolver/dcl/ob_drop_user_resolver.cpp +++ b/src/sql/resolver/dcl/ob_drop_user_resolver.cpp @@ -34,6 +34,7 @@ int ObDropUserResolver::resolve(const ParseNode &parse_tree) ParseNode * top_node = const_cast(&parse_tree); ParseNode * user_list_node = nullptr; ObDropUserStmt *drop_user_stmt = NULL; + bool if_exists = false; CHECK_COMPATIBILITY_MODE(params_.session_info_); if (OB_ISNULL(params_.session_info_)) { ret = OB_NOT_INIT; @@ -81,8 +82,15 @@ int ObDropUserResolver::resolve(const ParseNode &parse_tree) } else if (T_DROP_USER != top_node->type_ || top_node->num_child_ <= 0) { ret = OB_ERR_UNEXPECTED; SQL_RESV_LOG(WARN, "invalid argument", K(ret), K(top_node->type_), K(top_node->num_child_)); + } else if (OB_ISNULL(user_list_node = top_node->children_[0])) { + ret = OB_ERR_USER_EMPTY; + SQL_RESV_LOG(WARN, "user_list_node is null", K(ret)); + } else if(OB_UNLIKELY(top_node->num_child_ < 2)) { + ret = OB_ERR_UNEXPECTED; + SQL_RESV_LOG(WARN, "drop user top node num child shoud be 2", K(ret), K(top_node->type_), K(top_node->num_child_)); } else { - user_list_node = top_node; + ParseNode* if_exists_node = top_node->children_[1]; + if_exists = if_exists_node != NULL; } } if (OB_SUCC(ret)) { @@ -108,6 +116,7 @@ int ObDropUserResolver::resolve(const ParseNode &parse_tree) } if (OB_SUCC(ret)) { drop_user_stmt->set_tenant_id(tenant_id); + drop_user_stmt->set_if_exists(if_exists); } } } diff --git a/src/sql/resolver/dcl/ob_drop_user_stmt.h b/src/sql/resolver/dcl/ob_drop_user_stmt.h index a733235a78..b1dccab8c5 100644 --- a/src/sql/resolver/dcl/ob_drop_user_stmt.h +++ b/src/sql/resolver/dcl/ob_drop_user_stmt.h @@ -28,7 +28,9 @@ public: virtual ~ObDropUserStmt(); int add_user(const common::ObString &user_name, const common::ObString &host_name); void set_tenant_id(const uint64_t tenant_id) { tenant_id_ = tenant_id; }; + void set_if_exists(const bool if_exists) { if_exists_ = if_exists; } const common::ObStrings *get_users() const { return &users_; }; + bool get_if_exists() const { return if_exists_; }; uint64_t get_tenant_id() const { return tenant_id_; }; virtual bool cause_implicit_commit() const { return true; } virtual obrpc::ObDDLArg &get_ddl_arg() { return drop_user_arg_; } @@ -37,6 +39,7 @@ private: // data members common::ObStrings users_;//user1,host1; usr2,host2;... uint64_t tenant_id_; + bool if_exists_; obrpc::ObDropUserArg drop_user_arg_; // 用于返回exec_tenant_id_ private: DISALLOW_COPY_AND_ASSIGN(ObDropUserStmt); diff --git a/src/sql/resolver/dcl/ob_grant_resolver.cpp b/src/sql/resolver/dcl/ob_grant_resolver.cpp index 2431e0c5e7..2fe64906fd 100644 --- a/src/sql/resolver/dcl/ob_grant_resolver.cpp +++ b/src/sql/resolver/dcl/ob_grant_resolver.cpp @@ -1407,13 +1407,20 @@ int ObGrantResolver::resolve_mysql(const ParseNode &parse_tree) LOG_WARN("Resolve priv set error", K(ret)); } else if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, compat_version))) { LOG_WARN("fail to get data version", K(tenant_id)); - } else if (!sql::ObSQLUtils::is_data_version_ge_422_or_431(compat_version)) { - if ((priv_set & OB_PRIV_EXECUTE) != 0 || - (priv_set & OB_PRIV_ALTER_ROUTINE) != 0 || - (priv_set & OB_PRIV_CREATE_ROUTINE) != 0) { - ret = OB_NOT_SUPPORTED; - LOG_WARN("grammar is not support when MIN_DATA_VERSION is below DATA_VERSION_4_3_1_0 or 4_2_2_0", K(ret)); - } + } else if (!sql::ObSQLUtils::is_data_version_ge_422_or_431(compat_version) + && ((priv_set & OB_PRIV_EXECUTE) != 0 || + (priv_set & OB_PRIV_ALTER_ROUTINE) != 0 || + (priv_set & OB_PRIV_CREATE_ROUTINE) != 0)) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("grammar is not support when MIN_DATA_VERSION is below DATA_VERSION_4_3_1_0 or 4_2_2_0", K(ret)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "grant execute/alter routine/create routine privilege"); + } else if (!sql::ObSQLUtils::is_data_version_ge_423_or_432(compat_version) + && ((priv_set & OB_PRIV_CREATE_TABLESPACE) != 0 || + (priv_set & OB_PRIV_SHUTDOWN) != 0 || + (priv_set & OB_PRIV_RELOAD) != 0)) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("grammar is not support when MIN_DATA_VERSION is below DATA_VERSION_4_2_3_0 or 4_3_2_0", K(ret)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "grant create tablespace/shutdown/reload privilege"); } if (OB_FAIL(ret)) { } else { diff --git a/src/sql/resolver/dcl/ob_revoke_resolver.cpp b/src/sql/resolver/dcl/ob_revoke_resolver.cpp index 3885b058f9..fbe39633ac 100644 --- a/src/sql/resolver/dcl/ob_revoke_resolver.cpp +++ b/src/sql/resolver/dcl/ob_revoke_resolver.cpp @@ -459,13 +459,20 @@ int ObRevokeResolver::resolve_mysql(const ParseNode &parse_tree) LOG_WARN("Resolve priv set error", K(ret)); } else if (OB_FAIL(GET_MIN_DATA_VERSION(tenant_id, compat_version))) { LOG_WARN("fail to get data version", K(tenant_id)); - } else if (!sql::ObSQLUtils::is_data_version_ge_422_or_431(compat_version)) { - if ((priv_set & OB_PRIV_EXECUTE) != 0 || - (priv_set & OB_PRIV_ALTER_ROUTINE) != 0 || - (priv_set & OB_PRIV_CREATE_ROUTINE) != 0) { - ret = OB_NOT_SUPPORTED; - LOG_WARN("grammar is not support when MIN_DATA_VERSION is below DATA_VERSION_4_3_1_0 or 4_2_2_0", K(ret)); - } + } else if (!sql::ObSQLUtils::is_data_version_ge_422_or_431(compat_version) + && ((priv_set & OB_PRIV_EXECUTE) != 0 || + (priv_set & OB_PRIV_ALTER_ROUTINE) != 0 || + (priv_set & OB_PRIV_CREATE_ROUTINE) != 0)) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("grammar is not support when MIN_DATA_VERSION is below DATA_VERSION_4_3_1_0 or 4_2_2_0", K(ret)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "revoke execute/alter routine/create routine privilege"); + } else if (!sql::ObSQLUtils::is_data_version_ge_423_or_432(compat_version) + && ((priv_set & OB_PRIV_CREATE_TABLESPACE) != 0 || + (priv_set & OB_PRIV_SHUTDOWN) != 0 || + (priv_set & OB_PRIV_RELOAD) != 0)) { + ret = OB_NOT_SUPPORTED; + LOG_WARN("grammar is not support when MIN_DATA_VERSION is below DATA_VERSION_4_2_3_0 or 4_3_2_0", K(ret)); + LOG_USER_ERROR(OB_NOT_SUPPORTED, "revoke create tablespace/shutdown/reload privilege"); } if (OB_FAIL(ret)) { } else { diff --git a/src/sql/resolver/ddl/ob_alter_outline_stmt.h b/src/sql/resolver/ddl/ob_alter_outline_stmt.h index 6a5acab4aa..ff9d95970f 100644 --- a/src/sql/resolver/ddl/ob_alter_outline_stmt.h +++ b/src/sql/resolver/ddl/ob_alter_outline_stmt.h @@ -42,6 +42,7 @@ public: common::ObString &get_target_sql() { return alter_outline_arg_.alter_outline_info_.get_outline_target_str(); } ObStmt *&get_outline_stmt() { return outline_stmt_; } obrpc::ObAlterOutlineArg &get_alter_outline_arg() { return alter_outline_arg_; } + const obrpc::ObAlterOutlineArg &get_alter_outline_arg() const { return alter_outline_arg_; } virtual obrpc::ObDDLArg &get_ddl_arg() { return alter_outline_arg_; } TO_STRING_KV(K_(alter_outline_arg), K_(outline_stmt)); diff --git a/src/sql/resolver/ddl/ob_alter_table_resolver.cpp b/src/sql/resolver/ddl/ob_alter_table_resolver.cpp index c42ce001ff..6bf3ce5f74 100644 --- a/src/sql/resolver/ddl/ob_alter_table_resolver.cpp +++ b/src/sql/resolver/ddl/ob_alter_table_resolver.cpp @@ -1560,13 +1560,14 @@ int ObAlterTableResolver::resolve_index_column_list(const ParseNode &node, //column_order if (OB_FAIL(ret)) { //do nothing - } else if (sort_column_node->children_[2] && - T_SORT_DESC == sort_column_node->children_[2]->type_) { + } else if (is_oracle_mode() && sort_column_node->children_[2] + && T_SORT_DESC == sort_column_node->children_[2]->type_) { // sort_item.order_type_ = common::ObOrderType::DESC; ret = OB_NOT_SUPPORTED; LOG_WARN("not support desc index now", K(ret)); LOG_USER_ERROR(OB_NOT_SUPPORTED, "Desc index"); } else { + //兼容mysql5.7, 降序索引不生效且不报错 sort_item.order_type_ = common::ObOrderType::ASC; } diff --git a/src/sql/resolver/ddl/ob_create_index_resolver.cpp b/src/sql/resolver/ddl/ob_create_index_resolver.cpp index a1277d7757..b5ba0b3f54 100644 --- a/src/sql/resolver/ddl/ob_create_index_resolver.cpp +++ b/src/sql/resolver/ddl/ob_create_index_resolver.cpp @@ -222,13 +222,14 @@ int ObCreateIndexResolver::resolve_index_column_node( // 索引排序方式 if (OB_FAIL(ret)) { - } else if (col_node->children_[2] - && col_node->children_[2]->type_ == T_SORT_DESC) { + } else if (is_oracle_mode() && col_node->children_[2] + && col_node->children_[2]->type_ == T_SORT_DESC) { // sort_item.order_type_ = common::ObOrderType::DESC; ret = OB_NOT_SUPPORTED; LOG_WARN("not support desc index now", K(ret)); LOG_USER_ERROR(OB_NOT_SUPPORTED, "create desc index"); } else { + //兼容mysql5.7, 降序索引不生效且不报错 sort_item.order_type_ = common::ObOrderType::ASC; } @@ -365,12 +366,9 @@ int ObCreateIndexResolver::resolve_index_option_node( // block_size if (OB_SUCC(ret)) { - if(T_TABLE_OPTION_LIST != index_option_node->type_ || index_option_node->num_child_ < 1) { + if(T_TABLE_OPTION_LIST != index_option_node->type_) { ret = OB_ERR_UNEXPECTED; SQL_RESV_LOG(WARN, "invalid parse node", K(ret)); - } else if (OB_ISNULL(index_option_node->children_)) { - ret = OB_ERR_UNEXPECTED; - SQL_RESV_LOG(WARN, "node children is null", K(index_option_node->children_), K(ret)); } else { int64_t num = index_option_node->num_child_; for (int64_t i = 0; OB_SUCC(ret) && i < num; ++i) { diff --git a/src/sql/resolver/ddl/ob_create_outline_stmt.h b/src/sql/resolver/ddl/ob_create_outline_stmt.h index e498558488..684de63426 100644 --- a/src/sql/resolver/ddl/ob_create_outline_stmt.h +++ b/src/sql/resolver/ddl/ob_create_outline_stmt.h @@ -46,6 +46,7 @@ public: const common::ObString &get_target_sql() const { return create_outline_arg_.outline_info_.get_outline_target_str(); } common::ObString &get_target_sql() { return create_outline_arg_.outline_info_.get_outline_target_str(); } obrpc::ObCreateOutlineArg &get_create_outline_arg() { return create_outline_arg_; } + const obrpc::ObCreateOutlineArg &get_create_outline_arg() const { return create_outline_arg_; } common::ObString &get_hint() { return hint_; } common::ObString &get_sql_id() { return sql_id_; } virtual obrpc::ObDDLArg &get_ddl_arg() { return create_outline_arg_; } diff --git a/src/sql/resolver/ddl/ob_create_profile_resolver.cpp b/src/sql/resolver/ddl/ob_create_profile_resolver.cpp index 4f4849bd33..4cce3a95db 100644 --- a/src/sql/resolver/ddl/ob_create_profile_resolver.cpp +++ b/src/sql/resolver/ddl/ob_create_profile_resolver.cpp @@ -123,6 +123,7 @@ int ObUserProfileResolver::resolve(const ParseNode &parse_tree) stmt::StmtType stmt_type = stmt::T_NONE; CHECK_COMPATIBILITY_MODE(session_info_); ObUserProfileStmt *create_profile_stmt = NULL; + ObCompatType compat_type = COMPAT_MYSQL57; if (2 != parse_tree.num_child_) { ret = OB_INVALID_ARGUMENT; LOG_WARN("expect 2 child, create profile type", @@ -133,6 +134,8 @@ int ObUserProfileResolver::resolve(const ParseNode &parse_tree) || OB_ISNULL(schema_checker_->get_schema_guard())) { ret = OB_NOT_INIT; LOG_WARN("params not init", K(ret), KP(params_.allocator_), KP(params_.session_info_)); + } else if (OB_FAIL(params_.session_info_->get_compatibility_control(compat_type))) { + LOG_WARN("failed to get compat type", K(ret)); } else if (!lib::is_oracle_mode()) { ret = OB_NOT_SUPPORTED; LOG_USER_ERROR(OB_NOT_SUPPORTED, "create profile except Oracle mode"); @@ -253,7 +256,8 @@ int ObUserProfileResolver::resolve(const ParseNode &parse_tree) dtc_params.nls_collation_, NULL, params_.session_info_->get_sql_mode(), - false))) {// FIXME: enable decimal int + false, // FIXME: enable decimal int + compat_type))) { LOG_WARN("fail to resolve const", K(ret)); } else if (OB_FAIL(fill_arg(param_type->value_, numeric_value, arg))) { LOG_WARN("fail to fill arg", K(ret), K(param_type->value_)); diff --git a/src/sql/resolver/ddl/ob_create_table_resolver.cpp b/src/sql/resolver/ddl/ob_create_table_resolver.cpp index 0d94c530f1..1e7ceaf2e7 100644 --- a/src/sql/resolver/ddl/ob_create_table_resolver.cpp +++ b/src/sql/resolver/ddl/ob_create_table_resolver.cpp @@ -448,7 +448,8 @@ int ObCreateTableResolver::resolve(const ParseNode &parse_tree) CHECK_COMPATIBILITY_MODE(session_info_); if (OB_ISNULL(create_table_node) || T_CREATE_TABLE != create_table_node->type_ - || (CREATE_TABLE_NUM_CHILD != create_table_node->num_child_ && CREATE_TABLE_AS_SEL_NUM_CHILD != create_table_node->num_child_) + || (CREATE_TABLE_NUM_CHILD != create_table_node->num_child_ && + CREATE_TABLE_AS_SEL_NUM_CHILD != create_table_node->num_child_) || OB_ISNULL(create_table_node->children_)) { ret = OB_INVALID_ARGUMENT; SQL_RESV_LOG(WARN, "invalid argument.", K(ret)); @@ -617,6 +618,8 @@ int ObCreateTableResolver::resolve(const ParseNode &parse_tree) } else { if (OB_FAIL(resolve_table_elements(table_element_list_node, index_node_position_list, foreign_key_node_position_list, table_level_constraint_list, RESOLVE_COL_ONLY))) { SQL_RESV_LOG(WARN, "resolve table elements col failed", K(ret)); + } else if (OB_FAIL(resolve_insert_mode(&parse_tree))) { + SQL_RESV_LOG(WARN, "resolve ignore_or_replace flag failed", K(ret)); } else if (OB_FAIL(resolve_table_elements_from_select(parse_tree))) { SQL_RESV_LOG(WARN, "resolve table elements from select failed", K(ret)); } else if (OB_FAIL(resolve_table_elements(table_element_list_node, index_node_position_list, foreign_key_node_position_list, table_level_constraint_list, RESOLVE_NON_COL))) { @@ -821,7 +824,7 @@ int ObCreateTableResolver::resolve(const ParseNode &parse_tree) } } if (OB_SUCC(ret) && is_create_as_sel) { - if (OB_FAIL(resolve_hints(create_table_node->children_[CREATE_TABLE_AS_SEL_NUM_CHILD - 1], + if (OB_FAIL(resolve_hints(create_table_node->children_[9], *create_table_stmt, create_table_stmt->get_create_table_arg().schema_))) { LOG_WARN("fail to resolve hint", K(ret)); @@ -1851,6 +1854,36 @@ int ObCreateTableResolver::set_nullable_for_cta_column(ObSelectStmt *select_stmt } return ret; } +int ObCreateTableResolver::resolve_insert_mode(const ParseNode *parse_tree) +{ + int ret = OB_SUCCESS; + ParseNode *flag_node = NULL; + ObCreateTableStmt *create_table_stmt = static_cast(stmt_); + ObExecContext *exec_ctx = NULL; + ObSqlCtx *sql_ctx = NULL; + bool is_support = GET_MIN_CLUSTER_VERSION() >= CLUSTER_VERSION_4_3_2_0; + if (OB_ISNULL(parse_tree) || + OB_ISNULL(create_table_stmt) || + OB_ISNULL(params_.query_ctx_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected error",K(parse_tree), K(create_table_stmt), K(session_info_), K(exec_ctx), K(sql_ctx), K(ret)); + } else if (lib::is_oracle_mode() || !is_support) { + create_table_stmt->set_insert_mode(0); + } else if (parse_tree->num_child_ != CREATE_TABLE_AS_SEL_NUM_CHILD){ + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected child_num",K(parse_tree->num_child_), K(ret)); + } else { + flag_node = parse_tree->children_[10]; + if (flag_node == NULL) { + create_table_stmt->set_insert_mode(0); + } else if (flag_node->type_ == T_IGNORE) { + create_table_stmt->set_insert_mode(1); + } else if (flag_node->type_ == T_REPLACE) { + create_table_stmt->set_insert_mode(2); + } + } + return ret; +} //解析column_list和查询, 然后根据建表语句中的opt_column_list(可能无)和查询, 设置新表的列名和数据类型 int ObCreateTableResolver::resolve_table_elements_from_select(const ParseNode &parse_tree) @@ -1858,7 +1891,7 @@ int ObCreateTableResolver::resolve_table_elements_from_select(const ParseNode &p int ret = OB_SUCCESS; ObCreateTableStmt *create_table_stmt = static_cast(stmt_); const ObTableSchema *base_table_schema = NULL; - ParseNode *sub_sel_node = parse_tree.children_[CREATE_TABLE_AS_SEL_NUM_CHILD - 2]; + ParseNode *sub_sel_node = parse_tree.children_[8]; ObSelectStmt *select_stmt = NULL; ObSelectResolver select_resolver(params_); select_resolver.params_.is_from_create_table_ = true; @@ -2754,13 +2787,14 @@ int ObCreateTableResolver::resolve_index_node(const ParseNode *node) } if (OB_SUCC(ret)) { //column_order - if (NULL != index_column_node->children_[2] + if (is_oracle_mode && NULL != index_column_node->children_[2] && T_SORT_DESC == index_column_node->children_[2]->type_) { // sort_item.order_type_ = common::ObOrderType::DESC; ret = OB_NOT_SUPPORTED; LOG_WARN("not support desc index now", K(ret)); LOG_USER_ERROR(OB_NOT_SUPPORTED, "desc index"); } else { + //兼容mysql5.7, 降序索引不生效且不报错 sort_item.order_type_ = common::ObOrderType::ASC; } ObColumnNameHashWrapper column_key(column_name); @@ -3071,7 +3105,7 @@ int ObCreateTableResolver::resolve_index_name( int ObCreateTableResolver::resolve_table_charset_info(const ParseNode *node) { int ret = OB_SUCCESS; if (NULL != node) { - if (T_TABLE_OPTION_LIST != node->type_ || node->num_child_ < 1 || OB_ISNULL(node->children_)) { + if (T_TABLE_OPTION_LIST != node->type_) { ret = OB_ERR_UNEXPECTED; SQL_RESV_LOG(WARN, "invalid argument.", K(ret)); } else { diff --git a/src/sql/resolver/ddl/ob_create_table_resolver.h b/src/sql/resolver/ddl/ob_create_table_resolver.h index 1ddb51082b..221ecfe8c8 100644 --- a/src/sql/resolver/ddl/ob_create_table_resolver.h +++ b/src/sql/resolver/ddl/ob_create_table_resolver.h @@ -85,6 +85,7 @@ private: common::ObArray &foreign_key_node_position_list, common::ObArray &table_level_constraint_list, const int resolve_rule); + int resolve_insert_mode(const ParseNode *parse_tree); int resolve_table_elements_from_select(const ParseNode &parse_tree); int set_temp_table_info(share::schema::ObTableSchema &table_schema, ParseNode *commit_option_node); diff --git a/src/sql/resolver/ddl/ob_create_table_stmt.cpp b/src/sql/resolver/ddl/ob_create_table_stmt.cpp index 710a7dd3e5..2d08e62e0e 100644 --- a/src/sql/resolver/ddl/ob_create_table_stmt.cpp +++ b/src/sql/resolver/ddl/ob_create_table_stmt.cpp @@ -31,7 +31,8 @@ ObCreateTableStmt::ObCreateTableStmt(ObIAllocator *name_pool) is_view_stmt_(false), view_need_privs_(), sub_select_stmt_(NULL), - view_define_(NULL) + view_define_(NULL), + insert_mode_(0) { } @@ -41,7 +42,8 @@ ObCreateTableStmt::ObCreateTableStmt() is_view_stmt_(false), view_need_privs_(), sub_select_stmt_(NULL), - view_define_(NULL) + view_define_(NULL), + insert_mode_(0) { } diff --git a/src/sql/resolver/ddl/ob_create_table_stmt.h b/src/sql/resolver/ddl/ob_create_table_stmt.h index d01b39b8e0..72ef9c5532 100644 --- a/src/sql/resolver/ddl/ob_create_table_stmt.h +++ b/src/sql/resolver/ddl/ob_create_table_stmt.h @@ -78,6 +78,9 @@ public: const obrpc::ObSequenceDDLArg &get_sequence_ddl_arg() const; void set_masked_sql(const common::ObString &masked_sql) { masked_sql_ = masked_sql; } common::ObString get_masked_sql() const { return masked_sql_; } + void set_insert_mode(uint64_t mode) { insert_mode_ = mode; } + uint64_t get_insert_mode() const { return insert_mode_; } + ObTableType get_table_type() const { return create_table_arg_.schema_.get_table_type(); } INHERIT_TO_STRING_KV("ObTableStmt", ObTableStmt, K_(stmt_type), K_(create_table_arg), K_(index_arg_list)); private: @@ -100,6 +103,17 @@ private: protected: ObSelectStmt *sub_select_stmt_; //create table ... as select... ObSelectStmt *view_define_; + /** + * @brief insert_mode_ + *example: create table t1 [ignore/replace] select * from t2 + *1. create table ctas_t1(xxx); + *2. construct inner sql + * a. insert_mode_ = 0 -> normal insert -> insert into ctas_t1 select * from t2 + * b. insert_mode_ = 1 -> insert ignore -> insert ignore into ctas_t1 select * from t2 + * c. insert_mode_ = 2 -> replace into -> replace into ctas_t1 select * from t2 + 3. rename ctas_t1 as t1 + */ + uint64_t insert_mode_; }; inline obrpc::ObCreateTableArg &ObCreateTableStmt::get_create_table_arg() diff --git a/src/sql/resolver/ddl/ob_ddl_resolver.cpp b/src/sql/resolver/ddl/ob_ddl_resolver.cpp index 6fc0bdf110..77bf74544b 100644 --- a/src/sql/resolver/ddl/ob_ddl_resolver.cpp +++ b/src/sql/resolver/ddl/ob_ddl_resolver.cpp @@ -937,12 +937,12 @@ int ObDDLResolver::resolve_table_id_pre(ParseNode *node) if (NULL != node) { ParseNode *option_node = NULL; int32_t num = 0; - if(T_TABLE_OPTION_LIST != node->type_ || node->num_child_ < 1) { + if(T_TABLE_OPTION_LIST != node->type_) { ret = OB_ERR_UNEXPECTED; SQL_RESV_LOG(WARN, "invalid parse node", K(ret)); - } else if (OB_ISNULL(node->children_) || OB_ISNULL(session_info_)) { + } else if (OB_ISNULL(session_info_)) { ret = OB_ERR_UNEXPECTED; - SQL_RESV_LOG(WARN, "node children or session_info_ is null", K(node->children_), K(session_info_), K(ret)); + SQL_RESV_LOG(WARN, "session_info_ is null", K(session_info_), K(ret)); } else { num = node->num_child_; } @@ -968,12 +968,12 @@ int ObDDLResolver::resolve_table_options(ParseNode *node, bool is_index_option) if (NULL != node) { ParseNode *option_node = NULL; int32_t num = 0; - if(T_TABLE_OPTION_LIST != node->type_ || node->num_child_ < 1) { + if(T_TABLE_OPTION_LIST != node->type_) { ret = OB_ERR_UNEXPECTED; SQL_RESV_LOG(WARN, "invalid parse node", KR(ret), K(node->type_), K(node->num_child_)); - } else if (OB_ISNULL(node->children_) || OB_ISNULL(session_info_)) { + } else if ( OB_ISNULL(session_info_)) { ret = OB_ERR_UNEXPECTED; - SQL_RESV_LOG(WARN, "node children or session_info_ is null", K(node->children_), K(session_info_), K(ret)); + SQL_RESV_LOG(WARN, "session_info_ is null", K(session_info_), K(ret)); } else { num = node->num_child_; } diff --git a/src/sql/resolver/ddl/ob_ddl_resolver.h b/src/sql/resolver/ddl/ob_ddl_resolver.h index dab120bedc..a71a723a4f 100644 --- a/src/sql/resolver/ddl/ob_ddl_resolver.h +++ b/src/sql/resolver/ddl/ob_ddl_resolver.h @@ -50,7 +50,7 @@ struct PartitionInfo enum NUMCHILD { CREATE_TABLE_NUM_CHILD = 8, - CREATE_TABLE_AS_SEL_NUM_CHILD = 10, + CREATE_TABLE_AS_SEL_NUM_CHILD = 11, COLUMN_DEFINITION_NUM_CHILD = 4, COLUMN_DEF_NUM_CHILD = 3, INDEX_NUM_CHILD = 5, diff --git a/src/sql/resolver/ddl/ob_drop_outline_stmt.h b/src/sql/resolver/ddl/ob_drop_outline_stmt.h index 9038edd1a9..18ccee614d 100644 --- a/src/sql/resolver/ddl/ob_drop_outline_stmt.h +++ b/src/sql/resolver/ddl/ob_drop_outline_stmt.h @@ -31,6 +31,7 @@ public: void set_outline_name(const common::ObString &outline_name) { drop_outline_arg_.outline_name_ = outline_name; } void set_tenant_id(uint64_t tenant_id) { drop_outline_arg_.tenant_id_ = tenant_id; } obrpc::ObDropOutlineArg &get_drop_outline_arg() { return drop_outline_arg_; } + const obrpc::ObDropOutlineArg &get_drop_outline_arg() const { return drop_outline_arg_; } virtual obrpc::ObDDLArg &get_ddl_arg() { return drop_outline_arg_; } TO_STRING_KV(K_(drop_outline_arg)); private: diff --git a/src/sql/resolver/ddl/ob_sequence_stmt.h b/src/sql/resolver/ddl/ob_sequence_stmt.h index 78d08b2bcd..c3c00ea8d9 100644 --- a/src/sql/resolver/ddl/ob_sequence_stmt.h +++ b/src/sql/resolver/ddl/ob_sequence_stmt.h @@ -72,6 +72,7 @@ public: share::ObSequenceOption &option() { return arg_.option(); } virtual obrpc::ObDDLArg &get_ddl_arg() { return arg_; } obrpc::ObSequenceDDLArg &get_arg() { return arg_; } + const obrpc::ObSequenceDDLArg &get_arg() const { return arg_; } private: obrpc::ObSequenceDDLArg arg_; DISALLOW_COPY_AND_ASSIGN(ObSequenceDDLStmt); diff --git a/src/sql/resolver/ddl/ob_use_database_resolver.cpp b/src/sql/resolver/ddl/ob_use_database_resolver.cpp index ce87abe352..e29d503847 100644 --- a/src/sql/resolver/ddl/ob_use_database_resolver.cpp +++ b/src/sql/resolver/ddl/ob_use_database_resolver.cpp @@ -82,10 +82,11 @@ int ObUseDatabaseResolver::resolve(const ParseNode &parse_tree) use_database_stmt->set_db_name(db_name); uint64_t tenant_id = session_info_->get_effective_tenant_id(); share::schema::ObSessionPrivInfo session_priv; - session_info_->get_session_priv_info(session_priv); uint64_t database_id = OB_INVALID_ID; const share::schema::ObDatabaseSchema *db_schema = NULL; - if (OB_FAIL(schema_checker_->get_database_id(tenant_id, db_name, database_id))) { + if (OB_FAIL(session_info_->get_session_priv_info(session_priv))) { + LOG_WARN("faile to get session priv info", K(ret)); + } else if (OB_FAIL(schema_checker_->get_database_id(tenant_id, db_name, database_id))) { LOG_USER_ERROR(OB_ERR_BAD_DATABASE, db_name.length(), db_name.ptr()); LOG_WARN("invalid database name. ", K(db_name)); } else if (OB_FAIL(schema_checker_->check_db_access(session_priv, db_name))) { diff --git a/src/sql/resolver/dml/ob_delete_resolver.cpp b/src/sql/resolver/dml/ob_delete_resolver.cpp index 0152fa2be7..9be93ec1ce 100644 --- a/src/sql/resolver/dml/ob_delete_resolver.cpp +++ b/src/sql/resolver/dml/ob_delete_resolver.cpp @@ -60,7 +60,11 @@ int ObDeleteResolver::resolve(const ParseNode &parse_tree) // create the delete stmt ObDeleteStmt *delete_stmt = NULL; bool is_multi_table_delete = false; - if (NULL == (delete_stmt = create_stmt())) { + bool disable_limit_offset = false; + if (OB_ISNULL(session_info_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_ISNULL(delete_stmt = create_stmt())) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_ERROR("create delete stmt failed", K(ret)); } else if (OB_UNLIKELY(parse_tree.type_ != T_DELETE) || OB_UNLIKELY(parse_tree.num_child_ < 2)) { @@ -69,6 +73,9 @@ int ObDeleteResolver::resolve(const ParseNode &parse_tree) } else if (OB_ISNULL(parse_tree.children_[TABLE])) { ret = OB_ERR_UNEXPECTED; LOG_WARN("table_node is null", K(ret)); + } else if (OB_FAIL(session_info_->check_feature_enable(ObCompatFeatureType::UPD_LIMIT_OFFSET, + disable_limit_offset))) { + LOG_WARN("failed to check feature enable", K(ret)); } else { stmt_ = delete_stmt; if (OB_FAIL(resolve_outline_data_hints())) { @@ -106,7 +113,7 @@ int ObDeleteResolver::resolve(const ParseNode &parse_tree) LOG_WARN("resolve delete where clause failed", K(ret)); } else if (OB_FAIL(resolve_order_clause(parse_tree.children_[ORDER_BY]))) { LOG_WARN("resolve delete order clause failed", K(ret)); - } else if (OB_FAIL(resolve_limit_clause(parse_tree.children_[LIMIT]))) { + } else if (OB_FAIL(resolve_limit_clause(parse_tree.children_[LIMIT], disable_limit_offset))) { LOG_WARN("resolve delete limit clause failed", K(ret)); } else if (OB_FAIL(resolve_hints(parse_tree.children_[HINT]))) { LOG_WARN("resolve hints failed", K(ret)); diff --git a/src/sql/resolver/dml/ob_dml_resolver.cpp b/src/sql/resolver/dml/ob_dml_resolver.cpp index ae360dc2e3..125347f256 100755 --- a/src/sql/resolver/dml/ob_dml_resolver.cpp +++ b/src/sql/resolver/dml/ob_dml_resolver.cpp @@ -1699,6 +1699,7 @@ int ObDMLResolver::resolve_sql_expr(const ParseNode &node, ObRawExpr *&expr, ctx.is_for_dbms_sql_ = params_.is_dbms_sql_; ctx.view_ref_id_ = view_ref_id_; ctx.is_variable_allowed_ = !(is_mysql_mode() && params_.is_from_create_view_); + ctx.is_from_show_resolver_ = params_.is_from_show_resolver_; ctx.is_expanding_view_ = params_.is_expanding_view_; ctx.is_in_system_view_ = params_.is_in_sys_view_; ObRawExprResolverImpl expr_resolver(ctx); @@ -4668,11 +4669,10 @@ int ObDMLResolver::resolve_joined_table_item(const ParseNode &parse_node, Joined JoinedTable *cur_table = NULL; JoinedTable *child_table = NULL; TableItem *table_item = NULL; - ObSelectStmt *select_stmt = static_cast(stmt_); bool reverse_parse = false; - if (OB_ISNULL(select_stmt) || OB_UNLIKELY(parse_node.type_ != T_JOINED_TABLE)) { + if (OB_ISNULL(stmt_) || OB_UNLIKELY(parse_node.type_ != T_JOINED_TABLE)) { ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid argument", K(select_stmt), K_(parse_node.type)); + LOG_WARN("invalid argument", K_(stmt), K_(parse_node.type)); } else if (OB_FAIL(alloc_joined_table_item(cur_table))) { LOG_WARN("create joined table item failed", K(ret)); } else if (parse_node.children_[0]->type_ == T_JOIN_RIGHT && @@ -4766,6 +4766,10 @@ int ObDMLResolver::resolve_joined_table_item(const ParseNode &parse_node, Joined case T_JOIN_INNER: cur_table->joined_type_ = INNER_JOIN; break; + case T_STRAIGHT_JOIN: + cur_table->joined_type_ = INNER_JOIN; + cur_table->is_straight_join_ = true; + break; default: /* won't be here */ ret = OB_ERR_UNEXPECTED; @@ -5029,6 +5033,8 @@ int ObDMLResolver::resolve_str_const(const ParseNode &parse_tree, ObString& path ObCollationType nation_collation = OB_NOT_NULL(session_info_) ? session_info_->get_nls_collation_nation() : CS_TYPE_INVALID; ObCollationType collation_connection = CS_TYPE_INVALID; ObCharsetType character_set_connection = CHARSET_INVALID; + bool enable_decimal_int = false; + ObCompatType compat_type = COMPAT_MYSQL57; if (OB_ISNULL(params_.expr_factory_) || OB_ISNULL(params_.session_info_)) { ret = OB_NOT_INIT; LOG_WARN("resolve status is invalid", K_(params_.expr_factory), K_(params_.session_info)); @@ -5042,6 +5048,10 @@ int ObDMLResolver::resolve_str_const(const ParseNode &parse_tree, ObString& path } else if (lib::is_oracle_mode() && OB_FAIL( session_info->get_sys_variable(share::SYS_VAR_COLLATION_SERVER, server_collation))) { LOG_WARN("get sys variables failed", K(ret)); + } else if (OB_FAIL(session_info->get_compatibility_control(compat_type))) { + LOG_WARN("failed to get compat type", K(ret)); + } else if (OB_FAIL(ObSQLUtils::check_enable_decimalint(session_info, enable_decimal_int))) { + LOG_WARN("fail to check enable decimal int", K(ret)); } else if (OB_FAIL(ObResolverUtils::resolve_const(&parse_tree, // stmt_type is only used in oracle mode lib::is_oracle_mode() ? session_info->get_stmt_type() : stmt::T_NONE, @@ -5053,6 +5063,8 @@ int ObDMLResolver::resolve_str_const(const ParseNode &parse_tree, ObString& path static_cast(server_collation), &parents_expr_info, session_info->get_sql_mode(), + enable_decimal_int, + compat_type, nullptr != params_.secondary_namespace_))) { LOG_WARN("failed to resolve const", K(ret)); } else if (OB_ISNULL(buf = static_cast(allocator_->alloc(val.get_string().length())))) { // deep copy str value @@ -7330,7 +7342,7 @@ int ObDMLResolver::add_all_rowkey_columns_to_stmt(const TableItem &table_item, return ret; } -int ObDMLResolver::resolve_limit_clause(const ParseNode *node) +int ObDMLResolver::resolve_limit_clause(const ParseNode *node, bool disable_offset/*= false*/) { int ret = OB_SUCCESS; if (node) { @@ -7347,8 +7359,15 @@ int ObDMLResolver::resolve_limit_clause(const ParseNode *node) } ObRawExpr* limit_count = NULL; ObRawExpr* limit_offset = NULL; + if (disable_offset && OB_NOT_NULL(offset_node)) { + ret = OB_ERR_PARSE_SQL; + int32_t str_len = static_cast(offset_node->text_len_); + int32_t line_no = 1; + LOG_WARN("can't set offset for limit clause in delete/update stmt"); + LOG_USER_ERROR(OB_ERR_PARSE_SQL, ob_errpkt_strerror(OB_ERR_PARSER_SYNTAX, false), + str_len, offset_node->raw_text_, line_no); // resolve the question mark with less value first - if (limit_node != NULL && limit_node->type_ == T_QUESTIONMARK && offset_node != NULL + } else if (limit_node != NULL && limit_node->type_ == T_QUESTIONMARK && offset_node != NULL && offset_node->type_ == T_QUESTIONMARK && limit_node->value_ > offset_node->value_) { if (OB_FAIL(ObResolverUtils::resolve_const_expr(params_, *offset_node, limit_offset, NULL)) || OB_FAIL(ObResolverUtils::resolve_const_expr(params_, *limit_node, limit_count, NULL))) { diff --git a/src/sql/resolver/dml/ob_dml_resolver.h b/src/sql/resolver/dml/ob_dml_resolver.h index 0a1e61bc04..1ebab00711 100644 --- a/src/sql/resolver/dml/ob_dml_resolver.h +++ b/src/sql/resolver/dml/ob_dml_resolver.h @@ -414,7 +414,7 @@ protected: ObIArray &and_exprs); int resolve_where_clause(const ParseNode *node); int resolve_order_clause(const ParseNode *node, bool is_for_set_query = false); - int resolve_limit_clause(const ParseNode *node); + int resolve_limit_clause(const ParseNode *node, bool disable_offset = false); int resolve_into_clause(const ParseNode *node); int resolve_hints(const ParseNode *node); int resolve_outline_data_hints(); diff --git a/src/sql/resolver/dml/ob_dml_stmt.cpp b/src/sql/resolver/dml/ob_dml_stmt.cpp index 043a1bbf52..c2b6ab5826 100644 --- a/src/sql/resolver/dml/ob_dml_stmt.cpp +++ b/src/sql/resolver/dml/ob_dml_stmt.cpp @@ -130,7 +130,8 @@ bool JoinedTable::same_as(const JoinedTable &other) const } else { if (table_id_ != other.table_id_ || joined_type_ != other.joined_type_ - || join_conditions_.count() != other.join_conditions_.count()) { + || join_conditions_.count() != other.join_conditions_.count() + || is_straight_join_ != other.is_straight_join_) { bret = false; } else if (left_table_->type_ != other.left_table_->type_ || right_table_->type_ != other.right_table_->type_) { @@ -312,6 +313,7 @@ int JoinedTable::deep_copy(ObIAllocator &allocator, { int ret = OB_SUCCESS; joined_type_ = other.joined_type_; + is_straight_join_ = other.is_straight_join_; if (OB_ISNULL(other.left_table_) || OB_ISNULL(other.right_table_)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("null table item", K(other.left_table_), K(other.right_table_), K(ret)); @@ -4669,6 +4671,41 @@ bool ObDMLStmt::is_hierarchical_query() const : false; } +int ObDMLStmt::is_hierarchical_for_update(bool &is_hsfu) const +{ + int ret = OB_SUCCESS; + is_hsfu = false; + const TableItem *table = NULL; + const ObSelectStmt *select_stmt = NULL; + const ObSelectStmt *ref_view = NULL; + if (!is_select_stmt()) { + is_hsfu = false; + } else if (OB_ISNULL(select_stmt = static_cast(this))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("select stmt is NULL", K(ret)); + } else if (!select_stmt->has_for_update()) { + is_hsfu = false; + } else if (is_hierarchical_query()) { + is_hsfu = true; + } else if (get_table_size() != 1) { + is_hsfu = false; + } else if (OB_ISNULL(table = get_table_item(0))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table item is NULL", K(ret)); + } else if (!table->for_update_ || !table->is_generated_table()) { + is_hsfu = false; + } else if (select_stmt->get_for_update_dml_infos().count() == 0) { + // For "select * from (select c1 from t1 connect by xxx) view1 where xxx for update;" + is_hsfu = false; + } else if (OB_ISNULL(ref_view = table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("ref query is NULL", K(ret)); + } else if (ref_view->is_hierarchical_query()) { + is_hsfu = true; + } + return ret; +} + bool ObDMLStmt::is_set_stmt() const { return is_select_stmt() ? (static_cast(this)->is_set_stmt()) : false; diff --git a/src/sql/resolver/dml/ob_dml_stmt.h b/src/sql/resolver/dml/ob_dml_stmt.h index 84f7961254..365990b039 100644 --- a/src/sql/resolver/dml/ob_dml_stmt.h +++ b/src/sql/resolver/dml/ob_dml_stmt.h @@ -533,7 +533,8 @@ struct JoinedTable : public TableItem left_table_(NULL), right_table_(NULL), single_table_ids_(common::OB_MALLOC_NORMAL_BLOCK_SIZE), - join_conditions_(common::OB_MALLOC_NORMAL_BLOCK_SIZE) + join_conditions_(common::OB_MALLOC_NORMAL_BLOCK_SIZE), + is_straight_join_(false) { } @@ -545,6 +546,7 @@ struct JoinedTable : public TableItem bool is_left_join() const { return LEFT_OUTER_JOIN == joined_type_; } bool is_right_join() const { return RIGHT_OUTER_JOIN == joined_type_; } bool is_full_join() const { return FULL_OUTER_JOIN == joined_type_; } + bool is_straight_join() const { return is_inner_join() && is_straight_join_; } virtual bool has_for_update() const { return (left_table_ != NULL && left_table_->has_for_update()) @@ -557,13 +559,15 @@ struct JoinedTable : public TableItem N_JOIN_TYPE, ob_join_type_str(joined_type_), N_LEFT_TABLE, left_table_, N_RIGHT_TABLE, right_table_, - "join_condition", join_conditions_); + "join_condition", join_conditions_, + "is_straight_join", is_straight_join_); ObJoinType joined_type_; TableItem *left_table_; TableItem *right_table_; common::ObSEArray single_table_ids_; common::ObSEArray join_conditions_; + bool is_straight_join_; // In MySQL mode, mark INNER JOIN as STRAIGHT_JOIN. }; class SemiInfo @@ -696,6 +700,7 @@ public: virtual int init_stmt(TableHashAllocator &table_hash_alloc, ObWrapperAllocator &wrapper_alloc) override; bool is_hierarchical_query() const; + int is_hierarchical_for_update(bool &is_hsfu) const; int replace_relation_exprs(const common::ObIArray &other_exprs, const common::ObIArray &new_exprs); diff --git a/src/sql/resolver/dml/ob_select_resolver.cpp b/src/sql/resolver/dml/ob_select_resolver.cpp index 0c01c89384..8d178bb48e 100644 --- a/src/sql/resolver/dml/ob_select_resolver.cpp +++ b/src/sql/resolver/dml/ob_select_resolver.cpp @@ -1395,12 +1395,6 @@ int ObSelectResolver::resolve_normal_query(const ParseNode &parse_tree) } } - if (OB_SUCC(ret) && select_stmt->has_for_update() && select_stmt->is_hierarchical_query()) { - ret = OB_NOT_SUPPORTED; - LOG_WARN("for update with hierarchical not support", K(ret)); - LOG_USER_ERROR(OB_NOT_SUPPORTED, "for update with hierarchical"); - } - if (OB_SUCC(ret) && has_top_limit_) { has_top_limit_ = false; select_stmt->set_has_top_limit(NULL != parse_tree.children_[PARSE_SELECT_LIMIT]); @@ -1600,6 +1594,8 @@ int ObSelectResolver::resolve_query_options(const ParseNode *node) ret = OB_ERR_CANT_USE_OPTION_HERE; LOG_USER_ERROR(OB_ERR_CANT_USE_OPTION_HERE, "SQL_CALC_FOUND_ROWS"); } + } else if (option_node->type_ == T_STRAIGHT_JOIN) { + select_stmt->set_select_straight_join(true); } } } @@ -1878,6 +1874,9 @@ int ObSelectResolver::set_for_update_oracle(ObSelectStmt &stmt, if (OB_ISNULL(view = table->ref_query_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("view is invalid", K(ret), K(*table)); + } else if (0 == view->get_table_size()) { + // table is DUAL, does not need FOR UPDATE + table->for_update_ = false; } else if (NULL != col) { int64_t sel_id = col->get_column_id() - OB_APP_MIN_COLUMN_ID; ObRawExpr *sel_expr = NULL; @@ -2068,6 +2067,7 @@ int ObSelectResolver::resolve_field_list(const ParseNode &node) ParseNode *alias_node = NULL; bool is_bald_star = false; ObSelectStmt *select_stmt = NULL; + bool enable_modify_null_name = false; //LOG_INFO("resolve_select_1", "usec", ObSQLUtils::get_usec()); current_scope_ = T_FIELD_LIST_SCOPE; if (OB_ISNULL(session_info_) || OB_ISNULL(select_stmt = get_select_stmt())) { @@ -2106,6 +2106,17 @@ int ObSelectResolver::resolve_field_list(const ParseNode &node) LOG_WARN("Can not malloc space for alias name", K(ret)); } } + } else if (OB_FAIL(session_info_->check_feature_enable(ObCompatFeatureType::PROJECT_NULL, + enable_modify_null_name))) { + LOG_WARN("failed to check feature enable", K(ret)); + } else if (is_mysql_mode() && node.children_[i]->children_[0]->type_ == T_NULL && + enable_modify_null_name) { + // MySQL sets the alias of standalone null value("\N","null"...) to "NULL" during projection. + // Note: when null value is in a composite expression, its alias is not modified. + ObString alias_name = ObString::make_string("NULL"); + if (OB_FAIL(ob_write_string(*allocator_, alias_name, select_item.alias_name_))) { + LOG_WARN("Can not malloc space for alias name", K(ret)); + } } else { select_item.alias_name_.assign_ptr(node.children_[i]->str_value_, static_cast(node.children_[i]->str_len_)); diff --git a/src/sql/resolver/dml/ob_select_stmt.cpp b/src/sql/resolver/dml/ob_select_stmt.cpp index 37292ca164..f2e0f15c38 100644 --- a/src/sql/resolver/dml/ob_select_stmt.cpp +++ b/src/sql/resolver/dml/ob_select_stmt.cpp @@ -207,7 +207,9 @@ int ObSelectStmt::assign(const ObSelectStmt &other) } else if (OB_FAIL(sample_infos_.assign(other.sample_infos_))) { LOG_WARN("assign sample scan infos failed", K(ret)); } else if (OB_FAIL(set_query_.assign(other.set_query_))) { - LOG_WARN("assign sample scan infos failed", K(ret)); + LOG_WARN("assign set query failed", K(ret)); + } else if (OB_FAIL(for_update_dml_info_.assign(other.for_update_dml_info_))) { + LOG_WARN("assign for update dml info failed", K(ret)); } else { set_op_ = other.set_op_; is_recursive_cte_ = other.is_recursive_cte_; @@ -230,6 +232,7 @@ int ObSelectStmt::assign(const ObSelectStmt &other) has_prior_ = other.has_prior_; has_reverse_link_ = other.has_reverse_link_; is_expanded_mview_ = other.is_expanded_mview_; + is_select_straight_join_ = other.is_select_straight_join_; } return ret; } @@ -300,6 +303,11 @@ int ObSelectStmt::deep_copy_stmt_struct(ObIAllocator &allocator, other.cube_items_, cube_items_))) { LOG_WARN("deep copy cube items failed", K(ret)); + } else if (OB_FAIL(deep_copy_stmt_objects(allocator, + expr_copier, + other.for_update_dml_info_, + for_update_dml_info_))) { + LOG_WARN("deep copy for update dml info failed", K(ret)); } else { set_op_ = other.set_op_; is_recursive_cte_ = other.is_recursive_cte_; @@ -322,6 +330,7 @@ int ObSelectStmt::deep_copy_stmt_struct(ObIAllocator &allocator, has_prior_ = other.has_prior_; has_reverse_link_ = other.has_reverse_link_; is_expanded_mview_ = other.is_expanded_mview_; + is_select_straight_join_ = other.is_select_straight_join_; // copy insert into statement if (OB_SUCC(ret) && NULL != other.into_item_) { ObSelectIntoItem *temp_into_item = NULL; @@ -533,6 +542,7 @@ ObSelectStmt::ObSelectStmt() has_prior_ = false; has_reverse_link_ = false; is_expanded_mview_ = false; + is_select_straight_join_ = false; } ObSelectStmt::~ObSelectStmt() @@ -1053,6 +1063,41 @@ bool ObSelectStmt::contain_nested_aggr() const return ret; } +int ForUpdateDMLInfo::assign(const ForUpdateDMLInfo& other) +{ + int ret = OB_SUCCESS; + table_id_ = other.table_id_; + base_table_id_ = other.base_table_id_; + ref_table_id_ = other.ref_table_id_; + rowkey_cnt_ = other.rowkey_cnt_; + is_nullable_ = other.is_nullable_; + for_update_wait_us_ = other.for_update_wait_us_; + skip_locked_ = other.skip_locked_; + if (OB_FAIL(unique_column_ids_.assign(other.unique_column_ids_))) { + LOG_WARN("failed to assign", K(ret)); + } + return ret; +} + +int ForUpdateDMLInfo::deep_copy(ObIRawExprCopier &expr_copier, + const ForUpdateDMLInfo &other) +{ + int ret = OB_SUCCESS; + table_id_ = other.table_id_; + base_table_id_ = other.base_table_id_; + ref_table_id_ = other.ref_table_id_; + rowkey_cnt_ = other.rowkey_cnt_; + is_nullable_ = other.is_nullable_; + for_update_wait_us_ = other.for_update_wait_us_; + skip_locked_ = other.skip_locked_; + for (int64_t i = 0; OB_SUCC(ret) && i < other.unique_column_ids_.count(); ++i) { + if (OB_FAIL(unique_column_ids_.push_back(other.unique_column_ids_.at(i)))) { + LOG_WARN("failed to push back column ids", K(ret)); + } + } + return ret; +} + int ObGroupingSetsItem::assign(const ObGroupingSetsItem& other) { int ret = OB_SUCCESS; diff --git a/src/sql/resolver/dml/ob_select_stmt.h b/src/sql/resolver/dml/ob_select_stmt.h index a15385b90f..d62b2f1b39 100644 --- a/src/sql/resolver/dml/ob_select_stmt.h +++ b/src/sql/resolver/dml/ob_select_stmt.h @@ -243,6 +243,38 @@ struct ObGroupingSetsItem common::ObSEArray cube_items_; }; +struct ForUpdateDMLInfo +{ + ForUpdateDMLInfo() + : table_id_(OB_INVALID_ID), + base_table_id_(OB_INVALID_ID), + ref_table_id_(OB_INVALID_ID), + rowkey_cnt_(0), + is_nullable_(false), + for_update_wait_us_(-1), + skip_locked_(false) + {} + int assign(const ForUpdateDMLInfo& other); + int deep_copy(ObIRawExprCopier &expr_copier, + const ForUpdateDMLInfo &other); + TO_STRING_KV(K_(table_id), + K_(base_table_id), + K_(ref_table_id), + K_(rowkey_cnt), + K_(unique_column_ids), + K_(is_nullable), + K_(for_update_wait_us), + K_(skip_locked)); + uint64_t table_id_; // view table id + uint64_t base_table_id_; // for update base table id + uint64_t ref_table_id_; // base table ref id + int64_t rowkey_cnt_; + common::ObSEArray unique_column_ids_; + bool is_nullable_; + int64_t for_update_wait_us_; + bool skip_locked_; +}; + } namespace common @@ -649,6 +681,11 @@ public: int get_pure_set_exprs(ObIArray &pure_set_exprs) const; static ObRawExpr* get_pure_set_expr(ObRawExpr *expr); int get_all_group_by_exprs(ObIArray &group_by_exprs) const; + inline int add_for_update_dml_info(ForUpdateDMLInfo *for_update_dml_info) { return for_update_dml_info_.push_back(for_update_dml_info); } + inline const common::ObIArray& get_for_update_dml_infos() const { return for_update_dml_info_; } + inline common::ObIArray& get_for_update_dml_infos() { return for_update_dml_info_; } + void set_select_straight_join(bool flag) { is_select_straight_join_ = flag; } + bool is_select_straight_join() const { return is_select_straight_join_; } private: SetOperator set_op_; @@ -692,6 +729,9 @@ private: /* for set stmt child stmt*/ common::ObSEArray set_query_; + /* for hierarchical query with for update */ + common::ObSEArray for_update_dml_info_; + /* for show statment*/ ObShowStmtCtx show_stmt_ctx_; // view @@ -711,6 +751,8 @@ private: bool has_prior_; bool has_reverse_link_; bool is_expanded_mview_; + //denote if the query option 'STRAIGHT_JOIN' has been specified + bool is_select_straight_join_; }; } } diff --git a/src/sql/resolver/dml/ob_update_resolver.cpp b/src/sql/resolver/dml/ob_update_resolver.cpp index 47b7833e99..8cf568dc78 100644 --- a/src/sql/resolver/dml/ob_update_resolver.cpp +++ b/src/sql/resolver/dml/ob_update_resolver.cpp @@ -40,6 +40,7 @@ int ObUpdateResolver::resolve(const ParseNode &parse_tree) ObUpdateStmt *update_stmt = NULL; ObSEArray tables_assign; bool has_tg = false; + bool disable_limit_offset = false; if (T_UPDATE != parse_tree.type_ || 3 > parse_tree.num_child_ || OB_ISNULL(parse_tree.children_) @@ -50,6 +51,9 @@ int ObUpdateResolver::resolve(const ParseNode &parse_tree) } else if (OB_ISNULL(update_stmt = create_stmt())) { ret = OB_ALLOCATE_MEMORY_FAILED; LOG_ERROR("create update stmt failed"); + } else if (OB_FAIL(session_info_->check_feature_enable(ObCompatFeatureType::UPD_LIMIT_OFFSET, + disable_limit_offset))) { + LOG_WARN("failed to check feature enable", K(ret)); } else { stmt_ = update_stmt; update_stmt->set_ignore(false); @@ -156,7 +160,7 @@ int ObUpdateResolver::resolve(const ParseNode &parse_tree) LOG_WARN("failed to generate batched stmt info", K(ret)); } else if (OB_FAIL(resolve_order_clause(parse_tree.children_[ORDER_BY]))) { LOG_WARN("resolve order clause failed", K(ret)); - } else if (OB_FAIL(resolve_limit_clause(parse_tree.children_[LIMIT]))) { + } else if (OB_FAIL(resolve_limit_clause(parse_tree.children_[LIMIT], disable_limit_offset))) { LOG_WARN("resolve limit clause failed", K(ret)); } else if (OB_FAIL(resolve_hints(parse_tree.children_[HINT]))) { LOG_WARN("resolve hints failed", K(ret)); diff --git a/src/sql/resolver/expr/ob_raw_expr.h b/src/sql/resolver/expr/ob_raw_expr.h index b6232de502..308dcb798e 100644 --- a/src/sql/resolver/expr/ob_raw_expr.h +++ b/src/sql/resolver/expr/ob_raw_expr.h @@ -1648,7 +1648,8 @@ struct ObResolveContext is_variable_allowed_(true), is_expanding_view_(false), is_in_system_view_(false), - match_exprs_(NULL) + match_exprs_(NULL), + is_from_show_resolver_(false) { } @@ -1697,6 +1698,7 @@ struct ObResolveContext bool is_expanding_view_; bool is_in_system_view_; common::ObIArray *match_exprs_; + bool is_from_show_resolver_; }; typedef ObResolveContext ObExprResolveContext; diff --git a/src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp b/src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp index f0e1cfbd9c..c6546de253 100644 --- a/src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp +++ b/src/sql/resolver/expr/ob_raw_expr_resolver_impl.cpp @@ -2898,12 +2898,15 @@ int ObRawExprResolverImpl::process_datatype_or_questionmark(const ParseNode &nod ObCollationType nation_collation = OB_NOT_NULL(ctx_.session_info_) ? ctx_.session_info_->get_nls_collation_nation() : CS_TYPE_INVALID; uint64_t tenant_data_ver = 0; bool enable_decimal_int = false; - if (nullptr == session_info) { + ObCompatType compat_type = COMPAT_MYSQL57; + if (OB_ISNULL(session_info)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("session info is null", K(ret)); } else if (lib::is_oracle_mode() && OB_FAIL( session_info->get_sys_variable(share::SYS_VAR_COLLATION_SERVER, server_collation))) { LOG_WARN("get sys variables failed", K(ret)); + } else if (OB_FAIL(session_info->get_compatibility_control(compat_type))) { + LOG_WARN("failed to get compat type", K(ret)); } else if (OB_FAIL(ObSQLUtils::check_enable_decimalint(session_info, enable_decimal_int))) { LOG_WARN("fail to check enable decimal int", K(ret)); } else if (lib::is_oracle_mode() && ctx_.is_expanding_view_) { @@ -2924,6 +2927,7 @@ int ObRawExprResolverImpl::process_datatype_or_questionmark(const ParseNode &nod &(ctx_.parents_expr_info_), session_info->get_sql_mode(), enable_decimal_int, // FIXME: enable decimal int + compat_type, nullptr != ctx_.secondary_namespace_))) { LOG_WARN("failed to resolve const", K(ret)); } else if (OB_FAIL(ctx_.expr_factory_.create_raw_expr(lib::is_mysql_mode() && node.type_ == T_NCHAR ? @@ -8390,7 +8394,8 @@ int ObRawExprResolverImpl::check_internal_function(const ObString &name) bool is_internal = false; if (OB_FAIL(ret)) { } else if (ctx_.session_info_->is_inner() - || is_sys_view(ctx_.view_ref_id_)) { + || is_sys_view(ctx_.view_ref_id_) + || ctx_.is_from_show_resolver_) { // ignore } else if (FALSE_IT(ObExprOperatorFactory::get_internal_info_by_name(name, exist, is_internal))) { } else if (exist && is_internal) { diff --git a/src/sql/resolver/ob_resolver.cpp b/src/sql/resolver/ob_resolver.cpp index 332c8b6cd6..7fa687a5bd 100644 --- a/src/sql/resolver/ob_resolver.cpp +++ b/src/sql/resolver/ob_resolver.cpp @@ -89,6 +89,7 @@ #include "sql/resolver/dcl/ob_create_role_resolver.h" #include "sql/resolver/dcl/ob_drop_role_resolver.h" #include "sql/resolver/dcl/ob_alter_user_profile_resolver.h" +#include "sql/resolver/dcl/ob_alter_user_proxy_resolver.h" #include "sql/resolver/dcl/ob_alter_user_primary_zone_resolver.h" #include "sql/resolver/tcl/ob_start_trans_resolver.h" #include "sql/resolver/tcl/ob_end_trans_resolver.h" @@ -126,6 +127,7 @@ #include "sql/resolver/cmd/ob_drop_restore_point_resolver.h" #include "sql/resolver/cmd/ob_get_diagnostics_resolver.h" #include "sql/resolver/cmd/ob_switch_tenant_resolver.h" +#include "sql/resolver/cmd/ob_mock_resolver.h" #include "sql/resolver/dcl/ob_alter_role_resolver.h" #include "sql/resolver/dml/ob_multi_table_insert_resolver.h" #include "sql/resolver/ddl/ob_create_directory_resolver.h" @@ -419,6 +421,10 @@ int ObResolver::resolve(IsPrepared if_prepared, const ParseNode &parse_tree, ObS REGISTER_STMT_RESOLVER(FlushDagWarnings); break; } + case T_FLUSH_PRIVILEGES: { + REGISTER_STMT_RESOLVER(Mock); + break; + } case T_SWITCH_REPLICA_ROLE: { REGISTER_STMT_RESOLVER(SwitchReplicaRole); break; @@ -704,6 +710,7 @@ int ObResolver::resolve(IsPrepared if_prepared, const ParseNode &parse_tree, ObS case T_SHOW_TENANT: case T_SHOW_CREATE_TENANT: case T_SHOW_RECYCLEBIN: + case T_SHOW_PROFILE: case T_SHOW_PROCEDURE_STATUS: case T_SHOW_FUNCTION_STATUS: case T_SHOW_TRIGGERS: @@ -742,6 +749,10 @@ int ObResolver::resolve(IsPrepared if_prepared, const ParseNode &parse_tree, ObS REGISTER_STMT_RESOLVER(AlterUserProfile); break; } + case T_ALTER_USER_PROXY: { + REGISTER_STMT_RESOLVER(AlterUserProxy); + break; + } case T_ALTER_USER_PRIMARY_ZONE: { REGISTER_STMT_RESOLVER(AlterUserPrimaryZone); break; diff --git a/src/sql/resolver/ob_resolver_utils.cpp b/src/sql/resolver/ob_resolver_utils.cpp index ec281d88bd..8aad6307ea 100644 --- a/src/sql/resolver/ob_resolver_utils.cpp +++ b/src/sql/resolver/ob_resolver_utils.cpp @@ -41,6 +41,7 @@ #include "sql/parser/ob_parser_utils.h" #include "lib/json/ob_json_print_utils.h" #include "sql/engine/expr/ob_expr_unistr.h" +#include "lib/charset/ob_ctype.h" namespace oceanbase { @@ -2290,6 +2291,7 @@ stmt::StmtType ObResolverUtils::get_stmt_type_by_item_type(const ObItemType item SET_STMT_TYPE(T_SHOW_TRIGGERS); SET_STMT_TYPE(T_HELP); SET_STMT_TYPE(T_SHOW_RECYCLEBIN); + SET_STMT_TYPE(T_SHOW_PROFILE); SET_STMT_TYPE(T_SHOW_TENANT); SET_STMT_TYPE(T_SHOW_SEQUENCES); SET_STMT_TYPE(T_SHOW_STATUS); @@ -2492,6 +2494,7 @@ int ObResolverUtils::resolve_const(const ParseNode *node, ObExprInfo *parents_expr_info, const ObSQLMode sql_mode, bool enable_decimal_int_type, + const ObCompatType compat_type, bool is_from_pl /* false */) { int ret = OB_SUCCESS; @@ -3128,10 +3131,16 @@ int ObResolverUtils::resolve_const(const ParseNode *node, break; } case T_NULL: { - val.set_null(); - val.unset_result_flag(NOT_NULL_FLAG); - val.set_length(0); - val.set_param_meta(val.get_meta()); + if (OB_UNLIKELY(compat_type == COMPAT_MYSQL8 && node->value_ == 1)) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "\\N in MySQL8"); + LOG_WARN("\\N is not supprted in MySQL8", K(ret)); + } else { + val.set_null(); + val.unset_result_flag(NOT_NULL_FLAG); + val.set_length(0); + val.set_param_meta(val.get_meta()); + } break; } default: { @@ -5494,6 +5503,41 @@ int ObResolverUtils::check_comment_length( return ret; } +int ObResolverUtils::check_user_variable_length(char *str, int64_t str_len) +{ + int ret = OB_SUCCESS; + char *name = str; + char *end = str + str_len; + int name_length = 0; + bool last_char_is_space = true; + if ((NULL == str && str_len != 0)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpect null pointer", K(str), K(ret)); + } else { + const ObCharsetInfo *cs = ObCharset::get_charset(CS_TYPE_UTF8MB4_GENERAL_CI); + while (name < end) { + last_char_is_space = ObCharset::is_space(CS_TYPE_UTF8MB4_GENERAL_CI, *str); + if (use_mb(cs)) { + uint64_t char_len = ob_ismbchar(cs, str, str+cs->mbmaxlen); + if (char_len) { + name += char_len; + name_length++; + } else { + name++; + name_length++; + } + } + } + } + if (OB_SUCC(ret)) { + if (last_char_is_space || (name_length > MAX_NAME_CHAR_LEN)) { + ret = OB_ERR_ILLEGAL_USER_VAR; + LOG_USER_ERROR(OB_ERR_ILLEGAL_USER_VAR, name_length, str); + } + } + return ret; +} + int ObResolverUtils::resolve_check_constraint_expr( ObResolverParams ¶ms, const ParseNode *node, @@ -8899,9 +8943,12 @@ int ObResolverUtils::resolver_param(ObPlanCacheCtx &pc_ctx, const bool is_paramlize = false; int64_t server_collation = CS_TYPE_INVALID; obj_param.reset(); + ObCompatType compat_type = COMPAT_MYSQL57; if (OB_ISNULL(pc_param) || OB_ISNULL(raw_param = pc_param->node_)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret)); + } else if (OB_FAIL(session.get_compatibility_control(compat_type))) { + LOG_WARN("failed to get compat type", K(ret)); } else if (not_param_index.has_member(param_idx)) { /* do nothing */ is_param = false; @@ -8933,7 +8980,8 @@ int ObResolverUtils::resolver_param(ObPlanCacheCtx &pc_ctx, session.get_actual_nls_length_semantics(), static_cast(server_collation), NULL, session.get_sql_mode(), - enable_decimal_int))) { + enable_decimal_int, + compat_type))) { SQL_PC_LOG(WARN, "fail to resolve const", K(ret)); } else if (FALSE_IT(obj_param.set_raw_text_info(static_cast(raw_param->raw_sql_offset_), static_cast(raw_param->text_len_)))) { diff --git a/src/sql/resolver/ob_resolver_utils.h b/src/sql/resolver/ob_resolver_utils.h index e10f0aa1b7..ec1a8fa2be 100644 --- a/src/sql/resolver/ob_resolver_utils.h +++ b/src/sql/resolver/ob_resolver_utils.h @@ -374,6 +374,7 @@ public: ObExprInfo *parents_expr_info, const ObSQLMode mode, bool enable_decimal_int_type, + const ObCompatType compat_type, bool is_from_pl = false); static int set_string_val_charset(ObIAllocator &allocator, @@ -537,6 +538,7 @@ public: char *str, int64_t *str_len, const int64_t max_len); + static int check_user_variable_length(char *str, int64_t str_len); static int resolve_check_constraint_expr( ObResolverParams ¶ms, const ParseNode *node, diff --git a/src/sql/resolver/ob_stmt.h b/src/sql/resolver/ob_stmt.h index 4e0c57826f..6e3ea310dc 100644 --- a/src/sql/resolver/ob_stmt.h +++ b/src/sql/resolver/ob_stmt.h @@ -477,6 +477,7 @@ public: || stmt_type == stmt::T_ALTER_PROFILE || stmt_type == stmt::T_DROP_PROFILE || stmt_type == stmt::T_ALTER_USER_PROFILE + || stmt_type == stmt::T_ALTER_USER_PROXY || stmt_type == stmt::T_ALTER_USER_PRIMARY_ZONE || stmt_type == stmt::T_ALTER_USER // diff --git a/src/sql/resolver/ob_stmt_type.h b/src/sql/resolver/ob_stmt_type.h index bc9c157d82..fca76fd75e 100644 --- a/src/sql/resolver/ob_stmt_type.h +++ b/src/sql/resolver/ob_stmt_type.h @@ -133,9 +133,9 @@ OB_STMT_TYPE_DEF_UNKNOWN_AT(T_MIGRATE_UNIT, get_sys_tenant_alter_system_priv, 12 OB_STMT_TYPE_DEF_UNKNOWN_AT(T_UPGRADE_VIRTUAL_SCHEMA, get_sys_tenant_alter_system_priv, 121) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_RUN_JOB, get_sys_tenant_alter_system_priv, 122) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_EMPTY_QUERY, no_priv_needed, 123) -OB_STMT_TYPE_DEF(T_CREATE_OUTLINE, no_priv_needed, 124, ACTION_TYPE_CREATE_OUTLINE) -OB_STMT_TYPE_DEF(T_ALTER_OUTLINE, no_priv_needed, 125, ACTION_TYPE_ALTER_OUTLINE) -OB_STMT_TYPE_DEF(T_DROP_OUTLINE, no_priv_needed, 126, ACTION_TYPE_DROP_OUTLINE) +OB_STMT_TYPE_DEF(T_CREATE_OUTLINE, get_create_outline_stmt_need_privs, 124, ACTION_TYPE_CREATE_OUTLINE) +OB_STMT_TYPE_DEF(T_ALTER_OUTLINE, get_alter_outline_stmt_need_privs, 125, ACTION_TYPE_ALTER_OUTLINE) +OB_STMT_TYPE_DEF(T_DROP_OUTLINE, get_drop_outline_stmt_need_privs, 126, ACTION_TYPE_DROP_OUTLINE) // stmt type 127, 128 used by plan baseline, and is been delete OB_STMT_TYPE_DEF_UNKNOWN_AT(T_SWITCH_RS_ROLE, get_sys_tenant_alter_system_priv, 129) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_FLASHBACK_TENANT, get_flashback_tenant_stmt_need_privs, 130) @@ -171,9 +171,9 @@ OB_STMT_TYPE_DEF_UNKNOWN_AT(T_LOAD_DATA, get_load_data_stmt_need_privs, 161) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_STMT_TYPE_MAX, get_sys_tenant_super_priv, 162) OB_STMT_TYPE_DEF(T_CREATE_FUNC, no_priv_needed, 163, ACTION_TYPE_CREATE_FUNCTION) OB_STMT_TYPE_DEF(T_DROP_FUNC, no_priv_needed, 164, ACTION_TYPE_DROP_FUNCTION) -OB_STMT_TYPE_DEF(T_CREATE_SEQUENCE, no_priv_needed, 165, ACTION_TYPE_CREATE_SEQUENCE) -OB_STMT_TYPE_DEF(T_ALTER_SEQUENCE, no_priv_needed, 166, ACTION_TYPE_ALTER_SEQUENCE) -OB_STMT_TYPE_DEF(T_DROP_SEQUENCE, no_priv_needed, 167, ACTION_TYPE_DROP_SEQUENCE) +OB_STMT_TYPE_DEF(T_CREATE_SEQUENCE, get_create_sequence_stmt_need_privs, 165, ACTION_TYPE_CREATE_SEQUENCE) +OB_STMT_TYPE_DEF(T_ALTER_SEQUENCE, get_alter_sequence_stmt_need_privs, 166, ACTION_TYPE_ALTER_SEQUENCE) +OB_STMT_TYPE_DEF(T_DROP_SEQUENCE, get_drop_sequence_stmt_need_privs, 167, ACTION_TYPE_DROP_SEQUENCE) OB_STMT_TYPE_DEF(T_SET_TABLE_COMMENT, no_priv_needed, 168, ACTION_TYPE_COMMENT) OB_STMT_TYPE_DEF(T_SET_COLUMN_COMMENT, no_priv_needed, 169, ACTION_TYPE_COMMENT) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_SWITCHOVER, get_sys_tenant_super_priv, 170) @@ -192,8 +192,8 @@ OB_STMT_TYPE_DEF_UNKNOWN_AT(T_ROLLBACK_SAVEPOINT, no_priv_needed, 182) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_RELEASE_SAVEPOINT, no_priv_needed, 183) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_CREATE_KEYSTORE, no_priv_needed, 184) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_ALTER_KEYSTORE, no_priv_needed, 185) -OB_STMT_TYPE_DEF(T_CREATE_TABLESPACE, no_priv_needed, 186, ACTION_TYPE_CREATE_TABLESPACE) -OB_STMT_TYPE_DEF(T_DROP_TABLESPACE, no_priv_needed, 187, ACTION_TYPE_DROP_TABLESPACE) +OB_STMT_TYPE_DEF(T_CREATE_TABLESPACE, get_create_tablespace_priv, 186, ACTION_TYPE_CREATE_TABLESPACE) +OB_STMT_TYPE_DEF(T_DROP_TABLESPACE, get_create_tablespace_priv, 187, ACTION_TYPE_DROP_TABLESPACE) OB_STMT_TYPE_DEF(T_CREATE_TRIGGER, no_priv_needed, 188, ACTION_TYPE_CREATE_TRIGGER) OB_STMT_TYPE_DEF(T_DROP_TRIGGER, no_priv_needed, 189, ACTION_TYPE_DROP_TRIGGER) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_FLASHBACK_TABLE_TO_SCN, get_flashback_table_stmt_need_privs, 190) @@ -215,7 +215,7 @@ OB_STMT_TYPE_DEF_UNKNOWN_AT(T_BACKUP_MANAGE, get_sys_tenant_alter_system_priv, 2 OB_STMT_TYPE_DEF_UNKNOWN_AT(T_RESTORE_TENANT_2, get_sys_tenant_alter_system_priv, 206) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_REFRESH_MEMORY_STAT, get_sys_tenant_super_priv, 207) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_PHYSICAL_RESTORE_TENANT, get_sys_tenant_alter_system_priv, 208) -OB_STMT_TYPE_DEF(T_ALTER_TABLESPACE, no_priv_needed, 209, ACTION_TYPE_ALTER_TABLESPACE) +OB_STMT_TYPE_DEF(T_ALTER_TABLESPACE, get_create_tablespace_priv, 209, ACTION_TYPE_ALTER_TABLESPACE) OB_STMT_TYPE_DEF_UNKNOWN_AT(T_ADMIN_ROLLING_UPGRADE_CMD, get_sys_tenant_super_priv, 210) OB_STMT_TYPE_DEF(T_GRANT_ROLE, no_priv_needed, 211, ACTION_TYPE_GRANT_ROLE) OB_STMT_TYPE_DEF(T_REVOKE_ROLE, no_priv_needed, 212, ACTION_TYPE_REVOKE_ROLE) diff --git a/src/sql/rewrite/ob_transform_aggr_subquery.cpp b/src/sql/rewrite/ob_transform_aggr_subquery.cpp index 4cfd80fbbb..68563a80e3 100644 --- a/src/sql/rewrite/ob_transform_aggr_subquery.cpp +++ b/src/sql/rewrite/ob_transform_aggr_subquery.cpp @@ -175,6 +175,7 @@ int ObTransformAggrSubquery::transform_with_aggregation_first(ObDMLStmt *&stmt, ObSEArray exprs; const bool with_vector_assgin = true; const ObQueryHint* query_hint = nullptr; + bool is_hsfu = false; OPT_TRACE("try aggregation first"); if (OB_ISNULL(stmt) || OB_ISNULL(query_hint = stmt->get_stmt_hint().query_hint_)) { ret = OB_ERR_UNEXPECTED; @@ -183,6 +184,10 @@ int ObTransformAggrSubquery::transform_with_aggregation_first(ObDMLStmt *&stmt, LOG_WARN("invalid params", K(ret), K(stmt)); } else if (stmt->is_hierarchical_query() || stmt->is_set_stmt() || !stmt->is_sel_del_upd()) { OPT_TRACE("hierarchical/set/insert/merge query can not transform"); + } else if (OB_FAIL(stmt->is_hierarchical_for_update(is_hsfu))) { + LOG_WARN("failed to check hierarchical for update", K(ret)); + } else if (is_hsfu) { + OPT_TRACE("hierarchical for update query can not transform"); } else if (OB_FAIL(exprs.assign(stmt->get_condition_exprs()))) { LOG_WARN("failed to assign conditions", K(ret)); } else if (OB_FAIL(ObTransformUtils::get_post_join_exprs(stmt, exprs, with_vector_assgin))) { diff --git a/src/sql/rewrite/ob_transform_pre_process.cpp b/src/sql/rewrite/ob_transform_pre_process.cpp index 2986e55f0b..d6f3be9855 100644 --- a/src/sql/rewrite/ob_transform_pre_process.cpp +++ b/src/sql/rewrite/ob_transform_pre_process.cpp @@ -96,6 +96,15 @@ int ObTransformPreProcess::transform_one_stmt(common::ObIArray LOG_TRACE("succeed to flatten_condition", K(is_happened)); } } + if (OB_SUCC(ret) && is_mysql_mode()) { + if (OB_FAIL(try_gen_straight_join_leading(stmt, is_happened))) { + LOG_WARN("failed to generate straight join leading", K(ret)); + } else { + trans_happened |= is_happened; + OPT_TRACE("generate straight join leading", is_happened); + LOG_TRACE("succeed to generate straight join leading", K(is_happened), K(ret)); + } + } if (OB_SUCC(ret) && parent_stmts.empty()) { if (OB_FAIL(expand_correlated_cte(stmt, is_happened))) { LOG_WARN("failed to expand correlated cte", K(ret)); @@ -2004,6 +2013,8 @@ int ObTransformPreProcess::transform_for_hierarchical_query(ObDMLStmt *stmt, LOG_WARN("unexpect null stmt", K(ret)); } else if (OB_FAIL(create_and_mock_join_view(*hierarchical_stmt))) { LOG_WARN("failed to transform from item", K(ret)); + } else if (OB_FAIL(move_for_update_dml_info(select_stmt, hierarchical_stmt))) { + LOG_WARN("failed to pull up for update info", K(ret)); } else { trans_happened = true; } @@ -2404,6 +2415,8 @@ int ObTransformPreProcess::create_and_mock_join_view(ObSelectStmt &stmt) LOG_WARN("failed to extract shared expr", K(ret)); } else if (OB_FAIL(append_array_no_dup(select_list, shared_exprs))) { LOG_WARN("failed to append shared exprs", K(ret)); + } else if (has_for_update && OB_FAIL(add_select_item_for_update(left_view_stmt, select_list))) { + LOG_WARN("failed to add for update select item", K(ret)); } else if (OB_FAIL(ObTransformUtils::create_select_item(*ctx_->allocator_, select_list, left_view_stmt))) { @@ -2480,17 +2493,19 @@ int ObTransformPreProcess::create_and_mock_join_view(ObSelectStmt &stmt) left_view_stmt->get_start_with_exprs().reset(); } } - // 8. 如果stmt有for update标记,需要把标记打在connect by的右侧表上, - // 同时清除左侧表上的for update标记 + + // 8. adding FOR UPDATE to right table item if (OB_SUCC(ret) && has_for_update) { - for (int64_t i = 0; OB_SUCC(ret) && i < left_view_stmt->get_table_size(); ++i) { - TableItem *table = left_view_stmt->get_table_item(i); - if (OB_ISNULL(table)) { - ret = OB_ERR_UNEXPECTED; - LOG_WARN("unexpect null table item", K(ret)); - } else { - table->for_update_ = false; - } + // all rows of the CONNECT BY results will output through the right view, + // hence only create FOR UPDATE info for the right view table. + left_table_item->for_update_ = false; + right_table_item->for_update_ = true; + if (OB_FAIL(pull_up_part_exprs(&stmt, right_table_item))) { + LOG_WARN("failed to pullup part exprs", K(ret)); + } else if (OB_FAIL(create_for_update_dml_info(&stmt, right_table_item))) { + LOG_WARN("failed to create for update dml info", K(ret), KPC(right_table_item)); + } else if (OB_FAIL(clear_for_update_mark(left_table_item))) { + LOG_WARN("failed to clear for update mark", K(ret), KPC(left_table_item)); } } @@ -2579,6 +2594,378 @@ int ObTransformPreProcess::create_and_mock_join_view(ObSelectStmt &stmt) return ret; } +int ObTransformPreProcess::add_select_item_for_update(ObSelectStmt *view_stmt, ObIArray &select_list) +{ + int ret = OB_SUCCESS; + if (OB_ISNULL(view_stmt)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("stmt is null", K(ret)); + } else if (OB_UNLIKELY(view_stmt->has_distinct() || view_stmt->has_group_by())) { + // invalid usage, can not add rowkey into stmt with DISTINCT or GROUP BY. + // Oracle generates FOR UPDATE info after rewrite, so if DISTINCT can be + // removed by rewrite, we cannot achieve full compatibility. + ret = OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT; + LOG_USER_ERROR(OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < view_stmt->get_table_size(); ++i) { + TableItem *table = NULL; + ObSEArray unique_keys; + if (OB_ISNULL(table = view_stmt->get_table_item(i))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table item is null", K(ret)); + } else if (!table->for_update_) { + // do nothing + } else if (table->is_temp_table()) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "CTE used in hierarchical query with FOR UPDATE"); + LOG_WARN("CTE can not used in hierarchical query with FOR UPDATE", K(ret)); + } else if (table->is_generated_table()) { + ObSEArray sub_select_list; + ObSEArray new_select_list; + if (OB_FAIL(SMART_CALL(add_select_item_for_update(table->ref_query_, sub_select_list)))) { + LOG_WARN("failed to add select item for update", K(ret), KPC(table)); + } else if (OB_FAIL(ObTransformUtils::create_columns_for_view(ctx_, + *table, + view_stmt, + sub_select_list, + new_select_list))) { + LOG_WARN("failed to create columns for view", K(ret), KPC(table), K(sub_select_list)); + } else if (OB_FAIL(append_array_no_dup(select_list, new_select_list))) { + LOG_WARN("failed to append select list", K(ret)); + } + } else if (OB_UNLIKELY(!table->is_basic_table() || is_virtual_table(table->ref_id_))) { + // invalid usage + ret = OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT; + LOG_USER_ERROR(OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT); + } else if (OB_FAIL(ObTransformUtils::generate_unique_key_for_basic_table(ctx_, view_stmt, table, unique_keys))){ + LOG_WARN("fail to get rowkey expr", K(ret)); + } else if (OB_FAIL(append_array_no_dup(select_list, unique_keys))) { + LOG_WARN("failed to append unique key exprs", K(ret)); + } + } + } + return ret; +} + +int ObTransformPreProcess::create_for_update_dml_info(ObSelectStmt *stmt, TableItem *view_table) { + int ret = OB_SUCCESS; + ObSelectStmt *view_stmt = NULL; + if (OB_ISNULL(stmt) || OB_ISNULL(view_table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected NULL", K(ret), K(stmt), K(view_table)); + } else if (OB_ISNULL(view_stmt = view_table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("view stmt is null", K(ret), KPC(view_table)); + } + for (int64_t i = 0; OB_SUCC(ret) && i < view_stmt->get_table_size(); ++i) { + TableItem *table = NULL; + ForUpdateDMLInfo *for_update_info = NULL; + ObSEArray unique_keys; + ObSEArray column_items; + if (OB_ISNULL(table = view_stmt->get_table_item(i))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table item is null", K(ret)); + } else if (!table->for_update_) { + // do nothing + } else if (OB_UNLIKELY(table->is_temp_table())) { + ret = OB_NOT_SUPPORTED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "CTE used in hierarchical query with FOR UPDATE"); + LOG_WARN("CTE can not used in hierarchical query with FOR UPDATE", K(ret)); + } else if (table->is_generated_table()) { + if (OB_ISNULL(table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("ref query is NULL", K(ret), KPC(table)); + } else if (OB_UNLIKELY(!table->ref_query_->has_for_update())) { + if (view_stmt->is_hierarchical_query() || table->ref_query_->is_hierarchical_query()) { + // for "SELECT * FROM (SELECT * from t1 CONNECT BY xxx) v1 CONNECT BY xxx FOR UPDATE;" + ret = OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT; + LOG_WARN("nested hierarchical query can not do FOR UPDATE", K(ret)); + } else { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("ref query has no for update", K(ret), KPC(table)); + } + } else if (OB_FAIL(SMART_CALL(create_for_update_dml_info(view_stmt, table)))) { + LOG_WARN("failed to create for update dml info", K(ret), KPC(view_stmt), KPC(table)); + } else if (OB_FAIL(pull_up_for_update_dml_info(stmt, view_table))) { + LOG_WARN("failed to pull up for update dml info", K(ret)); + } else { + view_stmt->get_for_update_dml_infos().reuse(); + // clean base table for update mark, only allocate for update operator on top of + // connect by join. + table->for_update_ = false; + } + } else if (OB_UNLIKELY(!table->is_basic_table() || is_virtual_table(table->ref_id_))) { + // invalid usage + ret = OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT; + LOG_USER_ERROR(OB_ERR_FOR_UPDATE_SELECT_VIEW_CANNOT); + } else if (OB_ISNULL(for_update_info + = static_cast(ctx_->allocator_->alloc(sizeof(ForUpdateDMLInfo))))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("allocate memory failed", K(ret)); + } else if (FALSE_IT(for_update_info = new(for_update_info)ForUpdateDMLInfo())) { + } else if (OB_FAIL(ObTransformUtils::generate_unique_key_for_basic_table(ctx_, + view_stmt, + table, + unique_keys, + &for_update_info->rowkey_cnt_))) { + LOG_WARN("failed to get rowkey expr", K(ret)); + } else if (OB_FAIL(ObOptimizerUtil::is_table_on_null_side(view_stmt, + table->table_id_, + for_update_info->is_nullable_))) { + LOG_WARN("failed to check is table on null side", K(ret)); + } else if (OB_FAIL(stmt->get_column_items(view_table->table_id_, column_items))) { + LOG_WARN("failed to get column items", K(ret)); + } else { + for (int64_t j = unique_keys.count() - 1; OB_SUCC(ret) && j >= 0; --j) { + bool find = false; + for (int64_t k = 0; OB_SUCC(ret) && !find && k < column_items.count(); ++k) { + int64_t select_item_idx = -1; + if (OB_ISNULL(column_items.at(k).expr_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected NULL", K(ret), K(column_items.at(k))); + } else if (OB_FALSE_IT(select_item_idx = column_items.at(k).expr_->get_column_id() - OB_APP_MIN_COLUMN_ID)) { + } else if (select_item_idx < 0 || select_item_idx >= view_stmt->get_select_item_size()) { + // do nothing + } else if (unique_keys.at(j) == view_stmt->get_select_item(select_item_idx).expr_) { + find = true; + if (OB_FAIL(for_update_info->unique_column_ids_.push_back(column_items.at(k).column_id_))) { + LOG_WARN("failed to push back column id", K(ret)); + } + } + } + if (OB_SUCC(ret) && OB_UNLIKELY(!find)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to find column item", K(ret), KPC(unique_keys.at(j))); + } + } + if (OB_SUCC(ret)) { + // clean base table for update mark, only allocate for update operator on top of + // connect by join. + table->for_update_ = false; + // add for update dml info + for_update_info->table_id_ = view_table->table_id_; + for_update_info->base_table_id_ = table->table_id_; + for_update_info->ref_table_id_ = table->ref_id_; + for_update_info->for_update_wait_us_ = table->for_update_wait_us_; + for_update_info->skip_locked_ = table->skip_locked_; + if (OB_FAIL(stmt->add_for_update_dml_info(for_update_info))) { + LOG_WARN("failed to add for update dml info", K(ret)); + } + } + } + } + return ret; +} + +int ObTransformPreProcess::pull_up_for_update_dml_info(ObSelectStmt *upper_stmt, + TableItem *view_table) +{ + int ret = OB_SUCCESS; + ObSelectStmt *view_stmt = NULL; + if (OB_ISNULL(upper_stmt) || OB_ISNULL(view_table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected NULL", K(ret), K(upper_stmt), K(view_table)); + } else if (OB_UNLIKELY(!view_table->is_generated_table())) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table is not a generated table", K(ret), KPC(view_table)); + } else if (OB_ISNULL(view_stmt = view_table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("ref query is NULL", K(ret), KPC(view_table)); + } + + for (int64_t j = 0; OB_SUCC(ret) && j < view_stmt->get_for_update_dml_infos().count(); ++j) { + ForUpdateDMLInfo *for_update_info = NULL; + ForUpdateDMLInfo *view_for_update_info = NULL; + if (OB_ISNULL(view_for_update_info = view_stmt->get_for_update_dml_infos().at(j))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("for update dml info is null", K(ret), KPC(view_stmt)); + } else if (OB_ISNULL(for_update_info + = static_cast(ctx_->allocator_->alloc(sizeof(ForUpdateDMLInfo))))) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("allocate memory failed", K(ret)); + } else if (FALSE_IT(for_update_info = new(for_update_info)ForUpdateDMLInfo())) { + } else if (OB_FAIL(for_update_info->assign(*view_for_update_info))) { + LOG_WARN("fail to assign for update dml info", K(ret)); + } else { + for_update_info->table_id_ = view_table->table_id_; + for_update_info->unique_column_ids_.reuse(); + } + for (int64_t k = 0; OB_SUCC(ret) && k < view_for_update_info->unique_column_ids_.count(); ++k) { + bool find = false; + for (int64_t h = 0; OB_SUCC(ret) && !find && h < view_stmt->get_select_item_size(); ++h) { + SelectItem select_item = view_stmt->get_select_item(h); + const ObColumnRefRawExpr *select_expr = NULL; + if (OB_ISNULL(select_item.expr_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("select item expr is null", K(ret), K(select_item)); + } else if (!select_item.expr_->is_column_ref_expr()) { + // do nothing + } else if (OB_FALSE_IT(select_expr = static_cast(select_item.expr_))) { + } else if (select_expr->get_table_id() != view_for_update_info->table_id_ || + select_expr->get_column_id() != view_for_update_info->unique_column_ids_.at(k)) { + // do nothing + } else if (OB_FAIL(for_update_info->unique_column_ids_.push_back(h + OB_APP_MIN_COLUMN_ID))) { + LOG_WARN("failed to push column id", K(ret)); + } else { + find = true; + break; + } + } + if (OB_SUCC(ret) && OB_UNLIKELY(!find)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("failed to find column item", K(ret), K(view_for_update_info->unique_column_ids_.at(k))); + } + } + if (OB_SUCC(ret) && OB_FAIL(upper_stmt->add_for_update_dml_info(for_update_info))) { + LOG_WARN("failed to add for update dml info", K(ret)); + } + } + return ret; +} + +int ObTransformPreProcess::clear_for_update_mark(TableItem *view_table) +{ + int ret = OB_SUCCESS; + ObSelectStmt *view_stmt = NULL; + if (OB_ISNULL(view_table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected NULL", K(ret), K(view_table)); + } else if (OB_ISNULL(view_stmt = view_table->ref_query_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("view stmt is null", K(ret), KPC(view_table)); + } + for (int64_t i = 0; OB_SUCC(ret) && i < view_stmt->get_table_size(); ++i) { + TableItem *table = NULL; + if (OB_ISNULL(table = view_stmt->get_table_item(i))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table item is null", K(ret)); + } else if ((table->is_generated_table() || table->is_temp_table()) + && OB_FAIL(SMART_CALL(clear_for_update_mark(table)))) { + LOG_WARN("failed to clear for update mark", K(ret), KPC(table)); + } else { + table->for_update_ = false; + } + } + return ret; +} + +int ObTransformPreProcess::pull_up_part_exprs(ObDMLStmt *stmt, + TableItem *table) +{ + int ret = OB_SUCCESS; + if (OB_ISNULL(stmt) || OB_ISNULL(table) || OB_ISNULL(ctx_->expr_factory_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("params have NULL", K(ret)); + } else if (table->is_basic_table()) { + // skip + } else if (table->is_generated_table() || table->is_temp_table()) { + ObSelectStmt *sel_stmt = NULL; + ObSEArray view_columns; + ObSEArray base_columns; + ObRawExprCopier copier(*ctx_->expr_factory_); + if (OB_ISNULL(sel_stmt = table->ref_query_) ) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get select stmt for base table item failed", K(ret)); + } + for (int64_t i = 0; OB_SUCC(ret) && i < sel_stmt->get_table_size(); ++i) { + if (OB_FAIL(SMART_CALL(pull_up_part_exprs(sel_stmt, sel_stmt->get_table_item(i))))) { + LOG_WARN("failed to view pullup part exprs", K(ret)); + } + } + for (int64_t i = 0; OB_SUCC(ret) && i < stmt->get_column_size(); ++i) { + ColumnItem &parent_column = stmt->get_column_items().at(i); + int64_t select_item_idx = parent_column.column_id_ - OB_APP_MIN_COLUMN_ID; + const ObColumnRefRawExpr *select_expr = NULL; + if (parent_column.table_id_ != table->table_id_) { + // do nothing + } else if (select_item_idx < 0 || select_item_idx >= sel_stmt->get_select_item_size()) { + // do nothing + } else if (OB_ISNULL(sel_stmt->get_select_item(select_item_idx).expr_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("select item expr is null", K(ret), KPC(sel_stmt), K(select_item_idx)); + } else if (!sel_stmt->get_select_item(select_item_idx).expr_->is_column_ref_expr()) { + // do nothing + } else if (OB_FALSE_IT(select_expr = + static_cast(sel_stmt->get_select_item(select_item_idx).expr_))) { + } else { + for (int64_t j = 0; OB_SUCC(ret) && j < sel_stmt->get_column_size(); ++j) { + ColumnItem &child_column = sel_stmt->get_column_items().at(j); + if (child_column.table_id_ == select_expr->get_table_id() + && child_column.column_id_ == select_expr->get_column_id()) { + if (OB_FAIL(view_columns.push_back(parent_column.expr_)) || + OB_FAIL(base_columns.push_back(child_column.expr_))) { + LOG_WARN("failed to push back column expr", K(ret)); + } + } + } + } + } + if (OB_SUCC(ret) && OB_FAIL(copier.add_replaced_expr(base_columns, view_columns))) { + LOG_WARN("failed to add replace pair", K(ret)); + } + for (int64_t i = 0; OB_SUCC(ret) && i < sel_stmt->get_part_exprs().count(); ++i) { + ObDMLStmt::PartExprItem pei = sel_stmt->get_part_exprs().at(i); + if (OB_FAIL(copier.copy_on_replace(pei.part_expr_, pei.part_expr_))) { + LOG_WARN("failed to copy part expr", K(ret)); + } else if (pei.subpart_expr_ != NULL + && OB_FAIL(copier.copy_on_replace(pei.subpart_expr_, pei.subpart_expr_))) { + LOG_WARN("failed to copy subpart expr", K(ret)); + } else if (OB_FAIL(stmt->get_part_exprs().push_back(pei))) { + LOG_WARN("failed to push back pullup partition expr", K(ret)); + } + } + } + return ret; +} + +int ObTransformPreProcess::move_for_update_dml_info(ObSelectStmt *stmt, + ObSelectStmt *hierarchical_stmt) +{ + int ret = OB_SUCCESS; + TableItem *hierarchical_table = NULL; + ObSEArray column_exprs; + ObSEArray new_column_list; + if (OB_ISNULL(stmt) || OB_ISNULL(hierarchical_stmt)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("get unexpected NULL", K(ret), K(stmt), K(hierarchical_stmt)); + } else if (stmt == hierarchical_stmt) { + // do nothing + } else if (!hierarchical_stmt->has_for_update()) { + // do nothing + } else if (OB_ISNULL(hierarchical_table = stmt->get_table_item(0))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table item is null", K(ret)); + } else if (OB_UNLIKELY(hierarchical_table->ref_query_ != hierarchical_stmt)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpect ref query", K(ret), KPC(hierarchical_table->ref_query_), KPC(hierarchical_stmt)); + } else if (OB_FAIL(hierarchical_stmt->get_column_exprs(column_exprs))) { + LOG_WARN("failed to get column exprs", K(ret)); + } else if (OB_FAIL(ObTransformUtils::create_columns_for_view(ctx_, + *hierarchical_table, + stmt, + column_exprs, + new_column_list))) { + LOG_WARN("failed to create columns for view", K(ret)); + } else if (OB_FAIL(pull_up_for_update_dml_info(stmt, hierarchical_table))) { + LOG_WARN("failed to pull up for update dml info", K(ret)); + } else if (OB_FAIL(pull_up_part_exprs(stmt, hierarchical_table))) { + LOG_WARN("failed to pull up part exprs", K(ret)); + } else { + // handle for update mark + for (int64_t i = 0; OB_SUCC(ret) && i < hierarchical_stmt->get_table_size(); ++i) { + TableItem *mocked_table = hierarchical_stmt->get_table_item(i); + if (OB_ISNULL(mocked_table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("table item is NULL", K(ret)); + } else { + mocked_table->for_update_ = false; + } + } + hierarchical_table->for_update_ = true; + } + return ret; +} + int ObTransformPreProcess::classify_join_conds(ObSelectStmt &stmt, ObIArray &normal_join_conds, ObIArray &other_conds) @@ -10227,5 +10614,236 @@ int ObTransformPreProcess::disable_complex_dml_for_fulltext_index(ObDMLStmt *stm return ret; } +int ObTransformPreProcess::try_gen_straight_join_leading(ObDMLStmt *stmt, bool &trans_happened) +{ + int ret = OB_SUCCESS; + const ObQueryHint *query_hint = NULL; + if (OB_ISNULL(stmt)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_ISNULL(query_hint = stmt->get_stmt_hint().query_hint_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret), K(query_hint)); + } else { + ObHint *leading_hint = stmt->get_stmt_hint().get_normal_hint(T_LEADING); + bool exist_leading_hint = query_hint->has_outline_data() || + query_hint->has_user_def_outline() || + OB_NOT_NULL(leading_hint); + ObSEArray flattened_tables; + + //if the current qb already has leading hint or outline data, ignore straight_join info. + if (exist_leading_hint) { + //do nothing + } else if (stmt->is_select_stmt() && + static_cast(stmt)->is_select_straight_join()) { + if (OB_FAIL(add_ordered_hint(stmt, stmt->get_stmt_hint()))) { + LOG_WARN("failed to add ordered hint", K(ret)); + } else { + //for straight_join written in the select clause, an ordered hint is added by default. + trans_happened = true; + } + } else if (OB_FAIL(get_flattened_tables_of_pure_straight_join(stmt, flattened_tables))) { + LOG_WARN("failed to get flattend tables of first pure straight join table", K(ret)); + } else if (flattened_tables.count() < 2) { + //do nothing + } else if (OB_FAIL(add_leading_hint_by_flattened_tables(stmt, stmt->get_stmt_hint(), + flattened_tables))) { + LOG_WARN("failed to add leading hint by straight join table", K(ret)); + } else { + //for straight_join written in the from clause, generate partial leading info based on + //the first pure straight_join table found from left to right. + trans_happened = true; + } + } + return ret; +} + +int ObTransformPreProcess::get_flattened_tables_of_pure_straight_join(ObDMLStmt* stmt, + ObIArray &flattened_tables) +{ + int ret = OB_SUCCESS; + ObSEArray from_tables; + if (OB_ISNULL(stmt)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_FAIL(stmt->get_from_tables(from_tables))) { + LOG_WARN("failed to get from tables", K(ret)); + } else { + bool found = false; + for (int64_t i = 0; OB_SUCC(ret) && !found && i < from_tables.count(); i++) { + TableItem *table_item = NULL; + bool is_pure_straight_join = false; + if (OB_ISNULL(table_item = from_tables.at(i))) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (!table_item->is_joined_table()) { + //do nothing + } else if (OB_FAIL(check_pure_straight_join_table(table_item, is_pure_straight_join, + flattened_tables))) { + LOG_WARN("failed to check pure straight join table", K(ret)); + } else if (!is_pure_straight_join) { + flattened_tables.reuse(); + } else { + found = true; + } + } + } + return ret; +} + +// If all leaf nodes in the joined table are base tables and the join types within it are straight_join, +// then it is considered a pure_straight_join_table whose join order is considered to be determined +// (left associative after flattening). +int ObTransformPreProcess::check_pure_straight_join_table(TableItem* table_item, + bool &is_pure_straight_join, + ObIArray &flattened_tables) +{ + int ret = OB_SUCCESS; + is_pure_straight_join = false; + if (OB_ISNULL(table_item)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (table_item->is_basic_table()) { + is_pure_straight_join = true; + if (OB_FAIL(flattened_tables.push_back(table_item))) { + LOG_WARN("failed to push back table item", K(ret)); + } + } else if (!table_item->is_joined_table()) { + is_pure_straight_join = false; + } else { + JoinedTable *joined_table = static_cast(table_item); + bool is_left_pure_sj = false; + bool is_right_pure_sj = false; + if (OB_FAIL(SMART_CALL(check_pure_straight_join_table(joined_table->left_table_, + is_left_pure_sj, + flattened_tables)))) { + LOG_WARN("failed to check pure straight join table", K(ret)); + } else if (OB_FAIL(SMART_CALL(check_pure_straight_join_table(joined_table->right_table_, + is_right_pure_sj, + flattened_tables)))) { + LOG_WARN("failed to check pure straight join table", K(ret)); + } else if (joined_table->is_straight_join()) { + is_pure_straight_join = is_left_pure_sj && is_right_pure_sj; + } else { + is_pure_straight_join = false; + } + } + return ret; +} + +int ObTransformPreProcess::add_ordered_hint(ObDMLStmt* stmt, ObStmtHint &stmt_hint) +{ + int ret = OB_SUCCESS; + ObJoinOrderHint *join_order_hint = NULL; + ObString qb_name; + if (OB_ISNULL(stmt) || OB_ISNULL(ctx_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_FAIL(stmt->get_qb_name(qb_name))) { + LOG_WARN("failed to get qb name", K(ret)); + } else if (OB_FAIL(ObQueryHint::create_hint(ctx_->allocator_, T_ORDERED, join_order_hint))) { + LOG_WARN("failed to create hint", K(ret)); + } else if (OB_FALSE_IT(join_order_hint->set_qb_name(qb_name))) { + } else if (OB_FAIL(stmt_hint.normal_hints_.push_back(join_order_hint))) { + LOG_WARN("failed to push back hint", K(ret)); + } + return ret; +} + +int ObTransformPreProcess::add_leading_hint_by_flattened_tables(ObDMLStmt* stmt, + ObStmtHint &stmt_hint, + ObIArray &flattened_tables) +{ + int ret = OB_SUCCESS; + ObJoinOrderHint *join_order_hint = NULL; + ObString qb_name; + if (OB_ISNULL(stmt) || OB_ISNULL(ctx_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_FAIL(stmt->get_qb_name(qb_name))) { + LOG_WARN("failed to get qb name", K(ret)); + } else if (OB_FAIL(ObQueryHint::create_hint(ctx_->allocator_, T_LEADING, join_order_hint))) { + LOG_WARN("failed to create hint", K(ret)); + } else if (OB_ISNULL(join_order_hint)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_FALSE_IT(join_order_hint->set_qb_name(qb_name))) { + } else if (OB_FAIL(construct_leading_table(stmt, flattened_tables, join_order_hint->get_table()))) { + LOG_WARN("failed to construct leading table", K(ret)); + } else if (OB_FAIL(stmt_hint.normal_hints_.push_back(join_order_hint))) { + LOG_WARN("failed to push back hint", K(ret)); + } + return ret; +} + +int ObTransformPreProcess::construct_leading_table(ObDMLStmt* stmt, + ObIArray &flattened_tables, + ObLeadingTable &leading_table) +{ + int ret = OB_SUCCESS; + ObLeadingTable *cur_leading_table = NULL; + if (OB_ISNULL(ctx_) || OB_ISNULL(stmt)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (flattened_tables.count() < 2) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected table count", K(ret), K(flattened_tables.count())); + } else { + for (int64_t i = 0; OB_SUCC(ret) && i < flattened_tables.count(); i++) { + ObLeadingTable *left_leading_table = cur_leading_table; + ObLeadingTable *right_leading_table = NULL; + if (OB_ISNULL(cur_leading_table)) { + if (OB_FAIL(construct_leaf_leading_table(stmt, flattened_tables.at(i), cur_leading_table))) { + LOG_WARN("failed to construct leaf leading table", K(ret)); + } else if (OB_ISNULL(cur_leading_table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } + } else if (OB_FAIL(construct_leaf_leading_table(stmt, flattened_tables.at(i), right_leading_table))) { + LOG_WARN("failed to construct leaf leading table", K(ret)); + } else if (OB_FAIL(ObQueryHint::create_leading_table(ctx_->allocator_, cur_leading_table))) { + LOG_WARN("failed to create leading table", K(ret)); + } else if (OB_ISNULL(cur_leading_table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else { + cur_leading_table->left_table_ = left_leading_table; + cur_leading_table->right_table_ = right_leading_table; + } + } + if (OB_SUCC(ret) && OB_FAIL(leading_table.assign(*cur_leading_table))) { + LOG_WARN("failed to assign leading table", K(ret)); + } + } + return ret; +} + +int ObTransformPreProcess::construct_leaf_leading_table(ObDMLStmt *stmt, + TableItem *table, + ObLeadingTable *&leading_table) +{ + int ret = OB_SUCCESS; + if (OB_ISNULL(ctx_) || OB_ISNULL(stmt)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_FAIL(ObQueryHint::create_leading_table(ctx_->allocator_, leading_table))) { + LOG_WARN("failed to create leading table", K(ret)); + } else if (OB_ISNULL(leading_table)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_FAIL(ObQueryHint::create_hint_table(ctx_->allocator_, leading_table->table_))) { + LOG_WARN("fail to create hint table", K(ret)); + } else if (OB_ISNULL(leading_table->table_)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("unexpected null", K(ret)); + } else if (OB_FAIL(stmt->get_qb_name(leading_table->table_->qb_name_))) { + LOG_WARN("failed to get qb name", K(ret)); + } else { + leading_table->table_->db_name_ = table->database_name_; + leading_table->table_->table_name_ = table->table_name_; + } + return ret; +} + } // end namespace sql } // end namespace oceanbase diff --git a/src/sql/rewrite/ob_transform_pre_process.h b/src/sql/rewrite/ob_transform_pre_process.h index 4639502884..0de535d4f0 100644 --- a/src/sql/rewrite/ob_transform_pre_process.h +++ b/src/sql/rewrite/ob_transform_pre_process.h @@ -372,6 +372,13 @@ struct DistinctObjMeta int remove_nested_aggr_exprs(ObSelectStmt *stmt); int construct_column_items_from_exprs(const ObIArray &column_exprs, ObIArray &column_items); + int add_select_item_for_update(ObSelectStmt *view_stmt, + ObIArray &select_list); + int create_for_update_dml_info(ObSelectStmt *stmt, TableItem *view_table); + int pull_up_for_update_dml_info(ObSelectStmt *upper_stmt, TableItem *view_table); + int pull_up_part_exprs(ObDMLStmt *stmt, TableItem *table); + int clear_for_update_mark(TableItem *view_table); + int move_for_update_dml_info(ObSelectStmt *stmt, ObSelectStmt *hierarchical_stmt); /* * following functions are used to transform in_expr to or_expr */ @@ -661,6 +668,20 @@ struct DistinctObjMeta ObIArray &unique_keys, bool &is_valid); int disable_complex_dml_for_fulltext_index(ObDMLStmt *stmt); + int try_gen_straight_join_leading(ObDMLStmt *stmt, bool &trans_happened); + int get_flattened_tables_of_pure_straight_join(ObDMLStmt* stmt, + ObIArray &flattened_tables); + int check_pure_straight_join_table(TableItem* table_item, bool &is_pure_straight_join, + ObIArray &flattened_tables); + int add_ordered_hint(ObDMLStmt* stmt, ObStmtHint &stmt_hint); + int add_leading_hint_by_flattened_tables(ObDMLStmt* stmt, + ObStmtHint &stmt_hint, + ObIArray &flattened_tables); + int construct_leading_table(ObDMLStmt* stmt, + ObIArray &flattened_tables, + ObLeadingTable &leading_table); + int construct_leaf_leading_table(ObDMLStmt *stmt, TableItem *table, ObLeadingTable *&leading_table); + private: DISALLOW_COPY_AND_ASSIGN(ObTransformPreProcess); }; diff --git a/src/sql/rewrite/ob_transform_utils.cpp b/src/sql/rewrite/ob_transform_utils.cpp index fcaef4d019..75342f7e92 100644 --- a/src/sql/rewrite/ob_transform_utils.cpp +++ b/src/sql/rewrite/ob_transform_utils.cpp @@ -5844,7 +5844,8 @@ int ObTransformUtils::find_relation_expr(ObDMLStmt *stmt, int ObTransformUtils::generate_unique_key_for_basic_table(ObTransformerCtx *ctx, ObDMLStmt *stmt, TableItem *item, - ObIArray &unique_keys) + ObIArray &unique_keys, + int64_t *rowkey_count /* = NULL */) { int ret = OB_SUCCESS; const ObTableSchema *table_schema = NULL; @@ -5882,6 +5883,9 @@ int ObTransformUtils::generate_unique_key_for_basic_table(ObTransformerCtx *ctx, LOG_WARN("failed to push back expr", K(ret)); } else { /*do nothing*/ } } + if (OB_SUCC(ret) && rowkey_count != NULL) { + *rowkey_count = rowkey_info.get_size(); + } } return ret; } diff --git a/src/sql/rewrite/ob_transform_utils.h b/src/sql/rewrite/ob_transform_utils.h index 765699591c..946506b955 100644 --- a/src/sql/rewrite/ob_transform_utils.h +++ b/src/sql/rewrite/ob_transform_utils.h @@ -1050,7 +1050,8 @@ public: static int generate_unique_key_for_basic_table(ObTransformerCtx *ctx, ObDMLStmt *stmt, TableItem *item, - ObIArray &unique_keys); + ObIArray &unique_keys, + int64_t *rowkey_count = NULL); static int check_loseless_join(ObDMLStmt *stmt, ObTransformerCtx *ctx, diff --git a/src/sql/rewrite/ob_transform_where_subquery_pullup.cpp b/src/sql/rewrite/ob_transform_where_subquery_pullup.cpp index fb219fda9d..ce759cbf36 100644 --- a/src/sql/rewrite/ob_transform_where_subquery_pullup.cpp +++ b/src/sql/rewrite/ob_transform_where_subquery_pullup.cpp @@ -137,12 +137,17 @@ int ObWhereSubQueryPullup::transform_one_expr(ObDMLStmt *stmt, int ret = OB_SUCCESS; trans_happened = false; TransformParam trans_param; + bool is_hsfu = false; if (OB_ISNULL(stmt) || OB_ISNULL(expr)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("NULL pointer error", K(ret)); //bug: } else if (expr->has_flag(CNT_ROWNUM)) { /*do nothing */ + } else if (OB_FAIL(stmt->is_hierarchical_for_update(is_hsfu))) { + LOG_WARN("failed to check hierarchical for update", K(ret), KPC(stmt)); + } else if (is_hsfu) { + // do nothing } else if (OB_FAIL(gather_transform_params(stmt, expr, trans_param))) { LOG_WARN("failed to check can be pulled up ", K(expr), K(stmt), K(ret)); } else if (!trans_param.can_be_transform_) { diff --git a/src/sql/session/ob_basic_session_info.cpp b/src/sql/session/ob_basic_session_info.cpp index 82bf237dea..98b0a9688f 100644 --- a/src/sql/session/ob_basic_session_info.cpp +++ b/src/sql/session/ob_basic_session_info.cpp @@ -41,6 +41,7 @@ #endif #include "rpc/obmysql/ob_sql_sock_session.h" #include "sql/engine/expr/ob_expr_regexp_context.h" +#include "share/ob_compatibility_control.h" using namespace oceanbase::common; using namespace oceanbase::share; @@ -666,8 +667,6 @@ int ObBasicSessionInfo::set_user(const ObString &user_name, const ObString &host LOG_WARN("fail to write username to string_buf_", K(user_name), K(ret)); } else if (OB_FAIL(name_pool_.write_string(host_name, &thread_data_.host_name_))) { LOG_WARN("fail to write hostname to string_buf_", K(host_name), K(ret)); - } else if (OB_FAIL(name_pool_.write_string(tmp_string, &thread_data_.user_at_host_name_))) { - LOG_WARN("fail to write user_at_host_name to string_buf_", K(tmp_string), K(ret)); } else { user_id_ = user_id; } @@ -675,6 +674,35 @@ int ObBasicSessionInfo::set_user(const ObString &user_name, const ObString &host return ret; } +int ObBasicSessionInfo::set_proxy_user(const ObString &user_name, const ObString &host_name, const uint64_t user_id) +{ + int ret = OB_SUCCESS; + if (OB_UNLIKELY(user_name.length() > common::OB_MAX_USER_NAME_LENGTH_STORE) + || OB_UNLIKELY(host_name.length() > common::OB_MAX_USER_NAME_LENGTH_STORE)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("name length invalid_", K(user_name), K(host_name), K(ret)); + } else if (user_id == OB_INVALID_ID) { + proxy_user_id_ = user_id; + LockGuard lock_guard(thread_data_mutex_); + thread_data_.proxy_user_name_.reset(); + thread_data_.proxy_host_name_.reset(); + } else { + char tmp_buf[common::OB_MAX_USER_NAME_LENGTH_STORE + common::OB_MAX_USER_NAME_LENGTH_STORE + 2] = {}; + snprintf(tmp_buf, sizeof(tmp_buf), "%.*s@%.*s", user_name.length(), user_name.ptr(), + host_name.length(), host_name.ptr()); + ObString tmp_string(tmp_buf); + LockGuard lock_guard(thread_data_mutex_); + if (OB_FAIL(name_pool_.write_string(user_name, &thread_data_.proxy_user_name_))) { + LOG_WARN("fail to write username to string_buf_", K(user_name), K(ret)); + } else if (OB_FAIL(name_pool_.write_string(host_name, &thread_data_.proxy_host_name_))) { + LOG_WARN("fail to write hostname to string_buf_", K(host_name), K(ret)); + } else { + proxy_user_id_ = user_id; + } + } + return ret; +} + int ObBasicSessionInfo::set_real_client_ip_and_port(const common::ObString &client_ip, int32_t client_addr_port) { int ret = OB_SUCCESS; @@ -2741,6 +2769,18 @@ OB_INLINE int ObBasicSessionInfo::process_session_variable(ObSysVarClassType var OX (sys_vars_cache_.set_default_lob_inrow_threshold(int_val)); break; } + case SYS_VAR_OB_COMPATIBILITY_CONTROL: { + int64_t int_val = 0; + OZ (val.get_int(int_val), val); + OX (sys_vars_cache_.set_compat_type(static_cast(int_val))); + break; + } + case SYS_VAR_OB_COMPATIBILITY_VERSION: { + uint64_t uint_val = 0; + OZ (val.get_uint64(uint_val), val); + OX (sys_vars_cache_.set_compat_version(uint_val)); + break; + } default: { //do nothing } @@ -4822,13 +4862,20 @@ OB_DEF_DESERIALIZE(ObBasicSessionInfo) OB_UNIS_DECODE(sql_id); if (OB_SUCC(ret)) { set_cur_sql_id(sql_id.ptr()); - } - if (OB_SUCC(ret)) { LST_DO_CODE(OB_UNIS_DECODE, proxy_user_id_, thread_data_.proxy_user_name_, thread_data_.proxy_host_name_, enable_role_ids_); + if (OB_SUCC(ret)) { + if (OB_FAIL(name_pool_.write_string(thread_data_.proxy_user_name_, + &thread_data_.proxy_user_name_))) { + LOG_WARN("fail to write username to string_buf_", K(thread_data_.proxy_user_name_), K(ret)); + } else if (OB_FAIL(name_pool_.write_string(thread_data_.proxy_host_name_, + &thread_data_.proxy_host_name_))) { + LOG_WARN("fail to write userhost to string_buf_", K(thread_data_.proxy_host_name_), K(ret)); + } + } } return ret; } @@ -5942,6 +5989,50 @@ int ObBasicSessionInfo::get_sql_audit_mem_conf(int64_t &mem_pct) return ret; } +int ObBasicSessionInfo::get_compatibility_control(ObCompatType &compat_type) const +{ + compat_type = sys_vars_cache_.get_compat_type(); + return OB_SUCCESS; +} + +int ObBasicSessionInfo::get_compatibility_version(uint64_t &compat_version) const +{ + compat_version = sys_vars_cache_.get_compat_version(); + return OB_SUCCESS; +} + +int ObBasicSessionInfo::get_security_version(uint64_t &security_version) const +{ + int ret = OB_SUCCESS; + if (OB_FAIL(get_sys_variable(SYS_VAR_OB_SECURITY_VERSION, security_version))) { + LOG_WARN("fail to get ob security version", K(ret)); + } + return ret; +} + +int ObBasicSessionInfo::check_feature_enable(const ObCompatFeatureType feature_type, + bool &is_enable) const +{ + int ret = OB_SUCCESS; + uint64_t version = 0; + is_enable = false; + if (feature_type < ObCompatFeatureType::COMPAT_FEATURE_END) { + if (OB_FAIL(get_compatibility_version(version))) { + LOG_WARN("failed to get compat version", K(ret)); + } + } else { + if (OB_FAIL(get_security_version(version))) { + LOG_WARN("failed to get security version", K(ret)); + } + } + if (OB_FAIL(ret)) { + } else if (OB_FAIL(ObCompatControl::check_feature_enable(version, + feature_type, is_enable))) { + LOG_WARN("failed to get feature enable", K(ret)); + } + return ret; +} + //session 当前的query处于非retry的packet处理时 // 1)如果thread_data_.state_ == SESSION_KILLED时,调用该接口直接返回OB_ERR_SESSION_INTERRUPTED错误; // 2)如果thread_data_.state_ != SESSION_KILLED时,进行session state的设置 diff --git a/src/sql/session/ob_basic_session_info.h b/src/sql/session/ob_basic_session_info.h index 10dff8d723..4eabe4fcac 100644 --- a/src/sql/session/ob_basic_session_info.h +++ b/src/sql/session/ob_basic_session_info.h @@ -26,6 +26,7 @@ #include "lib/timezone/ob_timezone_info.h" #include "lib/ash/ob_active_session_guard.h" #include "rpc/ob_sql_request_operator.h" +#include "share/ob_compatibility_control.h" #include "share/ob_debug_sync.h" #include "share/schema/ob_schema_struct.h" #include "share/schema/ob_schema_getter_guard.h" @@ -759,8 +760,11 @@ public: int set_user(const common::ObString &user_name, const common::ObString &host_name, const uint64_t user_id); inline void set_proxy_user_id(const uint64_t proxy_user_id) { proxy_user_id_ = proxy_user_id; } int set_real_client_ip_and_port(const common::ObString &client_ip, int32_t client_addr_port); + int set_proxy_user(const common::ObString &user_name, const common::ObString &host_name, const uint64_t user_id); const common::ObString &get_user_name() const { return thread_data_.user_name_;} const common::ObString &get_host_name() const { return thread_data_.host_name_;} + const common::ObString &get_proxy_user_name() const { return thread_data_.proxy_user_name_;} + const common::ObString &get_proxy_host_name() const { return thread_data_.proxy_host_name_;} const common::ObString &get_client_ip() const { return thread_data_.client_ip_;} const common::ObString &get_user_at_host() const { return thread_data_.user_at_host_name_;} const common::ObString &get_user_at_client_ip() const { return thread_data_.user_at_client_ip_;} @@ -1409,6 +1413,10 @@ public: common::ActiveSessionStat &get_ash_stat() { return ash_stat_; } void update_tenant_config_version(int64_t v) { cached_tenant_config_version_ = v; }; static int check_optimizer_features_enable_valid(const ObObj &val); + int get_compatibility_control(share::ObCompatType &compat_type) const; + int get_compatibility_version(uint64_t &compat_version) const; + int get_security_version(uint64_t &security_version) const; + int check_feature_enable(const share::ObCompatFeatureType feature_type, bool &is_enable) const; protected: int process_session_variable(share::ObSysVarClassType var, const common::ObObj &value, const bool check_timezone_valid = true, @@ -1668,7 +1676,10 @@ public: runtime_filter_max_in_num_(0), runtime_bloom_filter_max_size_(INT_MAX32), enable_rich_vector_format_(false), - ncharacter_set_connection_(ObCharsetType::CHARSET_INVALID) + ncharacter_set_connection_(ObCharsetType::CHARSET_INVALID), + compat_type_(share::ObCompatType::COMPAT_MYSQL57), + compat_version_(0) + { for (int64_t i = 0; i < ObNLSFormatEnum::NLS_MAX; ++i) { MEMSET(nls_formats_buf_[i], 0, MAX_NLS_FORMAT_STR_LEN); @@ -1731,6 +1742,8 @@ public: enable_rich_vector_format_ = false; ncharacter_set_connection_ = ObCharsetType::CHARSET_INVALID; default_lob_inrow_threshold_ = OB_DEFAULT_LOB_INROW_THRESHOLD; + compat_type_ = share::ObCompatType::COMPAT_MYSQL57; + compat_version_ = 0; } inline bool operator==(const SysVarsCacheData &other) const { @@ -1778,7 +1791,9 @@ public: ob_max_read_stale_time_ == other.ob_max_read_stale_time_ && enable_rich_vector_format_ == other.enable_rich_vector_format_ && ncharacter_set_connection_ == other.ncharacter_set_connection_ && - default_lob_inrow_threshold_ == other.default_lob_inrow_threshold_; + default_lob_inrow_threshold_ == other.default_lob_inrow_threshold_ && + compat_type_ == other.compat_type_ && + compat_version_ == other.compat_version_; bool equal2 = true; for (int64_t i = 0; i < ObNLSFormatEnum::NLS_MAX; ++i) { if (nls_formats_[i] != other.nls_formats_[i]) { @@ -1958,6 +1973,8 @@ public: int64_t runtime_bloom_filter_max_size_; bool enable_rich_vector_format_; ObCharsetType ncharacter_set_connection_; + share::ObCompatType compat_type_; + uint64_t compat_version_; private: char nls_formats_buf_[ObNLSFormatEnum::NLS_MAX][MAX_NLS_FORMAT_STR_LEN]; }; @@ -2073,6 +2090,8 @@ private: DEF_SYS_VAR_CACHE_FUNCS(bool, enable_rich_vector_format); DEF_SYS_VAR_CACHE_FUNCS(ObCharsetType, ncharacter_set_connection); DEF_SYS_VAR_CACHE_FUNCS(int64_t, default_lob_inrow_threshold); + DEF_SYS_VAR_CACHE_FUNCS(share::ObCompatType, compat_type); + DEF_SYS_VAR_CACHE_FUNCS(uint64_t, compat_version); void set_autocommit_info(bool inc_value) { inc_data_.autocommit_ = inc_value; @@ -2144,6 +2163,8 @@ private: bool inc_ncharacter_set_connection_:1; bool inc_default_lob_inrow_threshold_:1; bool inc_ob_enable_pl_cache_:1; + bool inc_compat_type_:1; + bool inc_compat_version_:1; }; }; }; diff --git a/src/sql/session/ob_sql_session_info.cpp b/src/sql/session/ob_sql_session_info.cpp index b6ab30674b..20445b86e7 100644 --- a/src/sql/session/ob_sql_session_info.cpp +++ b/src/sql/session/ob_sql_session_info.cpp @@ -1070,8 +1070,9 @@ void ObSQLSessionInfo::update_show_warnings_buf() } } -void ObSQLSessionInfo::get_session_priv_info(share::schema::ObSessionPrivInfo &session_priv) const +int ObSQLSessionInfo::get_session_priv_info(share::schema::ObSessionPrivInfo &session_priv) const { + int ret = OB_SUCCESS; session_priv.tenant_id_ = get_priv_tenant_id(); session_priv.user_id_ = get_priv_user_id(); session_priv.user_name_ = get_user_name(); @@ -1079,7 +1080,12 @@ void ObSQLSessionInfo::get_session_priv_info(share::schema::ObSessionPrivInfo &s session_priv.db_ = get_database_name(); session_priv.user_priv_set_ = user_priv_set_; session_priv.db_priv_set_ = db_priv_set_; - session_priv.enable_role_id_array_.assign(get_enable_role_array()); + if (OB_FAIL(session_priv.enable_role_id_array_.assign(get_enable_role_array()))) { + LOG_WARN("failed to assign enable role id array", K(ret)); + } else if (OB_FAIL(get_security_version(session_priv.security_version_))) { + LOG_WARN("failed to get security version", K(ret)); + } + return ret; } ObPlanCache *ObSQLSessionInfo::get_plan_cache() @@ -1932,6 +1938,7 @@ const ObAuditRecordData &ObSQLSessionInfo::get_final_audit_record( audit_record_.proxy_session_id_ = get_proxy_sessid(); audit_record_.tenant_id_ = get_priv_tenant_id(); audit_record_.user_id_ = get_user_id(); + audit_record_.proxy_user_id_ = get_proxy_user_id(); audit_record_.effective_tenant_id_ = get_effective_tenant_id(); if (EXECUTE_INNER == mode || EXECUTE_LOCAL == mode @@ -1952,6 +1959,10 @@ const ObAuditRecordData &ObSQLSessionInfo::get_final_audit_record( audit_record_.db_name_len_ = min(get_database_name().length(), OB_MAX_DATABASE_NAME_LENGTH); + audit_record_.proxy_user_name_ = const_cast(get_proxy_user_name().ptr()); + audit_record_.proxy_user_name_len_ = min(get_proxy_user_name().length(), + OB_MAX_USER_NAME_LENGTH); + if (EXECUTE_PS_EXECUTE == mode || EXECUTE_PS_SEND_PIECE == mode || EXECUTE_PS_GET_PIECE == mode diff --git a/src/sql/session/ob_sql_session_info.h b/src/sql/session/ob_sql_session_info.h index 61b661bbbf..d6691ecee5 100644 --- a/src/sql/session/ob_sql_session_info.h +++ b/src/sql/session/ob_sql_session_info.h @@ -881,7 +881,7 @@ public: void set_trans_type(transaction::ObTxClass t) { trans_type_ = t; } transaction::ObTxClass get_trans_type() const { return trans_type_; } - void get_session_priv_info(share::schema::ObSessionPrivInfo &session_priv) const; + int get_session_priv_info(share::schema::ObSessionPrivInfo &session_priv) const; void set_found_rows(const int64_t count) { found_rows_ = count; } int64_t get_found_rows() const { return found_rows_; } void set_affected_rows(const int64_t count) { affected_rows_ = count; } diff --git a/src/sql/udr/ob_udr_utils.cpp b/src/sql/udr/ob_udr_utils.cpp index 9397e7ab27..d7b5aca66e 100644 --- a/src/sql/udr/ob_udr_utils.cpp +++ b/src/sql/udr/ob_udr_utils.cpp @@ -183,9 +183,12 @@ int ObUDRUtils::clac_dynamic_param_store(const DynamicParamInfoArray& dynamic_pa ObIArray &raw_params = pc_ctx.fp_result_.raw_params_; ObPhysicalPlanCtx *phy_ctx = pc_ctx.exec_ctx_.get_physical_plan_ctx(); bool enable_decimal_int = false; + ObCompatType compat_type = COMPAT_MYSQL57; if (OB_ISNULL(session) || OB_ISNULL(phy_ctx)) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret), KP(session), KP(phy_ctx)); + } else if (OB_FAIL(session->get_compatibility_control(compat_type))) { + LOG_WARN("failed to get compat type", K(ret)); } else if (OB_FAIL(param_store.reserve(dynamic_param_list.count()))) { LOG_WARN("failed to reserve array", K(ret), K(dynamic_param_list.count())); } else if (lib::is_oracle_mode() && OB_FAIL( @@ -229,7 +232,8 @@ int ObUDRUtils::clac_dynamic_param_store(const DynamicParamInfoArray& dynamic_pa session->get_actual_nls_length_semantics(), static_cast(server_collation), NULL, session->get_sql_mode(), - enable_decimal_int))) { + enable_decimal_int, + compat_type))) { LOG_WARN("fail to resolve const", K(ret)); } else if (OB_FAIL(add_param_to_param_store(value, param_store))) { LOG_WARN("failed to add param to param store", K(ret), K(value), K(param_store)); diff --git a/tools/deploy/mysql_test/r/mysql/information_schema.result b/tools/deploy/mysql_test/r/mysql/information_schema.result index e22b29159b..58f69eec0e 100644 --- a/tools/deploy/mysql_test/r/mysql/information_schema.result +++ b/tools/deploy/mysql_test/r/mysql/information_schema.result @@ -201,6 +201,7 @@ select * from information_schema.tables where table_schema in ('oceanbase', 'mys | def | information_schema | PARAMETERS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | PARTITIONS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | PROCESSLIST | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | information_schema | PROFILING | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | QUERY_RESPONSE_TIME | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | REFERENTIAL_CONSTRAINTS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | ROUTINES | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | @@ -430,6 +431,7 @@ select * from information_schema.tables where table_schema in ('oceanbase', 'mys | def | oceanbase | V$OB_COMPACTION_DIAGNOSE_INFO | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_COMPACTION_PROGRESS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_COMPACTION_SUGGESTIONS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | V$OB_COMPATIBILITY_CONTROL | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_DTL_INTERM_RESULT_MONITOR | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_ENCRYPTED_TABLES | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_KVCACHE | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | @@ -679,6 +681,10 @@ select * from information_schema.tables where table_schema in ('oceanbase', 'mys | def | oceanbase | __all_type_history | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_user | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_user_history | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_user_proxy_info | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_user_proxy_info_history | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_user_proxy_role_info | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_user_proxy_role_info_history | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_apply_stat | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_arbitration_member_info | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_arbitration_service_status | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | @@ -716,6 +722,7 @@ select * from information_schema.tables where table_schema in ('oceanbase', 'mys | def | oceanbase | __all_virtual_column_group_mapping_history | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_compaction_diagnose_info | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_compaction_suggestion | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_virtual_compatibility_control | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_core_all_table | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_core_column_table | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_core_meta_table | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | @@ -1591,6 +1598,28 @@ select * from information_schema.statistics where table_schema in ('oceanbase', | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 2 | user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 3 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 1 | oceanbase | idx_user_proxy_info_proxy_user_id | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 1 | oceanbase | idx_user_proxy_info_proxy_user_id | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 4 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 1 | oceanbase | idx_user_proxy_info_proxy_user_id_history | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 1 | oceanbase | idx_user_proxy_info_proxy_user_id_history | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 4 | role_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 4 | role_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 5 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 1 | oceanbase | idx_user_proxy_role_info_proxy_user_id_history | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 1 | oceanbase | idx_user_proxy_role_info_proxy_user_id_history | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +---------------+--------------+-------------------------------------------+------------+--------------+-----------------------------------------------------+--------------+-------------------------+-----------+-------------+----------+--------+----------+------------+---------+---------------+------------+------------+ select * from information_schema.schemata where schema_name in ('oceanbase', 'mysql', 'information_schema') order by CATALOG_NAME, SCHEMA_NAME; +--------------+--------------------+----------------------------+------------------------+----------+--------------------+ @@ -1642,6 +1671,7 @@ select * from information_schema.tables where table_schema in ('oceanbase', 'mys | def | information_schema | PARAMETERS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | PARTITIONS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | PROCESSLIST | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | information_schema | PROFILING | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | QUERY_RESPONSE_TIME | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | REFERENTIAL_CONSTRAINTS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | information_schema | ROUTINES | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | @@ -1871,6 +1901,7 @@ select * from information_schema.tables where table_schema in ('oceanbase', 'mys | def | oceanbase | V$OB_COMPACTION_DIAGNOSE_INFO | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_COMPACTION_PROGRESS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_COMPACTION_SUGGESTIONS | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | V$OB_COMPATIBILITY_CONTROL | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_DTL_INTERM_RESULT_MONITOR | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_ENCRYPTED_TABLES | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | V$OB_KVCACHE | SYSTEM VIEW | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | @@ -2119,6 +2150,10 @@ select * from information_schema.tables where table_schema in ('oceanbase', 'mys | def | oceanbase | __all_type_history | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_user | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_user_history | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_user_proxy_info | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_user_proxy_info_history | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_user_proxy_role_info | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_user_proxy_role_info_history | SYSTEM TABLE | InnoDB | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_apply_stat | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_arbitration_member_info | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_arbitration_service_status | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | @@ -2156,6 +2191,7 @@ select * from information_schema.tables where table_schema in ('oceanbase', 'mys | def | oceanbase | __all_virtual_column_group_mapping_history | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_compaction_diagnose_info | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_compaction_suggestion | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | +| def | oceanbase | __all_virtual_compatibility_control | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_core_all_table | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_core_column_table | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | | def | oceanbase | __all_virtual_core_meta_table | SYSTEM TABLE | MEMORY | NULL | DYNAMIC | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | utf8mb4_general_ci | NULL | NULL | | @@ -3345,6 +3381,28 @@ select * from information_schema.statistics where table_schema in ('oceanbase', | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 2 | user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 3 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 1 | oceanbase | idx_user_proxy_info_proxy_user_id | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 1 | oceanbase | idx_user_proxy_info_proxy_user_id | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 4 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 1 | oceanbase | idx_user_proxy_info_proxy_user_id_history | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 1 | oceanbase | idx_user_proxy_info_proxy_user_id_history | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 4 | role_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 4 | role_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 5 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 1 | oceanbase | idx_user_proxy_role_info_proxy_user_id_history | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 1 | oceanbase | idx_user_proxy_role_info_proxy_user_id_history | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_weak_read_service | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_weak_read_service | 0 | oceanbase | PRIMARY | 2 | level_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_weak_read_service | 0 | oceanbase | PRIMARY | 3 | level_value | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | @@ -4085,6 +4143,28 @@ select * from information_schema.statistics where table_schema in ('oceanbase', | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 2 | user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | oceanbase | __all_user_history | 0 | oceanbase | PRIMARY | 3 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 1 | oceanbase | idx_user_proxy_info_proxy_user_id | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info | 1 | oceanbase | idx_user_proxy_info_proxy_user_id | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 0 | oceanbase | PRIMARY | 4 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 1 | oceanbase | idx_user_proxy_info_proxy_user_id_history | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_info_history | 1 | oceanbase | idx_user_proxy_info_proxy_user_id_history | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info | 0 | oceanbase | PRIMARY | 4 | role_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 2 | client_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 3 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 4 | role_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 0 | oceanbase | PRIMARY | 5 | schema_version | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 1 | oceanbase | idx_user_proxy_role_info_proxy_user_id_history | 1 | tenant_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | +| def | oceanbase | __all_user_proxy_role_info_history | 1 | oceanbase | idx_user_proxy_role_info_proxy_user_id_history | 2 | proxy_user_id | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | test1 | t1tenant1 | 0 | test1 | PRIMARY | 1 | c1 | A | NULL | NULL | NULL | | BTREE | VALID | | YES | NULL | | def | test1 | t1tenant1 | 0 | test1 | t1tenant1_uidx | 1 | c2 | A | NULL | NULL | NULL | YES | BTREE | VALID | | YES | NULL | | def | test1 | t1tenant1 | 1 | test1 | t1tenant1_idx1 | 1 | c2 | A | NULL | NULL | NULL | YES | BTREE | VALID | | YES | NULL | diff --git a/tools/deploy/mysql_test/test_suite/information_schema/r/mysql/information_schema_desc.result b/tools/deploy/mysql_test/test_suite/information_schema/r/mysql/information_schema_desc.result index d12262cdff..a3d491dd0e 100644 --- a/tools/deploy/mysql_test/test_suite/information_schema/r/mysql/information_schema_desc.result +++ b/tools/deploy/mysql_test/test_suite/information_schema/r/mysql/information_schema_desc.result @@ -284,7 +284,7 @@ View Create View character_set_client collation_connection TABLES CREATE VIEW `TABLES` AS select /*+ leading(a) no_use_nl(ts)*/ cast('def' as char(512)) as TABLE_CATALOG, cast(b.database_name as char(64)) collate utf8mb4_name_case as TABLE_SCHEMA, cast(a.table_name as char(64)) collate utf8mb4_name_case as TABLE_NAME, cast(case when (a.database_id = 201002 or a.table_type = 1) then 'SYSTEM VIEW' when a.table_type in (0, 2) then 'SYSTEM TABLE' when a.table_type = 4 then 'VIEW' when a.table_type = 14 then 'EXTERNAL TABLE' else 'BASE TABLE' end as char(64)) as TABLE_TYPE, cast(case when a.table_type in (0,3,5,6,7,11,12,13,15) then 'InnoDB' else 'MEMORY' end as char(64)) as ENGINE, cast(NULL as unsigned) as VERSION, cast(a.store_format as char(10)) as ROW_FORMAT, cast( coalesce(ts.row_cnt,0) as unsigned) as TABLE_ROWS, cast( coalesce(ts.avg_row_len,0) as unsigned) as AVG_ROW_LENGTH, cast( coalesce(ts.data_size,0) as unsigned) as DATA_LENGTH, cast(NULL as unsigned) as MAX_DATA_LENGTH, cast(NULL as unsigned) as INDEX_LENGTH, cast(NULL as unsigned) as DATA_FREE, cast(NULL as unsigned) as AUTO_INCREMENT, cast(a.gmt_create as datetime) as CREATE_TIME, cast(a.gmt_modified as datetime) as UPDATE_TIME, cast(NULL as datetime) as CHECK_TIME, cast(d.collation as char(32)) as TABLE_COLLATION, cast(NULL as unsigned) as CHECKSUM, cast(NULL as char(255)) as CREATE_OPTIONS, cast(case when a.table_type = 4 then 'VIEW' else a.comment end as char(2048)) as TABLE_COMMENT from ( select cast(0 as signed) as tenant_id, c.database_id, c.table_id, c.table_name, c.collation_type, c.table_type, usec_to_time(d.schema_version) as gmt_create, usec_to_time(c.schema_version) as gmt_modified, c.comment, c.store_format from oceanbase.__all_virtual_core_all_table c join oceanbase.__all_virtual_core_all_table d on c.tenant_id = d.tenant_id and d.table_name = '__all_core_table' where c.tenant_id = effective_tenant_id() union all select tenant_id, database_id, table_id, table_name, collation_type, table_type, gmt_create, gmt_modified, comment, store_format from oceanbase.__all_table where table_mode >> 12 & 15 in (0,1)) a join oceanbase.__all_database b on a.database_id = b.database_id and a.tenant_id = b.tenant_id join oceanbase.__tenant_virtual_collation d on a.collation_type = d.collation_type left join ( select tenant_id, table_id, row_cnt, avg_row_len, (macro_blk_cnt * 2 * 1024 * 1024) as data_size from oceanbase.__all_table_stat where partition_id = -1 or partition_id = table_id) ts on a.table_id = ts.table_id and a.tenant_id = ts.tenant_id where a.tenant_id = 0 and a.table_type in (0, 1, 2, 3, 4, 14, 15) and b.database_name != '__recyclebin' and b.in_recyclebin = 0 and 0 = sys_privilege_check('table_acc', effective_tenant_id(), b.database_name, a.table_name) utf8mb4 utf8mb4_general_ci show create table user_privileges; View Create View character_set_client collation_connection -USER_PRIVILEGES CREATE VIEW `USER_PRIVILEGES` AS SELECT CAST(CONCAT('''', V.USER_NAME, '''', '@', '''', V.HOST, '''') AS CHAR(81)) AS GRANTEE , CAST('def' AS CHAR(512)) AS TABLE_CATALOG , CAST(V.PRIVILEGE_TYPE AS CHAR(64)) AS PRIVILEGE_TYPE , CAST(V.IS_GRANTABLE AS CHAR(3)) AS IS_GRANTABLE FROM (SELECT U.USER_NAME AS USER_NAME, U.HOST AS HOST, CASE WHEN V1.C1 = 1 AND U.PRIV_ALTER = 1 THEN 'ALTER' WHEN V1.C1 = 2 AND U.PRIV_CREATE = 1 THEN 'CREATE' WHEN V1.C1 = 3 AND U.PRIV_CREATE_USER = 1 THEN 'CREATE USER' WHEN V1.C1 = 4 AND U.PRIV_DELETE = 1 THEN 'DELETE' WHEN V1.C1 = 5 AND U.PRIV_DROP = 1 THEN 'DROP' WHEN V1.C1 = 7 AND U.PRIV_INSERT = 1 THEN 'INSERT' WHEN V1.C1 = 8 AND U.PRIV_UPDATE = 1 THEN 'UPDATE' WHEN V1.C1 = 9 AND U.PRIV_SELECT = 1 THEN 'SELECT' WHEN V1.C1 = 10 AND U.PRIV_INDEX = 1 THEN 'INDEX' WHEN V1.C1 = 11 AND U.PRIV_CREATE_VIEW = 1 THEN 'CREATE VIEW' WHEN V1.C1 = 12 AND U.PRIV_SHOW_VIEW = 1 THEN 'SHOW VIEW' WHEN V1.C1 = 13 AND U.PRIV_SHOW_DB = 1 THEN 'SHOW DATABASES' WHEN V1.C1 = 14 AND U.PRIV_SUPER = 1 THEN 'SUPER' WHEN V1.C1 = 15 AND U.PRIV_PROCESS = 1 THEN 'PROCESS' WHEN V1.C1 = 17 AND U.PRIV_CREATE_SYNONYM = 1 THEN 'CREATE SYNONYM' WHEN V1.C1 = 27 AND U.PRIV_FILE = 1 THEN 'FILE' WHEN V1.C1 = 28 AND U.PRIV_ALTER_TENANT = 1 THEN 'ALTER TENANT' WHEN V1.C1 = 29 AND U.PRIV_ALTER_SYSTEM = 1 THEN 'ALTER SYSTEM' WHEN V1.C1 = 30 AND U.PRIV_CREATE_RESOURCE_POOL = 1 THEN 'CREATE RESOURCE POOL' WHEN V1.C1 = 31 AND U.PRIV_CREATE_RESOURCE_UNIT = 1 THEN 'CREATE RESOURCE UNIT' WHEN V1.C1 = 33 AND U.PRIV_REPL_SLAVE = 1 THEN 'REPLICATION SLAVE' WHEN V1.C1 = 34 AND U.PRIV_REPL_CLIENT = 1 THEN 'REPLICATION CLIENT' WHEN V1.C1 = 35 AND U.PRIV_DROP_DATABASE_LINK = 1 THEN 'DROP DATABASE LINK' WHEN V1.C1 = 36 AND U.PRIV_CREATE_DATABASE_LINK = 1 THEN 'CREATE DATABASE LINK' WHEN V1.C1 = 37 AND (U.PRIV_OTHERS & (1 << 0)) != 0 THEN 'EXECUTE' WHEN V1.C1 = 38 AND (U.PRIV_OTHERS & (1 << 1)) != 0 THEN 'ALTER ROUTINE' WHEN V1.C1 = 39 AND (U.PRIV_OTHERS & (1 << 2)) != 0 THEN 'CREATE ROUTINE' WHEN V1.C1 = 0 AND U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'USAGE' END PRIVILEGE_TYPE , CASE WHEN U.PRIV_GRANT_OPTION = 0 THEN 'NO' WHEN U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'NO' WHEN U.PRIV_GRANT_OPTION = 1 THEN 'YES' END IS_GRANTABLE FROM oceanbase.__all_user U, (SELECT 0 AS C1 UNION ALL SELECT 1 AS C1 UNION ALL SELECT 2 AS C1 UNION ALL SELECT 3 AS C1 UNION ALL SELECT 4 AS C1 UNION ALL SELECT 5 AS C1 UNION ALL SELECT 7 AS C1 UNION ALL SELECT 8 AS C1 UNION ALL SELECT 9 AS C1 UNION ALL SELECT 10 AS C1 UNION ALL SELECT 11 AS C1 UNION ALL SELECT 12 AS C1 UNION ALL SELECT 13 AS C1 UNION ALL SELECT 14 AS C1 UNION ALL SELECT 15 AS C1 UNION ALL SELECT 17 AS C1 UNION ALL SELECT 27 AS C1 UNION ALL SELECT 28 AS C1 UNION ALL SELECT 29 AS C1 UNION ALL SELECT 30 AS C1 UNION ALL SELECT 31 AS C1 UNION ALL SELECT 33 AS C1 UNION ALL SELECT 34 AS C1 UNION ALL SELECT 35 AS C1 UNION ALL SELECT 36 AS C1 UNION ALL SELECT 37 AS C1 UNION ALL SELECT 38 AS C1 UNION ALL SELECT 39 AS C1) V1, (SELECT USER_ID FROM oceanbase.__all_user WHERE TENANT_ID = 0 AND CONCAT(USER_NAME, '@', HOST) = CURRENT_USER()) CURR LEFT JOIN (SELECT USER_ID FROM oceanbase.__all_database_privilege WHERE TENANT_ID = 0 AND DATABASE_NAME = 'mysql' AND PRIV_SELECT = 1) DB ON CURR.USER_ID = DB.USER_ID WHERE U.TENANT_ID = 0 AND (DB.USER_ID IS NOT NULL OR 512 & CURRENT_USER_PRIV() = 512 OR U.USER_ID = CURR.USER_ID)) V WHERE V.PRIVILEGE_TYPE IS NOT NULL utf8mb4 utf8mb4_general_ci +USER_PRIVILEGES CREATE VIEW `USER_PRIVILEGES` AS SELECT CAST(CONCAT('''', V.USER_NAME, '''', '@', '''', V.HOST, '''') AS CHAR(81)) AS GRANTEE , CAST('def' AS CHAR(512)) AS TABLE_CATALOG , CAST(V.PRIVILEGE_TYPE AS CHAR(64)) AS PRIVILEGE_TYPE , CAST(V.IS_GRANTABLE AS CHAR(3)) AS IS_GRANTABLE FROM (SELECT U.USER_NAME AS USER_NAME, U.HOST AS HOST, CASE WHEN V1.C1 = 1 AND U.PRIV_ALTER = 1 THEN 'ALTER' WHEN V1.C1 = 2 AND U.PRIV_CREATE = 1 THEN 'CREATE' WHEN V1.C1 = 3 AND U.PRIV_CREATE_USER = 1 THEN 'CREATE USER' WHEN V1.C1 = 4 AND U.PRIV_DELETE = 1 THEN 'DELETE' WHEN V1.C1 = 5 AND U.PRIV_DROP = 1 THEN 'DROP' WHEN V1.C1 = 7 AND U.PRIV_INSERT = 1 THEN 'INSERT' WHEN V1.C1 = 8 AND U.PRIV_UPDATE = 1 THEN 'UPDATE' WHEN V1.C1 = 9 AND U.PRIV_SELECT = 1 THEN 'SELECT' WHEN V1.C1 = 10 AND U.PRIV_INDEX = 1 THEN 'INDEX' WHEN V1.C1 = 11 AND U.PRIV_CREATE_VIEW = 1 THEN 'CREATE VIEW' WHEN V1.C1 = 12 AND U.PRIV_SHOW_VIEW = 1 THEN 'SHOW VIEW' WHEN V1.C1 = 13 AND U.PRIV_SHOW_DB = 1 THEN 'SHOW DATABASES' WHEN V1.C1 = 14 AND U.PRIV_SUPER = 1 THEN 'SUPER' WHEN V1.C1 = 15 AND U.PRIV_PROCESS = 1 THEN 'PROCESS' WHEN V1.C1 = 17 AND U.PRIV_CREATE_SYNONYM = 1 THEN 'CREATE SYNONYM' WHEN V1.C1 = 23 AND (U.PRIV_OTHERS & (1 << 0)) != 0 THEN 'EXECUTE' WHEN V1.C1 = 27 AND U.PRIV_FILE = 1 THEN 'FILE' WHEN V1.C1 = 28 AND U.PRIV_ALTER_TENANT = 1 THEN 'ALTER TENANT' WHEN V1.C1 = 29 AND U.PRIV_ALTER_SYSTEM = 1 THEN 'ALTER SYSTEM' WHEN V1.C1 = 30 AND U.PRIV_CREATE_RESOURCE_POOL = 1 THEN 'CREATE RESOURCE POOL' WHEN V1.C1 = 31 AND U.PRIV_CREATE_RESOURCE_UNIT = 1 THEN 'CREATE RESOURCE UNIT' WHEN V1.C1 = 33 AND U.PRIV_REPL_SLAVE = 1 THEN 'REPLICATION SLAVE' WHEN V1.C1 = 34 AND U.PRIV_REPL_CLIENT = 1 THEN 'REPLICATION CLIENT' WHEN V1.C1 = 35 AND U.PRIV_DROP_DATABASE_LINK = 1 THEN 'DROP DATABASE LINK' WHEN V1.C1 = 36 AND U.PRIV_CREATE_DATABASE_LINK = 1 THEN 'CREATE DATABASE LINK' WHEN V1.C1 = 37 AND (U.PRIV_OTHERS & (1 << 1)) != 0 THEN 'ALTER ROUTINE' WHEN V1.C1 = 38 AND (U.PRIV_OTHERS & (1 << 2)) != 0 THEN 'CREATE ROUTINE' WHEN V1.C1 = 39 AND (U.PRIV_OTHERS & (1 << 3)) != 0 THEN 'CREATE TABLESPACE' WHEN V1.C1 = 40 AND (U.PRIV_OTHERS & (1 << 4)) != 0 THEN 'SHUTDOWN' WHEN V1.C1 = 41 AND (U.PRIV_OTHERS & (1 << 5)) != 0 THEN 'RELOAD' WHEN V1.C1 = 0 AND U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'USAGE' END PRIVILEGE_TYPE , CASE WHEN U.PRIV_GRANT_OPTION = 0 THEN 'NO' WHEN U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'NO' WHEN U.PRIV_GRANT_OPTION = 1 THEN 'YES' END IS_GRANTABLE FROM oceanbase.__all_user U, (SELECT 0 AS C1 UNION ALL SELECT 1 AS C1 UNION ALL SELECT 2 AS C1 UNION ALL SELECT 3 AS C1 UNION ALL SELECT 4 AS C1 UNION ALL SELECT 5 AS C1 UNION ALL SELECT 7 AS C1 UNION ALL SELECT 8 AS C1 UNION ALL SELECT 9 AS C1 UNION ALL SELECT 10 AS C1 UNION ALL SELECT 11 AS C1 UNION ALL SELECT 12 AS C1 UNION ALL SELECT 13 AS C1 UNION ALL SELECT 14 AS C1 UNION ALL SELECT 15 AS C1 UNION ALL SELECT 17 AS C1 UNION ALL SELECT 23 AS C1 UNION ALL SELECT 27 AS C1 UNION ALL SELECT 28 AS C1 UNION ALL SELECT 29 AS C1 UNION ALL SELECT 30 AS C1 UNION ALL SELECT 31 AS C1 UNION ALL SELECT 33 AS C1 UNION ALL SELECT 34 AS C1 UNION ALL SELECT 35 AS C1 UNION ALL SELECT 36 AS C1 UNION ALL SELECT 37 AS C1 UNION ALL SELECT 38 AS C1 UNION ALL SELECT 39 AS C1 UNION ALL SELECT 40 AS C1 UNION ALL SELECT 41 AS C1) V1, (SELECT USER_ID FROM oceanbase.__all_user WHERE TENANT_ID = 0 AND CONCAT(USER_NAME, '@', HOST) = CURRENT_USER()) CURR LEFT JOIN (SELECT USER_ID FROM oceanbase.__all_database_privilege WHERE TENANT_ID = 0 AND DATABASE_NAME = 'mysql' AND PRIV_SELECT = 1) DB ON CURR.USER_ID = DB.USER_ID WHERE U.TENANT_ID = 0 AND (DB.USER_ID IS NOT NULL OR 512 & CURRENT_USER_PRIV() = 512 OR U.USER_ID = CURR.USER_ID)) V WHERE V.PRIVILEGE_TYPE IS NOT NULL utf8mb4 utf8mb4_general_ci show create table views; View Create View character_set_client collation_connection VIEWS CREATE VIEW `VIEWS` AS select cast('def' as CHAR(64)) AS TABLE_CATALOG, d.database_name collate utf8mb4_name_case as TABLE_SCHEMA, t.table_name collate utf8mb4_name_case as TABLE_NAME, t.view_definition as VIEW_DEFINITION, case t.view_check_option when 1 then 'LOCAL' when 2 then 'CASCADED' else 'NONE' end as CHECK_OPTION, case t.view_is_updatable when 1 then 'YES' else 'NO' end as IS_UPDATABLE, cast((case t.define_user_id when -1 then 'NONE' else concat(u.user_name, '@', u.host) end) as CHAR(288)) as DEFINER, cast('NONE' as CHAR(7)) AS SECURITY_TYPE, cast((case t.collation_type when 45 then 'utf8mb4' else 'NONE' end) as CHAR(64)) AS CHARACTER_SET_CLIENT, cast((case t.collation_type when 45 then 'utf8mb4_general_ci' else 'NONE' end) as CHAR(64)) AS COLLATION_CONNECTION from oceanbase.__all_table as t join oceanbase.__all_database as d on t.tenant_id = d.tenant_id and t.database_id = d.database_id left join oceanbase.__all_user as u on t.tenant_id = u.tenant_id and t.define_user_id = u.user_id and t.define_user_id != -1 where t.tenant_id = 0 and t.table_type in (1, 4) and t.table_mode >> 12 & 15 in (0,1) and d.in_recyclebin = 0 and d.database_name != '__recyclebin' and d.database_name != 'information_schema' and d.database_name != 'oceanbase' and 0 = sys_privilege_check('table_acc', effective_tenant_id(), d.database_name, t.table_name) utf8mb4 utf8mb4_general_ci diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_mysql.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_mysql.result index f374479bf9..f4a82b5a2e 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_mysql.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_mysql.result @@ -272,6 +272,29 @@ DATABASE_COLLATION varchar(32) NO NULL select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from information_schema.ROUTINES limit 1); cnt 1 +desc information_schema.PROFILING; +Field Type Null Key Default Extra +QUERY_ID bigint(20) NO +SEQ bigint(20) NO +STATE varchar(30) NO +DURATION decimal(9,6) NO +CPU_USER decimal(9,6) NO +CPU_SYSTEM decimal(9,6) NO +CONTEXT_VOLUNTARY bigint(20) NO +CONTEXT_INVOLUNTARY bigint(20) NO +BLOCK_OPS_IN bigint(20) NO +BLOCK_OPS_OUT bigint(20) NO +MESSAGES_SENT bigint(20) NO +MESSAGES_RECEIVED bigint(20) NO +PAGE_FAULTS_MAJOR bigint(20) NO +PAGE_FAULTS_MINOR bigint(20) NO +SWAPS bigint(20) NO +SOURCE_FUNCTION varchar(30) NO +SOURCE_FILE varchar(20) NO +SOURCE_LINE bigint(20) NO +select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from information_schema.PROFILING limit 1); +cnt +1 desc oceanbase.GV$SESSION_EVENT; Field Type Null Key Default Extra CON_ID bigint(20) NO NULL @@ -617,6 +640,7 @@ PL_TRACE_ID varchar(128) YES NULL PLSQL_EXEC_TIME bigint(20) NO NULL TOTAL_MEMSTORE_READ_ROW_COUNT bigint(20) NO NULL TOTAL_SSSTORE_READ_ROW_COUNT bigint(20) NO NULL +PROXY_USER varchar(128) YES NULL select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.GV$OB_SQL_AUDIT limit 1); cnt 1 @@ -934,6 +958,7 @@ PL_TRACE_ID varchar(128) NO PLSQL_EXEC_TIME bigint(20) NO TOTAL_MEMSTORE_READ_ROW_COUNT bigint(20) NO TOTAL_SSSTORE_READ_ROW_COUNT bigint(20) NO +PROXY_USER varchar(128) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.V$OB_SQL_AUDIT limit 1); cnt 1 @@ -2600,6 +2625,7 @@ IN_BYTES bigint(20) NO NULL OUT_BYTES bigint(20) NO NULL USER_CLIENT_PORT bigint(20) NO TOTAL_CPU_TIME bigint(21) NO NULL +PROXY_USER varchar(128) YES NULL select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.GV$OB_PROCESSLIST limit 1); cnt 1 @@ -2643,6 +2669,7 @@ IN_BYTES bigint(20) NO OUT_BYTES bigint(20) NO USER_CLIENT_PORT bigint(20) NO TOTAL_CPU_TIME bigint(21) NO +PROXY_USER varchar(128) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.V$OB_PROCESSLIST limit 1); cnt 1 @@ -4375,6 +4402,9 @@ PRIV_CREATE_DATABASE_LINK varchar(3) NO PRIV_EXECUTE varchar(3) NO PRIV_ALTER_ROUTINE varchar(3) NO PRIV_CREATE_ROUTINE varchar(3) NO +PRIV_CREATE_TABLESPACE varchar(3) NO +PRIV_SHUTDOWN varchar(3) NO +PRIV_RELOAD varchar(3) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.DBA_OB_USERS limit 1); cnt 1 @@ -6127,6 +6157,15 @@ TP_MATCH bigint(20) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.V$OB_TRACEPOINT_INFO limit 1); cnt 1 +desc oceanbase.V$OB_COMPATIBILITY_CONTROL; +Field Type Null Key Default Extra +NAME varchar(128) NO NULL +DESCRIPTION varchar(4096) NO NULL +IS_ENABLE varchar(5) NO NULL +ENABLE_VERSIONS longtext NO NULL +select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.V$OB_COMPATIBILITY_CONTROL limit 1); +cnt +1 desc oceanbase.GV$OB_TENANT_RESOURCE_LIMIT; Field Type Null Key Default Extra SVR_IP varchar(46) NO NULL diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_sys.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_sys.result index 50660ef2f1..5c3aae1505 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_sys.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_sys_views_in_sys.result @@ -273,6 +273,29 @@ DATABASE_COLLATION varchar(32) NO NULL select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from information_schema.ROUTINES limit 1); cnt 1 +desc information_schema.PROFILING; +Field Type Null Key Default Extra +QUERY_ID bigint(20) NO +SEQ bigint(20) NO +STATE varchar(30) NO +DURATION decimal(9,6) NO +CPU_USER decimal(9,6) NO +CPU_SYSTEM decimal(9,6) NO +CONTEXT_VOLUNTARY bigint(20) NO +CONTEXT_INVOLUNTARY bigint(20) NO +BLOCK_OPS_IN bigint(20) NO +BLOCK_OPS_OUT bigint(20) NO +MESSAGES_SENT bigint(20) NO +MESSAGES_RECEIVED bigint(20) NO +PAGE_FAULTS_MAJOR bigint(20) NO +PAGE_FAULTS_MINOR bigint(20) NO +SWAPS bigint(20) NO +SOURCE_FUNCTION varchar(30) NO +SOURCE_FILE varchar(20) NO +SOURCE_LINE bigint(20) NO +select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from information_schema.PROFILING limit 1); +cnt +1 desc oceanbase.GV$SESSION_EVENT; Field Type Null Key Default Extra CON_ID bigint(20) NO NULL @@ -618,6 +641,7 @@ PL_TRACE_ID varchar(128) YES NULL PLSQL_EXEC_TIME bigint(20) NO NULL TOTAL_MEMSTORE_READ_ROW_COUNT bigint(20) NO NULL TOTAL_SSSTORE_READ_ROW_COUNT bigint(20) NO NULL +PROXY_USER varchar(128) YES NULL select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.GV$OB_SQL_AUDIT limit 1); cnt 1 @@ -935,6 +959,7 @@ PL_TRACE_ID varchar(128) NO PLSQL_EXEC_TIME bigint(20) NO TOTAL_MEMSTORE_READ_ROW_COUNT bigint(20) NO TOTAL_SSSTORE_READ_ROW_COUNT bigint(20) NO +PROXY_USER varchar(128) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.V$OB_SQL_AUDIT limit 1); cnt 1 @@ -3870,6 +3895,7 @@ IN_BYTES bigint(20) NO NULL OUT_BYTES bigint(20) NO NULL USER_CLIENT_PORT bigint(20) NO TOTAL_CPU_TIME bigint(21) NO NULL +PROXY_USER varchar(128) YES NULL select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.GV$OB_PROCESSLIST limit 1); cnt 1 @@ -3913,6 +3939,7 @@ IN_BYTES bigint(20) NO OUT_BYTES bigint(20) NO USER_CLIENT_PORT bigint(20) NO TOTAL_CPU_TIME bigint(21) NO +PROXY_USER varchar(128) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.V$OB_PROCESSLIST limit 1); cnt 1 @@ -6108,6 +6135,9 @@ PRIV_CREATE_DATABASE_LINK varchar(3) NO PRIV_EXECUTE varchar(3) NO PRIV_ALTER_ROUTINE varchar(3) NO PRIV_CREATE_ROUTINE varchar(3) NO +PRIV_CREATE_TABLESPACE varchar(3) NO +PRIV_SHUTDOWN varchar(3) NO +PRIV_RELOAD varchar(3) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.DBA_OB_USERS limit 1); cnt 1 @@ -6156,6 +6186,9 @@ PRIV_CREATE_DATABASE_LINK varchar(3) NO PRIV_EXECUTE varchar(3) NO PRIV_ALTER_ROUTINE varchar(3) NO PRIV_CREATE_ROUTINE varchar(3) NO +PRIV_CREATE_TABLESPACE varchar(3) NO +PRIV_SHUTDOWN varchar(3) NO +PRIV_RELOAD varchar(3) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.CDB_OB_USERS limit 1); cnt 1 @@ -8876,6 +8909,15 @@ TP_MATCH bigint(20) NO select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.V$OB_TRACEPOINT_INFO limit 1); cnt 1 +desc oceanbase.V$OB_COMPATIBILITY_CONTROL; +Field Type Null Key Default Extra +NAME varchar(128) NO NULL +DESCRIPTION varchar(4096) NO NULL +IS_ENABLE varchar(5) NO NULL +ENABLE_VERSIONS longtext NO NULL +select /*+QUERY_TIMEOUT(60000000)*/ count(*) as cnt from (select * from oceanbase.V$OB_COMPATIBILITY_CONTROL limit 1); +cnt +1 desc oceanbase.GV$OB_TENANT_RESOURCE_LIMIT; Field Type Null Key Default Extra SVR_IP varchar(46) NO NULL diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result index 0ff5b161fc..cad9b99eff 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/desc_virtual_table_in_mysql.result @@ -4896,6 +4896,16 @@ IF(count(*) >= 0, 1, 0) "oceanbase.__all_virtual_tracepoint_info runs in single server" IF(count(*) >= 0, 1, 0) 1 +desc oceanbase.__all_virtual_compatibility_control; +Field Type Null Key Default Extra +tenant_id bigint(20) NO NULL +name varchar(128) NO NULL +description varchar(4096) NO NULL +is_enable tinyint(4) NO NULL +enable_versions longtext NO NULL +select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_compatibility_control; +IF(count(*) >= 0, 1, 0) +1 desc oceanbase.__all_virtual_tenant_resource_limit; Field Type Null Key Default Extra svr_ip varchar(46) NO NULL 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 3c7dce84a8..72b1914b20 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 @@ -9445,6 +9445,66 @@ IF(count(*) >= 0, 1, 0) "oceanbase.__all_virtual_tracepoint_info runs in single server" IF(count(*) >= 0, 1, 0) 1 +desc oceanbase.__all_virtual_compatibility_control; +Field Type Null Key Default Extra +tenant_id bigint(20) NO NULL +name varchar(128) NO NULL +description varchar(4096) NO NULL +is_enable tinyint(4) NO NULL +enable_versions longtext NO NULL +select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_compatibility_control; +IF(count(*) >= 0, 1, 0) +1 +desc oceanbase.__all_virtual_user_proxy_info; +Field Type Null Key Default Extra +tenant_id bigint(20) NO PRI NULL +client_user_id bigint(20) NO PRI NULL +proxy_user_id bigint(20) NO PRI NULL +gmt_create timestamp(6) NO NULL +gmt_modified timestamp(6) NO NULL +credential_type bigint(20) NO 0 +flags bigint(20) NO 0 +select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_user_proxy_info; +IF(count(*) >= 0, 1, 0) +1 +desc oceanbase.__all_virtual_user_proxy_info_history; +Field Type Null Key Default Extra +tenant_id bigint(20) NO PRI NULL +client_user_id bigint(20) NO PRI NULL +proxy_user_id bigint(20) NO PRI NULL +schema_version bigint(20) NO PRI NULL +gmt_create timestamp(6) NO NULL +gmt_modified timestamp(6) NO NULL +is_deleted bigint(20) NO NULL +credential_type bigint(20) YES 0 +flags bigint(20) YES 0 +select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_user_proxy_info_history; +IF(count(*) >= 0, 1, 0) +1 +desc oceanbase.__all_virtual_user_proxy_role_info; +Field Type Null Key Default Extra +tenant_id bigint(20) NO PRI NULL +client_user_id bigint(20) NO PRI NULL +proxy_user_id bigint(20) NO PRI NULL +role_id bigint(20) NO PRI NULL +gmt_create timestamp(6) NO NULL +gmt_modified timestamp(6) NO NULL +select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_user_proxy_role_info; +IF(count(*) >= 0, 1, 0) +1 +desc oceanbase.__all_virtual_user_proxy_role_info_history; +Field Type Null Key Default Extra +tenant_id bigint(20) NO PRI NULL +client_user_id bigint(20) NO PRI NULL +proxy_user_id bigint(20) NO PRI NULL +role_id bigint(20) NO PRI NULL +schema_version bigint(20) NO PRI NULL +gmt_create timestamp(6) NO NULL +gmt_modified timestamp(6) NO NULL +is_deleted bigint(20) NO NULL +select /*+QUERY_TIMEOUT(60000000)*/ IF(count(*) >= 0, 1, 0) from oceanbase.__all_virtual_user_proxy_role_info_history; +IF(count(*) >= 0, 1, 0) +1 desc oceanbase.__all_virtual_tenant_resource_limit; Field Type Null Key Default Extra svr_ip varchar(46) NO NULL diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/inner_table_overall.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/inner_table_overall.result index 366eef4018..977b4911db 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/inner_table_overall.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/inner_table_overall.result @@ -293,6 +293,10 @@ select 0xffffffffff & table_id, table_name, table_type, database_id, part_num fr 505 __all_column_privilege 0 201001 1 506 __all_column_privilege_history 0 201001 1 507 __all_tenant_snapshot_ls_replica_history 0 201001 1 +512 __all_user_proxy_info 0 201001 1 +513 __all_user_proxy_info_history 0 201001 1 +514 __all_user_proxy_role_info 0 201001 1 +515 __all_user_proxy_role_info_history 0 201001 1 518 __all_mview_dep 0 201001 1 10001 __tenant_virtual_all_table 2 201001 1 10002 __tenant_virtual_table_column 2 201001 1 @@ -737,6 +741,11 @@ select 0xffffffffff & table_id, table_name, table_type, database_id, part_num fr 12464 __all_virtual_tenant_snapshot_ls_replica_history 2 201001 1 12466 ENABLED_ROLES 2 201002 1 12469 __all_virtual_tracepoint_info 2 201001 1 +12473 __all_virtual_compatibility_control 2 201001 1 +12474 __all_virtual_user_proxy_info 2 201001 1 +12475 __all_virtual_user_proxy_info_history 2 201001 1 +12476 __all_virtual_user_proxy_role_info 2 201001 1 +12477 __all_virtual_user_proxy_role_info_history 2 201001 1 12481 __all_virtual_tenant_resource_limit 2 201001 1 12482 __all_virtual_tenant_resource_limit_detail 2 201001 1 12487 __all_virtual_nic_info 2 201001 1 @@ -754,6 +763,7 @@ select 0xffffffffff & table_id, table_name, table_type, database_id, part_num fr 20012 KEY_COLUMN_USAGE 1 201002 1 20014 ENGINES 1 201002 1 20015 ROUTINES 1 201002 1 +20016 PROFILING 1 201002 1 21000 GV$SESSION_EVENT 1 201001 1 21001 GV$SESSION_WAIT 1 201001 1 21002 GV$SESSION_WAIT_HISTORY 1 201001 1 @@ -1149,6 +1159,7 @@ select 0xffffffffff & table_id, table_name, table_type, database_id, part_num fr 21540 DBA_MVREF_STMT_STATS 1 201001 1 21543 GV$OB_TRACEPOINT_INFO 1 201001 1 21544 V$OB_TRACEPOINT_INFO 1 201001 1 +21545 V$OB_COMPATIBILITY_CONTROL 1 201001 1 21550 GV$OB_TENANT_RESOURCE_LIMIT 1 201001 1 21551 V$OB_TENANT_RESOURCE_LIMIT 1 201001 1 21552 GV$OB_TENANT_RESOURCE_LIMIT_DETAIL 1 201001 1 diff --git a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/user_privileges.result b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/user_privileges.result index c036fb5f58..d953d0602b 100644 --- a/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/user_privileges.result +++ b/tools/deploy/mysql_test/test_suite/inner_table/r/mysql/user_privileges.result @@ -1,6 +1,6 @@ show create table information_schema.user_privileges; View Create View character_set_client collation_connection -USER_PRIVILEGES CREATE VIEW `USER_PRIVILEGES` AS SELECT CAST(CONCAT('''', V.USER_NAME, '''', '@', '''', V.HOST, '''') AS CHAR(81)) AS GRANTEE , CAST('def' AS CHAR(512)) AS TABLE_CATALOG , CAST(V.PRIVILEGE_TYPE AS CHAR(64)) AS PRIVILEGE_TYPE , CAST(V.IS_GRANTABLE AS CHAR(3)) AS IS_GRANTABLE FROM (SELECT U.USER_NAME AS USER_NAME, U.HOST AS HOST, CASE WHEN V1.C1 = 1 AND U.PRIV_ALTER = 1 THEN 'ALTER' WHEN V1.C1 = 2 AND U.PRIV_CREATE = 1 THEN 'CREATE' WHEN V1.C1 = 3 AND U.PRIV_CREATE_USER = 1 THEN 'CREATE USER' WHEN V1.C1 = 4 AND U.PRIV_DELETE = 1 THEN 'DELETE' WHEN V1.C1 = 5 AND U.PRIV_DROP = 1 THEN 'DROP' WHEN V1.C1 = 7 AND U.PRIV_INSERT = 1 THEN 'INSERT' WHEN V1.C1 = 8 AND U.PRIV_UPDATE = 1 THEN 'UPDATE' WHEN V1.C1 = 9 AND U.PRIV_SELECT = 1 THEN 'SELECT' WHEN V1.C1 = 10 AND U.PRIV_INDEX = 1 THEN 'INDEX' WHEN V1.C1 = 11 AND U.PRIV_CREATE_VIEW = 1 THEN 'CREATE VIEW' WHEN V1.C1 = 12 AND U.PRIV_SHOW_VIEW = 1 THEN 'SHOW VIEW' WHEN V1.C1 = 13 AND U.PRIV_SHOW_DB = 1 THEN 'SHOW DATABASES' WHEN V1.C1 = 14 AND U.PRIV_SUPER = 1 THEN 'SUPER' WHEN V1.C1 = 15 AND U.PRIV_PROCESS = 1 THEN 'PROCESS' WHEN V1.C1 = 17 AND U.PRIV_CREATE_SYNONYM = 1 THEN 'CREATE SYNONYM' WHEN V1.C1 = 27 AND U.PRIV_FILE = 1 THEN 'FILE' WHEN V1.C1 = 28 AND U.PRIV_ALTER_TENANT = 1 THEN 'ALTER TENANT' WHEN V1.C1 = 29 AND U.PRIV_ALTER_SYSTEM = 1 THEN 'ALTER SYSTEM' WHEN V1.C1 = 30 AND U.PRIV_CREATE_RESOURCE_POOL = 1 THEN 'CREATE RESOURCE POOL' WHEN V1.C1 = 31 AND U.PRIV_CREATE_RESOURCE_UNIT = 1 THEN 'CREATE RESOURCE UNIT' WHEN V1.C1 = 33 AND U.PRIV_REPL_SLAVE = 1 THEN 'REPLICATION SLAVE' WHEN V1.C1 = 34 AND U.PRIV_REPL_CLIENT = 1 THEN 'REPLICATION CLIENT' WHEN V1.C1 = 35 AND U.PRIV_DROP_DATABASE_LINK = 1 THEN 'DROP DATABASE LINK' WHEN V1.C1 = 36 AND U.PRIV_CREATE_DATABASE_LINK = 1 THEN 'CREATE DATABASE LINK' WHEN V1.C1 = 37 AND (U.PRIV_OTHERS & (1 << 0)) != 0 THEN 'EXECUTE' WHEN V1.C1 = 38 AND (U.PRIV_OTHERS & (1 << 1)) != 0 THEN 'ALTER ROUTINE' WHEN V1.C1 = 39 AND (U.PRIV_OTHERS & (1 << 2)) != 0 THEN 'CREATE ROUTINE' WHEN V1.C1 = 0 AND U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'USAGE' END PRIVILEGE_TYPE , CASE WHEN U.PRIV_GRANT_OPTION = 0 THEN 'NO' WHEN U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'NO' WHEN U.PRIV_GRANT_OPTION = 1 THEN 'YES' END IS_GRANTABLE FROM oceanbase.__all_user U, (SELECT 0 AS C1 UNION ALL SELECT 1 AS C1 UNION ALL SELECT 2 AS C1 UNION ALL SELECT 3 AS C1 UNION ALL SELECT 4 AS C1 UNION ALL SELECT 5 AS C1 UNION ALL SELECT 7 AS C1 UNION ALL SELECT 8 AS C1 UNION ALL SELECT 9 AS C1 UNION ALL SELECT 10 AS C1 UNION ALL SELECT 11 AS C1 UNION ALL SELECT 12 AS C1 UNION ALL SELECT 13 AS C1 UNION ALL SELECT 14 AS C1 UNION ALL SELECT 15 AS C1 UNION ALL SELECT 17 AS C1 UNION ALL SELECT 27 AS C1 UNION ALL SELECT 28 AS C1 UNION ALL SELECT 29 AS C1 UNION ALL SELECT 30 AS C1 UNION ALL SELECT 31 AS C1 UNION ALL SELECT 33 AS C1 UNION ALL SELECT 34 AS C1 UNION ALL SELECT 35 AS C1 UNION ALL SELECT 36 AS C1 UNION ALL SELECT 37 AS C1 UNION ALL SELECT 38 AS C1 UNION ALL SELECT 39 AS C1) V1, (SELECT USER_ID FROM oceanbase.__all_user WHERE TENANT_ID = 0 AND CONCAT(USER_NAME, '@', HOST) = CURRENT_USER()) CURR LEFT JOIN (SELECT USER_ID FROM oceanbase.__all_database_privilege WHERE TENANT_ID = 0 AND DATABASE_NAME = 'mysql' AND PRIV_SELECT = 1) DB ON CURR.USER_ID = DB.USER_ID WHERE U.TENANT_ID = 0 AND (DB.USER_ID IS NOT NULL OR 512 & CURRENT_USER_PRIV() = 512 OR U.USER_ID = CURR.USER_ID)) V WHERE V.PRIVILEGE_TYPE IS NOT NULL utf8mb4 utf8mb4_general_ci +USER_PRIVILEGES CREATE VIEW `USER_PRIVILEGES` AS SELECT CAST(CONCAT('''', V.USER_NAME, '''', '@', '''', V.HOST, '''') AS CHAR(81)) AS GRANTEE , CAST('def' AS CHAR(512)) AS TABLE_CATALOG , CAST(V.PRIVILEGE_TYPE AS CHAR(64)) AS PRIVILEGE_TYPE , CAST(V.IS_GRANTABLE AS CHAR(3)) AS IS_GRANTABLE FROM (SELECT U.USER_NAME AS USER_NAME, U.HOST AS HOST, CASE WHEN V1.C1 = 1 AND U.PRIV_ALTER = 1 THEN 'ALTER' WHEN V1.C1 = 2 AND U.PRIV_CREATE = 1 THEN 'CREATE' WHEN V1.C1 = 3 AND U.PRIV_CREATE_USER = 1 THEN 'CREATE USER' WHEN V1.C1 = 4 AND U.PRIV_DELETE = 1 THEN 'DELETE' WHEN V1.C1 = 5 AND U.PRIV_DROP = 1 THEN 'DROP' WHEN V1.C1 = 7 AND U.PRIV_INSERT = 1 THEN 'INSERT' WHEN V1.C1 = 8 AND U.PRIV_UPDATE = 1 THEN 'UPDATE' WHEN V1.C1 = 9 AND U.PRIV_SELECT = 1 THEN 'SELECT' WHEN V1.C1 = 10 AND U.PRIV_INDEX = 1 THEN 'INDEX' WHEN V1.C1 = 11 AND U.PRIV_CREATE_VIEW = 1 THEN 'CREATE VIEW' WHEN V1.C1 = 12 AND U.PRIV_SHOW_VIEW = 1 THEN 'SHOW VIEW' WHEN V1.C1 = 13 AND U.PRIV_SHOW_DB = 1 THEN 'SHOW DATABASES' WHEN V1.C1 = 14 AND U.PRIV_SUPER = 1 THEN 'SUPER' WHEN V1.C1 = 15 AND U.PRIV_PROCESS = 1 THEN 'PROCESS' WHEN V1.C1 = 17 AND U.PRIV_CREATE_SYNONYM = 1 THEN 'CREATE SYNONYM' WHEN V1.C1 = 23 AND (U.PRIV_OTHERS & (1 << 0)) != 0 THEN 'EXECUTE' WHEN V1.C1 = 27 AND U.PRIV_FILE = 1 THEN 'FILE' WHEN V1.C1 = 28 AND U.PRIV_ALTER_TENANT = 1 THEN 'ALTER TENANT' WHEN V1.C1 = 29 AND U.PRIV_ALTER_SYSTEM = 1 THEN 'ALTER SYSTEM' WHEN V1.C1 = 30 AND U.PRIV_CREATE_RESOURCE_POOL = 1 THEN 'CREATE RESOURCE POOL' WHEN V1.C1 = 31 AND U.PRIV_CREATE_RESOURCE_UNIT = 1 THEN 'CREATE RESOURCE UNIT' WHEN V1.C1 = 33 AND U.PRIV_REPL_SLAVE = 1 THEN 'REPLICATION SLAVE' WHEN V1.C1 = 34 AND U.PRIV_REPL_CLIENT = 1 THEN 'REPLICATION CLIENT' WHEN V1.C1 = 35 AND U.PRIV_DROP_DATABASE_LINK = 1 THEN 'DROP DATABASE LINK' WHEN V1.C1 = 36 AND U.PRIV_CREATE_DATABASE_LINK = 1 THEN 'CREATE DATABASE LINK' WHEN V1.C1 = 37 AND (U.PRIV_OTHERS & (1 << 1)) != 0 THEN 'ALTER ROUTINE' WHEN V1.C1 = 38 AND (U.PRIV_OTHERS & (1 << 2)) != 0 THEN 'CREATE ROUTINE' WHEN V1.C1 = 39 AND (U.PRIV_OTHERS & (1 << 3)) != 0 THEN 'CREATE TABLESPACE' WHEN V1.C1 = 40 AND (U.PRIV_OTHERS & (1 << 4)) != 0 THEN 'SHUTDOWN' WHEN V1.C1 = 41 AND (U.PRIV_OTHERS & (1 << 5)) != 0 THEN 'RELOAD' WHEN V1.C1 = 0 AND U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'USAGE' END PRIVILEGE_TYPE , CASE WHEN U.PRIV_GRANT_OPTION = 0 THEN 'NO' WHEN U.PRIV_ALTER = 0 AND U.PRIV_CREATE = 0 AND U.PRIV_CREATE_USER = 0 AND U.PRIV_DELETE = 0 AND U.PRIV_DROP = 0 AND U.PRIV_INSERT = 0 AND U.PRIV_UPDATE = 0 AND U.PRIV_SELECT = 0 AND U.PRIV_INDEX = 0 AND U.PRIV_CREATE_VIEW = 0 AND U.PRIV_SHOW_VIEW = 0 AND U.PRIV_SHOW_DB = 0 AND U.PRIV_SUPER = 0 AND U.PRIV_PROCESS = 0 AND U.PRIV_CREATE_SYNONYM = 0 AND U.PRIV_FILE = 0 AND U.PRIV_ALTER_TENANT = 0 AND U.PRIV_ALTER_SYSTEM = 0 AND U.PRIV_CREATE_RESOURCE_POOL = 0 AND U.PRIV_CREATE_RESOURCE_UNIT = 0 AND U.PRIV_REPL_SLAVE = 0 AND U.PRIV_REPL_CLIENT = 0 AND U.PRIV_DROP_DATABASE_LINK = 0 AND U.PRIV_CREATE_DATABASE_LINK = 0 AND U.PRIV_OTHERS = 0 THEN 'NO' WHEN U.PRIV_GRANT_OPTION = 1 THEN 'YES' END IS_GRANTABLE FROM oceanbase.__all_user U, (SELECT 0 AS C1 UNION ALL SELECT 1 AS C1 UNION ALL SELECT 2 AS C1 UNION ALL SELECT 3 AS C1 UNION ALL SELECT 4 AS C1 UNION ALL SELECT 5 AS C1 UNION ALL SELECT 7 AS C1 UNION ALL SELECT 8 AS C1 UNION ALL SELECT 9 AS C1 UNION ALL SELECT 10 AS C1 UNION ALL SELECT 11 AS C1 UNION ALL SELECT 12 AS C1 UNION ALL SELECT 13 AS C1 UNION ALL SELECT 14 AS C1 UNION ALL SELECT 15 AS C1 UNION ALL SELECT 17 AS C1 UNION ALL SELECT 23 AS C1 UNION ALL SELECT 27 AS C1 UNION ALL SELECT 28 AS C1 UNION ALL SELECT 29 AS C1 UNION ALL SELECT 30 AS C1 UNION ALL SELECT 31 AS C1 UNION ALL SELECT 33 AS C1 UNION ALL SELECT 34 AS C1 UNION ALL SELECT 35 AS C1 UNION ALL SELECT 36 AS C1 UNION ALL SELECT 37 AS C1 UNION ALL SELECT 38 AS C1 UNION ALL SELECT 39 AS C1 UNION ALL SELECT 40 AS C1 UNION ALL SELECT 41 AS C1) V1, (SELECT USER_ID FROM oceanbase.__all_user WHERE TENANT_ID = 0 AND CONCAT(USER_NAME, '@', HOST) = CURRENT_USER()) CURR LEFT JOIN (SELECT USER_ID FROM oceanbase.__all_database_privilege WHERE TENANT_ID = 0 AND DATABASE_NAME = 'mysql' AND PRIV_SELECT = 1) DB ON CURR.USER_ID = DB.USER_ID WHERE U.TENANT_ID = 0 AND (DB.USER_ID IS NOT NULL OR 512 & CURRENT_USER_PRIV() = 512 OR U.USER_ID = CURR.USER_ID)) V WHERE V.PRIVILEGE_TYPE IS NOT NULL utf8mb4 utf8mb4_general_ci desc information_schema.user_privileges; Field Type Null Key Default Extra GRANTEE varchar(81) NO @@ -53,6 +53,7 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'root'@'%' def SUPER YES 'root'@'%' def PROCESS YES 'root'@'%' def CREATE SYNONYM YES +'root'@'%' def EXECUTE YES 'root'@'%' def FILE YES 'root'@'%' def ALTER TENANT YES 'root'@'%' def ALTER SYSTEM YES @@ -62,9 +63,11 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'root'@'%' def REPLICATION CLIENT YES 'root'@'%' def DROP DATABASE LINK YES 'root'@'%' def CREATE DATABASE LINK YES -'root'@'%' def EXECUTE YES 'root'@'%' def ALTER ROUTINE YES 'root'@'%' def CREATE ROUTINE YES +'root'@'%' def CREATE TABLESPACE YES +'root'@'%' def SHUTDOWN YES +'root'@'%' def RELOAD YES 'admin'@'%' def ALTER YES 'admin'@'%' def CREATE YES 'admin'@'%' def CREATE USER YES @@ -80,6 +83,7 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'admin'@'%' def SUPER YES 'admin'@'%' def PROCESS YES 'admin'@'%' def CREATE SYNONYM YES +'admin'@'%' def EXECUTE YES 'admin'@'%' def FILE YES 'admin'@'%' def ALTER TENANT YES 'admin'@'%' def ALTER SYSTEM YES @@ -89,6 +93,8 @@ GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE 'admin'@'%' def REPLICATION CLIENT YES 'admin'@'%' def DROP DATABASE LINK YES 'admin'@'%' def CREATE DATABASE LINK YES -'admin'@'%' def EXECUTE YES 'admin'@'%' def ALTER ROUTINE YES 'admin'@'%' def CREATE ROUTINE YES +'admin'@'%' def CREATE TABLESPACE YES +'admin'@'%' def SHUTDOWN YES +'admin'@'%' def RELOAD YES diff --git a/unittest/sql/resolver/expr/test_raw_expr_hash.cpp b/unittest/sql/resolver/expr/test_raw_expr_hash.cpp index 7f94aa01ee..2cfc287d97 100644 --- a/unittest/sql/resolver/expr/test_raw_expr_hash.cpp +++ b/unittest/sql/resolver/expr/test_raw_expr_hash.cpp @@ -87,6 +87,10 @@ TEST_F(TestRawExprToStr, basic) ctx.session_info_ = &session; OBSERVER.init_version(); + EXPECT_TRUE(OB_SUCCESS == oceanbase::ObPreProcessSysVars::init_sys_var()); + EXPECT_TRUE(OB_SUCCESS == session.test_init(0, 0, 0, NULL)); + EXPECT_TRUE(OB_SUCCESS == session.load_default_sys_variable(false, true)); + // const int64_t buf_len = 1024; //int64_t pos = 0; //char buf[buf_len]; diff --git a/unittest/sql/resolver/expr/test_raw_expr_resolver.cpp b/unittest/sql/resolver/expr/test_raw_expr_resolver.cpp index 142edb686f..b7df3792df 100644 --- a/unittest/sql/resolver/expr/test_raw_expr_resolver.cpp +++ b/unittest/sql/resolver/expr/test_raw_expr_resolver.cpp @@ -81,6 +81,11 @@ void TestRawExprResolver::resolve(const char* expr, const char *&json_expr) ctx.is_extract_param_type_ = false; ObSQLSessionInfo session; ctx.session_info_ = &session; + + EXPECT_TRUE(OB_SUCCESS == oceanbase::ObPreProcessSysVars::init_sys_var()); + EXPECT_TRUE(OB_SUCCESS == session.test_init(0, 0, 0, NULL)); + EXPECT_TRUE(OB_SUCCESS == session.load_default_sys_variable(false, true)); + ObRawExpr *raw_expr = NULL; OBSERVER.init_version(); OK(ObRawExprUtils::make_raw_expr_from_str(expr_str, strlen(expr_str), ctx, raw_expr, columns, diff --git a/unittest/sql/resolver/expr/test_raw_expr_to_str.cpp b/unittest/sql/resolver/expr/test_raw_expr_to_str.cpp index 2e1282efa5..d55c44323d 100644 --- a/unittest/sql/resolver/expr/test_raw_expr_to_str.cpp +++ b/unittest/sql/resolver/expr/test_raw_expr_to_str.cpp @@ -79,6 +79,10 @@ TEST_F(TestRawExprToStr, basic) ctx.session_info_ = &session; OBSERVER.init_version(); + EXPECT_TRUE(OB_SUCCESS == oceanbase::ObPreProcessSysVars::init_sys_var()); + EXPECT_TRUE(OB_SUCCESS == session.test_init(0, 0, 0, NULL)); + EXPECT_TRUE(OB_SUCCESS == session.load_default_sys_variable(false, true)); + const int64_t buf_len = 1024; int64_t pos = 0; char buf[buf_len]; diff --git a/unittest/sql/rewrite/test_query_range.cpp b/unittest/sql/rewrite/test_query_range.cpp index 31d95ed8be..0c4ec49bbf 100644 --- a/unittest/sql/rewrite/test_query_range.cpp +++ b/unittest/sql/rewrite/test_query_range.cpp @@ -61,6 +61,10 @@ public: ObSQLSessionInfo session; ctx.session_info_ = &session; + EXPECT_TRUE(OB_SUCCESS == oceanbase::ObPreProcessSysVars::init_sys_var()); + EXPECT_TRUE(OB_SUCCESS == session.test_init(0, 0, 0, NULL)); + EXPECT_TRUE(OB_SUCCESS == session.load_default_sys_variable(false, true)); + OK(ObRawExprUtils::make_raw_expr_from_str(expr_str, strlen(expr_str), ctx, expr, columns, sys_vars, &sub_query_info, @@ -135,6 +139,10 @@ public: ObSQLSessionInfo session; ctx.session_info_ = &session; + EXPECT_TRUE(OB_SUCCESS == oceanbase::ObPreProcessSysVars::init_sys_var()); + EXPECT_TRUE(OB_SUCCESS == session.test_init(0, 0, 0, NULL)); + EXPECT_TRUE(OB_SUCCESS == session.load_default_sys_variable(false, true)); + for (int64_t i = 0; i < more_range_columns_.count(); ++i) { OK(tmp_range_columns.push_back(more_range_columns_.at(i))); } @@ -1303,6 +1311,8 @@ TEST_F(ObQueryRangeTest, serialize_geo_keypart) int main(int argc, char **argv) { init_sql_factories(); + system("rm -rf test_query_range.log*"); + OB_LOGGER.set_file_name("test_query_range.log", true); OB_LOGGER.set_log_level("TRACE"); int ret = 0; ContextParam param;