Remove SQL EXPLAIN command
This commit is contained in:
parent
bde073cd36
commit
f37ec653d1
28 changed files with 44 additions and 175 deletions
|
@ -26,10 +26,6 @@ func executeCreateStatement(txn kvs.TX, ast *sql.CreateStatement) (out []interfa
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
|
16
db/define.go
16
db/define.go
|
@ -26,10 +26,6 @@ func executeDefineTableStatement(txn kvs.TX, ast *sql.DefineTableStatement) (out
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
@ -67,10 +63,6 @@ func executeDefineRulesStatement(txn kvs.TX, ast *sql.DefineRulesStatement) (out
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
@ -118,10 +110,6 @@ func executeDefineFieldStatement(txn kvs.TX, ast *sql.DefineFieldStatement) (out
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
@ -165,10 +153,6 @@ func executeDefineIndexStatement(txn kvs.TX, ast *sql.DefineIndexStatement) (out
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
|
|
@ -25,10 +25,6 @@ func executeDeleteStatement(txn kvs.TX, ast *sql.DeleteStatement) (out []interfa
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
|
|
@ -25,10 +25,6 @@ import (
|
||||||
|
|
||||||
func executeInfoStatement(txn kvs.TX, ast *sql.InfoStatement) (out []interface{}, err error) {
|
func executeInfoStatement(txn kvs.TX, ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
txn, err = db.Txn(false)
|
txn, err = db.Txn(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -25,10 +25,6 @@ func executeModifyStatement(txn kvs.TX, ast *sql.ModifyStatement) (out []interfa
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
|
16
db/remove.go
16
db/remove.go
|
@ -24,10 +24,6 @@ func executeRemoveTableStatement(txn kvs.TX, ast *sql.RemoveTableStatement) (out
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
@ -83,10 +79,6 @@ func executeRemoveRulesStatement(txn kvs.TX, ast *sql.RemoveRulesStatement) (out
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
@ -122,10 +114,6 @@ func executeRemoveFieldStatement(txn kvs.TX, ast *sql.RemoveFieldStatement) (out
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
@ -157,10 +145,6 @@ func executeRemoveIndexStatement(txn kvs.TX, ast *sql.RemoveIndexStatement) (out
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
|
|
@ -23,10 +23,6 @@ import (
|
||||||
|
|
||||||
func executeSelectStatement(txn kvs.TX, ast *sql.SelectStatement) (out []interface{}, err error) {
|
func executeSelectStatement(txn kvs.TX, ast *sql.SelectStatement) (out []interface{}, err error) {
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
txn, err = db.Txn(false)
|
txn, err = db.Txn(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -25,10 +25,6 @@ func executeUpdateStatement(txn kvs.TX, ast *sql.UpdateStatement) (out []interfa
|
||||||
|
|
||||||
var local bool
|
var local bool
|
||||||
|
|
||||||
if ast.EX {
|
|
||||||
return append(out, ast), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if txn == nil {
|
if txn == nil {
|
||||||
local = true
|
local = true
|
||||||
txn, err = db.Txn(true)
|
txn, err = db.Txn(true)
|
||||||
|
|
16
sql/ast.go
16
sql/ast.go
|
@ -64,7 +64,6 @@ type UseStatement struct {
|
||||||
|
|
||||||
// InfoStatement represents an SQL INFO statement.
|
// InfoStatement represents an SQL INFO statement.
|
||||||
type InfoStatement struct {
|
type InfoStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -77,7 +76,6 @@ type InfoStatement struct {
|
||||||
|
|
||||||
// SelectStatement represents a SQL SELECT statement.
|
// SelectStatement represents a SQL SELECT statement.
|
||||||
type SelectStatement struct {
|
type SelectStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -94,7 +92,6 @@ type SelectStatement struct {
|
||||||
|
|
||||||
// CreateStatement represents a SQL CREATE statement.
|
// CreateStatement represents a SQL CREATE statement.
|
||||||
type CreateStatement struct {
|
type CreateStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -105,7 +102,6 @@ type CreateStatement struct {
|
||||||
|
|
||||||
// UpdateStatement represents a SQL UPDATE statement.
|
// UpdateStatement represents a SQL UPDATE statement.
|
||||||
type UpdateStatement struct {
|
type UpdateStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -117,7 +113,6 @@ type UpdateStatement struct {
|
||||||
|
|
||||||
// ModifyStatement represents a SQL MODIFY statement.
|
// ModifyStatement represents a SQL MODIFY statement.
|
||||||
type ModifyStatement struct {
|
type ModifyStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -129,7 +124,6 @@ type ModifyStatement struct {
|
||||||
|
|
||||||
// DeleteStatement represents a SQL DELETE statement.
|
// DeleteStatement represents a SQL DELETE statement.
|
||||||
type DeleteStatement struct {
|
type DeleteStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -141,7 +135,6 @@ type DeleteStatement struct {
|
||||||
|
|
||||||
// RelateStatement represents a SQL RELATE statement.
|
// RelateStatement represents a SQL RELATE statement.
|
||||||
type RelateStatement struct {
|
type RelateStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -154,7 +147,6 @@ type RelateStatement struct {
|
||||||
|
|
||||||
// RecordStatement represents a SQL RECORD statement.
|
// RecordStatement represents a SQL RECORD statement.
|
||||||
type RecordStatement struct {
|
type RecordStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -170,7 +162,6 @@ type RecordStatement struct {
|
||||||
|
|
||||||
// DefineTableStatement represents an SQL DEFINE TABLE statement.
|
// DefineTableStatement represents an SQL DEFINE TABLE statement.
|
||||||
type DefineTableStatement struct {
|
type DefineTableStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -179,7 +170,6 @@ type DefineTableStatement struct {
|
||||||
|
|
||||||
// RemoveTableStatement represents an SQL REMOVE TABLE statement.
|
// RemoveTableStatement represents an SQL REMOVE TABLE statement.
|
||||||
type RemoveTableStatement struct {
|
type RemoveTableStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -192,7 +182,6 @@ type RemoveTableStatement struct {
|
||||||
|
|
||||||
// DefineRulesStatement represents an SQL DEFINE RULES statement.
|
// DefineRulesStatement represents an SQL DEFINE RULES statement.
|
||||||
type DefineRulesStatement struct {
|
type DefineRulesStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -204,7 +193,6 @@ type DefineRulesStatement struct {
|
||||||
|
|
||||||
// RemoveRulesStatement represents an SQL REMOVE RULES statement.
|
// RemoveRulesStatement represents an SQL REMOVE RULES statement.
|
||||||
type RemoveRulesStatement struct {
|
type RemoveRulesStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -218,7 +206,6 @@ type RemoveRulesStatement struct {
|
||||||
|
|
||||||
// DefineFieldStatement represents an SQL DEFINE FIELD statement.
|
// DefineFieldStatement represents an SQL DEFINE FIELD statement.
|
||||||
type DefineFieldStatement struct {
|
type DefineFieldStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -239,7 +226,6 @@ type DefineFieldStatement struct {
|
||||||
|
|
||||||
// RemoveFieldStatement represents an SQL REMOVE FIELD statement.
|
// RemoveFieldStatement represents an SQL REMOVE FIELD statement.
|
||||||
type RemoveFieldStatement struct {
|
type RemoveFieldStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -253,7 +239,6 @@ type RemoveFieldStatement struct {
|
||||||
|
|
||||||
// DefineIndexStatement represents an SQL DEFINE INDEX statement.
|
// DefineIndexStatement represents an SQL DEFINE INDEX statement.
|
||||||
type DefineIndexStatement struct {
|
type DefineIndexStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
@ -265,7 +250,6 @@ type DefineIndexStatement struct {
|
||||||
|
|
||||||
// RemoveIndexStatement represents an SQL REMOVE INDEX statement.
|
// RemoveIndexStatement represents an SQL REMOVE INDEX statement.
|
||||||
type RemoveIndexStatement struct {
|
type RemoveIndexStatement struct {
|
||||||
EX bool `codec:"-"`
|
|
||||||
KV string `codec:"-"`
|
KV string `codec:"-"`
|
||||||
NS string `codec:"-"`
|
NS string `codec:"-"`
|
||||||
DB string `codec:"-"`
|
DB string `codec:"-"`
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseCreateStatement(explain bool) (stmt *CreateStatement, err error) {
|
func (p *parser) parseCreateStatement() (stmt *CreateStatement, err error) {
|
||||||
|
|
||||||
stmt = &CreateStatement{}
|
stmt = &CreateStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,20 +14,20 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseDefineStatement(explain bool) (Statement, error) {
|
func (p *parser) parseDefineStatement() (Statement, error) {
|
||||||
|
|
||||||
// Inspect the next token.
|
// Inspect the next token.
|
||||||
tok, _, err := p.shouldBe(TABLE, RULES, FIELD, INDEX)
|
tok, _, err := p.shouldBe(TABLE, RULES, FIELD, INDEX)
|
||||||
|
|
||||||
switch tok {
|
switch tok {
|
||||||
case TABLE:
|
case TABLE:
|
||||||
return p.parseDefineTableStatement(explain)
|
return p.parseDefineTableStatement()
|
||||||
case RULES:
|
case RULES:
|
||||||
return p.parseDefineRulesStatement(explain)
|
return p.parseDefineRulesStatement()
|
||||||
case FIELD:
|
case FIELD:
|
||||||
return p.parseDefineFieldStatement(explain)
|
return p.parseDefineFieldStatement()
|
||||||
case INDEX:
|
case INDEX:
|
||||||
return p.parseDefineIndexStatement(explain)
|
return p.parseDefineIndexStatement()
|
||||||
default:
|
default:
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseDeleteStatement(explain bool) (stmt *DeleteStatement, err error) {
|
func (p *parser) parseDeleteStatement() (stmt *DeleteStatement, err error) {
|
||||||
|
|
||||||
stmt = &DeleteStatement{}
|
stmt = &DeleteStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseDefineFieldStatement(explain bool) (stmt *DefineFieldStatement, err error) {
|
func (p *parser) parseDefineFieldStatement() (stmt *DefineFieldStatement, err error) {
|
||||||
|
|
||||||
stmt = &DefineFieldStatement{}
|
stmt = &DefineFieldStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
@ -135,12 +133,10 @@ func (p *parser) parseDefineFieldStatement(explain bool) (stmt *DefineFieldState
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) parseRemoveFieldStatement(explain bool) (stmt *RemoveFieldStatement, err error) {
|
func (p *parser) parseRemoveFieldStatement() (stmt *RemoveFieldStatement, err error) {
|
||||||
|
|
||||||
stmt = &RemoveFieldStatement{}
|
stmt = &RemoveFieldStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseDefineIndexStatement(explain bool) (stmt *DefineIndexStatement, err error) {
|
func (p *parser) parseDefineIndexStatement() (stmt *DefineIndexStatement, err error) {
|
||||||
|
|
||||||
stmt = &DefineIndexStatement{}
|
stmt = &DefineIndexStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
@ -54,12 +52,10 @@ func (p *parser) parseDefineIndexStatement(explain bool) (stmt *DefineIndexState
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) parseRemoveIndexStatement(explain bool) (stmt *RemoveIndexStatement, err error) {
|
func (p *parser) parseRemoveIndexStatement() (stmt *RemoveIndexStatement, err error) {
|
||||||
|
|
||||||
stmt = &RemoveIndexStatement{}
|
stmt = &RemoveIndexStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseInfoStatement(explain bool) (stmt *InfoStatement, err error) {
|
func (p *parser) parseInfoStatement() (stmt *InfoStatement, err error) {
|
||||||
|
|
||||||
stmt = &InfoStatement{}
|
stmt = &InfoStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseModifyStatement(explain bool) (stmt *ModifyStatement, err error) {
|
func (p *parser) parseModifyStatement() (stmt *ModifyStatement, err error) {
|
||||||
|
|
||||||
stmt = &ModifyStatement{}
|
stmt = &ModifyStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -115,48 +115,42 @@ func (p *parser) parseMulti() (*Query, error) {
|
||||||
// parseSingle parses a single SQL SELECT statement.
|
// parseSingle parses a single SQL SELECT statement.
|
||||||
func (p *parser) parseSingle() (Statement, error) {
|
func (p *parser) parseSingle() (Statement, error) {
|
||||||
|
|
||||||
var explain bool
|
|
||||||
|
|
||||||
if _, _, exi := p.mightBe(EXPLAIN); exi {
|
|
||||||
explain = true
|
|
||||||
}
|
|
||||||
|
|
||||||
tok, _, err := p.shouldBe(USE, INFO, LET, BEGIN, CANCEL, COMMIT, ROLLBACK, SELECT, CREATE, UPDATE, INSERT, UPSERT, MODIFY, DELETE, RELATE, RECORD, DEFINE, REMOVE)
|
tok, _, err := p.shouldBe(USE, INFO, LET, BEGIN, CANCEL, COMMIT, ROLLBACK, SELECT, CREATE, UPDATE, INSERT, UPSERT, MODIFY, DELETE, RELATE, RECORD, DEFINE, REMOVE)
|
||||||
|
|
||||||
switch tok {
|
switch tok {
|
||||||
|
|
||||||
case USE:
|
case USE:
|
||||||
return p.parseUseStatement(explain)
|
return p.parseUseStatement()
|
||||||
|
|
||||||
case INFO:
|
case INFO:
|
||||||
return p.parseInfoStatement(explain)
|
return p.parseInfoStatement()
|
||||||
|
|
||||||
case BEGIN:
|
case BEGIN:
|
||||||
return p.parseBeginStatement(explain)
|
return p.parseBeginStatement()
|
||||||
case CANCEL, ROLLBACK:
|
case CANCEL, ROLLBACK:
|
||||||
return p.parseCancelStatement(explain)
|
return p.parseCancelStatement()
|
||||||
case COMMIT:
|
case COMMIT:
|
||||||
return p.parseCommitStatement(explain)
|
return p.parseCommitStatement()
|
||||||
|
|
||||||
case SELECT:
|
case SELECT:
|
||||||
return p.parseSelectStatement(explain)
|
return p.parseSelectStatement()
|
||||||
case CREATE, INSERT:
|
case CREATE, INSERT:
|
||||||
return p.parseCreateStatement(explain)
|
return p.parseCreateStatement()
|
||||||
case UPDATE, UPSERT:
|
case UPDATE, UPSERT:
|
||||||
return p.parseUpdateStatement(explain)
|
return p.parseUpdateStatement()
|
||||||
case MODIFY:
|
case MODIFY:
|
||||||
return p.parseModifyStatement(explain)
|
return p.parseModifyStatement()
|
||||||
case DELETE:
|
case DELETE:
|
||||||
return p.parseDeleteStatement(explain)
|
return p.parseDeleteStatement()
|
||||||
case RELATE:
|
case RELATE:
|
||||||
return p.parseRelateStatement(explain)
|
return p.parseRelateStatement()
|
||||||
case RECORD:
|
case RECORD:
|
||||||
return p.parseRecordStatement(explain)
|
return p.parseRecordStatement()
|
||||||
|
|
||||||
case DEFINE:
|
case DEFINE:
|
||||||
return p.parseDefineStatement(explain)
|
return p.parseDefineStatement()
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
return p.parseRemoveStatement(explain)
|
return p.parseRemoveStatement()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseRecordStatement(explain bool) (stmt *RecordStatement, err error) {
|
func (p *parser) parseRecordStatement() (stmt *RecordStatement, err error) {
|
||||||
|
|
||||||
stmt = &RecordStatement{}
|
stmt = &RecordStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseRelateStatement(explain bool) (stmt *RelateStatement, err error) {
|
func (p *parser) parseRelateStatement() (stmt *RelateStatement, err error) {
|
||||||
|
|
||||||
stmt = &RelateStatement{}
|
stmt = &RelateStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,20 +14,20 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseRemoveStatement(explain bool) (Statement, error) {
|
func (p *parser) parseRemoveStatement() (Statement, error) {
|
||||||
|
|
||||||
// Inspect the next token.
|
// Inspect the next token.
|
||||||
tok, _, err := p.shouldBe(TABLE, RULES, FIELD, INDEX)
|
tok, _, err := p.shouldBe(TABLE, RULES, FIELD, INDEX)
|
||||||
|
|
||||||
switch tok {
|
switch tok {
|
||||||
case TABLE:
|
case TABLE:
|
||||||
return p.parseRemoveTableStatement(explain)
|
return p.parseRemoveTableStatement()
|
||||||
case RULES:
|
case RULES:
|
||||||
return p.parseRemoveRulesStatement(explain)
|
return p.parseRemoveRulesStatement()
|
||||||
case FIELD:
|
case FIELD:
|
||||||
return p.parseRemoveFieldStatement(explain)
|
return p.parseRemoveFieldStatement()
|
||||||
case INDEX:
|
case INDEX:
|
||||||
return p.parseRemoveIndexStatement(explain)
|
return p.parseRemoveIndexStatement()
|
||||||
default:
|
default:
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseDefineRulesStatement(explain bool) (stmt *DefineRulesStatement, err error) {
|
func (p *parser) parseDefineRulesStatement() (stmt *DefineRulesStatement, err error) {
|
||||||
|
|
||||||
stmt = &DefineRulesStatement{}
|
stmt = &DefineRulesStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
@ -77,12 +75,10 @@ func (p *parser) parseDefineRulesStatement(explain bool) (stmt *DefineRulesState
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) parseRemoveRulesStatement(explain bool) (stmt *RemoveRulesStatement, err error) {
|
func (p *parser) parseRemoveRulesStatement() (stmt *RemoveRulesStatement, err error) {
|
||||||
|
|
||||||
stmt = &RemoveRulesStatement{}
|
stmt = &RemoveRulesStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseSelectStatement(explain bool) (stmt *SelectStatement, err error) {
|
func (p *parser) parseSelectStatement() (stmt *SelectStatement, err error) {
|
||||||
|
|
||||||
stmt = &SelectStatement{}
|
stmt = &SelectStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -249,25 +249,6 @@ func Test_Parse_Queries_Use(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_Parse_Queries_Explain(t *testing.T) {
|
|
||||||
|
|
||||||
var tests = []tester{
|
|
||||||
{
|
|
||||||
sql: `EXPLAIN SELECT ALL FROM person`,
|
|
||||||
res: &Query{Statements: []Statement{&SelectStatement{
|
|
||||||
EX: true,
|
|
||||||
Expr: []*Field{{Expr: &All{}, Alias: "ALL"}},
|
|
||||||
What: []Expr{&Table{"person"}},
|
|
||||||
}}},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
testsql(t, test)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_Parse_Queries_Select(t *testing.T) {
|
func Test_Parse_Queries_Select(t *testing.T) {
|
||||||
|
|
||||||
date, _ := time.Parse("2006-01-02", "1987-06-22")
|
date, _ := time.Parse("2006-01-02", "1987-06-22")
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseDefineTableStatement(explain bool) (stmt *DefineTableStatement, err error) {
|
func (p *parser) parseDefineTableStatement() (stmt *DefineTableStatement, err error) {
|
||||||
|
|
||||||
stmt = &DefineTableStatement{}
|
stmt = &DefineTableStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
@ -36,12 +34,10 @@ func (p *parser) parseDefineTableStatement(explain bool) (stmt *DefineTableState
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) parseRemoveTableStatement(explain bool) (stmt *RemoveTableStatement, err error) {
|
func (p *parser) parseRemoveTableStatement() (stmt *RemoveTableStatement, err error) {
|
||||||
|
|
||||||
stmt = &RemoveTableStatement{}
|
stmt = &RemoveTableStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -124,7 +124,6 @@ const (
|
||||||
DISTINCT
|
DISTINCT
|
||||||
EMPTY
|
EMPTY
|
||||||
ENUM
|
ENUM
|
||||||
EXPLAIN
|
|
||||||
EXPUNGE
|
EXPUNGE
|
||||||
FALSE
|
FALSE
|
||||||
FIELD
|
FIELD
|
||||||
|
@ -284,7 +283,6 @@ var tokens = [...]string{
|
||||||
DISTINCT: "DISTINCT",
|
DISTINCT: "DISTINCT",
|
||||||
EMPTY: "EMPTY",
|
EMPTY: "EMPTY",
|
||||||
ENUM: "ENUM",
|
ENUM: "ENUM",
|
||||||
EXPLAIN: "EXPLAIN",
|
|
||||||
EXPUNGE: "EXPUNGE",
|
EXPUNGE: "EXPUNGE",
|
||||||
FALSE: "FALSE",
|
FALSE: "FALSE",
|
||||||
FIELD: "FIELD",
|
FIELD: "FIELD",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseBeginStatement(explain bool) (stmt *BeginStatement, err error) {
|
func (p *parser) parseBeginStatement() (stmt *BeginStatement, err error) {
|
||||||
|
|
||||||
stmt = &BeginStatement{}
|
stmt = &BeginStatement{}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func (p *parser) parseBeginStatement(explain bool) (stmt *BeginStatement, err er
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) parseCancelStatement(explain bool) (stmt *CancelStatement, err error) {
|
func (p *parser) parseCancelStatement() (stmt *CancelStatement, err error) {
|
||||||
|
|
||||||
stmt = &CancelStatement{}
|
stmt = &CancelStatement{}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ func (p *parser) parseCancelStatement(explain bool) (stmt *CancelStatement, err
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) parseCommitStatement(explain bool) (stmt *CommitStatement, err error) {
|
func (p *parser) parseCommitStatement() (stmt *CommitStatement, err error) {
|
||||||
|
|
||||||
stmt = &CommitStatement{}
|
stmt = &CommitStatement{}
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,10 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseUpdateStatement(explain bool) (stmt *UpdateStatement, err error) {
|
func (p *parser) parseUpdateStatement() (stmt *UpdateStatement, err error) {
|
||||||
|
|
||||||
stmt = &UpdateStatement{}
|
stmt = &UpdateStatement{}
|
||||||
|
|
||||||
stmt.EX = explain
|
|
||||||
|
|
||||||
stmt.KV = p.c.Get("KV").(string)
|
stmt.KV = p.c.Get("KV").(string)
|
||||||
stmt.NS = p.c.Get("NS").(string)
|
stmt.NS = p.c.Get("NS").(string)
|
||||||
stmt.DB = p.c.Get("DB").(string)
|
stmt.DB = p.c.Get("DB").(string)
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
package sql
|
package sql
|
||||||
|
|
||||||
func (p *parser) parseUseStatement(explain bool) (stmt *UseStatement, err error) {
|
func (p *parser) parseUseStatement() (stmt *UseStatement, err error) {
|
||||||
|
|
||||||
stmt = &UseStatement{}
|
stmt = &UseStatement{}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue