[FEAT MERGE]:Oracle Json Supported
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
* 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.
|
||||
* This file is for define of func json expr helper
|
||||
*/
|
||||
|
||||
#ifndef OCEANBASE_SQL_OB_EXPR_JSON_FUNC_HELPER_H_
|
||||
@ -21,6 +22,7 @@
|
||||
#include "lib/json_type/ob_json_base.h"
|
||||
#include "lib/json_type/ob_json_bin.h"
|
||||
#include "lib/json_type/ob_json_parse.h"
|
||||
#include "sql/engine/expr/ob_expr_result_type_util.h"
|
||||
|
||||
using namespace oceanbase::common;
|
||||
|
||||
@ -56,8 +58,9 @@ public:
|
||||
static int get_json_doc(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
common::ObArenaAllocator &allocator,
|
||||
uint16_t index, ObIJsonBase*& j_base,
|
||||
bool &is_null, bool need_to_tree=true);
|
||||
bool &is_null, bool need_to_tree=true, bool relax = true);
|
||||
|
||||
static int cast_to_json_tree(ObString &text, common::ObIAllocator *allocator, uint32_t parse_flag = 0);
|
||||
/*
|
||||
get json doc to JsonBase in old_typing_engine
|
||||
@param[in] objs the input arguments
|
||||
@ -83,7 +86,8 @@ public:
|
||||
*/
|
||||
static int get_json_val(const ObExpr &expr, ObEvalCtx &ctx,
|
||||
common::ObIAllocator *allocator, uint16_t index,
|
||||
ObIJsonBase*& j_base, bool to_bin = false);
|
||||
ObIJsonBase*& j_base, bool to_bin = false, bool format_json = false,
|
||||
uint32_t parse_flag = ObJsonParser::JSN_RELAXED_FLAG);
|
||||
|
||||
/*
|
||||
get json value to JsonBase in old_typing_engine
|
||||
@ -133,6 +137,7 @@ public:
|
||||
common::ObIAllocator *allocator,
|
||||
ObScale scale,
|
||||
const ObTimeZoneInfo *tz_info,
|
||||
ObBasicSessionInfo *session,
|
||||
ObIJsonBase*& j_base,
|
||||
bool to_bin);
|
||||
/*
|
||||
@ -153,7 +158,33 @@ public:
|
||||
ObCollationType cs_type,
|
||||
ObIJsonBase*& j_base,
|
||||
bool to_bin,
|
||||
bool deep_copy = false);
|
||||
bool deep_copy = false,
|
||||
bool relax_type = true,
|
||||
bool format_json = false);
|
||||
|
||||
static int transform_convertible_2String(const ObExpr &expr,
|
||||
ObEvalCtx &ctx,
|
||||
const ObDatum &datum,
|
||||
ObObjType type,
|
||||
ObCollationType cs_type,
|
||||
ObJsonBuffer &j_buf,
|
||||
bool format_json,
|
||||
bool strict_json,
|
||||
int32_t pos);
|
||||
|
||||
static int transform_scalar_2String(ObEvalCtx &ctx,
|
||||
const ObDatum &datum,
|
||||
ObObjType type,
|
||||
ObScale scale,
|
||||
const ObTimeZoneInfo *tz_info,
|
||||
ObJsonBuffer &j_buf);
|
||||
static bool is_cs_type_bin(ObCollationType &cs_type);
|
||||
static int get_timestamp_str_in_oracle_mode(ObEvalCtx &ctx,
|
||||
const ObDatum &datum,
|
||||
ObObjType type,
|
||||
ObScale scale,
|
||||
const ObTimeZoneInfo *tz_info,
|
||||
ObJsonBuffer &j_buf);
|
||||
|
||||
static bool is_convertible_to_json(ObObjType &type);
|
||||
static int is_valid_for_json(ObExprResType* types_stack, uint32_t index, const char* func_name);
|
||||
@ -162,7 +193,43 @@ public:
|
||||
static void set_type_for_value(ObExprResType* types_stack, uint32_t index);
|
||||
static int ensure_collation(ObObjType type, ObCollationType cs_type);
|
||||
static ObJsonInType get_json_internal_type(ObObjType type);
|
||||
|
||||
/**
|
||||
* the following 3 functions is used for json_query and json_mergepatch
|
||||
* as the returning type is the same
|
||||
*
|
||||
* get_cast_type
|
||||
* set_dest_type
|
||||
* get_cast_string_len
|
||||
*
|
||||
*/
|
||||
static int get_cast_type(const ObExprResType param_type2, ObExprResType &dst_type);
|
||||
// check item function and returning type
|
||||
static int check_item_func_with_return(ObJsonPathNodeType path_type, ObObjType dst_type, common::ObCollationType dst_coll_type, int8_t JSON_EXPR_FLAG);
|
||||
static int set_dest_type(ObExprResType &type1, ObExprResType &type,
|
||||
ObExprResType &dst_type, ObExprTypeCtx &type_ctx);
|
||||
static int get_ascii_type(const ObExprResType param_type2, int64_t &dst_type);
|
||||
static int calc_asciistr_in_expr(const ObString &src,
|
||||
const ObCollationType src_cs_type,
|
||||
const ObCollationType dst_cs_type,
|
||||
char* buf, const int64_t buf_len, int32_t &pos);
|
||||
static int get_dest_type(const ObExpr &expr, int64_t pos,
|
||||
ObEvalCtx& ctx,
|
||||
ObObjType &dest_type, int32_t &dst_len);
|
||||
static int get_cast_string_len(ObExprResType &type1,
|
||||
ObExprResType &type2,
|
||||
common::ObExprTypeCtx &type_ctx,
|
||||
int32_t &res_len,
|
||||
int16_t &length_semantics,
|
||||
common::ObCollationType conn);
|
||||
static int eval_and_check_res_type(int64_t value, ObObjType& type, int32_t& dst_len);
|
||||
static int parse_res_type(ObExprResType& type1,
|
||||
ObExprResType& json_res_type,
|
||||
ObExprResType& result_type,
|
||||
ObExprTypeCtx& type_ctx);
|
||||
static int pre_default_value_check(ObObjType dst_type, ObString time_str, ObObjType val_type);
|
||||
private:
|
||||
const static uint32_t RESERVE_MIN_BUFF_SIZE = 32;
|
||||
DISALLOW_COPY_AND_ASSIGN(ObJsonExprHelper);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user