Fix incorrect plan sharing causing crash
This commit is contained in:
		@ -6076,10 +6076,12 @@ int ObSPIService::spi_interface_impl(pl::ObPLExecCtx *ctx, const char *interface
 | 
			
		||||
    LOG_WARN("Argument passed in is NULL", K(ctx), K(interface_name), K(ret));
 | 
			
		||||
  } else if (OB_ISNULL(ctx->exec_ctx_)
 | 
			
		||||
      || OB_ISNULL(ctx->params_)
 | 
			
		||||
      || OB_ISNULL(ctx->result_)) {
 | 
			
		||||
      || OB_ISNULL(ctx->result_)
 | 
			
		||||
      || OB_ISNULL(ctx->exec_ctx_->get_my_session())) {
 | 
			
		||||
    ret = OB_ERR_UNEXPECTED;
 | 
			
		||||
    LOG_WARN("Invalid context", K(ctx->exec_ctx_), K(ctx->params_), K(ctx->result_));
 | 
			
		||||
  } else {
 | 
			
		||||
    ctx->exec_ctx_->get_my_session()->init_use_rich_format();
 | 
			
		||||
    ObString name(interface_name);
 | 
			
		||||
    PL_C_INTERFACE_t fp = GCTX.pl_engine_->get_interface_service().get_entry(name);
 | 
			
		||||
    if (nullptr != fp) {
 | 
			
		||||
 | 
			
		||||
@ -2312,6 +2312,7 @@ OB_INLINE int ObPlanCache::construct_plan_cache_key(ObSQLSessionInfo &session,
 | 
			
		||||
  pc_key.namespace_ = ns;
 | 
			
		||||
  pc_key.sys_vars_str_ = session.get_sys_var_in_pc_str();
 | 
			
		||||
  pc_key.config_str_ = session.get_config_in_pc_str();
 | 
			
		||||
  pc_key.use_rich_vector_format_ = session.use_rich_format();
 | 
			
		||||
  pc_key.is_weak_read_ = is_weak;
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -56,7 +56,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
 | 
			
		||||
        db_id_(common::OB_INVALID_ID),
 | 
			
		||||
        sessid_(0),
 | 
			
		||||
        mode_(PC_TEXT_MODE),
 | 
			
		||||
        is_weak_read_(false) {}
 | 
			
		||||
        flag_(0) {}
 | 
			
		||||
 | 
			
		||||
  inline void reset()
 | 
			
		||||
  {
 | 
			
		||||
@ -67,7 +67,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
 | 
			
		||||
    mode_ = PC_TEXT_MODE;
 | 
			
		||||
    sys_vars_str_.reset();
 | 
			
		||||
    config_str_.reset();
 | 
			
		||||
    is_weak_read_ = false;
 | 
			
		||||
    flag_ = 0;
 | 
			
		||||
    namespace_ = NS_INVALID;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -92,7 +92,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
 | 
			
		||||
      sessid_ = pc_key.sessid_;
 | 
			
		||||
      mode_ = pc_key.mode_;
 | 
			
		||||
      namespace_ = pc_key.namespace_;
 | 
			
		||||
      is_weak_read_ = pc_key.is_weak_read_;
 | 
			
		||||
      flag_ = pc_key.flag_;
 | 
			
		||||
    }
 | 
			
		||||
    return ret;
 | 
			
		||||
  }
 | 
			
		||||
@ -116,6 +116,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
 | 
			
		||||
    hash_ret = common::murmurhash(&db_id_, sizeof(uint64_t), hash_ret);
 | 
			
		||||
    hash_ret = common::murmurhash(&sessid_, sizeof(uint32_t), hash_ret);
 | 
			
		||||
    hash_ret = common::murmurhash(&mode_, sizeof(PlanCacheMode), hash_ret);
 | 
			
		||||
    hash_ret = common::murmurhash(&flag_, sizeof(flag_), hash_ret);
 | 
			
		||||
    hash_ret = sys_vars_str_.hash(hash_ret);
 | 
			
		||||
    hash_ret = config_str_.hash(hash_ret);
 | 
			
		||||
    hash_ret = common::murmurhash(&namespace_, sizeof(ObLibCacheNameSpace), hash_ret);
 | 
			
		||||
@ -133,7 +134,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
 | 
			
		||||
                   mode_ == pc_key.mode_ &&
 | 
			
		||||
                   sys_vars_str_ == pc_key.sys_vars_str_ &&
 | 
			
		||||
                   config_str_ == pc_key.config_str_ &&
 | 
			
		||||
                   is_weak_read_ == pc_key.is_weak_read_ &&
 | 
			
		||||
                   flag_ == pc_key.flag_ &&
 | 
			
		||||
                   namespace_ == pc_key.namespace_;
 | 
			
		||||
 | 
			
		||||
    return cmp_ret;
 | 
			
		||||
@ -145,7 +146,7 @@ struct ObPlanCacheKey : public ObILibCacheKey
 | 
			
		||||
               K_(mode),
 | 
			
		||||
               K_(sys_vars_str),
 | 
			
		||||
               K_(config_str),
 | 
			
		||||
               K_(is_weak_read),
 | 
			
		||||
               K_(flag),
 | 
			
		||||
               K_(namespace));
 | 
			
		||||
  //通过name来进行查找,一般是shared sql/procedure
 | 
			
		||||
  //cursor用这种方式,对应的namespace是CRSR
 | 
			
		||||
@ -158,7 +159,16 @@ struct ObPlanCacheKey : public ObILibCacheKey
 | 
			
		||||
  PlanCacheMode mode_;
 | 
			
		||||
  common::ObString sys_vars_str_;
 | 
			
		||||
  common::ObString config_str_;
 | 
			
		||||
  bool is_weak_read_;
 | 
			
		||||
  union
 | 
			
		||||
  {
 | 
			
		||||
    uint16_t flag_;
 | 
			
		||||
    struct
 | 
			
		||||
    {
 | 
			
		||||
      uint16_t is_weak_read_ : 1;
 | 
			
		||||
      uint16_t use_rich_vector_format_ : 1;
 | 
			
		||||
      uint16_t reserved_ : 14; // reserved
 | 
			
		||||
    };
 | 
			
		||||
  };
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//记录快速化参数后不需要扣参数的原始字符串及相关信息
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user