[CP] sync bugfix json->year cast on not null constraint

This commit is contained in:
obdev 2024-11-23 21:49:12 +00:00 committed by ob-robot
parent 70d9cc1e8f
commit 226981c115
2 changed files with 12 additions and 2 deletions

View File

@ -8844,7 +8844,12 @@ static int json_year(const ObObjType expect_type, ObObjCastParams &params,
LOG_WARN("fail to cast json int to year type", K(ret), K(int_value), K(expect_type));
} else {
if (lib::is_mysql_mode() && (params.warning_ == OB_DATA_OUT_OF_RANGE)) {
out.set_null(); // not change the behavior of int_year
if (CM_IS_WARN_ON_FAIL(cast_mode)) {
value = 0;
SET_RES_YEAR(out);
} else {
out.set_null(); // not change the behavior of int_year
}
} else {
SET_RES_YEAR(out);
}

View File

@ -8788,7 +8788,12 @@ CAST_FUNC_NAME(json, year)
LOG_WARN("fail to cast json int to year type", K(ret), K(int_val));
} else {
if (lib::is_mysql_mode() && (warning == OB_DATA_OUT_OF_RANGE)) {
res_datum.set_null(); // not change the behavior of int_year
if (CM_IS_WARN_ON_FAIL(expr.extra_)) {
out_val = 0;
SET_RES_YEAR(out_val);
} else {
res_datum.set_null(); // not change the behavior of int_year
}
} else {
SET_RES_YEAR(out_val);
}