bugfix json_object with year data core dump

This commit is contained in:
obdev
2023-08-23 02:10:22 +00:00
committed by ob-robot
parent 70178a611b
commit 01a8cc78da

View File

@ -759,8 +759,7 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
case ObUSmallIntType:
case ObUMediumIntType:
case ObUInt32Type:
case ObUInt64Type:
case ObYearType: {
case ObUInt64Type: {
buf = allocator->alloc(sizeof(ObJsonUint));
if (OB_ISNULL(buf)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
@ -770,6 +769,19 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum,
}
break;
}
case ObYearType: {
buf = allocator->alloc(sizeof(ObJsonInt));
int64_t value = 0;
if (OB_FAIL(ObTimeConverter::year_to_int(datum.get_year(), value))) {
LOG_WARN("fail to get year data", K(ret));
} else if (OB_ISNULL(buf)) {
ret = OB_ALLOCATE_MEMORY_FAILED;
LOG_WARN("buf allocate failed", K(ret), K(type));
} else {
json_node = (ObJsonInt*)new(buf)ObJsonInt(value);
}
break;
}
case ObDateTimeType:
case ObTimestampType:
case ObTimestampNanoType: