fix compilation errors when OB_ENABLE_PCH=OFF
This commit is contained in:
parent
7110e4aefa
commit
acaa03edd3
@ -30,6 +30,7 @@
|
||||
#include "lib/lock/ob_mutex.h"
|
||||
#include "lib/allocator/ob_malloc.h"
|
||||
#include "lib/oblog/ob_async_log_struct.h"
|
||||
#include "lib/thread/ob_thread_name.h"
|
||||
|
||||
using namespace oceanbase::lib;
|
||||
|
||||
|
@ -10,27 +10,28 @@
|
||||
* See the Mulan PubL v2 for more details.
|
||||
*/
|
||||
|
||||
#define USING_LOG_PREFIX SERVER
|
||||
#include "ob_table_query_sync_processor.h"
|
||||
#include "ob_table_rpc_processor_util.h"
|
||||
#include "observer/ob_service.h"
|
||||
#include "storage/ob_partition_service.h"
|
||||
#include "ob_table_end_trans_cb.h"
|
||||
#include "sql/optimizer/ob_table_location.h" // ObTableLocation
|
||||
#include "lib/stat/ob_diagnose_info.h"
|
||||
#include "lib/stat/ob_session_stat.h"
|
||||
#include "observer/ob_server.h"
|
||||
#include "lib/string/ob_strings.h"
|
||||
#define USING_LOG_PREFIX SERVER
|
||||
#include "ob_table_query_sync_processor.h"
|
||||
#include "ob_table_rpc_processor_util.h"
|
||||
#include "observer/ob_service.h"
|
||||
#include "storage/ob_partition_service.h"
|
||||
#include "ob_table_end_trans_cb.h"
|
||||
#include "sql/optimizer/ob_table_location.h" // ObTableLocation
|
||||
#include "lib/stat/ob_diagnose_info.h"
|
||||
#include "lib/stat/ob_session_stat.h"
|
||||
#include "observer/ob_server.h"
|
||||
#include "lib/string/ob_strings.h"
|
||||
#include "lib/rc/ob_rc.h"
|
||||
|
||||
using namespace oceanbase::observer;
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::table;
|
||||
using namespace oceanbase::share;
|
||||
using namespace oceanbase::sql;
|
||||
using namespace oceanbase::observer;
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::table;
|
||||
using namespace oceanbase::share;
|
||||
using namespace oceanbase::sql;
|
||||
|
||||
/**
|
||||
* ---------------------------------------- ObTableQuerySyncSession ----------------------------------------
|
||||
*/
|
||||
/**
|
||||
* ---------------------------------------- ObTableQuerySyncSession ----------------------------------------
|
||||
*/
|
||||
int ObTableQuerySyncSession::deep_copy_select_columns(const ObTableQuery &query)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
@ -44,7 +45,7 @@ int ObTableQuerySyncSession::deep_copy_select_columns(const ObTableQuery &query)
|
||||
} else if (OB_FAIL(query_.add_select_column(tmp_str))) {
|
||||
LOG_WARN("failed to add column name", K(ret));
|
||||
}
|
||||
} // end for
|
||||
} // end for
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -57,7 +58,8 @@ void ObTableQuerySyncSession::set_result_iterator(ObNormalTableQueryResultIterat
|
||||
}
|
||||
}
|
||||
|
||||
int ObTableQuerySyncSession::init() {
|
||||
int ObTableQuerySyncSession::init()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
lib::MemoryContext mem_context = nullptr;
|
||||
lib::ContextParam param;
|
||||
@ -164,9 +166,9 @@ int ObQuerySyncMgr::get_query_session(uint64_t sessid, ObTableQuerySyncSession *
|
||||
} else if (OB_ISNULL(query_session)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("Unexpected null query session", K(ret), K(sessid));
|
||||
} else if (query_session->is_in_use()) { // one session cannot be held concurrently
|
||||
} else if (query_session->is_in_use()) { // one session cannot be held concurrently
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("query session already in use", K(sessid));
|
||||
LOG_WARN("query session already in use", K(sessid));
|
||||
} else {
|
||||
query_session->set_in_use(true);
|
||||
}
|
||||
@ -225,8 +227,7 @@ void ObQuerySyncMgr::clean_timeout_query_session()
|
||||
LOG_WARN("clean timeout query session success", K(ret), K(sess_id));
|
||||
}
|
||||
get_locker(sess_id).unlock();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,7 +250,8 @@ ObTableQuerySyncSession *ObQuerySyncMgr::alloc_query_session()
|
||||
return query_session;
|
||||
}
|
||||
|
||||
int ObQuerySyncMgr::ObGetAllSessionIdOp::operator()(QuerySessionPair& entry) {
|
||||
int ObQuerySyncMgr::ObGetAllSessionIdOp::operator()(QuerySessionPair &entry)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (OB_FAIL(session_id_array_.push_back(entry.first))) {
|
||||
LOG_WARN("fail to push back query session id", K(ret));
|
||||
@ -429,7 +431,7 @@ int ObTableQuerySyncP::query_scan_with_new_context(
|
||||
ret = OB_SUCCESS;
|
||||
result_.is_end_ = true;
|
||||
}
|
||||
} else if (result_iterator->has_more_result()){
|
||||
} else if (result_iterator->has_more_result()) {
|
||||
result_.is_end_ = false;
|
||||
query_session->deep_copy_select_columns(arg_.query_);
|
||||
query_session->set_result_iterator(dynamic_cast<ObNormalTableQueryResultIterator *>(result_iterator));
|
||||
@ -445,8 +447,7 @@ int ObTableQuerySyncP::query_scan_with_init()
|
||||
table_service_ctx_ = query_session_->get_table_service_ctx();
|
||||
table_service_ctx_->scan_param_.is_thread_scope_ = false;
|
||||
uint64_t &table_id = table_service_ctx_->param_table_id();
|
||||
table_service_ctx_->init_param(
|
||||
timeout_ts_,
|
||||
table_service_ctx_->init_param(timeout_ts_,
|
||||
this,
|
||||
query_session_->get_allocator(),
|
||||
false /*ignored*/,
|
||||
@ -465,8 +466,8 @@ int ObTableQuerySyncP::query_scan_with_init()
|
||||
ret = OB_NOT_SUPPORTED;
|
||||
LOG_WARN("should have one partition", K(ret), K(part_ids));
|
||||
} else if (FALSE_IT(table_service_ctx_->param_partition_id() = part_ids.at(0))) {
|
||||
} else if (OB_FAIL(start_trans(
|
||||
is_readonly, sql::stmt::T_SELECT, consistency_level, table_id, part_ids, timeout_ts_))) {
|
||||
} else if (OB_FAIL(
|
||||
start_trans(is_readonly, sql::stmt::T_SELECT, consistency_level, table_id, part_ids, timeout_ts_))) {
|
||||
LOG_WARN("failed to start readonly transaction", K(ret));
|
||||
} else if (OB_FAIL(table_service_->execute_query(*table_service_ctx_, arg_.query_, result_, result_iterator))) {
|
||||
if (OB_TRY_LOCK_ROW_CONFLICT != ret) {
|
||||
@ -533,7 +534,7 @@ int ObTableQuerySyncP::try_process()
|
||||
} else {
|
||||
if (ObQueryOperationType::QUERY_START == arg_.query_type_) {
|
||||
ret = process_query_start();
|
||||
} else if(ObQueryOperationType::QUERY_NEXT == arg_.query_type_) {
|
||||
} else if (ObQueryOperationType::QUERY_NEXT == arg_.query_type_) {
|
||||
ret = process_query_next();
|
||||
}
|
||||
if (OB_FAIL(ret)) {
|
||||
@ -581,7 +582,7 @@ int ObTableQuerySyncP::check_query_type()
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
if (arg_.query_type_ != table::ObQueryOperationType::QUERY_START &&
|
||||
arg_.query_type_ != table::ObQueryOperationType::QUERY_NEXT){
|
||||
arg_.query_type_ != table::ObQueryOperationType::QUERY_NEXT) {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
LOG_WARN("invalid query operation type", K(ret), K(arg_.query_type_));
|
||||
}
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "ob_backup_path.h"
|
||||
#include "ob_backup_file_lock_mgr.h"
|
||||
#include "lib/utility/ob_tracepoint.h"
|
||||
#include "lib/container/ob_array.h"
|
||||
#include "lib/container/ob_array_iterator.h"
|
||||
|
||||
using namespace oceanbase;
|
||||
using namespace common;
|
||||
@ -668,7 +670,7 @@ int ObLogArchiveBackupInfoMgr::get_log_archive_backup_backup_info(
|
||||
} else if (OB_FAIL(result->next()) && OB_ITER_END != ret) {
|
||||
OB_LOG(WARN, "fail to get next result", K(ret), K(sql));
|
||||
} else if (OB_UNLIKELY(OB_ITER_END == ret)) {
|
||||
// 仅租户级归档backup info未持久化之前获取出现OB_ITER_END的情况
|
||||
// only for tenant:OB_ITER_END happen before backup info is persisted
|
||||
ret = OB_ENTRY_NOT_EXIST;
|
||||
OB_LOG(WARN, "tenant backup info not exist", K(ret), K(tenant_id), K(sql));
|
||||
} else if (OB_ISNULL(result)) {
|
||||
|
@ -21,7 +21,8 @@
|
||||
#include "share/backup/ob_log_archive_backup_info_mgr.h"
|
||||
#include "lib/restore/ob_storage.h"
|
||||
#include "share/backup/ob_backup_info_mgr.h"
|
||||
|
||||
#include "lib/container/ob_array.h"
|
||||
#include "lib/container/ob_array_iterator.h"
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::share;
|
||||
|
||||
@ -499,8 +500,7 @@ int ObMultiBackupDestUtil::check_can_restore_by_set_or_piece(
|
||||
bool set_exist = false;
|
||||
if (OB_FAIL(get_backup_set_info_path(simple_path.get_simple_path(), backup_set_path))) {
|
||||
LOG_WARN("failed to get backup set info path", KR(ret), K_(simple_path.backup_dest));
|
||||
} else if (OB_FAIL(util.is_exist(
|
||||
backup_set_path.get_obstr(), simple_path.get_storage_info(), set_exist))) {
|
||||
} else if (OB_FAIL(util.is_exist(backup_set_path.get_obstr(), simple_path.get_storage_info(), set_exist))) {
|
||||
LOG_WARN("failed to check set file exist", KR(ret), K(backup_set_path));
|
||||
} else if (!set_exist) {
|
||||
ret = OB_BACKUP_FILE_NOT_EXIST;
|
||||
@ -513,8 +513,7 @@ int ObMultiBackupDestUtil::check_can_restore_by_set_or_piece(
|
||||
bool piece_exist = false;
|
||||
if (OB_FAIL(get_backup_piece_info_path(simple_path.get_simple_path(), backup_piece_path))) {
|
||||
LOG_WARN("failed to get backup piece info path", KR(ret), K_(simple_path.backup_dest));
|
||||
} else if (OB_FAIL(util.is_exist(
|
||||
backup_piece_path.get_obstr(), simple_path.get_storage_info(), piece_exist))) {
|
||||
} else if (OB_FAIL(util.is_exist(backup_piece_path.get_obstr(), simple_path.get_storage_info(), piece_exist))) {
|
||||
LOG_WARN("failed to check piece file exist", KR(ret), K(backup_piece_path));
|
||||
} else if (!piece_exist) {
|
||||
ret = OB_BACKUP_FILE_NOT_EXIST;
|
||||
|
@ -14,14 +14,13 @@
|
||||
#define USING_LOG_PREFIX SQL_ENG
|
||||
#include "sql/engine/ob_exec_context.h"
|
||||
#include "ob_expr_json_func_helper.h"
|
||||
#include "lib/json_type/ob_json_bin.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
using namespace oceanbase::sql;
|
||||
|
||||
namespace oceanbase
|
||||
{
|
||||
namespace sql
|
||||
{
|
||||
namespace oceanbase {
|
||||
namespace sql {
|
||||
ObJsonInType ObJsonExprHelper::get_json_internal_type(ObObjType type)
|
||||
{
|
||||
return type == ObJsonType ? ObJsonInType::JSON_BIN : ObJsonInType::JSON_TREE;
|
||||
@ -39,10 +38,8 @@ int ObJsonExprHelper::ensure_collation(ObObjType type, ObCollationType cs_type)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::get_json_doc(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
common::ObArenaAllocator &allocator,
|
||||
uint16_t index, ObIJsonBase*& j_base,
|
||||
bool &is_null, bool need_to_tree)
|
||||
int ObJsonExprHelper::get_json_doc(const ObExpr &expr, ObEvalCtx &ctx, common::ObArenaAllocator &allocator,
|
||||
uint16_t index, ObIJsonBase *&j_base, bool &is_null, bool need_to_tree)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
ObDatum *json_datum = NULL;
|
||||
@ -63,8 +60,7 @@ int ObJsonExprHelper::get_json_doc(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
ObString j_str = json_datum->get_string();
|
||||
ObJsonInType j_in_type = ObJsonExprHelper::get_json_internal_type(val_type);
|
||||
ObJsonInType expect_type = need_to_tree ? ObJsonInType::JSON_TREE : j_in_type;
|
||||
if (OB_FAIL(ObJsonBaseFactory::get_json_base(&allocator, j_str, j_in_type,
|
||||
expect_type, j_base))) {
|
||||
if (OB_FAIL(ObJsonBaseFactory::get_json_base(&allocator, j_str, j_in_type, expect_type, j_base))) {
|
||||
LOG_WARN("fail to get json base", K(ret), K(j_in_type));
|
||||
ret = OB_ERR_INVALID_JSON_TEXT_IN_PARAM;
|
||||
LOG_USER_ERROR(OB_ERR_INVALID_JSON_TEXT_IN_PARAM);
|
||||
@ -73,9 +69,8 @@ int ObJsonExprHelper::get_json_doc(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::get_json_doc(const ObObj *objs, common::ObIAllocator *allocator,
|
||||
uint16_t index, ObIJsonBase*& j_base,
|
||||
bool &is_null, bool need_to_tree)
|
||||
int ObJsonExprHelper::get_json_doc(const ObObj *objs, common::ObIAllocator *allocator, uint16_t index,
|
||||
ObIJsonBase *&j_base, bool &is_null, bool need_to_tree)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
ObObjType val_type = objs[index].get_type();
|
||||
@ -92,8 +87,7 @@ int ObJsonExprHelper::get_json_doc(const ObObj *objs, common::ObIAllocator *allo
|
||||
ObString j_str = objs[index].get_string();
|
||||
ObJsonInType j_in_type = ObJsonExprHelper::get_json_internal_type(val_type);
|
||||
ObJsonInType expect_type = need_to_tree ? ObJsonInType::JSON_TREE : j_in_type;
|
||||
if (OB_FAIL(ObJsonBaseFactory::get_json_base(allocator, j_str, j_in_type,
|
||||
expect_type, j_base))) {
|
||||
if (OB_FAIL(ObJsonBaseFactory::get_json_base(allocator, j_str, j_in_type, expect_type, j_base))) {
|
||||
LOG_WARN("fail to get json base", K(ret), K(j_in_type));
|
||||
ret = OB_ERR_INVALID_JSON_TEXT_IN_PARAM;
|
||||
LOG_USER_ERROR(OB_ERR_INVALID_JSON_TEXT_IN_PARAM);
|
||||
@ -102,9 +96,8 @@ int ObJsonExprHelper::get_json_doc(const ObObj *objs, common::ObIAllocator *allo
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::get_json_val(const common::ObObj &data, ObExprCtx &ctx,
|
||||
bool is_bool, common::ObIAllocator *allocator,
|
||||
ObIJsonBase*& j_base, bool to_bin)
|
||||
int ObJsonExprHelper::get_json_val(const common::ObObj &data, ObExprCtx &ctx, bool is_bool,
|
||||
common::ObIAllocator *allocator, ObIJsonBase *&j_base, bool to_bin)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
ObObjType val_type = data.get_type();
|
||||
@ -114,7 +107,7 @@ int ObJsonExprHelper::get_json_val(const common::ObObj &data, ObExprCtx &ctx,
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed: alloscate jsonboolean", K(ret));
|
||||
} else {
|
||||
ObJsonNull *null_node = static_cast<ObJsonNull*>(new(json_node_buf) ObJsonNull());
|
||||
ObJsonNull *null_node = static_cast<ObJsonNull *>(new (json_node_buf) ObJsonNull());
|
||||
if (to_bin) {
|
||||
if (OB_FAIL(ObJsonBaseFactory::transform(allocator, null_node, ObJsonInType::JSON_BIN, j_base))) {
|
||||
LOG_WARN("failed: json tree to bin", K(ret));
|
||||
@ -129,7 +122,7 @@ int ObJsonExprHelper::get_json_val(const common::ObObj &data, ObExprCtx &ctx,
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed: alloscate jsonboolean", K(ret));
|
||||
} else {
|
||||
ObJsonBoolean *bool_node = (ObJsonBoolean*)new(json_node_buf)ObJsonBoolean(data.get_bool());
|
||||
ObJsonBoolean *bool_node = (ObJsonBoolean *)new (json_node_buf) ObJsonBoolean(data.get_bool());
|
||||
if (to_bin) {
|
||||
if (OB_FAIL(ObJsonBaseFactory::transform(allocator, bool_node, ObJsonInType::JSON_BIN, j_base))) {
|
||||
LOG_WARN("failed: json tree to bin", K(ret));
|
||||
@ -140,8 +133,8 @@ int ObJsonExprHelper::get_json_val(const common::ObObj &data, ObExprCtx &ctx,
|
||||
}
|
||||
} else if (ObJsonExprHelper::is_convertible_to_json(val_type)) {
|
||||
ObCollationType cs_type = data.get_collation_type();
|
||||
if (OB_FAIL(ObJsonExprHelper::transform_convertible_2jsonBase(data, val_type, allocator,
|
||||
cs_type, j_base, to_bin))) {
|
||||
if (OB_FAIL(
|
||||
ObJsonExprHelper::transform_convertible_2jsonBase(data, val_type, allocator, cs_type, j_base, to_bin))) {
|
||||
LOG_WARN("failed: parse value to jsonBase", K(ret), K(val_type));
|
||||
}
|
||||
} else {
|
||||
@ -149,20 +142,17 @@ int ObJsonExprHelper::get_json_val(const common::ObObj &data, ObExprCtx &ctx,
|
||||
if (OB_ISNULL(session)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session is NULL", K(ret));
|
||||
} else if (OB_FAIL(ObJsonExprHelper::transform_scalar_2jsonBase(data, val_type,
|
||||
allocator, data.get_scale(),
|
||||
session->get_timezone_info(),
|
||||
j_base, to_bin))) {
|
||||
LOG_WARN("failed: parse value to jsonBase", K(ret), K(val_type));
|
||||
} else if (OB_FAIL(ObJsonExprHelper::transform_scalar_2jsonBase(
|
||||
data, val_type, allocator, data.get_scale(), session->get_timezone_info(), j_base, to_bin))) {
|
||||
LOG_WARN("failed: parse value to jsonBase", K(ret), K(val_type));
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::get_json_val(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
common::ObIAllocator *allocator, uint16_t index,
|
||||
ObIJsonBase*& j_base, bool to_bin)
|
||||
int ObJsonExprHelper::get_json_val(const ObExpr &expr, ObEvalCtx &ctx, common::ObIAllocator *allocator, uint16_t index,
|
||||
ObIJsonBase *&j_base, bool to_bin)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
ObDatum *json_datum = NULL;
|
||||
@ -176,7 +166,7 @@ int ObJsonExprHelper::get_json_val(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed: alloscate jsonboolean", K(ret));
|
||||
} else {
|
||||
ObJsonNull *null_node = static_cast<ObJsonNull*>(new(json_node_buf) ObJsonNull());
|
||||
ObJsonNull *null_node = static_cast<ObJsonNull *>(new (json_node_buf) ObJsonNull());
|
||||
if (to_bin) {
|
||||
if (OB_FAIL(ObJsonBaseFactory::transform(allocator, null_node, ObJsonInType::JSON_BIN, j_base))) {
|
||||
LOG_WARN("failed: json tree to bin", K(ret));
|
||||
@ -184,14 +174,14 @@ int ObJsonExprHelper::get_json_val(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
} else {
|
||||
j_base = null_node;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (json_arg->is_boolean_ == 1) {
|
||||
void *json_node_buf = allocator->alloc(sizeof(ObJsonBoolean));
|
||||
if (OB_ISNULL(json_node_buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
LOG_WARN("failed: alloscate jsonboolean", K(ret));
|
||||
} else {
|
||||
ObJsonBoolean *bool_node = (ObJsonBoolean*)new(json_node_buf)ObJsonBoolean(json_datum->get_bool());
|
||||
ObJsonBoolean *bool_node = (ObJsonBoolean *)new (json_node_buf) ObJsonBoolean(json_datum->get_bool());
|
||||
if (to_bin) {
|
||||
if (OB_FAIL(ObJsonBaseFactory::transform(allocator, bool_node, ObJsonInType::JSON_BIN, j_base))) {
|
||||
LOG_WARN("failed: json tree to bin", K(ret));
|
||||
@ -202,9 +192,8 @@ int ObJsonExprHelper::get_json_val(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
}
|
||||
} else if (ObJsonExprHelper::is_convertible_to_json(val_type)) {
|
||||
ObCollationType cs_type = json_arg->datum_meta_.cs_type_;
|
||||
if (OB_FAIL(ObJsonExprHelper::transform_convertible_2jsonBase(*json_datum, val_type,
|
||||
allocator, cs_type,
|
||||
j_base, to_bin))) {
|
||||
if (OB_FAIL(ObJsonExprHelper::transform_convertible_2jsonBase(
|
||||
*json_datum, val_type, allocator, cs_type, j_base, to_bin))) {
|
||||
LOG_WARN("failed: parse value to jsonBase", K(ret), K(val_type));
|
||||
}
|
||||
} else {
|
||||
@ -213,18 +202,15 @@ int ObJsonExprHelper::get_json_val(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
if (OB_ISNULL(session)) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session is NULL", K(ret));
|
||||
} else if (OB_FAIL(ObJsonExprHelper::transform_scalar_2jsonBase(*json_datum, val_type,
|
||||
allocator, scale,
|
||||
session->get_timezone_info(),
|
||||
j_base, to_bin))) {
|
||||
} else if (OB_FAIL(ObJsonExprHelper::transform_scalar_2jsonBase(
|
||||
*json_datum, val_type, allocator, scale, session->get_timezone_info(), j_base, to_bin))) {
|
||||
LOG_WARN("failed: parse value to jsonBase", K(ret), K(val_type));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::json_base_replace(ObIJsonBase *json_old, ObIJsonBase *json_new,
|
||||
ObIJsonBase *&json_doc)
|
||||
int ObJsonExprHelper::json_base_replace(ObIJsonBase *json_old, ObIJsonBase *json_new, ObIJsonBase *&json_doc)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
if (json_old == json_doc) {
|
||||
@ -237,7 +223,7 @@ int ObJsonExprHelper::json_base_replace(ObIJsonBase *json_old, ObIJsonBase *json
|
||||
LOG_WARN("fail to transform to tree", K(ret), K(*json_old));
|
||||
} else {
|
||||
ObIJsonBase *parent = static_cast<ObJsonNode *>(json_old_tree)->get_parent();
|
||||
if(OB_NOT_NULL(parent) && parent != json_doc) {
|
||||
if (OB_NOT_NULL(parent) && parent != json_doc) {
|
||||
if (OB_FAIL(parent->replace(json_old_tree, json_new))) {
|
||||
LOG_WARN("json base replace failed", K(ret));
|
||||
}
|
||||
@ -252,12 +238,12 @@ int ObJsonExprHelper::json_base_replace(ObIJsonBase *json_old, ObIJsonBase *json
|
||||
}
|
||||
|
||||
// get json expr path cache context, if not exists cache context do nothing
|
||||
ObJsonPathCache* ObJsonExprHelper::get_path_cache_ctx(const uint64_t& id, ObExecContext *exec_ctx)
|
||||
ObJsonPathCache *ObJsonExprHelper::get_path_cache_ctx(const uint64_t &id, ObExecContext *exec_ctx)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
ObJsonPathCacheCtx* cache_ctx = NULL;
|
||||
ObJsonPathCacheCtx *cache_ctx = NULL;
|
||||
if (ObExpr::INVALID_EXP_CTX_ID != id) {
|
||||
cache_ctx = static_cast<ObJsonPathCacheCtx*>(exec_ctx->get_expr_op_ctx(id));
|
||||
cache_ctx = static_cast<ObJsonPathCacheCtx *>(exec_ctx->get_expr_op_ctx(id));
|
||||
if (OB_ISNULL(cache_ctx)) {
|
||||
// if pathcache not exist, create one
|
||||
void *cache_ctx_buf = NULL;
|
||||
@ -270,8 +256,8 @@ ObJsonPathCache* ObJsonExprHelper::get_path_cache_ctx(const uint64_t& id, ObExec
|
||||
return (cache_ctx == NULL) ? NULL : cache_ctx->get_path_cache();
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::find_and_add_cache(ObJsonPathCache* path_cache, ObJsonPath*& res_path,
|
||||
ObString& path_str, int arg_idx, bool enable_wildcard)
|
||||
int ObJsonExprHelper::find_and_add_cache(
|
||||
ObJsonPathCache *path_cache, ObJsonPath *&res_path, ObString &path_str, int arg_idx, bool enable_wildcard)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
if (OB_FAIL(path_cache->find_and_add_cache(res_path, path_str, arg_idx))) {
|
||||
@ -305,9 +291,7 @@ bool ObJsonExprHelper::is_convertible_to_json(ObObjType &type)
|
||||
return val;
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::is_valid_for_json(ObExprResType* types_stack,
|
||||
uint32_t index,
|
||||
const char* func_name)
|
||||
int ObJsonExprHelper::is_valid_for_json(ObExprResType *types_stack, uint32_t index, const char *func_name)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
ObObjType in_type = types_stack[index].get_type();
|
||||
@ -315,8 +299,7 @@ int ObJsonExprHelper::is_valid_for_json(ObExprResType* types_stack,
|
||||
if (!is_convertible_to_json(in_type)) {
|
||||
ret = OB_ERR_INVALID_TYPE_FOR_JSON;
|
||||
LOG_USER_ERROR(OB_ERR_INVALID_TYPE_FOR_JSON, index + 1, func_name);
|
||||
} else if (ob_is_string_type(in_type)
|
||||
&& types_stack[index].get_collation_type() != CS_TYPE_BINARY) {
|
||||
} else if (ob_is_string_type(in_type) && types_stack[index].get_collation_type() != CS_TYPE_BINARY) {
|
||||
if (types_stack[index].get_charset_type() != CHARSET_UTF8MB4) {
|
||||
types_stack[index].set_calc_collation_type(CS_TYPE_UTF8MB4_BIN);
|
||||
}
|
||||
@ -325,13 +308,11 @@ int ObJsonExprHelper::is_valid_for_json(ObExprResType* types_stack,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::is_valid_for_json(ObExprResType& type,
|
||||
uint32_t index,
|
||||
const char* func_name)
|
||||
int ObJsonExprHelper::is_valid_for_json(ObExprResType &type, uint32_t index, const char *func_name)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
ObObjType in_type = type.get_type();
|
||||
|
||||
|
||||
if (!is_convertible_to_json(in_type)) {
|
||||
ret = OB_ERR_INVALID_TYPE_FOR_JSON;
|
||||
LOG_USER_ERROR(OB_ERR_INVALID_TYPE_FOR_JSON, index, func_name);
|
||||
@ -344,7 +325,7 @@ int ObJsonExprHelper::is_valid_for_json(ObExprResType& type,
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::is_valid_for_path(ObExprResType* types_stack, uint32_t index)
|
||||
int ObJsonExprHelper::is_valid_for_path(ObExprResType *types_stack, uint32_t index)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
ObObjType in_type = types_stack[index].get_type();
|
||||
@ -360,7 +341,7 @@ int ObJsonExprHelper::is_valid_for_path(ObExprResType* types_stack, uint32_t ind
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ObJsonExprHelper::set_type_for_value(ObExprResType* types_stack, uint32_t index)
|
||||
void ObJsonExprHelper::set_type_for_value(ObExprResType *types_stack, uint32_t index)
|
||||
{
|
||||
ObObjType in_type = types_stack[index].get_type();
|
||||
if (in_type == ObNullType) {
|
||||
@ -368,18 +349,18 @@ void ObJsonExprHelper::set_type_for_value(ObExprResType* types_stack, uint32_t i
|
||||
if (types_stack[index].get_charset_type() != CHARSET_UTF8MB4) {
|
||||
types_stack[index].set_calc_collation_type(CS_TYPE_UTF8MB4_BIN);
|
||||
}
|
||||
} else if (in_type == ObJsonType) {
|
||||
} else if (in_type == ObJsonType) {
|
||||
types_stack[index].set_calc_collation_type(CS_TYPE_UTF8MB4_BIN);
|
||||
}
|
||||
}
|
||||
|
||||
int ObJsonExprHelper::is_json_zero(const ObString& data, int& result)
|
||||
int ObJsonExprHelper::is_json_zero(const ObString &data, int &result)
|
||||
{
|
||||
INIT_SUCC(ret);
|
||||
int tmp_result = 0;
|
||||
ObJsonBin j_bin(data.ptr(), data.length());
|
||||
if (data.length() == 0) {
|
||||
result = 1;
|
||||
result = 1;
|
||||
} else if (OB_FAIL(j_bin.reset_iter())) {
|
||||
LOG_WARN("failed: reset iter", K(ret));
|
||||
} else if (OB_FAIL(ObJsonBaseUtil::compare_int_json(0, &j_bin, tmp_result))) {
|
||||
@ -391,26 +372,21 @@ int ObJsonExprHelper::is_json_zero(const ObString& data, int& result)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
ObObjType type,
|
||||
common::ObIAllocator *allocator,
|
||||
ObScale scale,
|
||||
const ObTimeZoneInfo *tz_info,
|
||||
ObIJsonBase*& j_base,
|
||||
bool to_bin)
|
||||
int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum, ObObjType type, common::ObIAllocator *allocator,
|
||||
ObScale scale, const ObTimeZoneInfo *tz_info, ObIJsonBase *&j_base, bool to_bin)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
void* buf = NULL;
|
||||
ObIJsonBase* json_node = NULL;
|
||||
void *buf = NULL;
|
||||
ObIJsonBase *json_node = NULL;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case ObTinyIntType: {
|
||||
// mysql boolean type
|
||||
// mysql boolean type
|
||||
buf = allocator->alloc(sizeof(ObJsonInt));
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
} else {
|
||||
json_node = (ObJsonInt*)new(buf)ObJsonInt(datum.get_int());
|
||||
json_node = (ObJsonInt *)new (buf) ObJsonInt(datum.get_int());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -422,7 +398,7 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
} else {
|
||||
json_node = (ObJsonInt*)new(buf)ObJsonInt(datum.get_int());
|
||||
json_node = (ObJsonInt *)new (buf) ObJsonInt(datum.get_int());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -435,7 +411,7 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
} else {
|
||||
json_node = (ObJsonInt*)new(buf)ObJsonUint(datum.get_uint64());
|
||||
json_node = (ObJsonInt *)new (buf) ObJsonUint(datum.get_uint64());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -450,26 +426,22 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
node_type = ObJsonNodeType::J_DATE;
|
||||
value = datum.get_date();
|
||||
ob_time.mode_ = DT_TYPE_DATE;
|
||||
if (OB_FAIL(ObTimeConverter::date_to_ob_time(value, ob_time))) {
|
||||
}
|
||||
if (OB_FAIL(ObTimeConverter::date_to_ob_time(value, ob_time))) {}
|
||||
} else if (type == ObTimeType) {
|
||||
node_type = ObJsonNodeType::J_TIME;
|
||||
value = datum.get_time();
|
||||
ob_time.mode_ = DT_TYPE_TIME;
|
||||
if (OB_FAIL(ObTimeConverter::time_to_ob_time(value, ob_time))) {
|
||||
}
|
||||
if (OB_FAIL(ObTimeConverter::time_to_ob_time(value, ob_time))) {}
|
||||
} else if (type == ObDateTimeType) {
|
||||
node_type = ObJsonNodeType::J_DATETIME;
|
||||
value = datum.get_datetime();
|
||||
ob_time.mode_ = DT_TYPE_DATETIME;
|
||||
if (OB_FAIL(ObTimeConverter::datetime_to_ob_time(value, tz_info, ob_time))) {
|
||||
}
|
||||
if (OB_FAIL(ObTimeConverter::datetime_to_ob_time(value, tz_info, ob_time))) {}
|
||||
} else {
|
||||
node_type = ObJsonNodeType::J_TIMESTAMP;
|
||||
value = datum.get_timestamp();
|
||||
ob_time.mode_ = DT_TYPE_DATETIME;
|
||||
if (OB_FAIL(ObTimeConverter::datetime_to_ob_time(value, tz_info, ob_time))) {
|
||||
}
|
||||
if (OB_FAIL(ObTimeConverter::datetime_to_ob_time(value, tz_info, ob_time))) {}
|
||||
}
|
||||
|
||||
if (OB_SUCC(ret)) {
|
||||
@ -477,7 +449,7 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
} else {
|
||||
json_node = (ObJsonDatetime *)new(buf)ObJsonDatetime(node_type, ob_time);
|
||||
json_node = (ObJsonDatetime *)new (buf) ObJsonDatetime(node_type, ob_time);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -491,7 +463,7 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
} else {
|
||||
json_node = (ObJsonDouble *)new(buf)ObJsonDouble(datum.get_double());
|
||||
json_node = (ObJsonDouble *)new (buf) ObJsonDouble(datum.get_double());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -507,7 +479,7 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
;
|
||||
} else {
|
||||
// shadow copy
|
||||
json_node = (ObJsonDecimal *)new(buf)ObJsonDecimal(num, -1, scale);
|
||||
json_node = (ObJsonDecimal *)new (buf) ObJsonDecimal(num, -1, scale);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -516,12 +488,11 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
} else {
|
||||
json_node = (ObJsonOpaque *)new(buf)ObJsonOpaque(datum.get_string(), type);
|
||||
json_node = (ObJsonOpaque *)new (buf) ObJsonOpaque(datum.get_string(), type);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
@ -540,32 +511,27 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
int ObJsonExprHelper::transform_convertible_2jsonBase(const T &datum,
|
||||
ObObjType type,
|
||||
common::ObIAllocator *allocator,
|
||||
ObCollationType cs_type,
|
||||
ObIJsonBase*& j_base,
|
||||
bool to_bin,
|
||||
bool deep_copy)
|
||||
int ObJsonExprHelper::transform_convertible_2jsonBase(const T &datum, ObObjType type, common::ObIAllocator *allocator,
|
||||
ObCollationType cs_type, ObIJsonBase *&j_base, bool to_bin, bool deep_copy)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
void* buf = NULL;
|
||||
ObIJsonBase* json_node = NULL;
|
||||
void *buf = NULL;
|
||||
ObIJsonBase *json_node = NULL;
|
||||
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case ObNullType: {
|
||||
buf = allocator->alloc(sizeof(ObJsonNull));
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
} else {
|
||||
json_node = (ObJsonNull*)new(buf)ObJsonNull();
|
||||
json_node = (ObJsonNull *)new (buf) ObJsonNull();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ObVarcharType:
|
||||
case ObCharType:
|
||||
case ObTinyTextType:
|
||||
case ObTextType :
|
||||
case ObTextType:
|
||||
case ObMediumTextType:
|
||||
case ObLongTextType: {
|
||||
ObString value;
|
||||
@ -585,7 +551,7 @@ int ObJsonExprHelper::transform_convertible_2jsonBase(const T &datum,
|
||||
if (OB_ISNULL(buf)) {
|
||||
ret = OB_ALLOCATE_MEMORY_FAILED;
|
||||
} else {
|
||||
json_node = (ObJsonString*)new(buf)ObJsonString(ptr, len);
|
||||
json_node = (ObJsonString *)new (buf) ObJsonString(ptr, len);
|
||||
}
|
||||
}
|
||||
|
||||
@ -594,23 +560,20 @@ int ObJsonExprHelper::transform_convertible_2jsonBase(const T &datum,
|
||||
case ObJsonType: {
|
||||
ObString value;
|
||||
if (deep_copy) {
|
||||
if (OB_FAIL(deep_copy_ob_string(*allocator, datum.get_string(), value))) {
|
||||
}
|
||||
if (OB_FAIL(deep_copy_ob_string(*allocator, datum.get_string(), value))) {}
|
||||
} else {
|
||||
value = datum.get_string();
|
||||
}
|
||||
if (OB_SUCC(ret)) {
|
||||
ObJsonInType to_type = to_bin ? ObJsonInType::JSON_BIN : ObJsonInType::JSON_TREE;
|
||||
if (OB_FAIL(ObJsonBaseFactory::get_json_base(allocator, value, ObJsonInType::JSON_BIN,
|
||||
to_type, json_node))) {
|
||||
if (OB_FAIL(ObJsonBaseFactory::get_json_base(allocator, value, ObJsonInType::JSON_BIN, to_type, json_node))) {
|
||||
ret = OB_ERR_INVALID_JSON_TEXT_IN_PARAM;
|
||||
LOG_WARN("fail to get json base", K(ret));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
ret = OB_INVALID_ARGUMENT;
|
||||
}
|
||||
}
|
||||
@ -628,5 +591,5 @@ int ObJsonExprHelper::transform_convertible_2jsonBase(const T &datum,
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace sql
|
||||
} // namespace oceanbase
|
||||
|
Loading…
x
Reference in New Issue
Block a user