Fix convert/to_type and get_ddl compatibility bugs

This commit is contained in:
2149
2023-08-02 05:48:31 +00:00
committed by ob-robot
parent 45f2690b0a
commit 258affd57c
6 changed files with 61 additions and 14 deletions

View File

@ -2128,6 +2128,12 @@ int ObSchemaPrinter::print_table_definition_table_options(
OB_LOG(WARN, "fail to print global/local", K(ret), K(table_schema)); OB_LOG(WARN, "fail to print global/local", K(ret), K(table_schema));
} }
} }
if (OB_SUCC(ret) && !strict_compat_
&& is_index_tbl && is_oracle_mode && !table_schema.is_index_visible()) {
if (OB_FAIL(databuff_printf(buf, buf_len, pos, "INVISIBLE"))) {
OB_LOG(WARN, "fail to print invisible option", K(ret), K(table_schema));
}
}
if (OB_SUCC(ret) && !strict_compat_ && !is_index_tbl) { if (OB_SUCC(ret) && !strict_compat_ && !is_index_tbl) {
if (OB_FAIL(databuff_printf(buf, buf_len, pos, "USE_BLOOM_FILTER = %s ", if (OB_FAIL(databuff_printf(buf, buf_len, pos, "USE_BLOOM_FILTER = %s ",
table_schema.is_use_bloomfilter() ? "TRUE" : "FALSE"))) { table_schema.is_use_bloomfilter() ? "TRUE" : "FALSE"))) {

View File

@ -83,9 +83,36 @@ int calc_convert_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datum)
ObDatum *child_res = NULL; ObDatum *child_res = NULL;
if (OB_FAIL(expr.args_[0]->eval(ctx, child_res))) { if (OB_FAIL(expr.args_[0]->eval(ctx, child_res))) {
LOG_WARN("eval arg 0 failed", K(ret)); LOG_WARN("eval arg 0 failed", K(ret));
} else {
ObCollationType cs_type = expr.args_[0]->datum_meta_.cs_type_;
int64_t mbmaxlen = 1;
if (OB_FAIL(ObCharset::get_mbmaxlen_by_coll(cs_type, mbmaxlen))) {
LOG_WARN("fail to get mbmaxlen", K(cs_type), K(ret));
} else if (mbmaxlen > 1 && !child_res->is_null()) {
ObString checked_res;
bool is_null = false;
const ObSQLSessionInfo *session = ctx.exec_ctx_.get_my_session();
if (OB_ISNULL(session)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("session is null", K(ret));
} else if (OB_FAIL(ObSQLUtils::check_well_formed_str(child_res->get_string(),
cs_type,
checked_res,
is_null,
is_strict_mode(session->get_sql_mode()),
false))) {
LOG_WARN("check_well_formed_str failed", K(ret),
K(child_res->get_string()),
K(expr.datum_meta_));
} else if (is_null) {
res_datum.set_null();
} else {
res_datum.set_string(checked_res);
}
} else { } else {
res_datum.set_datum(*child_res); res_datum.set_datum(*child_res);
} }
}
return ret; return ret;
} }

View File

@ -40,9 +40,8 @@ int ObExprToBlob::calc_result_type1(ObExprResType &type,
UNUSED(type_ctx); UNUSED(type_ctx);
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
if (ob_is_null(text.get_type())) { if (ob_is_null(text.get_type())
type.set_null(); || ob_is_blob(text.get_type(), text.get_collation_type())
} else if (ob_is_blob(text.get_type(), text.get_collation_type())
|| ob_is_raw(text.get_type()) || ob_is_raw(text.get_type())
|| ob_is_string_tc(text.get_type())) { || ob_is_string_tc(text.get_type())) {
type.set_blob(); type.set_blob();

View File

@ -44,9 +44,8 @@ int ObExprToClob::calc_result_type1(ObExprResType &type,
if (OB_ISNULL(type_ctx.get_session())) { if (OB_ISNULL(type_ctx.get_session())) {
ret = OB_ERR_UNEXPECTED; ret = OB_ERR_UNEXPECTED;
LOG_WARN("session is NULL", K(ret)); LOG_WARN("session is NULL", K(ret));
} else if (ob_is_null(text.get_type())) { } else if (ob_is_null(text.get_type())
type.set_null(); || ob_is_string_tc(text.get_type())
} else if (ob_is_string_tc(text.get_type())
|| ob_is_clob(text.get_type(), text.get_collation_type()) || ob_is_clob(text.get_type(), text.get_collation_type())
|| ob_is_raw(text.get_type()) || ob_is_raw(text.get_type())
|| ob_is_numeric_type(text.get_type()) || ob_is_numeric_type(text.get_type())

View File

@ -76,11 +76,15 @@ int ObExprToNumberBase::calc_result_typeN(ObExprResType &type,
if (param_num == 3) { if (param_num == 3) {
types[2].set_calc_type_default_varchar(); types[2].set_calc_type_default_varchar();
} }
if (types[0].is_null()) {
type.set_null();
} else {
type.set_type(ObNumberType); type.set_type(ObNumberType);
type.set_scale(ORA_NUMBER_SCALE_UNKNOWN_YET); type.set_scale(ORA_NUMBER_SCALE_UNKNOWN_YET);
type.set_precision(PRECISION_UNKNOWN_YET); type.set_precision(PRECISION_UNKNOWN_YET);
} }
} }
}
return ret; return ret;
} }
@ -325,8 +329,12 @@ int ObExprToBinaryFloat::calc_result_typeN(ObExprResType &type,
LOG_WARN("input type can not cast to binary_float", K(types[0].get_type()), K(ret)); LOG_WARN("input type can not cast to binary_float", K(types[0].get_type()), K(ret));
} else { } else {
types[0].set_calc_type(ObFloatType); types[0].set_calc_type(ObFloatType);
if (types[0].is_null()) {
type.set_null();
} else {
type.set_type(ObFloatType); type.set_type(ObFloatType);
} }
}
return ret; return ret;
} }
@ -388,8 +396,12 @@ int ObExprToBinaryDouble::calc_result_typeN(ObExprResType &type,
LOG_WARN("input type can not cast to binary_double", K(types[0].get_type()), K(ret)); LOG_WARN("input type can not cast to binary_double", K(types[0].get_type()), K(ret));
} else { } else {
types[0].set_calc_type(ObDoubleType); types[0].set_calc_type(ObDoubleType);
if (types[0].is_null()) {
type.set_null();
} else {
type.set_type(ObDoubleType); type.set_type(ObDoubleType);
} }
}
return ret; return ret;
} }

View File

@ -244,6 +244,10 @@ int ObExprToTemporalBase::calc_result_typeN(ObExprResType &type,
//result type //result type
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {
type.set_type(get_my_target_obj_type()); type.set_type(get_my_target_obj_type());
if (ObDateTimeType == get_my_target_obj_type() && input_char.is_null()) {
//set to_date(null) to null type
type.set_null();
}
} }
//result scale //result scale
if (OB_SUCC(ret)) { if (OB_SUCC(ret)) {