Skip to content

Commit 5a66f17

Browse files
kyleconroyclaude
andcommitted
Add ALTER COLUMN support for ALTER FULLTEXT INDEX statement
- Added AlterColumnAlterFullTextIndexAction AST type - Added parsing for ALTER COLUMN clause in ALTER FULLTEXT INDEX - Added JSON marshaling for the new type Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 09af88d commit 5a66f17

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

ast/alter_simple_statements.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,15 @@ type DropAlterFullTextIndexAction struct {
295295
func (*DropAlterFullTextIndexAction) node() {}
296296
func (*DropAlterFullTextIndexAction) alterFullTextIndexAction() {}
297297

298+
// AlterColumnAlterFullTextIndexAction represents an ALTER COLUMN action for fulltext index
299+
type AlterColumnAlterFullTextIndexAction struct {
300+
Column *FullTextIndexColumn `json:"Column,omitempty"`
301+
WithNoPopulation bool `json:"WithNoPopulation"`
302+
}
303+
304+
func (*AlterColumnAlterFullTextIndexAction) node() {}
305+
func (*AlterColumnAlterFullTextIndexAction) alterFullTextIndexAction() {}
306+
298307
// FullTextIndexColumn represents a column in a fulltext index
299308
type FullTextIndexColumn struct {
300309
Name *Identifier `json:"Name,omitempty"`

parser/marshal.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17658,6 +17658,15 @@ func alterFullTextIndexActionToJSON(a ast.AlterFullTextIndexActionOption) jsonNo
1765817658
node["StopListOption"] = stopListFullTextIndexOptionToJSON(action.StopListOption)
1765917659
}
1766017660
return node
17661+
case *ast.AlterColumnAlterFullTextIndexAction:
17662+
node := jsonNode{
17663+
"$type": "AlterColumnAlterFullTextIndexAction",
17664+
"WithNoPopulation": action.WithNoPopulation,
17665+
}
17666+
if action.Column != nil {
17667+
node["Column"] = fullTextIndexColumnToJSON(action.Column)
17668+
}
17669+
return node
1766117670
}
1766217671
return nil
1766317672
}

parser/parse_ddl.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8737,12 +8737,59 @@ func (p *Parser) tryParseAlterFullTextIndexAction() ast.AlterFullTextIndexAction
87378737
case "DROP":
87388738
action, _ := p.parseDropAlterFullTextIndexAction()
87398739
return action
8740+
case "ALTER":
8741+
action, _ := p.parseAlterColumnAlterFullTextIndexAction()
8742+
return action
87408743
}
87418744

87428745
// No action found
87438746
return nil
87448747
}
87458748

8749+
func (p *Parser) parseAlterColumnAlterFullTextIndexAction() (*ast.AlterColumnAlterFullTextIndexAction, error) {
8750+
p.nextToken() // consume ALTER
8751+
8752+
if strings.ToUpper(p.curTok.Literal) != "COLUMN" {
8753+
return nil, fmt.Errorf("expected COLUMN after ALTER, got %s", p.curTok.Literal)
8754+
}
8755+
p.nextToken() // consume COLUMN
8756+
8757+
action := &ast.AlterColumnAlterFullTextIndexAction{
8758+
Column: &ast.FullTextIndexColumn{
8759+
Name: p.parseIdentifier(),
8760+
},
8761+
}
8762+
8763+
// Parse ADD or DROP STATISTICAL_SEMANTICS
8764+
if strings.ToUpper(p.curTok.Literal) == "ADD" {
8765+
p.nextToken() // consume ADD
8766+
if strings.ToUpper(p.curTok.Literal) == "STATISTICAL_SEMANTICS" {
8767+
p.nextToken() // consume STATISTICAL_SEMANTICS
8768+
action.Column.StatisticalSemantics = true
8769+
}
8770+
} else if strings.ToUpper(p.curTok.Literal) == "DROP" {
8771+
p.nextToken() // consume DROP
8772+
if strings.ToUpper(p.curTok.Literal) == "STATISTICAL_SEMANTICS" {
8773+
p.nextToken() // consume STATISTICAL_SEMANTICS
8774+
action.Column.StatisticalSemantics = false
8775+
}
8776+
}
8777+
8778+
// Check for WITH NO POPULATION
8779+
if p.curTok.Type == TokenWith {
8780+
p.nextToken() // consume WITH
8781+
if strings.ToUpper(p.curTok.Literal) == "NO" {
8782+
p.nextToken() // consume NO
8783+
if strings.ToUpper(p.curTok.Literal) == "POPULATION" {
8784+
p.nextToken() // consume POPULATION
8785+
action.WithNoPopulation = true
8786+
}
8787+
}
8788+
}
8789+
8790+
return action, nil
8791+
}
8792+
87468793
func (p *Parser) parseAddAlterFullTextIndexAction() (*ast.AddAlterFullTextIndexAction, error) {
87478794
p.nextToken() // consume ADD
87488795

0 commit comments

Comments
 (0)