[CP]:sync json pl manage from 42x to master
This commit is contained in:
@ -98,22 +98,20 @@ int ObExprTreat::cg_expr(ObExprCGCtx &expr_cg_ctx,
|
||||
static int treat_as_json_udt(const ObExpr &expr, ObEvalCtx &ctx, common::ObIAllocator &temp_allocator,
|
||||
pl::ObPLOpaque *opaque, ObDatum &res) {
|
||||
INIT_SUCC(ret);
|
||||
ObJsonNode *json_doc = nullptr;
|
||||
pl::ObPLJsonBaseType *jsontype = nullptr;
|
||||
pl::ObPlJsonNode *pl_json_node = nullptr;
|
||||
pl::ObPLJsonBaseType *new_jsontype = nullptr;
|
||||
ObObj res_obj;
|
||||
|
||||
if(OB_ISNULL(jsontype = static_cast<pl::ObPLJsonBaseType*>(opaque))) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("cast to json type is null", K(ret), K(opaque));
|
||||
} else if(OB_ISNULL(json_doc = jsontype->get_data())) {
|
||||
} else if(OB_ISNULL(pl_json_node = jsontype->get_data())) {
|
||||
res.set_null();
|
||||
} else {
|
||||
ObJsonNode * json_node_copy = nullptr;
|
||||
if (OB_ISNULL(json_node_copy = json_doc->clone(&ctx.exec_ctx_.get_allocator()))) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to clone json node", K(ret));
|
||||
} else if (OB_FAIL(pl::ObPlJsonUtil::transform_JsonBase_2_PLJsonType(ctx.exec_ctx_, json_node_copy, new_jsontype))) {
|
||||
if (OB_FAIL(pl::ObPlJsonUtil::transform_JsonBase_2_PLJsonType(ctx.exec_ctx_,
|
||||
pl_json_node->get_ref_node() ? pl_json_node->get_ref_node() : pl_json_node->get_data_node(),
|
||||
new_jsontype))) {
|
||||
LOG_WARN("failed to transfrom ObJsonNode to ObPLJsonBaseType", K(ret));
|
||||
} else if(OB_ISNULL(new_jsontype)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "share/rc/ob_tenant_base.h"
|
||||
#include "pl/sys_package/ob_dbms_sql.h"
|
||||
#include "pl/ob_pl_package_state.h"
|
||||
#include "pl/ob_pl_json_type.h"
|
||||
#include "rpc/obmysql/ob_sql_sock_session.h"
|
||||
#include "sql/engine/expr/ob_expr_regexp_context.h"
|
||||
|
||||
@ -94,6 +95,7 @@ ObBasicSessionInfo::ObBasicSessionInfo(const uint64_t tenant_id)
|
||||
package_info_allocator_(sizeof(pl::ObPLPackageState), common::OB_MALLOC_NORMAL_BLOCK_SIZE - 32,
|
||||
ObMalloc(lib::ObMemAttr(orig_tenant_id_, "SessPackageInfo"))),
|
||||
name_pool_(lib::ObMemAttr(orig_tenant_id_, ObModIds::OB_SQL_SESSION), OB_MALLOC_NORMAL_BLOCK_SIZE),
|
||||
json_pl_mngr_(0),
|
||||
trans_flags_(),
|
||||
sql_scope_flags_(),
|
||||
need_reset_package_(false),
|
||||
@ -286,6 +288,9 @@ void ObBasicSessionInfo::destroy()
|
||||
}
|
||||
total_stmt_tables_.reset();
|
||||
cur_stmt_tables_.reset();
|
||||
#ifdef OB_BUILD_ORACLE_PL
|
||||
pl::ObPlJsonTypeManager::release(get_json_pl_mngr());
|
||||
#endif
|
||||
}
|
||||
|
||||
void ObBasicSessionInfo::clean_status()
|
||||
@ -6657,5 +6662,48 @@ observer::ObSMConnection *ObBasicSessionInfo::get_sm_connection()
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
void ObBasicSessionInfo::destory_json_pl_mngr()
|
||||
{
|
||||
#ifdef OB_BUILD_ORACLE_PL
|
||||
if (json_pl_mngr_) {
|
||||
pl::ObPlJsonTypeManager* handle = reinterpret_cast<pl::ObPlJsonTypeManager*>(json_pl_mngr_);
|
||||
handle->destroy();
|
||||
common::ObIAllocator& allocator = get_session_allocator();
|
||||
allocator.free(handle);
|
||||
json_pl_mngr_ = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
intptr_t ObBasicSessionInfo::get_json_pl_mngr()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
#ifdef OB_BUILD_ORACLE_PL
|
||||
if (!json_pl_mngr_) {
|
||||
common::ObIAllocator& allocator = get_session_allocator();
|
||||
pl::ObPlJsonTypeManager* handle = static_cast<pl::ObPlJsonTypeManager*>(
|
||||
allocator.alloc(sizeof(pl::ObPlJsonTypeManager)));
|
||||
if (OB_ISNULL(handle)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed to allocate handle", K(ret));
|
||||
} else {
|
||||
handle = new (handle) pl::ObPlJsonTypeManager(orig_tenant_id_);
|
||||
if (OB_FAIL(handle->init())) {
|
||||
allocator.free(handle);
|
||||
LOG_WARN("failed to init json pl type manager", K(ret));
|
||||
} else {
|
||||
json_pl_mngr_ = reinterpret_cast<intptr_t>(handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("failed to create json pl type manager", K(ret));
|
||||
#endif
|
||||
|
||||
return json_pl_mngr_;
|
||||
}
|
||||
|
||||
}//end of namespace sql
|
||||
}//end of namespace oceanbase
|
||||
|
||||
@ -592,8 +592,8 @@ public:
|
||||
const common::ObLogIdLevelMap *get_log_id_level_map() const;
|
||||
const common::ObString &get_client_version() const { return client_version_; }
|
||||
const common::ObString &get_driver_version() const { return driver_version_; }
|
||||
|
||||
|
||||
void destory_json_pl_mngr();
|
||||
intptr_t get_json_pl_mngr();
|
||||
int get_tx_timeout(int64_t &tx_timeout) const
|
||||
{
|
||||
tx_timeout = sys_vars_cache_.get_ob_trx_timeout();
|
||||
@ -2181,6 +2181,7 @@ protected:
|
||||
common::ObSmallBlockAllocator<> cursor_info_allocator_; // for alloc memory of PS CURSOR/SERVER REF CURSOR
|
||||
common::ObSmallBlockAllocator<> package_info_allocator_; // for alloc memory of session package state
|
||||
common::ObStringBuf name_pool_; // for variables names and statement names
|
||||
intptr_t json_pl_mngr_; // for pl json manage
|
||||
TransFlags trans_flags_;
|
||||
SqlScopeFlags sql_scope_flags_;
|
||||
bool need_reset_package_; // for dbms_session.reset_package
|
||||
|
||||
Reference in New Issue
Block a user