@@ -10451,11 +10451,35 @@ func (p *Parser) parseCreateXmlIndexStatement() (*ast.CreateXmlIndexStatement, e
1045110451 }
1045210452
1045310453 stmt := & ast.CreateXmlIndexStatement {
10454- Name : p .parseIdentifier (),
10454+ Primary : true ,
10455+ SecondaryXmlIndexType : "NotSpecified" ,
10456+ Name : p .parseIdentifier (),
10457+ }
10458+
10459+ // Parse ON table_name
10460+ if strings .ToUpper (p .curTok .Literal ) == "ON" {
10461+ p .nextToken () // consume ON
10462+ stmt .OnName , _ = p .parseSchemaObjectName ()
10463+ }
10464+
10465+ // Parse (column)
10466+ if p .curTok .Type == TokenLParen {
10467+ p .nextToken () // consume (
10468+ stmt .XmlColumn = p .parseIdentifier ()
10469+ if p .curTok .Type == TokenRParen {
10470+ p .nextToken () // consume )
10471+ }
10472+ }
10473+
10474+ // Parse WITH (options) if present
10475+ if strings .ToUpper (p .curTok .Literal ) == "WITH" {
10476+ p .nextToken () // consume WITH
10477+ if p .curTok .Type == TokenLParen {
10478+ // parseCreateIndexOptions expects to consume ( and ) itself
10479+ stmt .IndexOptions = p .parseCreateIndexOptions ()
10480+ }
1045510481 }
1045610482
10457- // Skip rest of statement
10458- p .skipToEndOfStatement ()
1045910483 return stmt , nil
1046010484}
1046110485
@@ -10466,11 +10490,61 @@ func (p *Parser) parseCreateXmlIndexFromXml() (*ast.CreateXmlIndexStatement, err
1046610490 }
1046710491
1046810492 stmt := & ast.CreateXmlIndexStatement {
10469- Name : p .parseIdentifier (),
10493+ Primary : false ,
10494+ SecondaryXmlIndexType : "NotSpecified" ,
10495+ Name : p .parseIdentifier (),
10496+ }
10497+
10498+ // Parse ON table_name
10499+ if strings .ToUpper (p .curTok .Literal ) == "ON" {
10500+ p .nextToken () // consume ON
10501+ stmt .OnName , _ = p .parseSchemaObjectName ()
10502+ }
10503+
10504+ // Parse (column)
10505+ if p .curTok .Type == TokenLParen {
10506+ p .nextToken () // consume (
10507+ stmt .XmlColumn = p .parseIdentifier ()
10508+ if p .curTok .Type == TokenRParen {
10509+ p .nextToken () // consume )
10510+ }
10511+ }
10512+
10513+ // Parse USING XML INDEX name FOR VALUE|PATH|PROPERTY
10514+ if strings .ToUpper (p .curTok .Literal ) == "USING" {
10515+ p .nextToken () // consume USING
10516+ if strings .ToUpper (p .curTok .Literal ) == "XML" {
10517+ p .nextToken () // consume XML
10518+ }
10519+ if p .curTok .Type == TokenIndex {
10520+ p .nextToken () // consume INDEX
10521+ }
10522+ stmt .SecondaryXmlIndexName = p .parseIdentifier ()
10523+ if strings .ToUpper (p .curTok .Literal ) == "FOR" {
10524+ p .nextToken () // consume FOR
10525+ switch strings .ToUpper (p .curTok .Literal ) {
10526+ case "VALUE" :
10527+ stmt .SecondaryXmlIndexType = "Value"
10528+ p .nextToken ()
10529+ case "PATH" :
10530+ stmt .SecondaryXmlIndexType = "Path"
10531+ p .nextToken ()
10532+ case "PROPERTY" :
10533+ stmt .SecondaryXmlIndexType = "Property"
10534+ p .nextToken ()
10535+ }
10536+ }
10537+ }
10538+
10539+ // Parse WITH (options) if present
10540+ if strings .ToUpper (p .curTok .Literal ) == "WITH" {
10541+ p .nextToken () // consume WITH
10542+ if p .curTok .Type == TokenLParen {
10543+ // parseCreateIndexOptions expects to consume ( and ) itself
10544+ stmt .IndexOptions = p .parseCreateIndexOptions ()
10545+ }
1047010546 }
1047110547
10472- // Skip rest of statement
10473- p .skipToEndOfStatement ()
1047410548 return stmt , nil
1047510549}
1047610550
0 commit comments