-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: year type should have an unsigned flag #7542
Conversation
/run-all-tests |
ddl/ddl_api.go
Outdated
@@ -394,6 +394,12 @@ func columnDefToCol(ctx sessionctx.Context, offset int, colDef *ast.ColumnDef, o | |||
col.Flag &= ^mysql.BinaryFlag | |||
col.Flag |= mysql.ZerofillFlag | |||
} | |||
// If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column. | |||
// See https://dev.mysql.com/doc/refman/8.0/en/numeric-type-overview.html for more details. | |||
// But some types like bit and year, won't show its unsigned flag in `show create table`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not support zerofill as #6688?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it still could work in some client/driver, see #7525
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
myabe we need use 5.7
|
||
// Test show create table with zerofill flag | ||
tk.MustExec(`drop table if exists t`) | ||
tk.MustExec(`create table t(id int primary key, val tinyint(10) zerofill);`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a year type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
year with zerofill?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not allowed, according to #7542 (comment) @shenli
@winkyao in this pr #6745 , I've tested the schema in it, but MySQL does not return an error.
MySQL allow create table for a year type with zerofill/unsigned constraint. I think we should fix it in parser. |
PTAL @winkyao |
Add the parser support for year with field option according to https://github.com/mysql/mysql-server/blob/68816f735f02735e10ea6bea8efc291e4d3cac33/sql/sql_yacc.yy#L6263 |
for _, col := range tbl.Meta().Columns { | ||
if col.Name.String() == "y" { | ||
yearCol = col | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this removal affect test-case's behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
/run-all-tests |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
Fix #7537. year type should have an unsigned flag. According to https://dev.mysql.com/doc/refman/8.0/en/numeric-type-overview.html ,
if you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column.
What is changed and how it works?
Add unsigned flag back to year type, and add zerofill flag for all types except year type in
show create table
.Check List
Tests
Code changes
Side effects
Related changes
PTAL @zimulala @winkyao