(pos Pos)
| 1514 | } |
| 1515 | |
| 1516 | func (p *Parser) parseShowStmt(pos Pos) (*ShowStmt, error) { |
| 1517 | if err := p.expectKeyword(KeywordShow); err != nil { |
| 1518 | return nil, err |
| 1519 | } |
| 1520 | |
| 1521 | var showType string |
| 1522 | var target *TableIdentifier |
| 1523 | |
| 1524 | // Parse the type of SHOW statement |
| 1525 | switch { |
| 1526 | case p.matchKeyword(KeywordCreate): |
| 1527 | // SHOW CREATE TABLE table_name |
| 1528 | showType = "CREATE" |
| 1529 | _ = p.lexer.consumeToken() |
| 1530 | |
| 1531 | if err := p.expectKeyword(KeywordTable); err != nil { |
| 1532 | return nil, err |
| 1533 | } |
| 1534 | showType += " TABLE" |
| 1535 | |
| 1536 | tableIdent, err := p.parseTableIdentifier(p.Pos()) |
| 1537 | if err != nil { |
| 1538 | return nil, err |
| 1539 | } |
| 1540 | target = tableIdent |
| 1541 | |
| 1542 | case p.matchKeyword(KeywordDatabases): |
| 1543 | // SHOW DATABASES [optional clauses] |
| 1544 | showType = "DATABASES" |
| 1545 | _ = p.lexer.consumeToken() |
| 1546 | |
| 1547 | case p.matchKeyword(KeywordTables): |
| 1548 | // SHOW TABLES |
| 1549 | showType = "TABLES" |
| 1550 | _ = p.lexer.consumeToken() |
| 1551 | |
| 1552 | default: |
| 1553 | return nil, fmt.Errorf("expected CREATE, DATABASES, or TABLES after SHOW, got %q", p.last().String) |
| 1554 | } |
| 1555 | |
| 1556 | stmt := &ShowStmt{ |
| 1557 | ShowPos: pos, |
| 1558 | ShowType: showType, |
| 1559 | Target: target, |
| 1560 | } |
| 1561 | |
| 1562 | // Parse optional clauses for SHOW DATABASES |
| 1563 | if showType == "DATABASES" { |
| 1564 | // Parse [[NOT] LIKE | ILIKE '<pattern>'] |
| 1565 | if p.matchKeyword(KeywordNot) { |
| 1566 | stmt.NotLike = true |
| 1567 | _ = p.lexer.consumeToken() |
| 1568 | } |
| 1569 | |
| 1570 | if p.matchKeyword(KeywordLike) || p.matchKeyword(KeywordIlike) { |
| 1571 | if p.matchKeyword(KeywordLike) { |
| 1572 | stmt.LikeType = "LIKE" |
| 1573 | } else { |
no test coverage detected