Skip to content

Commit

Permalink
parser: create integer type field with specified length should have w…
Browse files Browse the repository at this point in the history
…arings (pingcap#939)

* .

Signed-off-by: AilinKid <314806019@qq.com>

* .

Signed-off-by: AilinKid <314806019@qq.com>

* .

Signed-off-by: AilinKid <314806019@qq.com>

* .

Signed-off-by: AilinKid <314806019@qq.com>

* .

Signed-off-by: AilinKid <314806019@qq.com>
  • Loading branch information
AilinKid authored Jul 24, 2020
1 parent 44bfb50 commit 2dedd43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions parser.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -9791,6 +9791,10 @@ NumericType:
// TODO: check flen 0
x := types.NewFieldType($1.(byte))
x.Flen = $2.(int)
if $2.(int) != types.UnspecifiedLength {
yylex.AppendError(yylex.Errorf("Integer display width is deprecated and will be removed in a future release."))
parser.lastErrorAsWarn()
}
for _, o := range $3.([]*ast.TypeOpt) {
if o.IsUnsigned {
x.Flag |= mysql.UnsignedFlag
Expand Down
4 changes: 4 additions & 0 deletions yy_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ var (
ErrUnknownAlterAlgorithm = terror.ClassParser.New(mysql.ErrUnknownAlterAlgorithm, mysql.MySQLErrName[mysql.ErrUnknownAlterAlgorithm])
// ErrWrongValue returns for wrong value
ErrWrongValue = terror.ClassParser.New(mysql.ErrWrongValue, mysql.MySQLErrName[mysql.ErrWrongValue])
// ErrWarnDeprecatedSyntaxNoReplacement return when the syntax was deprecated and there is no replacement.
ErrWarnDeprecatedSyntaxNoReplacement = terror.ClassParser.New(mysql.ErrWarnDeprecatedSyntaxNoReplacement, mysql.MySQLErrName[mysql.ErrWarnDeprecatedSyntaxNoReplacement])
// ErrWarnDeprecatedIntegerDisplayWidth share the same code 1681, and it will be returned when length is specified in integer.
ErrWarnDeprecatedIntegerDisplayWidth = terror.ClassParser.New(mysql.ErrWarnDeprecatedSyntaxNoReplacement, "Integer display width is deprecated and will be removed in a future release.")
// SpecFieldPattern special result field pattern
SpecFieldPattern = regexp.MustCompile(`(\/\*!(M?[0-9]{5,6})?|\*\/)`)
specCodeStart = regexp.MustCompile(`^\/\*!(M?[0-9]{5,6})?[ \t]*`)
Expand Down

0 comments on commit 2dedd43

Please sign in to comment.