Skip to content

Commit 9a17fed

Browse files
committed
Handle IF EMPTY syntax in DROP TABLE/DATABASE statements
Parse the IF EMPTY modifier in addition to IF EXISTS for DROP statements.
1 parent 38227b2 commit 9a17fed

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

parser/parser.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4755,12 +4755,15 @@ func (p *Parser) parseDrop() *ast.DropQuery {
47554755
}
47564756
}
47574757

4758-
// Handle IF EXISTS
4758+
// Handle IF EXISTS or IF EMPTY
47594759
if p.currentIs(token.IF) {
47604760
p.nextToken()
47614761
if p.currentIs(token.EXISTS) {
47624762
drop.IfExists = true
47634763
p.nextToken()
4764+
} else if p.currentIs(token.IDENT) && strings.ToUpper(p.current.Value) == "EMPTY" {
4765+
// IF EMPTY - skip the EMPTY keyword
4766+
p.nextToken()
47644767
}
47654768
}
47664769

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt10": true,
4-
"stmt11": true,
5-
"stmt13": true
6-
}
7-
}
1+
{}

0 commit comments

Comments
 (0)