Skip to content

Commit

Permalink
Merge pull request #59 from thinkdb/bug_alter_no_option
Browse files Browse the repository at this point in the history
修复 alter table 命令没有其他选项时能正常通过的bug
  • Loading branch information
hanchuanchuan authored Jul 22, 2019
2 parents e956fd7 + 822be03 commit dfacfb7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions session/session_inception.go
Original file line number Diff line number Diff line change
Expand Up @@ -3108,6 +3108,9 @@ func (s *session) checkAlterTable(node *ast.AlterTableStmt, sql string) {
for i, alter := range node.Specs {
switch alter.Tp {
case ast.AlterTableOption:
if len(alter.Options) == 0 {
s.AppendErrorNo(ER_NOT_SUPPORTED_YET)
}
s.checkTableOptions(alter.Options, node.Table.Name.String(), false)
case ast.AlterTableAddColumns:
s.checkAddColumn(table, alter)
Expand Down
11 changes: 11 additions & 0 deletions session/session_inception_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2217,3 +2217,14 @@ func (s *testSessionIncSuite) TestTimestampType(c *C) {
session.NewErr(session.ER_INVALID_DATA_TYPE, "a"))
config.GetGlobalConfig().Inc.EnableTimeStampType = true
}

func (s *testSessionIncSuite) TestAlterNoOption(c *C) {
saved := config.GetGlobalConfig().Inc
defer func() {
config.GetGlobalConfig().Inc = saved
}()

sql := `alter table t1;`
s.testErrorCode(c, sql,
session.NewErr(session.ER_NOT_SUPPORTED_YET))
}

0 comments on commit dfacfb7

Please sign in to comment.