diff --git a/src/objit/include/objit/common/ob_item_type.h b/src/objit/include/objit/common/ob_item_type.h index 032c6fc77d..d492677a4c 100755 --- a/src/objit/include/objit/common/ob_item_type.h +++ b/src/objit/include/objit/common/ob_item_type.h @@ -2385,6 +2385,7 @@ typedef enum ObItemType T_BLOCKING, T_PQ_SUBQUERY, T_FLUSH_PRIVILEGES, + T_SCHEMA_ID, T_MAX //Attention: add a new type before T_MAX } ObItemType; diff --git a/src/observer/ob_rpc_processor_simple.cpp b/src/observer/ob_rpc_processor_simple.cpp index 83914582d9..93a3af766c 100644 --- a/src/observer/ob_rpc_processor_simple.cpp +++ b/src/observer/ob_rpc_processor_simple.cpp @@ -72,6 +72,7 @@ #include "sql/spm/ob_spm_controller.h" #endif #include "sql/plan_cache/ob_ps_cache.h" +#include "pl/pl_cache/ob_pl_cache_mgr.h" #include "rootserver/ob_primary_ls_service.h" // for ObPrimaryLSService #include "rootserver/ob_root_utils.h" #include "sql/session/ob_sql_session_info.h" @@ -1348,7 +1349,27 @@ int ObFlushCacheP::process() break; } case CACHE_TYPE_PL_OBJ: { - if (arg_.is_all_tenant_) { + if (arg_.is_fine_grained_) { // fine-grained plan cache evict + bool is_evict_by_schema_id = common::OB_INVALID_ID != arg_.schema_id_; + MTL_SWITCH(arg_.tenant_id_) { + ObPlanCache* plan_cache = MTL(ObPlanCache*); + if (arg_.db_ids_.count() == 0) { + if (is_evict_by_schema_id) { + ret = plan_cache->flush_pl_cache_single_cache_obj(OB_INVALID_ID, arg_.schema_id_); + } else { + ret = plan_cache->flush_pl_cache_single_cache_obj(OB_INVALID_ID, arg_.sql_id_); + } + } else { + for (uint64_t i=0; iflush_pl_cache_single_cache_obj(arg_.db_ids_.at(i), arg_.schema_id_); + } else { + ret = plan_cache->flush_pl_cache_single_cache_obj(arg_.db_ids_.at(i), arg_.sql_id_); + } + } + } + } + } else if (arg_.is_all_tenant_) { common::ObArray tenant_ids; if (OB_ISNULL(GCTX.omt_)) { ret = OB_ERR_UNEXPECTED; diff --git a/src/observer/virtual_table/ob_gv_sql.cpp b/src/observer/virtual_table/ob_gv_sql.cpp index efa0279acd..2b49e22de1 100644 --- a/src/observer/virtual_table/ob_gv_sql.cpp +++ b/src/observer/virtual_table/ob_gv_sql.cpp @@ -206,7 +206,17 @@ int ObGVSql::fill_cells(const ObILibCacheObject *cache_obj, const ObPlanCache &p //sql_id case share::ALL_VIRTUAL_PLAN_STAT_CDE::SQL_ID: { ObString sql_id; - if (!cache_obj->is_sql_crsr()) { + if (OB_NOT_NULL(pl_func)) { + if (OB_FAIL(ob_write_string(*allocator_, + pl_func->get_stat().sql_id_, + sql_id))) { + SERVER_LOG(ERROR, "copy sql_id failed", K(ret)); + } else { + cells[i].set_varchar(sql_id); + cells[i].set_collation_type(ObCharset::get_default_collation( + ObCharset::get_default_charset())); + } + } else if (!cache_obj->is_sql_crsr()) { cells[i].set_null(); } else if (OB_FAIL(ob_write_string(*allocator_, plan->stat_.sql_id_, diff --git a/src/pl/ob_pl.cpp b/src/pl/ob_pl.cpp index 98472e3adc..997a5bda71 100644 --- a/src/pl/ob_pl.cpp +++ b/src/pl/ob_pl.cpp @@ -2098,7 +2098,14 @@ int ObPL::get_pl_function(ObExecContext &ctx, pc_ctx.schema_guard_ = ctx.get_sql_ctx()->schema_guard_; pc_ctx.cache_params_ = ¶ms; pc_ctx.raw_sql_ = sql; - MEMCPY(pc_ctx.sql_id_, ctx.get_sql_ctx()->sql_id_, (int32_t)sizeof(ctx.get_sql_ctx()->sql_id_)); + if (ctx.get_sql_ctx()->sql_id_[0] != '\0') { + MEMCPY(pc_ctx.sql_id_, ctx.get_sql_ctx()->sql_id_, (int32_t)sizeof(ctx.get_sql_ctx()->sql_id_)); + } else { + CK (!pc_ctx.raw_sql_.empty()); + OX ((void)ObSQLUtils::md5(pc_ctx.raw_sql_, + pc_ctx.sql_id_, + (int32_t)sizeof(pc_ctx.sql_id_))); + } pc_ctx.key_.namespace_ = ObLibCacheNameSpace::NS_ANON; pc_ctx.key_.db_id_ = database_id; diff --git a/src/pl/pl_cache/ob_pl_cache.cpp b/src/pl/pl_cache/ob_pl_cache.cpp index a2dabfc32d..e73d09bf5d 100644 --- a/src/pl/pl_cache/ob_pl_cache.cpp +++ b/src/pl/pl_cache/ob_pl_cache.cpp @@ -992,7 +992,19 @@ int ObPLObjectSet::inner_add_cache_obj(ObILibCacheCtx &ctx, LOG_WARN("failed to init pl function", K(ret)); } else { bool is_old_version = false; - if (pl_object_value->check_value_version(pc_ctx.schema_guard_, + if (cache_object->is_anon() || + cache_object->is_call_stmt()) { + common::ObString sql_id_org(common::OB_MAX_SQL_ID_LENGTH, (const char*)&pc_ctx.sql_id_); + if (sql_id_.empty()) { + if (OB_FAIL(ob_write_string(allocator_, sql_id_org, sql_id_))) { + LOG_WARN("failed to deep copy sql_id_", K(sql_id_org), K(ret)); + } + } else { + CK (sql_id_ == sql_id_org); + } + } + if (OB_FAIL(ret)) { + } else if (pl_object_value->check_value_version(pc_ctx.schema_guard_, true, schema_array, is_old_version)) { diff --git a/src/pl/pl_cache/ob_pl_cache.h b/src/pl/pl_cache/ob_pl_cache.h index 8f08ddcf46..3164b63fea 100644 --- a/src/pl/pl_cache/ob_pl_cache.h +++ b/src/pl/pl_cache/ob_pl_cache.h @@ -55,6 +55,7 @@ struct PCVPlSchemaObj schema_version_(0), schema_type_(share::schema::OB_MAX_SCHEMA), table_type_(share::schema::MAX_TABLE_TYPE), + table_name_(), is_tmp_table_(false), is_explicit_db_name_(false), inner_alloc_(nullptr) {} @@ -66,6 +67,7 @@ struct PCVPlSchemaObj schema_version_(0), schema_type_(share::schema::OB_MAX_SCHEMA), table_type_(share::schema::MAX_TABLE_TYPE), + table_name_(), is_tmp_table_(false), is_explicit_db_name_(false), inner_alloc_(alloc) {} @@ -298,6 +300,8 @@ public: void destroy(); + common::ObString &get_sql_id() { return sql_id_; } + int create_new_pl_object_value(ObPLObjectValue *&pl_object_value); void free_pl_object_value(ObPLObjectValue *pl_object_value); int64_t get_mem_size(); @@ -306,6 +310,7 @@ public: private: bool is_inited_; ObPLObjectKey key_; //used for manager key memory + common::ObString sql_id_; // a list of plan sets with different param types combination common::ObDList object_value_sets_; }; diff --git a/src/pl/pl_cache/ob_pl_cache_mgr.cpp b/src/pl/pl_cache/ob_pl_cache_mgr.cpp index 4bde114b1a..5d19674a27 100644 --- a/src/pl/pl_cache/ob_pl_cache_mgr.cpp +++ b/src/pl/pl_cache/ob_pl_cache_mgr.cpp @@ -204,5 +204,27 @@ int ObPLCacheMgr::cache_evict_all_pl(ObPlanCache *lib_cache) return ret; } +template +int ObPLCacheMgr::cache_evict_pl_cache_single(ObPlanCache *lib_cache, uint64_t db_id, EvictAttr &attr) +{ + int ret = OB_SUCCESS; + PL_CACHE_LOG(TRACE, "cache evict single plan start"); + if (OB_ISNULL(lib_cache)) { + ret = OB_ERR_UNEXPECTED; + LOG_WARN("lib cache is null"); + } else { + LCKeyValueArray to_evict_keys; + GETPLKVEntryOp get_ids_op(db_id, attr, &to_evict_keys, PCV_GET_PL_KEY_HANDLE); + if (OB_FAIL(lib_cache->foreach_cache_evict(get_ids_op))) { + PL_CACHE_LOG(WARN, "failed to foreach cache evict", K(ret)); + } + } + PL_CACHE_LOG(TRACE, "cache evict single plan end"); + return ret; +} + +template int ObPLCacheMgr::cache_evict_pl_cache_single(ObPlanCache *lib_cache, uint64_t db_id, uint64_t &schema_id); +template int ObPLCacheMgr::cache_evict_pl_cache_single(ObPlanCache *lib_cache, uint64_t db_id, common::ObString &sql_id); + } } \ No newline at end of file diff --git a/src/pl/pl_cache/ob_pl_cache_mgr.h b/src/pl/pl_cache/ob_pl_cache_mgr.h index b919624bb6..59d4f886b5 100644 --- a/src/pl/pl_cache/ob_pl_cache_mgr.h +++ b/src/pl/pl_cache/ob_pl_cache_mgr.h @@ -53,6 +53,84 @@ struct ObGetPLKVEntryOp : public sql::ObKVEntryTraverseOp } }; +struct ObGetPLKVEntryBySchemaIdOp : public ObKVEntryTraverseOp +{ + explicit ObGetPLKVEntryBySchemaIdOp(uint64_t db_id, + uint64_t schema_id, + LCKeyValueArray *key_val_list, + const CacheRefHandleID ref_handle) + : ObKVEntryTraverseOp(key_val_list, ref_handle), + db_id_(db_id), + schema_id_(schema_id) + { + } + virtual int check_entry_match(LibCacheKVEntry &entry, bool &is_match) + { + int ret = OB_SUCCESS; + is_match = false; + if (ObLibCacheNameSpace::NS_PRCR == entry.first->namespace_ || + ObLibCacheNameSpace::NS_SFC == entry.first->namespace_ || + ObLibCacheNameSpace::NS_PKG == entry.first->namespace_) { + ObPLObjectKey *key = static_cast(entry.first); + if (db_id_ != common::OB_INVALID_ID && db_id_ != key->db_id_) { + // skip entry that has non-matched db_id + } else if (schema_id_ != key->key_id_) { + // skip entry which is not same schema id + } else { + is_match = true; + } + } + return ret; + } + + uint64_t db_id_; + uint64_t schema_id_; +}; + +struct ObGetPLKVEntryBySQLIDOp : public ObKVEntryTraverseOp +{ + explicit ObGetPLKVEntryBySQLIDOp(uint64_t db_id, + common::ObString sql_id, + LCKeyValueArray *key_val_list, + const CacheRefHandleID ref_handle) + : ObKVEntryTraverseOp(key_val_list, ref_handle), + db_id_(db_id), + sql_id_(sql_id) + { + } + virtual int check_entry_match(LibCacheKVEntry &entry, bool &is_match) + { + int ret = OB_SUCCESS; + is_match = false; + if (ObLibCacheNameSpace::NS_ANON == entry.first->namespace_ || + ObLibCacheNameSpace::NS_CALLSTMT == entry.first->namespace_) { + ObPLObjectKey *key = static_cast(entry.first); + ObPLObjectSet *node = static_cast(entry.second); + if (db_id_ != common::OB_INVALID_ID && db_id_ != key->db_id_) { + // skip entry that has non-matched db_id + } else if (sql_id_ != node->get_sql_id()) { + // skip entry which not contains same sql_id + } else { + is_match = true; + } + } + return ret; + } + bool contain_sql_id(common::ObIArray &sql_ids) + { + bool contains = false; + for (int64_t i = 0; !contains && i < sql_ids.count(); i++) { + if (sql_ids.at(i) == sql_id_) { + contains = true; + } + } + return contains; + } + + uint64_t db_id_; + common::ObString sql_id_; +}; + class ObPLCacheMgr { public: @@ -65,6 +143,8 @@ public: ObCacheObjGuard& guard, ObPLCacheCtx &pc_ctx); static int cache_evict_all_pl(ObPlanCache *lib_cache); + template + static int cache_evict_pl_cache_single(ObPlanCache *lib_cache, uint64_t db_id, EvictAttr &attr); private: static int add_pl_object(ObPlanCache *lib_cache, diff --git a/src/rootserver/ob_system_admin_util.cpp b/src/rootserver/ob_system_admin_util.cpp index 35096ddaf4..641b28a72d 100644 --- a/src/rootserver/ob_system_admin_util.cpp +++ b/src/rootserver/ob_system_admin_util.cpp @@ -1963,6 +1963,7 @@ int ObAdminFlushCache::execute(const obrpc::ObAdminFlushCacheArg &arg) if (arg.is_fine_grained_) { fc_arg.sql_id_ = arg.sql_id_; fc_arg.is_fine_grained_ = arg.is_fine_grained_; + fc_arg.schema_id_ = arg.schema_id_; for(int64_t j=0; OB_SUCC(ret) && jflush_pl_cache_single_cache_obj(OB_INVALID_ID, stmt.flush_cache_arg_.schema_id_); + } else { + ret = plan_cache->flush_pl_cache_single_cache_obj(OB_INVALID_ID, sql_id); + } + } else { // evict db by db + for(int64_t j = 0; j < db_num; j++) { // ignore ret + if (is_evict_by_schema_id) { + ret = plan_cache->flush_pl_cache_single_cache_obj(stmt.flush_cache_arg_.db_ids_.at(j), stmt.flush_cache_arg_.schema_id_); + } else { + ret = plan_cache->flush_pl_cache_single_cache_obj(stmt.flush_cache_arg_.db_ids_.at(j), sql_id); + } + } + } + } + } + } + } else if (0 == tenant_num) { common::ObArray tenant_ids; if (OB_ISNULL(GCTX.omt_)) { ret = OB_ERR_UNEXPECTED; diff --git a/src/sql/parser/non_reserved_keywords_mysql_mode.c b/src/sql/parser/non_reserved_keywords_mysql_mode.c index 9c07c9f32b..5c1dc2c4cc 100644 --- a/src/sql/parser/non_reserved_keywords_mysql_mode.c +++ b/src/sql/parser/non_reserved_keywords_mysql_mode.c @@ -809,6 +809,7 @@ static const NonReservedKeyword Mysql_none_reserved_keywords[] = {"sql_buffer_result", SQL_BUFFER_RESULT}, {"sql_cache", SQL_CACHE}, {"sql_id", SQL_ID}, + {"schema_id", SCHEMA_ID}, {"sql_no_cache", SQL_NO_CACHE}, {"sql_thread", SQL_THREAD}, {"sql_tsi_day", SQL_TSI_DAY}, diff --git a/src/sql/parser/sql_parser_mysql_mode.y b/src/sql/parser/sql_parser_mysql_mode.y index cb17fc60c0..ccbe3d68f7 100644 --- a/src/sql/parser/sql_parser_mysql_mode.y +++ b/src/sql/parser/sql_parser_mysql_mode.y @@ -340,7 +340,7 @@ END_P SET_VAR DELIMITER SERVER_IP SERVER_PORT SERVER_TYPE SERVICE SESSION SESSION_USER SET_MASTER_CLUSTER SET_SLAVE_CLUSTER SET_TP SHARE SHUTDOWN SIGNED SIMPLE SKIP_INDEX SLAVE SLOW SLOT_IDX SNAPSHOT SOCKET SOME SONAME SOUNDS SOURCE SPFILE SPLIT SQL_AFTER_GTIDS SQL_AFTER_MTS_GAPS SQL_BEFORE_GTIDS SQL_BUFFER_RESULT - SQL_CACHE SQL_NO_CACHE SQL_ID SQL_THREAD SQL_TSI_DAY SQL_TSI_HOUR SQL_TSI_MINUTE SQL_TSI_MONTH + SQL_CACHE SQL_NO_CACHE SQL_ID SCHEMA_ID SQL_THREAD SQL_TSI_DAY SQL_TSI_HOUR SQL_TSI_MINUTE SQL_TSI_MONTH SQL_TSI_QUARTER SQL_TSI_SECOND SQL_TSI_WEEK SQL_TSI_YEAR SRID STANDBY STAT START STARTS STATS_AUTO_RECALC STATS_PERSISTENT STATS_SAMPLE_PAGES STATUS STATEMENTS STATISTICS STD STDDEV STDDEV_POP STDDEV_SAMP STRONG SYNCHRONIZATION SYNCHRONOUS STOP STORAGE STORAGE_FORMAT_VERSION STORE STORING STRING @@ -475,7 +475,7 @@ END_P SET_VAR DELIMITER %type ls opt_tenant_list_or_ls_or_tablet_id ls_server_or_server_or_zone_or_tenant add_or_alter_zone_option %type opt_tenant_list_v2 %type suspend_or_resume tenant_name opt_tenant_name cache_name opt_cache_name file_id opt_file_id cancel_task_type -%type sql_id_expr opt_sql_id +%type sql_id_or_schema_id_expr opt_sql_id_or_schema_id %type namespace_expr opt_namespace %type server_action server_list opt_server_list %type zone_action upgrade_action @@ -16012,7 +16012,7 @@ ALTER SYSTEM BOOTSTRAP server_info_list malloc_non_terminal_node($$, result->malloc_pool_, T_BOOTSTRAP, 1, server_list); } | -ALTER SYSTEM FLUSH cache_type CACHE opt_namespace opt_sql_id opt_databases opt_tenant_list flush_scope +ALTER SYSTEM FLUSH cache_type CACHE opt_namespace opt_sql_id_or_schema_id opt_databases opt_tenant_list flush_scope { // system tenant use only. malloc_non_terminal_node($$, result->malloc_pool_, T_FLUSH_CACHE, 6, $4, $6, $7, $8, $9, $10); @@ -17677,16 +17677,21 @@ SUSPEND } ; -sql_id_expr: +sql_id_or_schema_id_expr: SQL_ID opt_equal_mark STRING_VALUE { (void)($2); malloc_non_terminal_node($$, result->malloc_pool_, T_SQL_ID, 1, $3); } +| SCHEMA_ID opt_equal_mark INTNUM +{ + (void)($2); + malloc_non_terminal_node($$, result->malloc_pool_, T_SCHEMA_ID, 1, $3); +} ; -opt_sql_id: -sql_id_expr +opt_sql_id_or_schema_id: +sql_id_or_schema_id_expr { $$ = $1; } @@ -19806,6 +19811,7 @@ ACCOUNT | SQL_BUFFER_RESULT | SQL_CACHE | SQL_ID +| SCHEMA_ID | SQL_NO_CACHE | SQL_THREAD | SQL_TSI_DAY diff --git a/src/sql/plan_cache/ob_plan_cache.cpp b/src/sql/plan_cache/ob_plan_cache.cpp index b260fbee93..d6467eb420 100644 --- a/src/sql/plan_cache/ob_plan_cache.cpp +++ b/src/sql/plan_cache/ob_plan_cache.cpp @@ -1342,6 +1342,8 @@ int ObPlanCache::foreach_cache_evict(CallBack &cb) } template int ObPlanCache::foreach_cache_evict(pl::ObGetPLKVEntryOp &); +template int ObPlanCache::foreach_cache_evict(pl::ObGetPLKVEntryBySchemaIdOp &); +template int ObPlanCache::foreach_cache_evict(pl::ObGetPLKVEntryBySQLIDOp &); // Remove all cache object in the lib cache int ObPlanCache::cache_evict_all_obj() @@ -2567,6 +2569,42 @@ int ObPlanCache::flush_lib_cache_by_ns(const ObLibCacheNameSpace ns) return ret; } +template +int ObPlanCache::flush_pl_cache_single_cache_obj(uint64_t db_id, EvictAttr &attr) +{ + int ret = OB_SUCCESS; + observer::ObReqTimeGuard req_timeinfo_guard; + if (OB_FAIL(ObPLCacheMgr::cache_evict_pl_cache_single(this, db_id, attr))) { + SQL_PC_LOG(ERROR, "Plan cache evict failed, please check", K(ret)); + } + ObArray deleted_objs; + int64_t safe_timestamp = INT64_MAX; + if (OB_FAIL(ret)) { + // do nothing + } else if (OB_FAIL(observer::ObGlobalReqTimeService::get_instance() + .get_global_safe_timestamp(safe_timestamp))) { + SQL_PC_LOG(ERROR, "failed to get global safe timestamp", K(ret)); + } else if (OB_FAIL(dump_deleted_objs(deleted_objs, safe_timestamp))) { + SQL_PC_LOG(WARN, "failed to get deleted sql objs", K(ret)); + } else { + int tmp_ret = OB_SUCCESS; + tmp_ret = OB_E(EventTable::EN_FLUSH_PC_NOT_CLEANUP_LEAK_MEM_ERROR) OB_SUCCESS; + if (OB_SUCCESS == tmp_ret) { + LOG_INFO("Deleted Cache Objs", K(deleted_objs)); + for (int64_t i = 0; i < deleted_objs.count(); i++) { // ignore error code and continue + if (OB_FAIL(ObCacheObjectFactory::destroy_cache_obj(true, + deleted_objs.at(i).obj_id_, + this))) { + LOG_WARN("failed to destroy cache obj", K(ret)); + } + } + } + } + return ret; +} + +template int ObPlanCache::flush_pl_cache_single_cache_obj(uint64_t db_id, uint64_t &schema_id); +template int ObPlanCache::flush_pl_cache_single_cache_obj(uint64_t db_id, common::ObString &sql_id); int ObPlanCache::flush_pl_cache() { diff --git a/src/sql/plan_cache/ob_plan_cache.h b/src/sql/plan_cache/ob_plan_cache.h index b30c83a4f1..4f45cb64d1 100644 --- a/src/sql/plan_cache/ob_plan_cache.h +++ b/src/sql/plan_cache/ob_plan_cache.h @@ -424,6 +424,8 @@ public: public: int flush_plan_cache(); int flush_plan_cache_by_sql_id(uint64_t db_id, common::ObString sql_id); + template + int flush_pl_cache_single_cache_obj(uint64_t db_id, EvictAttr &attr); int flush_lib_cache(); int flush_lib_cache_by_ns(const ObLibCacheNameSpace ns); int flush_pl_cache(); diff --git a/src/sql/resolver/cmd/ob_alter_system_resolver.cpp b/src/sql/resolver/cmd/ob_alter_system_resolver.cpp index c3ff248a63..c14626db40 100644 --- a/src/sql/resolver/cmd/ob_alter_system_resolver.cpp +++ b/src/sql/resolver/cmd/ob_alter_system_resolver.cpp @@ -818,7 +818,8 @@ int ObFlushCacheResolver::resolve(const ParseNode &parse_tree) } else if (OB_ISNULL(sql_id_node)) { // do nothing // currently, only support plan cache's fine-grained cache evict - } else if (stmt->flush_cache_arg_.cache_type_ != CACHE_TYPE_PLAN) { + } else if (stmt->flush_cache_arg_.cache_type_ != CACHE_TYPE_PLAN && + stmt->flush_cache_arg_.cache_type_ != CACHE_TYPE_PL_OBJ) { ret = OB_NOT_SUPPORTED; LOG_WARN("only support plan cache's fine-grained cache evict", K(stmt->flush_cache_arg_.cache_type_), K(ret)); LOG_USER_ERROR(OB_NOT_SUPPORTED, "only support plan cache's fine-grained cache evict, other type"); @@ -827,18 +828,25 @@ int ObFlushCacheResolver::resolve(const ParseNode &parse_tree) LOG_WARN("not supported plan cache's fine-grained cache evict in oracle mode", K(ret)); LOG_USER_ERROR(OB_NOT_SUPPORTED, "plan cache's fine-grained cache evict in oracle mode is"); } else if (OB_ISNULL(sql_id_node->children_) - || OB_ISNULL(sql_id_node->children_[0]) - || T_SQL_ID != sql_id_node->type_) { + || OB_ISNULL(sql_id_node->children_[0])) { ret = OB_INVALID_ARGUMENT; LOG_WARN("invalid argument", K(ret)); - } else if (sql_id_node->children_[0]->str_len_ > (OB_MAX_SQL_ID_LENGTH+1)) { - ret = OB_INVALID_ARGUMENT; - LOG_WARN("invalid argument", K(ret)); - } else { - stmt->flush_cache_arg_.sql_id_.assign_ptr( - sql_id_node->children_[0]->str_value_, - static_cast(sql_id_node->children_[0]->str_len_)); + } else if (T_SQL_ID == sql_id_node->type_) { + if (sql_id_node->children_[0]->str_len_ > (OB_MAX_SQL_ID_LENGTH+1)) { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid argument", K(ret)); + } else { + stmt->flush_cache_arg_.sql_id_.assign_ptr( + sql_id_node->children_[0]->str_value_, + static_cast(sql_id_node->children_[0]->str_len_)); + stmt->flush_cache_arg_.is_fine_grained_ = true; + } + } else if (T_SCHEMA_ID == sql_id_node->type_) { + stmt->flush_cache_arg_.schema_id_ = sql_id_node->children_[0]->value_; stmt->flush_cache_arg_.is_fine_grained_ = true; + } else { + ret = OB_INVALID_ARGUMENT; + LOG_WARN("invalid argument", K(ret)); } // retrive schema guard diff --git a/src/sql/resolver/cmd/ob_call_procedure_resolver.cpp b/src/sql/resolver/cmd/ob_call_procedure_resolver.cpp index e6977b4214..008e304a52 100644 --- a/src/sql/resolver/cmd/ob_call_procedure_resolver.cpp +++ b/src/sql/resolver/cmd/ob_call_procedure_resolver.cpp @@ -240,6 +240,9 @@ int ObCallProcedureResolver::generate_pl_cache_ctx(pl::ObPLCacheCtx &pc_ctx) pc_ctx.key_.sessid_ = 0; pc_ctx.key_.key_id_ = OB_INVALID_ID; pc_ctx.key_.name_ = params_.cur_sql_; + (void)ObSQLUtils::md5(pc_ctx.raw_sql_, + pc_ctx.sql_id_, + (int32_t)sizeof(pc_ctx.sql_id_)); } return ret; }