Skip to content

Commit 75af8d1

Browse files
kyleconroyclaude
andcommitted
Fix SETTINGS clause parsing after MODIFY COLUMN REMOVE
When parsing MODIFY COLUMN REMOVE, stop at SETTINGS keyword so that the statement-level SETTINGS clause is properly parsed. Also handle IF EXISTS in ALTER DROP INDEX. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bcc22f3 commit 75af8d1

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

parser/parser.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5475,7 +5475,15 @@ func (p *Parser) parseAlterCommand() *ast.AlterCommand {
54755475
} else if p.currentIs(token.INDEX) {
54765476
cmd.Type = ast.AlterDropIndex
54775477
p.nextToken()
5478-
if p.currentIs(token.IDENT) {
5478+
// Handle IF EXISTS
5479+
if p.currentIs(token.IF) {
5480+
p.nextToken()
5481+
if p.currentIs(token.EXISTS) {
5482+
cmd.IfExists = true
5483+
p.nextToken()
5484+
}
5485+
}
5486+
if p.currentIs(token.IDENT) || p.current.Token.IsKeyword() {
54795487
cmd.Index = p.current.Value
54805488
p.nextToken()
54815489
}
@@ -5724,8 +5732,8 @@ func (p *Parser) parseAlterCommand() *ast.AlterCommand {
57245732
colName := p.current.Value
57255733
p.nextToken() // skip column name
57265734
cmd.Column = &ast.ColumnDeclaration{Name: colName}
5727-
// Skip REMOVE COMMENT etc.
5728-
for !p.currentIs(token.EOF) && !p.currentIs(token.SEMICOLON) && !p.currentIs(token.COMMA) {
5735+
// Skip REMOVE COMMENT etc. but stop at SETTINGS clause
5736+
for !p.currentIs(token.EOF) && !p.currentIs(token.SEMICOLON) && !p.currentIs(token.COMMA) && !p.currentIs(token.SETTINGS) {
57295737
p.nextToken()
57305738
}
57315739
} else if (p.currentIs(token.IDENT) || p.current.Token.IsKeyword()) && p.peek.Token == token.MODIFY {
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"explain_todo": {
3-
"stmt5": true
4-
}
5-
}
1+
{}

0 commit comments

Comments
 (0)