Open ablegao opened 11 years ago
stmt, err := db.Prepare("update user set alias='abc111' where Username=?") stmt.Raw.Delete()
.........
autorc is intended for long life processes that create some server side statements at start and use them for different data for whole life of process. There is conceptually problem with close a connection, or destroy statement because such operation can return an error (especially a network error).
autorc is intended to recover from errors by reconnect and recreate all previously created statements. But in this case (close connection, delete a statement) it shouldn't do this. So autorc.Conn.Close and autorc.Stmt.Delete will have inconsistent behavior with other functions. I didn't found any proper solution for this problem and it turned out that these functions aren't necessary in all my real applications. So they haven't be implemented but Raw field is there so you can call Delete and Close yourself and because it is special case you should handle all errors yourself and probably invalidate Conn/Stmt (by set Raw = nil) if you didn't plan to use it in feature (if you don't invalidate them, they probably can be recreated at second use).
@ziutek Just came across this issue today, is this still the recommended solution 2 years later?
this my code . http://play.golang.org/p/3q18mG9mbJ
so , https://github.com/go-sql-driver/mysql/blob/master/statement.go have stmt.Close(). how to use it in mymysql?