Skip to content

Commit

Permalink
cascade drop table (pingcap#5938)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp authored and shenli committed Mar 3, 2018
1 parent 1a812fc commit d34f702
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions parser/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -1960,11 +1960,11 @@ DropIndexStmt:
}

DropTableStmt:
"DROP" TableOrTables TableNameList
"DROP" TableOrTables TableNameList RestrictOrCascadeOpt
{
$$ = &ast.DropTableStmt{Tables: $3.([]*ast.TableName)}
}
| "DROP" TableOrTables "IF" "EXISTS" TableNameList
| "DROP" TableOrTables "IF" "EXISTS" TableNameList RestrictOrCascadeOpt
{
$$ = &ast.DropTableStmt{IfExists: true, Tables: $5.([]*ast.TableName)}
}
Expand All @@ -1991,6 +1991,11 @@ DropStatsStmt:
$$ = &ast.DropStatsStmt{Table: $3.(*ast.TableName)}
}

RestrictOrCascadeOpt:
{}
| "RESTRICT"
| "CASCADE"

TableOrTables:
"TABLE"
| "TABLES"
Expand Down
3 changes: 3 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,9 @@ 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 table xxx restrict", true},
{"drop table xxx, yyy cascade", true},
{"drop table if exists xxx restrict", true},
{"drop view if exists xxx", true},
{"drop stats t", true},
// for issue 974
Expand Down

0 comments on commit d34f702

Please sign in to comment.