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

Method parseDropSequenceStatement

pkg/sql/parser/mariadb.go:89–118  ·  view source on GitHub ↗

parseDropSequenceStatement parses: DROP SEQUENCE [IF EXISTS | IF NOT EXISTS] name The caller has already consumed DROP and SEQUENCE.

()

Source from the content-addressed store, hash-verified

87// parseDropSequenceStatement parses: DROP SEQUENCE [IF EXISTS | IF NOT EXISTS] name
88// The caller has already consumed DROP and SEQUENCE.
89func (p *Parser) parseDropSequenceStatement() (*ast.DropSequenceStatement, error) {
90 stmt := ast.NewDropSequenceStatement()
91
92 if strings.EqualFold(p.currentToken.Token.Value, "IF") {
93 p.advance()
94 if strings.EqualFold(p.currentToken.Token.Value, "NOT") {
95 // IF NOT EXISTS is a non-standard permissive extension (MariaDB only supports
96 // IF EXISTS natively). We accept it and reuse the IfExists flag since both
97 // forms mean "suppress the error if the sequence is absent".
98 p.advance()
99 if !strings.EqualFold(p.currentToken.Token.Value, "EXISTS") {
100 return nil, p.expectedError("EXISTS")
101 }
102 p.advance()
103 stmt.IfExists = true
104 } else if strings.EqualFold(p.currentToken.Token.Value, "EXISTS") {
105 p.advance()
106 stmt.IfExists = true
107 } else {
108 return nil, p.expectedError("EXISTS or NOT EXISTS")
109 }
110 }
111
112 name := p.parseIdent()
113 if name == nil || name.Name == "" {
114 return nil, p.expectedError("sequence name")
115 }
116 stmt.Name = name
117 return stmt, nil
118}
119
120// parseAlterSequenceStatement parses: ALTER SEQUENCE [IF EXISTS] name [options...]
121// The caller has already consumed ALTER and SEQUENCE.

Callers 1

parseStatementMethod · 0.95

Calls 4

advanceMethod · 0.95
expectedErrorMethod · 0.95
parseIdentMethod · 0.95
NewDropSequenceStatementFunction · 0.92

Tested by

no test coverage detected