fix bugs
This commit is contained in:
@ -1111,13 +1111,16 @@ static OB_INLINE int common_string_number(const ObExpr &expr,
|
||||
number::ObNumber &nmb)
|
||||
{
|
||||
int ret = OB_SUCCESS;
|
||||
const ObCastMode cast_mode = expr.extra_;
|
||||
DEF_IN_OUT_TYPE();
|
||||
if (ObHexStringType == in_type) {
|
||||
ret = nmb.from(hex_to_uint64(in_str), alloc);
|
||||
} else if (0 == in_str.length()) {
|
||||
// in mysql mode, this err will be ignored(because default cast_mode is WARN_ON_FAIL)
|
||||
nmb.set_zero();
|
||||
ret = OB_ERR_TRUNCATED_WRONG_VALUE_FOR_FIELD;
|
||||
if (lib::is_oracle_mode() || CM_IS_COLUMN_CONVERT(cast_mode)) {
|
||||
ret = OB_ERR_TRUNCATED_WRONG_VALUE_FOR_FIELD;
|
||||
}
|
||||
} else {
|
||||
ObPrecision res_precision; // useless
|
||||
ObScale res_scale;
|
||||
@ -1151,7 +1154,6 @@ static OB_INLINE int common_string_number(const ObExpr &expr,
|
||||
}
|
||||
}
|
||||
|
||||
const ObCastMode cast_mode = expr.extra_;
|
||||
if (CAST_FAIL(ret)) {
|
||||
LOG_WARN("string_number failed", K(ret), K(in_type), K(out_type), K(cast_mode), K(in_str));
|
||||
} else if (ObUNumberType == out_type && CAST_FAIL(numeric_negative_check(nmb))) {
|
||||
|
||||
@ -189,13 +189,13 @@ int ObExprColumnConv::convert_skip_null_check(ObObj &result,
|
||||
LOG_WARN("failed to check accuracy", K(ret), K(accuracy), K(collation_type), KPC(res_obj));
|
||||
if (OB_ERR_DATA_TOO_LONG == ret && lib::is_oracle_mode()
|
||||
&& OB_NOT_NULL(column_info) && !column_info->empty()) {
|
||||
ObString column_info_connection;
|
||||
ObArenaAllocator allocator;
|
||||
ObSQLUtils::copy_and_convert_string_charset(allocator, *column_info,
|
||||
column_info_connection, CS_TYPE_UTF8MB4_BIN,
|
||||
cast_ctx.dtc_params_.connection_collation_);
|
||||
LOG_ORACLE_USER_ERROR(OB_ERR_DATA_TOO_LONG_MSG_FMT_V2, column_info_connection.length(),
|
||||
column_info_connection.ptr(), str_len_byte, max_accuracy_len);
|
||||
int64_t col_length = str_len_byte;
|
||||
if (ObStringTC == ob_obj_type_class(type)
|
||||
&& !is_oracle_byte_length(lib::is_oracle_mode(), accuracy.get_length_semantics())) {
|
||||
col_length = ObCharset::strlen_char(collation_type, result.get_string().ptr(), str_len_byte);
|
||||
}
|
||||
LOG_ORACLE_USER_ERROR(OB_ERR_DATA_TOO_LONG_MSG_FMT_V2, column_info->length(),
|
||||
column_info->ptr(), col_length, max_accuracy_len);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -350,12 +350,27 @@ static inline int column_convert_datum_accuracy_check(const ObExpr &expr,
|
||||
LOG_WARN("evaluate parameter failed", K(ret));
|
||||
} else {
|
||||
column_info_str = column_info->get_string();
|
||||
int64_t col_length = str_len_byte;
|
||||
if (ObStringTC == ob_obj_type_class(expr.datum_meta_.get_type())
|
||||
&& !is_oracle_byte_length(lib::is_oracle_mode(), expr.datum_meta_.length_semantics_)) {
|
||||
col_length = ObCharset::strlen_char(expr.datum_meta_.cs_type_, datum_for_check.ptr_, str_len_byte);
|
||||
}
|
||||
LOG_ORACLE_USER_ERROR(OB_ERR_DATA_TOO_LONG_MSG_FMT_V2, column_info_str.length(),
|
||||
column_info_str.ptr(), str_len_byte, max_accuracy_len);
|
||||
column_info_str.ptr(), col_length, max_accuracy_len);
|
||||
}
|
||||
ret = OB_ERR_DATA_TOO_LONG;
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && lib::is_mysql_mode() && OB_ERR_DATA_TOO_LONG == warning) {
|
||||
ObDatum *column_info = NULL;
|
||||
int64_t rownum = ctx.exec_ctx_.get_cur_rownum();
|
||||
if (rownum > 0
|
||||
&& ObExprColumnConv::PARAMS_COUNT_WITH_COLUMN_INFO == expr.arg_cnt_
|
||||
&& OB_SUCCESS == expr.args_[5]->eval(ctx, column_info)) {
|
||||
LOG_USER_WARN(OB_ERR_DATA_TRUNCATED, column_info->get_string().length(),
|
||||
column_info->get_string().ptr(), rownum);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ int internal_calc_result_length(ObExprResType &type, ObExprResType &text)
|
||||
ret = OB_ERR_INVALID_TYPE_FOR_OP;
|
||||
LOG_USER_ERROR(OB_ERR_INVALID_TYPE_FOR_OP, "RAW", ob_obj_type_str(param_type));
|
||||
LOG_WARN("ORA-00932: inconsistent datatypes: expected - got LOB", K(ret));
|
||||
} else if (ob_is_string_type(param_type)) {
|
||||
} else if (ob_is_string_type(param_type) || ob_is_raw(param_type)) {
|
||||
length = 2 * text.get_length();
|
||||
if (text.get_length_semantics() == LS_CHAR) {
|
||||
length *= 4;
|
||||
|
||||
@ -256,7 +256,7 @@ int ObExprSubstr::calc_result_typeN(ObExprResType &type,
|
||||
types_array[i].set_calc_type(ObIntType);
|
||||
}
|
||||
}
|
||||
if (OB_SUCC(ret) && type.is_varchar()) {
|
||||
if (OB_SUCC(ret) && !ob_is_text_tc(type.get_type())) {
|
||||
// Set cast mode for integer parameters, truncate string to integer.
|
||||
// see: ObExprSubstr::cast_param_type_for_mysql
|
||||
OX(type_ctx.set_cast_mode(type_ctx.get_cast_mode() | CM_STRING_INTEGER_TRUNC));
|
||||
|
||||
Reference in New Issue
Block a user