@@ -1438,10 +1438,14 @@ func (p *Parser) parseNamedTableReference() (*ast.NamedTableReference, error) {
14381438 }
14391439 }
14401440
1441- // Parse optional table hints WITH (hint, hint, ...)
1441+ // Parse optional table hints WITH (hint, hint, ...) or old-style (hint, hint, ...)
14421442 if p .curTok .Type == TokenWith {
14431443 p .nextToken () // consume WITH
1444- if p .curTok .Type == TokenLParen {
1444+ }
1445+ if p .curTok .Type == TokenLParen {
1446+ // Check if this looks like hints (first token is a hint keyword)
1447+ // Save position to peek
1448+ if p .peekIsTableHint () {
14451449 p .nextToken () // consume (
14461450 for p .curTok .Type != TokenRParen && p .curTok .Type != TokenEOF {
14471451 hint , err := p .parseTableHint ()
@@ -1454,6 +1458,10 @@ func (p *Parser) parseNamedTableReference() (*ast.NamedTableReference, error) {
14541458 if p .curTok .Type == TokenComma {
14551459 p .nextToken ()
14561460 } else if p .curTok .Type != TokenRParen {
1461+ // Check if the next token is a valid table hint (space-separated hints)
1462+ if p .isTableHintToken () {
1463+ continue // Continue parsing space-separated hints
1464+ }
14571465 break
14581466 }
14591467 }
@@ -1564,6 +1572,46 @@ func getTableHintKind(name string) string {
15641572 }
15651573}
15661574
1575+ // isTableHintToken checks if the current token is a valid table hint keyword
1576+ func (p * Parser ) isTableHintToken () bool {
1577+ // Check for keyword tokens that are table hints
1578+ if p .curTok .Type == TokenHoldlock || p .curTok .Type == TokenNowait {
1579+ return true
1580+ }
1581+ // Check for identifiers that are table hints
1582+ if p .curTok .Type == TokenIdent {
1583+ switch strings .ToUpper (p .curTok .Literal ) {
1584+ case "HOLDLOCK" , "NOLOCK" , "PAGLOCK" , "READCOMMITTED" , "READPAST" ,
1585+ "READUNCOMMITTED" , "REPEATABLEREAD" , "ROWLOCK" , "SERIALIZABLE" ,
1586+ "SNAPSHOT" , "TABLOCK" , "TABLOCKX" , "UPDLOCK" , "XLOCK" , "NOWAIT" ,
1587+ "INDEX" , "FORCESEEK" , "FORCESCAN" , "KEEPIDENTITY" , "KEEPDEFAULTS" ,
1588+ "IGNORE_CONSTRAINTS" , "IGNORE_TRIGGERS" , "NOEXPAND" , "SPATIAL_WINDOW_MAX_CELLS" :
1589+ return true
1590+ }
1591+ }
1592+ return false
1593+ }
1594+
1595+ // peekIsTableHint checks if the peek token (next token after current) is a valid table hint keyword
1596+ func (p * Parser ) peekIsTableHint () bool {
1597+ // Check for keyword tokens that are table hints
1598+ if p .peekTok .Type == TokenHoldlock || p .peekTok .Type == TokenNowait || p .peekTok .Type == TokenIndex {
1599+ return true
1600+ }
1601+ // Check for identifiers that are table hints
1602+ if p .peekTok .Type == TokenIdent {
1603+ switch strings .ToUpper (p .peekTok .Literal ) {
1604+ case "HOLDLOCK" , "NOLOCK" , "PAGLOCK" , "READCOMMITTED" , "READPAST" ,
1605+ "READUNCOMMITTED" , "REPEATABLEREAD" , "ROWLOCK" , "SERIALIZABLE" ,
1606+ "SNAPSHOT" , "TABLOCK" , "TABLOCKX" , "UPDLOCK" , "XLOCK" , "NOWAIT" ,
1607+ "INDEX" , "FORCESEEK" , "FORCESCAN" , "KEEPIDENTITY" , "KEEPDEFAULTS" ,
1608+ "IGNORE_CONSTRAINTS" , "IGNORE_TRIGGERS" , "NOEXPAND" , "SPATIAL_WINDOW_MAX_CELLS" :
1609+ return true
1610+ }
1611+ }
1612+ return false
1613+ }
1614+
15671615func (p * Parser ) parseSchemaObjectName () (* ast.SchemaObjectName , error ) {
15681616 var identifiers []* ast.Identifier
15691617
0 commit comments