MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / parseCreateSequenceStatement

Method parseCreateSequenceStatement

pkg/sql/parser/mariadb.go:55–85  ·  view source on GitHub ↗

parseCreateSequenceStatement parses: CREATE [OR REPLACE] SEQUENCE [IF NOT EXISTS] name [options...] The caller has already consumed CREATE and SEQUENCE.

(orReplace bool)

Source from the content-addressed store, hash-verified

53//
54// The caller has already consumed CREATE and SEQUENCE.
55func (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.

Callers 1

parseCreateStatementMethod · 0.95

Calls 5

advanceMethod · 0.95
expectedErrorMethod · 0.95
parseIdentMethod · 0.95
parseSequenceOptionsMethod · 0.95

Tested by

no test coverage detected