Fix convert/to_type and get_ddl compatibility bugs
This commit is contained in:
@ -2128,6 +2128,12 @@ int ObSchemaPrinter::print_table_definition_table_options(
|
||||
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_FAIL(databuff_printf(buf, buf_len, pos, "USE_BLOOM_FILTER = %s ",
|
||||
table_schema.is_use_bloomfilter() ? "TRUE" : "FALSE"))) {
|
||||
|
@ -84,7 +84,34 @@ int calc_convert_expr(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &res_datum)
|
||||
if (OB_FAIL(expr.args_[0]->eval(ctx, child_res))) {
|
||||
LOG_WARN("eval arg 0 failed", K(ret));
|
||||
} else {
|
||||
res_datum.set_datum(*child_res);
|
||||
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 {
|
||||
res_datum.set_datum(*child_res);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -40,11 +40,10 @@ int ObExprToBlob::calc_result_type1(ObExprResType &type,
|
||||
UNUSED(type_ctx);
|
||||
int ret = OB_SUCCESS;
|
||||
|
||||
if (ob_is_null(text.get_type())) {
|
||||
type.set_null();
|
||||
} else if (ob_is_blob(text.get_type(), text.get_collation_type())
|
||||
|| ob_is_raw(text.get_type())
|
||||
|| ob_is_string_tc(text.get_type())) {
|
||||
if (ob_is_null(text.get_type())
|
||||
|| ob_is_blob(text.get_type(), text.get_collation_type())
|
||||
|| ob_is_raw(text.get_type())
|
||||
|| ob_is_string_tc(text.get_type())) {
|
||||
type.set_blob();
|
||||
type.set_collation_type(CS_TYPE_BINARY);
|
||||
if (ob_is_string_tc(text.get_type())) {
|
||||
|
@ -44,9 +44,8 @@ int ObExprToClob::calc_result_type1(ObExprResType &type,
|
||||
if (OB_ISNULL(type_ctx.get_session())) {
|
||||
ret = OB_ERR_UNEXPECTED;
|
||||
LOG_WARN("session is NULL", K(ret));
|
||||
} else if (ob_is_null(text.get_type())) {
|
||||
type.set_null();
|
||||
} else if (ob_is_string_tc(text.get_type())
|
||||
} else if (ob_is_null(text.get_type())
|
||||
|| ob_is_string_tc(text.get_type())
|
||||
|| ob_is_clob(text.get_type(), text.get_collation_type())
|
||||
|| ob_is_raw(text.get_type())
|
||||
|| ob_is_numeric_type(text.get_type())
|
||||
|
@ -76,9 +76,13 @@ int ObExprToNumberBase::calc_result_typeN(ObExprResType &type,
|
||||
if (param_num == 3) {
|
||||
types[2].set_calc_type_default_varchar();
|
||||
}
|
||||
type.set_type(ObNumberType);
|
||||
type.set_scale(ORA_NUMBER_SCALE_UNKNOWN_YET);
|
||||
type.set_precision(PRECISION_UNKNOWN_YET);
|
||||
if (types[0].is_null()) {
|
||||
type.set_null();
|
||||
} else {
|
||||
type.set_type(ObNumberType);
|
||||
type.set_scale(ORA_NUMBER_SCALE_UNKNOWN_YET);
|
||||
type.set_precision(PRECISION_UNKNOWN_YET);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@ -325,7 +329,11 @@ int ObExprToBinaryFloat::calc_result_typeN(ObExprResType &type,
|
||||
LOG_WARN("input type can not cast to binary_float", K(types[0].get_type()), K(ret));
|
||||
} else {
|
||||
types[0].set_calc_type(ObFloatType);
|
||||
type.set_type(ObFloatType);
|
||||
if (types[0].is_null()) {
|
||||
type.set_null();
|
||||
} else {
|
||||
type.set_type(ObFloatType);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -388,7 +396,11 @@ int ObExprToBinaryDouble::calc_result_typeN(ObExprResType &type,
|
||||
LOG_WARN("input type can not cast to binary_double", K(types[0].get_type()), K(ret));
|
||||
} else {
|
||||
types[0].set_calc_type(ObDoubleType);
|
||||
type.set_type(ObDoubleType);
|
||||
if (types[0].is_null()) {
|
||||
type.set_null();
|
||||
} else {
|
||||
type.set_type(ObDoubleType);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -244,6 +244,10 @@ int ObExprToTemporalBase::calc_result_typeN(ObExprResType &type,
|
||||
//result type
|
||||
if (OB_SUCC(ret)) {
|
||||
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
|
||||
if (OB_SUCC(ret)) {
|
||||
|
Reference in New Issue
Block a user