First keyword was DESCRIBE
()
| 504 | |
| 505 | // First keyword was DESCRIBE |
| 506 | func (m *Sqlbridge) parseDescribe() (SqlStatement, error) { |
| 507 | |
| 508 | req := &SqlDescribe{Raw: m.l.RawInput()} |
| 509 | req.Tok = m.Cur() |
| 510 | m.Next() // Consume Describe |
| 511 | |
| 512 | //u.Debugf("token: %v", m.Cur()) |
| 513 | switch nextWord := strings.ToLower(m.Cur().V); nextWord { |
| 514 | case "select": |
| 515 | // TODO: make the lexer handle this |
| 516 | sqlText := strings.Replace(m.l.RawInput(), req.Tok.V, "", 1) |
| 517 | sqlSel, err := ParseSql(sqlText) |
| 518 | if err != nil { |
| 519 | return nil, err |
| 520 | } |
| 521 | req.Stmt = sqlSel |
| 522 | return req, nil |
| 523 | case "extended": |
| 524 | sqlText := strings.Replace(m.l.RawInput(), req.Tok.V, "", 1) |
| 525 | sqlText = strings.Replace(sqlText, m.Cur().V, "", 1) |
| 526 | sqlSel, err := ParseSql(sqlText) |
| 527 | if err != nil { |
| 528 | return nil, err |
| 529 | } |
| 530 | req.Stmt = sqlSel |
| 531 | return req, nil |
| 532 | default: |
| 533 | if lex.TokenIdentity == m.Cur().T { |
| 534 | req.Identity = m.Cur().V |
| 535 | } else { |
| 536 | return nil, m.ErrMsg("expected idenity") |
| 537 | } |
| 538 | |
| 539 | } |
| 540 | |
| 541 | return req, nil |
| 542 | } |
| 543 | |
| 544 | // First keyword was SHOW |
| 545 | func (m *Sqlbridge) parseShow() (*SqlShow, error) { |