Implement PARALLEL keyword on queries

This commit is contained in:
Tobie Morgan Hitchcock 2018-07-17 09:35:36 +01:00
parent 8a41cc8a08
commit c0f9ec1f26
9 changed files with 47 additions and 0 deletions

View file

@ -38,6 +38,10 @@ func (p *parser) parseCreateStatement() (stmt *CreateStatement, err error) {
return nil, err
}
if stmt.Parallel, err = p.parseParallel(); err != nil {
return nil, err
}
return
}

View file

@ -47,6 +47,10 @@ func (p *parser) parseDeleteStatement() (stmt *DeleteStatement, err error) {
return nil, err
}
if stmt.Parallel, err = p.parseParallel(); err != nil {
return nil, err
}
return
}

View file

@ -218,6 +218,23 @@ func (p *parser) parsePriority() (float64, error) {
}
func (p *parser) parseParallel() (int, error) {
if _, _, exi := p.mightBe(PARALLEL); !exi {
return 0, nil
}
tok, lit, err := p.shouldBe(NUMBER)
if err != nil {
return 0, &ParseError{Found: lit, Expected: []string{"number"}}
}
val, err := p.declare(tok, lit)
return int(val.(float64)), err
}
func (p *parser) parseType() (t, k string, err error) {
_, t, err = p.shouldBe(IDENT, STRING, PASSWORD)

View file

@ -44,6 +44,10 @@ func (p *parser) parseInsertStatement() (stmt *InsertStatement, err error) {
return nil, err
}
if stmt.Parallel, err = p.parseParallel(); err != nil {
return nil, err
}
return
}

View file

@ -56,6 +56,10 @@ func (p *parser) parseRelateStatement() (stmt *RelateStatement, err error) {
return nil, err
}
if stmt.Parallel, err = p.parseParallel(); err != nil {
return nil, err
}
return
}

View file

@ -67,6 +67,10 @@ func (p *parser) parseSelectStatement() (stmt *SelectStatement, err error) {
return nil, err
}
if stmt.Parallel, err = p.parseParallel(); err != nil {
return nil, err
}
if err = checkExpression(aggrs, stmt.Expr, stmt.Group); err != nil {
return nil, err
}

View file

@ -163,6 +163,7 @@ const (
ON
OR
ORDER
PARALLEL
PASSWORD
PERMISSIONS
PRIORITY
@ -335,6 +336,7 @@ var tokens = [...]string{
ON: "ON",
OR: "OR",
ORDER: "ORDER",
PARALLEL: "PARALLEL",
PASSWORD: "PASSWORD",
PERMISSIONS: "PERMISSIONS",
PRIORITY: "PRIORITY",

View file

@ -42,6 +42,10 @@ func (p *parser) parseUpdateStatement() (stmt *UpdateStatement, err error) {
return nil, err
}
if stmt.Parallel, err = p.parseParallel(); err != nil {
return nil, err
}
return
}

View file

@ -44,6 +44,10 @@ func (p *parser) parseUpsertStatement() (stmt *UpsertStatement, err error) {
return nil, err
}
if stmt.Parallel, err = p.parseParallel(); err != nil {
return nil, err
}
return
}