Skip to content

Commit

Permalink
parser: update the alter table... add column (pingcap#5054)
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala authored Nov 10, 2017
1 parent 03e23ee commit dd5767a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -842,12 +842,11 @@ AlterTableSpec:
Position: $4.(*ast.ColumnPosition),
}
}
| "ADD" ColumnKeywordOpt '(' ColumnDef ColumnPosition ')'
| "ADD" ColumnKeywordOpt '(' ColumnDef ')'
{
$$ = &ast.AlterTableSpec{
Tp: ast.AlterTableAddColumn,
NewColumn: $4.(*ast.ColumnDef),
Position: $5.(*ast.ColumnPosition),
}
}
| "ADD" Constraint
Expand Down
3 changes: 2 additions & 1 deletion parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,8 @@ func (s *testParserSuite) TestDDL(c *C) {
{"CREATE TABLE IF NOT EXISTS `general_log` (`event_time` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),`user_host` mediumtext NOT NULL,`thread_id` bigint(20) unsigned NOT NULL,`server_id` int(10) unsigned NOT NULL,`command_type` varchar(64) NOT NULL,`argument` mediumblob NOT NULL) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='General log'", true},

// for alter table
{"ALTER TABLE t ADD COLUMN( a SMALLINT UNSIGNED )", true},
{"ALTER TABLE t ADD COLUMN (a SMALLINT UNSIGNED)", true},
{"ALTER TABLE t ADD COLUMN (a SMALLINT UNSIGNED FIRST)", false},
{"ALTER TABLE t ADD COLUMN a SMALLINT UNSIGNED", true},
{"ALTER TABLE t ADD COLUMN a SMALLINT UNSIGNED FIRST", true},
{"ALTER TABLE t ADD COLUMN a SMALLINT UNSIGNED AFTER b", true},
Expand Down

0 comments on commit dd5767a

Please sign in to comment.