diff --git a/sql/create.go b/sql/create.go index 51958895..564fb5f7 100644 --- a/sql/create.go +++ b/sql/create.go @@ -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 } diff --git a/sql/delete.go b/sql/delete.go index b49b81f2..015de6b7 100644 --- a/sql/delete.go +++ b/sql/delete.go @@ -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 } diff --git a/sql/exprs.go b/sql/exprs.go index afbf67b0..bac0690d 100644 --- a/sql/exprs.go +++ b/sql/exprs.go @@ -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) diff --git a/sql/insert.go b/sql/insert.go index 507628d5..ecfcee65 100644 --- a/sql/insert.go +++ b/sql/insert.go @@ -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 } diff --git a/sql/relate.go b/sql/relate.go index 432a71bb..96acb368 100644 --- a/sql/relate.go +++ b/sql/relate.go @@ -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 } diff --git a/sql/select.go b/sql/select.go index e12f8d66..9b85d896 100644 --- a/sql/select.go +++ b/sql/select.go @@ -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 } diff --git a/sql/tokens.go b/sql/tokens.go index d23f0cd3..eef96c3f 100644 --- a/sql/tokens.go +++ b/sql/tokens.go @@ -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", diff --git a/sql/update.go b/sql/update.go index a7fbc7c2..da0cc7b8 100644 --- a/sql/update.go +++ b/sql/update.go @@ -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 } diff --git a/sql/upsert.go b/sql/upsert.go index 627a967e..4c51e6c7 100644 --- a/sql/upsert.go +++ b/sql/upsert.go @@ -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 }