patch 4.0

This commit is contained in:
wangzelin.wzl
2022-10-24 10:34:53 +08:00
parent 4ad6e00ec3
commit 93a1074b0c
10533 changed files with 2588271 additions and 2299373 deletions

View File

@ -17,46 +17,72 @@
#include "lib/oblog/ob_log.h"
#include "share/object/ob_obj_cast.h"
namespace oceanbase {
namespace oceanbase
{
using namespace common;
namespace sql {
namespace sql
{
#include "sql/engine/expr/ob_expr_div_promotion.map"
#include "sql/engine/expr/ob_expr_nvl_promotion.map"
struct MyIntegrityChecker3 {
struct MyIntegrityChecker3
{
MyIntegrityChecker3()
{
for (int tc1 = ObNullTC; tc1 < ObMaxTC; tc1++) {
for (int tc2 = ObNullTC; tc2 < tc1; tc2++) {
if (DIV_TYPE_PROMOTION[tc1][tc2] != DIV_TYPE_PROMOTION[tc2][tc1]) {
LOG_ERROR("DIV_TYPE_PROMOTION is wrong",
"ret",
OB_ERR_UNEXPECTED,
K(tc1),
K(tc2),
"tc1 => tc2",
DIV_TYPE_PROMOTION[tc1][tc2],
"tc2 => tc1",
DIV_TYPE_PROMOTION[tc2][tc1]);
LOG_ERROR("DIV_TYPE_PROMOTION is wrong", "ret", OB_ERR_UNEXPECTED,
K(tc1), K(tc2),
"tc1 => tc2", DIV_TYPE_PROMOTION[tc1][tc2],
"tc2 => tc1", DIV_TYPE_PROMOTION[tc2][tc1]);
}
}
}
}
} MY_DIV_TYPE_PROMOTION_CHECKER;
int ObExprPromotionUtil::get_nvl_type(ObExprResType& type, const ObExprResType& type1, const ObExprResType& type2)
int ObExprPromotionUtil::get_nvl_type(ObExprResType &type, const ObExprResType &type1,
const ObExprResType &type2)
{
return get_calc_type(type, type1, type2, lib::is_oracle_mode() ? NVL_TYPE_PROMOTION_ORACLE : NVL_TYPE_PROMOTION);
int ret = OB_SUCCESS;
if (lib::is_oracle_mode()) {
// process boolean parameter in pl/sql
if (type1.get_type() == ObTinyIntType || type2.get_type() == ObTinyIntType) {
if (ObNullType == type1.get_type()
|| ObNullType == type2.get_type()
|| (ObTinyIntType == type1.get_type() && ObTinyIntType == type2.get_type())) {
type.set_type(ObTinyIntType);
} else {
if (OB_FAIL(get_calc_type(type, type1, type2, NVL_TYPE_PROMOTION_ORACLE))) {
LOG_WARN("failed to get calc type", K(ret), K(type1), K(type2), K(type));
}
}
} else {
if (OB_FAIL(get_calc_type(type, type1, type2, NVL_TYPE_PROMOTION_ORACLE))) {
LOG_WARN("failed to get calc type", K(ret), K(type1), K(type2), K(type));
}
}
} else {
if (OB_FAIL(get_calc_type(type, type1, type2, NVL_TYPE_PROMOTION))) {
LOG_WARN("failed to get calc type", K(ret), K(type1), K(type2), K(type));
}
}
return ret;
}
int ObExprPromotionUtil::get_calc_type(
ObExprResType& type, const ObExprResType& type1, const ObExprResType& type2, const ObObjType map[ObMaxTC][ObMaxTC])
int ObExprPromotionUtil::get_calc_type(ObExprResType &type,
const ObExprResType &type1,
const ObExprResType &type2,
const ObObjType map[ObMaxTC][ObMaxTC])
{
int ret = OB_SUCCESS;
ObObjTypeClass l_tc = type1.get_type_class();
ObObjTypeClass r_tc = type2.get_type_class();
if (OB_UNLIKELY(l_tc < ObNullTC || l_tc >= ObMaxTC || r_tc < ObNullTC || r_tc >= ObMaxTC || OB_ISNULL(map))) {
if (OB_UNLIKELY(l_tc < ObNullTC || l_tc >= ObMaxTC || r_tc < ObNullTC || r_tc >= ObMaxTC
|| OB_ISNULL(map))) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("left / right tc out of range, or map array is null", K(ret), K(l_tc), K(r_tc));
} else {
@ -68,5 +94,5 @@ int ObExprPromotionUtil::get_calc_type(
return ret;
}
} // namespace sql
} // namespace oceanbase
} // namespace sql
} // namespace oceanbase