fix print type scale bug

This commit is contained in:
st0
2021-09-13 17:45:22 +08:00
committed by wangzelin.wzl
parent 65e00203c5
commit c19f7ea941
25 changed files with 22507 additions and 22248 deletions

View File

@ -2667,6 +2667,14 @@ bool ObSysFunRawExpr::same_as(const ObRawExpr& expr, ObExprEqualCheckContext* ch
bool_ret = false;
}
}
if (0 == get_param_count()
&& (T_FUN_SYS_CUR_TIMESTAMP == get_expr_type()
|| T_FUN_SYS_SYSDATE == get_expr_type()
|| T_FUN_SYS_CUR_TIME == get_expr_type()
|| T_FUN_SYS_UTC_TIMESTAMP == get_expr_type()
|| T_FUN_SYS_UTC_TIME == get_expr_type())) {
bool_ret = result_type_.get_scale() == s_expr->get_result_type().get_scale();
}
}
}
return bool_ret;

View File

@ -2230,8 +2230,16 @@ int ObRawExprPrinter::print_cast_type(ObRawExpr* expr)
}
case T_DATETIME: {
// oracle mode treate date as datetime
const char* type_str = lib::is_oracle_mode() ? "date" : "datetime";
DATA_PRINTF(type_str);
if (lib::is_oracle_mode()) {
DATA_PRINTF("date");
} else {
int16_t scale = parse_node.int16_values_[OB_NODE_CAST_N_SCALE_IDX];
if (scale >= 0) {
DATA_PRINTF("datetime(%d)", scale);
} else {
DATA_PRINTF("datetime");
}
}
break;
}
case T_DATE: {
@ -2239,7 +2247,12 @@ int ObRawExprPrinter::print_cast_type(ObRawExpr* expr)
break;
}
case T_TIME: {
DATA_PRINTF("time");
int16_t scale = parse_node.int16_values_[OB_NODE_CAST_N_SCALE_IDX];
if (scale >= 0) {
DATA_PRINTF("time(%d)", scale);
} else {
DATA_PRINTF("time");
}
break;
}
case T_NUMBER: {
@ -2281,15 +2294,30 @@ int ObRawExprPrinter::print_cast_type(ObRawExpr* expr)
break;
}
case T_TIMESTAMP_TZ: {
DATA_PRINTF("timestamp with time zone");
int16_t scale = parse_node.int16_values_[OB_NODE_CAST_N_SCALE_IDX];
if (scale >= 0) {
DATA_PRINTF("timestamp(%d) with time zone", scale);
} else {
DATA_PRINTF("timestamp with time zone");
}
break;
}
case T_TIMESTAMP_LTZ: {
DATA_PRINTF("timestamp with local time zone");
int16_t scale = parse_node.int16_values_[OB_NODE_CAST_N_SCALE_IDX];
if (scale >= 0) {
DATA_PRINTF("timestamp(%d) with local time zone", scale);
} else {
DATA_PRINTF("timestamp with local time zone");
}
break;
}
case T_TIMESTAMP_NANO: {
DATA_PRINTF("timestamp");
int16_t scale = parse_node.int16_values_[OB_NODE_CAST_N_SCALE_IDX];
if (scale >= 0) {
DATA_PRINTF("timestamp(%d)", scale);
} else {
DATA_PRINTF("timestamp");
}
break;
}
case T_RAW: {