default rownum not allowed and fix obj deserialize bug

This commit is contained in:
sdc
2023-06-01 12:42:00 +00:00
committed by ob-robot
parent d83fc8474e
commit 623c7d90aa
4 changed files with 19 additions and 33 deletions

View File

@ -1490,35 +1490,7 @@ DEF_ENUMSET_INNER_FUNCS(ObSetInnerType, set_inner, ObString);
} }
#define DEF_TEXT_SERIALIZE_FUNCS(OBJTYPE, TYPE, VTYPE) \ #define DEF_TEXT_SERIALIZE_FUNCS(OBJTYPE, TYPE, VTYPE) \
template <> \ DEF_SERIALIZE_FUNCS(OBJTYPE, TYPE, VTYPE)
inline int obj_val_serialize<OBJTYPE>(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<OBJTYPE>(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<OBJTYPE>(const ObObj &obj) \
{ \
int64_t len = 0; \
OB_UNIS_ADD_LEN(obj.get_##TYPE()); \
return len; \
}
// ToDo: @gehao // ToDo: @gehao
// 1. SERIALIZE/DESERIALIZE will drop has_lob_header flag. However, only table api use these functions, // 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<ObJsonType>(const ObObj &obj, char *buf, int64_t buf_l
ret = serialization::decode_otimestamp_tz_type(buf, buf_len, pos, \ ret = serialization::decode_otimestamp_tz_type(buf, buf_len, pos, \
*((int64_t *)&ot_data.time_us_), \ *((int64_t *)&ot_data.time_us_), \
*((uint32_t *)&ot_data.time_ctx_.desc_)); \ *((uint32_t *)&ot_data.time_ctx_.desc_)); \
obj.set_otimestamp_value(OBJTYPE, ot_data);\ obj.set_obj_value(ot_data);\
return ret;\ return ret;\
} \ } \
\ \
@ -2036,7 +2008,7 @@ inline int obj_print_json<ObJsonType>(const ObObj &obj, char *buf, int64_t buf_l
ret = serialization::decode_otimestamp_type(buf, buf_len, pos, \ ret = serialization::decode_otimestamp_type(buf, buf_len, pos, \
*((int64_t *)&ot_data.time_us_), \ *((int64_t *)&ot_data.time_us_), \
*((uint16_t *)&ot_data.time_ctx_.time_desc_)); \ *((uint16_t *)&ot_data.time_ctx_.time_desc_)); \
obj.set_otimestamp_value(OBJTYPE, ot_data);\ obj.set_obj_value(ot_data);\
return ret;\ return ret;\
} \ } \
\ \
@ -2395,7 +2367,7 @@ template <>
int64_t val = 0; int64_t val = 0;
OB_UNIS_DECODE(val); OB_UNIS_DECODE(val);
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
obj.set_unknown(val); obj.set_obj_value(val);
} }
return ret; return ret;
} }

View File

@ -3790,6 +3790,7 @@ DEFINE_SET_COMMON_OBJ_VALUE(float, float);
DEFINE_SET_COMMON_OBJ_VALUE(double, double); DEFINE_SET_COMMON_OBJ_VALUE(double, double);
DEFINE_SET_COMMON_OBJ_VALUE(int64, int64_t); DEFINE_SET_COMMON_OBJ_VALUE(int64, int64_t);
DEFINE_SET_COMMON_OBJ_VALUE(uint64, uint64_t); DEFINE_SET_COMMON_OBJ_VALUE(uint64, uint64_t);
template<> template<>
inline void ObObj::set_obj_value<ObString>(const ObString &v) inline void ObObj::set_obj_value<ObString>(const ObString &v)
{ {
@ -3818,6 +3819,13 @@ inline void ObObj::set_obj_value<ObURowIDData>(const ObURowIDData &urowid)
val_len_ = static_cast<int32_t>(urowid.rowid_len_); val_len_ = static_cast<int32_t>(urowid.rowid_len_);
} }
template<>
inline void ObObj::set_obj_value<ObOTimestampData>(const ObOTimestampData &otimestamp)
{
time_ctx_ = otimestamp.time_ctx_;
v_.datetime_ = otimestamp.time_us_;
}
struct ParamFlag struct ParamFlag
{ {
ParamFlag() : need_to_check_type_(true), ParamFlag() : need_to_check_type_(true),

View File

@ -61,7 +61,10 @@ int ObExprRowNum::rownum_eval(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &expr_
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
uint64_t operator_id = expr.extra_; uint64_t operator_id = expr.extra_;
ObOperatorKit *kit = ctx.exec_ctx_.get_operator_kit(operator_id); 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; ret = OB_ERR_UNEXPECTED;
LOG_WARN("operator is NULL", K(ret), K(operator_id), KP(kit)); LOG_WARN("operator is NULL", K(ret), K(operator_id), KP(kit));
} else if (OB_UNLIKELY(PHY_COUNT != kit->op_->get_spec().type_)) { } else if (OB_UNLIKELY(PHY_COUNT != kit->op_->get_spec().type_)) {

View File

@ -4763,6 +4763,9 @@ int ObResolverUtils::resolve_default_expr_v2_column_expr(ObResolverParams &param
LOG_USER_ERROR(OB_ERR_BAD_FIELD_ERROR, col_name.length(), col_name.ptr(), scope_name.length(), scope_name.ptr()); 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))) { } else if (OB_FAIL(expr->formalize(session_info))) {
LOG_WARN("formalize expr failed", K(ret)); 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 { } else {
LOG_DEBUG("succ to resolve_default_expr_v2_column_expr", LOG_DEBUG("succ to resolve_default_expr_v2_column_expr",
"is_const_expr", expr->is_const_raw_expr(), "is_const_expr", expr->is_const_raw_expr(),