diff --git a/deps/oblib/src/common/object/ob_obj_funcs.h b/deps/oblib/src/common/object/ob_obj_funcs.h index 9d51601313..8afa499cf2 100644 --- a/deps/oblib/src/common/object/ob_obj_funcs.h +++ b/deps/oblib/src/common/object/ob_obj_funcs.h @@ -1490,35 +1490,7 @@ DEF_ENUMSET_INNER_FUNCS(ObSetInnerType, set_inner, ObString); } #define DEF_TEXT_SERIALIZE_FUNCS(OBJTYPE, TYPE, VTYPE) \ - template <> \ - inline int obj_val_serialize(const ObObj &obj, char* buf, \ - const int64_t buf_len, int64_t& pos) \ - { \ - int ret = OB_SUCCESS; \ - OB_UNIS_ENCODE(obj.get_##TYPE()); \ - return ret; \ - } \ - \ - template <> \ - inline int obj_val_deserialize(ObObj &obj, const char* buf, \ - const int64_t data_len, int64_t& pos) \ - { \ - int ret = OB_SUCCESS; \ - VTYPE v = VTYPE(); \ - OB_UNIS_DECODE(v); \ - if (OB_SUCC(ret)) { \ - obj.set_##TYPE(OBJTYPE, v); \ - } \ - return ret; \ - } \ - \ - template <> \ - inline int64_t obj_val_get_serialize_size(const ObObj &obj) \ - { \ - int64_t len = 0; \ - OB_UNIS_ADD_LEN(obj.get_##TYPE()); \ - return len; \ - } + DEF_SERIALIZE_FUNCS(OBJTYPE, TYPE, VTYPE) // ToDo: @gehao // 1. SERIALIZE/DESERIALIZE will drop has_lob_header flag. However, only table api use these functions, @@ -1950,7 +1922,7 @@ inline int obj_print_json(const ObObj &obj, char *buf, int64_t buf_l ret = serialization::decode_otimestamp_tz_type(buf, buf_len, pos, \ *((int64_t *)&ot_data.time_us_), \ *((uint32_t *)&ot_data.time_ctx_.desc_)); \ - obj.set_otimestamp_value(OBJTYPE, ot_data);\ + obj.set_obj_value(ot_data);\ return ret;\ } \ \ @@ -2036,7 +2008,7 @@ inline int obj_print_json(const ObObj &obj, char *buf, int64_t buf_l ret = serialization::decode_otimestamp_type(buf, buf_len, pos, \ *((int64_t *)&ot_data.time_us_), \ *((uint16_t *)&ot_data.time_ctx_.time_desc_)); \ - obj.set_otimestamp_value(OBJTYPE, ot_data);\ + obj.set_obj_value(ot_data);\ return ret;\ } \ \ @@ -2395,7 +2367,7 @@ template <> int64_t val = 0; OB_UNIS_DECODE(val); if (OB_SUCC(ret)) { - obj.set_unknown(val); + obj.set_obj_value(val); } return ret; } diff --git a/deps/oblib/src/common/object/ob_object.h b/deps/oblib/src/common/object/ob_object.h index ed7a0fcf94..3ed7c62317 100644 --- a/deps/oblib/src/common/object/ob_object.h +++ b/deps/oblib/src/common/object/ob_object.h @@ -3790,6 +3790,7 @@ DEFINE_SET_COMMON_OBJ_VALUE(float, float); DEFINE_SET_COMMON_OBJ_VALUE(double, double); DEFINE_SET_COMMON_OBJ_VALUE(int64, int64_t); DEFINE_SET_COMMON_OBJ_VALUE(uint64, uint64_t); + template<> inline void ObObj::set_obj_value(const ObString &v) { @@ -3818,6 +3819,13 @@ inline void ObObj::set_obj_value(const ObURowIDData &urowid) val_len_ = static_cast(urowid.rowid_len_); } +template<> +inline void ObObj::set_obj_value(const ObOTimestampData &otimestamp) +{ + time_ctx_ = otimestamp.time_ctx_; + v_.datetime_ = otimestamp.time_us_; +} + struct ParamFlag { ParamFlag() : need_to_check_type_(true), diff --git a/src/sql/engine/expr/ob_expr_rownum.cpp b/src/sql/engine/expr/ob_expr_rownum.cpp index 6b41205c42..45989f0962 100644 --- a/src/sql/engine/expr/ob_expr_rownum.cpp +++ b/src/sql/engine/expr/ob_expr_rownum.cpp @@ -61,7 +61,10 @@ int ObExprRowNum::rownum_eval(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_ int ret = OB_SUCCESS; uint64_t operator_id = expr.extra_; ObOperatorKit *kit = ctx.exec_ctx_.get_operator_kit(operator_id); - if (OB_ISNULL(kit) || OB_ISNULL(kit->op_)) { + if (OB_UNLIKELY(OB_INVALID_ID == operator_id)) { + ret = OB_ERR_CBY_PSEUDO_COLUMN_NOT_ALLOWED; + LOG_USER_ERROR(OB_NOT_SUPPORTED, "Usage of rownum is"); + } else if (OB_ISNULL(kit) || OB_ISNULL(kit->op_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("operator is NULL", K(ret), K(operator_id), KP(kit)); } else if (OB_UNLIKELY(PHY_COUNT != kit->op_->get_spec().type_)) { diff --git a/src/sql/resolver/ob_resolver_utils.cpp b/src/sql/resolver/ob_resolver_utils.cpp index 7a35f38232..878daa9ba0 100644 --- a/src/sql/resolver/ob_resolver_utils.cpp +++ b/src/sql/resolver/ob_resolver_utils.cpp @@ -4763,6 +4763,9 @@ int ObResolverUtils::resolve_default_expr_v2_column_expr(ObResolverParams ¶m LOG_USER_ERROR(OB_ERR_BAD_FIELD_ERROR, col_name.length(), col_name.ptr(), scope_name.length(), scope_name.ptr()); } else if (OB_FAIL(expr->formalize(session_info))) { LOG_WARN("formalize expr failed", K(ret)); + } else if (OB_UNLIKELY(expr->has_flag(CNT_ROWNUM))) { + ret = OB_ERR_CBY_PSEUDO_COLUMN_NOT_ALLOWED; + LOG_WARN("rownum in default value is not allowed", K(ret)); } else { LOG_DEBUG("succ to resolve_default_expr_v2_column_expr", "is_const_expr", expr->is_const_raw_expr(),