Skip to content

Commit

Permalink
parser: support drop view if exists (pingcap#1969)
Browse files Browse the repository at this point in the history
mydumper executes this statement before create a table,
since we don't support view, we can simply return success.
  • Loading branch information
coocood authored and zimulala committed Nov 7, 2016
1 parent 5044a87 commit 1eecf8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions parser/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ var tokenMap = map[string]int{
"VALUES": values,
"VARIABLES": variables,
"VERSION": version,
"VIEW": view,
"WARNINGS": warnings,
"WEEK": week,
"WEEKDAY": weekday,
Expand Down
11 changes: 10 additions & 1 deletion parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ import (
user "USER"
value "VALUE"
variables "VARIABLES"
view "VIEW"
warnings "WARNINGS"
week "WEEK"
yearType "YEAR"
Expand Down Expand Up @@ -471,6 +472,7 @@ import (
DropIndexStmt "DROP INDEX statement"
DropTableStmt "DROP TABLE statement"
DropUserStmt "DROP USER"
DropViewStmt "DROP VIEW statement"
EmptyStmt "empty statement"
Enclosed "Enclosed by"
EqOpt "= or empty"
Expand Down Expand Up @@ -1515,6 +1517,12 @@ DropTableStmt:
$$ = &ast.DropTableStmt{IfExists: true, Tables: $5.([]*ast.TableName)}
}

DropViewStmt:
"DROP" "VIEW" "IF" "EXISTS" TableNameList
{
$$ = &ast.DoStmt{}
}

DropUserStmt:
"DROP" "USER" UsernameList
{
Expand Down Expand Up @@ -1985,7 +1993,7 @@ UnReservedKeyword:
| "COLLATION" | "COMMENT" | "AVG_ROW_LENGTH" | "CONNECTION" | "CHECKSUM" | "COMPRESSION" | "KEY_BLOCK_SIZE" | "MAX_ROWS"
| "MIN_ROWS" | "NATIONAL" | "ROW" | "ROW_FORMAT" | "QUARTER" | "GRANTS" | "TRIGGERS" | "DELAY_KEY_WRITE" | "ISOLATION"
| "REPEATABLE" | "COMMITTED" | "UNCOMMITTED" | "ONLY" | "SERIALIZABLE" | "LEVEL" | "VARIABLES" | "SQL_CACHE" | "INDEXES" | "PROCESSLIST"
| "SQL_NO_CACHE" | "DISABLE" | "ENABLE" | "REVERSE" | "SPACE" | "PRIVILEGES" | "NO" | "BINLOG" | "FUNCTION"
| "SQL_NO_CACHE" | "DISABLE" | "ENABLE" | "REVERSE" | "SPACE" | "PRIVILEGES" | "NO" | "BINLOG" | "FUNCTION" | "VIEW"

NotKeywordToken:
"ABS" | "ADDDATE" | "ADMIN" | "COALESCE" | "CONCAT" | "CONCAT_WS" | "CONNECTION_ID" | "CUR_TIME"| "COUNT" | "DAY"
Expand Down Expand Up @@ -4251,6 +4259,7 @@ Statement:
| DropDatabaseStmt
| DropIndexStmt
| DropTableStmt
| DropViewStmt
| DropUserStmt
| FlushStmt
| GrantStmt
Expand Down
1 change: 1 addition & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ func (s *testParserSuite) TestDDL(c *C) {
{"drop tables xxx, yyy", true},
{"drop table if exists xxx", true},
{"drop table if not exists xxx", false},
{"drop view if exists xxx", true},
// For issue 974
{`CREATE TABLE address (
id bigint(20) NOT NULL AUTO_INCREMENT,
Expand Down

0 comments on commit 1eecf8e

Please sign in to comment.