diff --git a/src/sql/parser/sql_parser_mysql_mode.y b/src/sql/parser/sql_parser_mysql_mode.y index 6b25cab02463c46fecc383b76456e0df22063760..d4024bcbdd42b1d083fba7eb8333df992c3ff9c3 100644 --- a/src/sql/parser/sql_parser_mysql_mode.y +++ b/src/sql/parser/sql_parser_mysql_mode.y @@ -4536,6 +4536,10 @@ int_type_i opt_int_length_i opt_unsigned_i opt_zerofill_i } | float_type_i opt_float_precision opt_unsigned_i opt_zerofill_i { + if (T_FLOAT != $1[0] && NULL != $2 && -1 == $2->int16_values_[1]) { + yyerror(&@2, result, "double type not support double(M) syntax\n"); + YYERROR; + } malloc_terminal_node($$, result->malloc_pool_, ($3[0] || $4[0]) ? $1[0] + (T_UFLOAT - T_FLOAT) : $1[0]); if (NULL != $2) { $$->int16_values_[0] = $2->int16_values_[0]; @@ -4759,6 +4763,14 @@ opt_float_precision: $$->int16_values_[0] = $2->value_; $$->int16_values_[1] = -1; } +| '(' DECIMAL_VAL ')' +{ + malloc_terminal_node($$, result->malloc_pool_, T_LINK_NODE); + int err_no = 0; + $2->value_ = ob_strntoll($2->str_value_, $2->str_len_, 10, NULL, &err_no); + $$->int16_values_[0] = $2->value_; + $$->int16_values_[1] = -1; +} | /*EMPTY*/ { $$ = NULL; diff --git a/src/sql/resolver/ob_resolver_utils.cpp b/src/sql/resolver/ob_resolver_utils.cpp index 598e09d21d3bd8ffeefaf14ddbe7ed9d4f3df083..33f9b9660b760656c1c150ab8cdadbd24b5308da 100644 --- a/src/sql/resolver/ob_resolver_utils.cpp +++ b/src/sql/resolver/ob_resolver_utils.cpp @@ -3807,10 +3807,17 @@ int ObResolverUtils::resolve_data_type(const ParseNode& type_node, const ObStrin ret = OB_ERR_TOO_BIG_SCALE; LOG_USER_ERROR(OB_ERR_TOO_BIG_SCALE, scale, ident_name.ptr(), OB_MAX_DOUBLE_FLOAT_SCALE); LOG_WARN("scale of double overflow", K(ret), K(scale), K(precision)); - } else if (OB_UNLIKELY(precision > OB_MAX_DOUBLE_FLOAT_PRECISION)) { + } else if (OB_UNLIKELY(OB_DECIMAL_NOT_SPECIFIED == scale && + precision > OB_MAX_DOUBLE_FLOAT_PRECISION)) { ret = OB_ERR_COLUMN_SPEC; LOG_USER_ERROR(OB_ERR_COLUMN_SPEC, ident_name.length(), ident_name.ptr()); LOG_WARN("precision of double overflow", K(ret), K(scale), K(precision)); + } else if (OB_UNLIKELY(OB_DECIMAL_NOT_SPECIFIED != scale && + precision > OB_MAX_DOUBLE_FLOAT_DISPLAY_WIDTH)) { + ret = OB_ERR_TOO_BIG_DISPLAYWIDTH; + LOG_USER_ERROR(OB_ERR_TOO_BIG_DISPLAYWIDTH, + ident_name.ptr(), + OB_MAX_INTEGER_DISPLAY_WIDTH); } else if (OB_UNLIKELY(precision < scale)) { ret = OB_ERR_M_BIGGER_THAN_D; LOG_USER_ERROR(OB_ERR_M_BIGGER_THAN_D, to_cstring(ident_name));