diff options
author | Gleb Shchepa <gleb.shchepa@oracle.com> | 2012-06-29 12:55:45 +0400 |
---|---|---|
committer | Gleb Shchepa <gleb.shchepa@oracle.com> | 2012-06-29 12:55:45 +0400 |
commit | 767501fb54f19adf3c136e5131daf11e34b3f039 (patch) | |
tree | 7f5c6c4320c4997d6be1e35c5562c5795a1efc72 /sql/sql_yacc.yy | |
parent | 07a17e302c816ff0b5f6eb577f3683b6fd3645ea (diff) | |
download | mariadb-git-767501fb54f19adf3c136e5131daf11e34b3f039.tar.gz |
Backport of the deprecation warning from WL#6219: "Deprecate and remove YEAR(2) type"
Print the warning(note):
YEAR(x) is deprecated and will be removed in a future release. Please use YEAR(4) instead
on "CREATE TABLE ... YEAR(x)" or "ALTER TABLE MODIFY ... YEAR(x)", where x != 4
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7e7ff7e91ca..854ba432362 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5034,7 +5034,23 @@ type: $$= MYSQL_TYPE_VARCHAR; } | YEAR_SYM opt_field_length field_options - { $$=MYSQL_TYPE_YEAR; } + { + if (Lex->length) + { + errno= 0; + ulong length= strtoul(Lex->length, NULL, 10); + if (errno == 0 && length <= MAX_FIELD_BLOBLENGTH && length != 4) + { + char buff[sizeof("YEAR()") + MY_INT64_NUM_DECIMAL_DIGITS + 1]; + snprintf(buff, sizeof(buff), "YEAR(%lu)", length); + push_warning_printf(YYTHD, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_WARN_DEPRECATED_SYNTAX, + ER(ER_WARN_DEPRECATED_SYNTAX), + buff, "YEAR(4)"); + } + } + $$=MYSQL_TYPE_YEAR; + } | DATE_SYM { $$=MYSQL_TYPE_DATE; } | TIME_SYM |