Improve SQL DEFINE LOGIN statements

This commit is contained in:
Tobie Morgan Hitchcock 2016-11-22 19:10:32 +00:00
parent f150e5b587
commit 063de926ed
3 changed files with 9 additions and 19 deletions

View file

@ -64,7 +64,7 @@ func (p *parser) parseWhat() (mul []Expr, err error) {
func (p *parser) parseName() (string, error) {
_, lit, err := p.shouldBe(IDENT, NUMBER, DOUBLE)
_, lit, err := p.shouldBe(IDENT, STRING, NUMBER, DOUBLE)
if err != nil {
return string(""), &ParseError{Found: lit, Expected: []string{"name"}}
}

View file

@ -18,6 +18,10 @@ func (p *parser) parseDefineLoginStatement() (stmt *DefineLoginStatement, err er
stmt = &DefineLoginStatement{}
if stmt.User, err = p.parseName(); err != nil {
return nil, err
}
if _, _, err = p.shouldBe(ON); err != nil {
return nil, err
}
@ -38,14 +42,6 @@ func (p *parser) parseDefineLoginStatement() (stmt *DefineLoginStatement, err er
}
}
if _, _, err := p.shouldBe(USERNAME); err != nil {
return nil, err
}
if stmt.User, err = p.parseString(); err != nil {
return nil, err
}
if _, _, err := p.shouldBe(PASSWORD); err != nil {
return nil, err
}
@ -70,6 +66,10 @@ func (p *parser) parseRemoveLoginStatement() (stmt *RemoveLoginStatement, err er
stmt = &RemoveLoginStatement{}
if stmt.User, err = p.parseName(); err != nil {
return nil, err
}
if _, _, err = p.shouldBe(ON); err != nil {
return nil, err
}
@ -90,14 +90,6 @@ func (p *parser) parseRemoveLoginStatement() (stmt *RemoveLoginStatement, err er
}
}
if _, _, err := p.shouldBe(USERNAME); err != nil {
return nil, err
}
if stmt.User, err = p.parseString(); err != nil {
return nil, err
}
if _, _, err = p.shouldBe(EOF, SEMICOLON); err != nil {
return nil, err
}

View file

@ -183,7 +183,6 @@ const (
UPDATE
UPSERT
USE
USERNAME
VALIDATE
VERSION
VIEW
@ -346,7 +345,6 @@ var tokens = [...]string{
UPDATE: "UPDATE",
UPSERT: "UPSERT",
USE: "USE",
USERNAME: "USERNAME",
VALIDATE: "VALIDATE",
VERSION: "VERSION",
VIEW: "VIEW",