Allow SQL USE queries to run inside transactions
This commit is contained in:
parent
7c962f7bdc
commit
1da702e04b
5 changed files with 0 additions and 23 deletions
|
@ -43,14 +43,6 @@ func (e *BlankError) Error() string {
|
|||
return fmt.Sprint("You need to specify a namespace and a database to use")
|
||||
}
|
||||
|
||||
// TransError represents an error that occured when switching access.
|
||||
type TransError struct{}
|
||||
|
||||
// Error returns the string representation of the error.
|
||||
func (e *TransError) Error() string {
|
||||
return fmt.Sprintf("You can't change NAMESPACE or DATABASE inside of a transaction")
|
||||
}
|
||||
|
||||
// PermsError represents an error that occured when switching access.
|
||||
type PermsError struct {
|
||||
Resource string
|
||||
|
|
|
@ -30,7 +30,6 @@ type parser struct {
|
|||
buf struct {
|
||||
n int // buffer size
|
||||
rw bool // writeable
|
||||
txn bool // inside txn
|
||||
tok Token // last read token
|
||||
lit string // last read literal
|
||||
val interface{} // Last read value
|
||||
|
|
|
@ -175,10 +175,6 @@ func TestMain(t *testing.T) {
|
|||
sql: `USE DATABASE name something`,
|
||||
err: "Found `something` but expected `;`",
|
||||
},
|
||||
{
|
||||
sql: `BEGIN; USE NS name DB name; COMMIT;`,
|
||||
err: "You can't change NAMESPACE or DATABASE inside of a transaction",
|
||||
},
|
||||
{
|
||||
sql: "USE NS `*` DB `*`",
|
||||
str: "USE NAMESPACE `*` DATABASE `*`",
|
||||
|
|
|
@ -20,8 +20,6 @@ func (p *parser) parseBeginStatement() (stmt *BeginStatement, err error) {
|
|||
|
||||
_, _, _ = p.mightBe(TRANSACTION)
|
||||
|
||||
p.buf.txn = true
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
@ -32,8 +30,6 @@ func (p *parser) parseCancelStatement() (stmt *CancelStatement, err error) {
|
|||
|
||||
_, _, _ = p.mightBe(TRANSACTION)
|
||||
|
||||
p.buf.txn = false
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
@ -44,8 +40,6 @@ func (p *parser) parseCommitStatement() (stmt *CommitStatement, err error) {
|
|||
|
||||
_, _, _ = p.mightBe(TRANSACTION)
|
||||
|
||||
p.buf.txn = false
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
|
|
@ -21,10 +21,6 @@ func (p *parser) parseUseStatement() (stmt *UseStatement, err error) {
|
|||
var tok Token
|
||||
var exi bool
|
||||
|
||||
if p.buf.txn {
|
||||
return nil, &TransError{}
|
||||
}
|
||||
|
||||
tok, _, err = p.shouldBe(NAMESPACE, DATABASE, NS, DB)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue