No need to pass statements in from goroutine

A series of statements on one request are always handled and run serially, so there is no need to loop over them in a goroutine.
This commit is contained in:
Tobie Morgan Hitchcock 2017-02-28 00:00:39 +00:00
parent d5ee46ab17
commit 3167be73bb

View file

@ -217,39 +217,18 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
} }
}() }()
stms := make(chan sql.Statement)
// Loop over the defined query statements and // Loop over the defined query statements and
// pass them to the statement processing // process them, while listening for the quit
// channel for execution. // channel to see if the client has gone away.
go func() { for _, stm := range e.ast.Statements {
for _, stm := range e.ast.Statements {
stms <- stm
}
close(stms)
}()
// Listen for any new statements to process and
// at the same time listen for the quit signal
// notifying us whether the client has gone away.
for {
select { select {
case <-quit: case <-quit:
return return
case stm, open := <-stms: default:
// If we have reached the end of the statement
// processing channel then return out of this
// for loop and exit.
if !open {
return
}
// If we are not inside a global transaction // If we are not inside a global transaction
// then reset the error to nil so that the // then reset the error to nil so that the