flike / kingshard

A high-performance MySQL proxy
6.41k stars 1.23k forks source link

why set autocommit(0) when connection is still in unautocommit status?? #599

Open pingworld opened 3 years ago

pingworld commented 3 years ago

https://github.com/flike/kingshard/blob/f17b3939474659568b3aa14aa89beeef8da4f24b/proxy/server/conn_query.go#L139

if !c.isAutoCommit() { // not in autocommit ??  
    // then set it again ??  
    if err = co.SetAutoCommit(0); err != nil {  
        return  
    }  
  } else {  
    // do transaction ??  
    if err = co.Begin(); err != nil {  
        return  
    }  
}  

thanks for your response.

fenngwd commented 3 years ago

isAutoCommit is check whether need to set autocommit. When isAutoCommit return false, it need to SetAutoCommit(0)