parseCreateSequenceStatement parses: CREATE [OR REPLACE] SEQUENCE [IF NOT EXISTS] name [options...] The caller has already consumed CREATE and SEQUENCE.
(orReplace bool)
| 53 | // |
| 54 | // The caller has already consumed CREATE and SEQUENCE. |
| 55 | func (p *Parser) parseCreateSequenceStatement(orReplace bool) (*ast.CreateSequenceStatement, error) { |
| 56 | stmt := ast.NewCreateSequenceStatement() |
| 57 | stmt.OrReplace = orReplace |
| 58 | |
| 59 | // IF NOT EXISTS |
| 60 | if strings.EqualFold(p.currentToken.Token.Value, "IF") { |
| 61 | p.advance() |
| 62 | if !strings.EqualFold(p.currentToken.Token.Value, "NOT") { |
| 63 | return nil, p.expectedError("NOT") |
| 64 | } |
| 65 | p.advance() |
| 66 | if !strings.EqualFold(p.currentToken.Token.Value, "EXISTS") { |
| 67 | return nil, p.expectedError("EXISTS") |
| 68 | } |
| 69 | p.advance() |
| 70 | stmt.IfNotExists = true |
| 71 | } |
| 72 | |
| 73 | name := p.parseIdent() |
| 74 | if name == nil || name.Name == "" { |
| 75 | return nil, p.expectedError("sequence name") |
| 76 | } |
| 77 | stmt.Name = name |
| 78 | |
| 79 | opts, err := p.parseSequenceOptions() |
| 80 | if err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | stmt.Options = opts |
| 84 | return stmt, nil |
| 85 | } |
| 86 | |
| 87 | // parseDropSequenceStatement parses: DROP SEQUENCE [IF EXISTS | IF NOT EXISTS] name |
| 88 | // The caller has already consumed DROP and SEQUENCE. |
no test coverage detected