@@ -2867,20 +2867,21 @@ func (p *Parser) parseAlterTableAlterIndexStatement(tableName *ast.SchemaObjectN
28672867
28682868func convertIndexOptionKind (name string ) string {
28692869 optionMap := map [string ]string {
2870- "BUCKET_COUNT" : "BucketCount" ,
2871- "PAD_INDEX" : "PadIndex" ,
2872- "FILLFACTOR" : "FillFactor" ,
2873- "SORT_IN_TEMPDB" : "SortInTempDB" ,
2874- "IGNORE_DUP_KEY" : "IgnoreDupKey" ,
2875- "STATISTICS_NORECOMPUTE" : "StatisticsNoRecompute" ,
2876- "DROP_EXISTING" : "DropExisting" ,
2877- "ONLINE" : "Online" ,
2878- "ALLOW_ROW_LOCKS" : "AllowRowLocks" ,
2879- "ALLOW_PAGE_LOCKS" : "AllowPageLocks" ,
2880- "MAXDOP" : "MaxDop" ,
2881- "DATA_COMPRESSION" : "DataCompression" ,
2882- "COMPRESS_ALL_ROW_GROUPS" : "CompressAllRowGroups" ,
2883- "COMPRESSION_DELAY" : "CompressionDelay" ,
2870+ "BUCKET_COUNT" : "BucketCount" ,
2871+ "PAD_INDEX" : "PadIndex" ,
2872+ "FILLFACTOR" : "FillFactor" ,
2873+ "SORT_IN_TEMPDB" : "SortInTempDB" ,
2874+ "IGNORE_DUP_KEY" : "IgnoreDupKey" ,
2875+ "STATISTICS_NORECOMPUTE" : "StatisticsNoRecompute" ,
2876+ "DROP_EXISTING" : "DropExisting" ,
2877+ "ONLINE" : "Online" ,
2878+ "ALLOW_ROW_LOCKS" : "AllowRowLocks" ,
2879+ "ALLOW_PAGE_LOCKS" : "AllowPageLocks" ,
2880+ "MAXDOP" : "MaxDop" ,
2881+ "DATA_COMPRESSION" : "DataCompression" ,
2882+ "COMPRESS_ALL_ROW_GROUPS" : "CompressAllRowGroups" ,
2883+ "COMPRESSION_DELAY" : "CompressionDelay" ,
2884+ "OPTIMIZE_FOR_SEQUENTIAL_KEY" : "OptimizeForSequentialKey" ,
28842885 }
28852886 if mapped , ok := optionMap [name ]; ok {
28862887 return mapped
@@ -3085,12 +3086,27 @@ func (p *Parser) parseAlterTableAddStatement(tableName *ast.SchemaObjectName) (*
30853086 if p .curTok .Type == TokenEquals {
30863087 p .nextToken () // consume =
30873088 }
3088- expr , _ := p .parseScalarExpression ()
3089- option := & ast.IndexExpressionOption {
3090- OptionKind : convertIndexOptionKind (optionName ),
3091- Expression : expr ,
3089+ // Check for ON/OFF state options
3090+ valueUpper := strings .ToUpper (p .curTok .Literal )
3091+ if valueUpper == "ON" || valueUpper == "OFF" || p .curTok .Type == TokenOn {
3092+ state := "On"
3093+ if valueUpper == "OFF" {
3094+ state = "Off"
3095+ }
3096+ p .nextToken () // consume ON/OFF
3097+ option := & ast.IndexStateOption {
3098+ OptionKind : convertIndexOptionKind (optionName ),
3099+ OptionState : state ,
3100+ }
3101+ constraint .IndexOptions = append (constraint .IndexOptions , option )
3102+ } else {
3103+ expr , _ := p .parseScalarExpression ()
3104+ option := & ast.IndexExpressionOption {
3105+ OptionKind : convertIndexOptionKind (optionName ),
3106+ Expression : expr ,
3107+ }
3108+ constraint .IndexOptions = append (constraint .IndexOptions , option )
30923109 }
3093- constraint .IndexOptions = append (constraint .IndexOptions , option )
30943110 if p .curTok .Type == TokenComma {
30953111 p .nextToken ()
30963112 } else {
@@ -3195,12 +3211,27 @@ func (p *Parser) parseAlterTableAddStatement(tableName *ast.SchemaObjectName) (*
31953211 if p .curTok .Type == TokenEquals {
31963212 p .nextToken () // consume =
31973213 }
3198- expr , _ := p .parseScalarExpression ()
3199- option := & ast.IndexExpressionOption {
3200- OptionKind : convertIndexOptionKind (optionName ),
3201- Expression : expr ,
3214+ // Check for ON/OFF state options
3215+ valueUpper := strings .ToUpper (p .curTok .Literal )
3216+ if valueUpper == "ON" || valueUpper == "OFF" || p .curTok .Type == TokenOn {
3217+ state := "On"
3218+ if valueUpper == "OFF" {
3219+ state = "Off"
3220+ }
3221+ p .nextToken () // consume ON/OFF
3222+ option := & ast.IndexStateOption {
3223+ OptionKind : convertIndexOptionKind (optionName ),
3224+ OptionState : state ,
3225+ }
3226+ constraint .IndexOptions = append (constraint .IndexOptions , option )
3227+ } else {
3228+ expr , _ := p .parseScalarExpression ()
3229+ option := & ast.IndexExpressionOption {
3230+ OptionKind : convertIndexOptionKind (optionName ),
3231+ Expression : expr ,
3232+ }
3233+ constraint .IndexOptions = append (constraint .IndexOptions , option )
32023234 }
3203- constraint .IndexOptions = append (constraint .IndexOptions , option )
32043235 if p .curTok .Type == TokenComma {
32053236 p .nextToken ()
32063237 } else {
0 commit comments