Closed
Description
Issue description
Parse multiple result sets will be block when use NextResultSet()
if the procedure has no select , error will be return in Query().
but if it has select, error will be nil and NextResultSet() function will be block in the end
Example mysql procedure
-- first procedure
CREATE DEFINER=`root`@`%` PROCEDURE `test_proc1`()
BEGIN
SIGNAL SQLSTATE '10000' SET MESSAGE_TEXT = "some error", MYSQL_ERRNO = 10000;
END;
-- second procedure
CREATE DEFINER=`root`@`%` PROCEDURE `test_proc2`()
BEGIN
SELECT 1,2;
SELECT 3,4;
SIGNAL SQLSTATE '10000' SET MESSAGE_TEXT = "some error", MYSQL_ERRNO = 10000;
END;
Example code
dsn := "usr:passwd@tcp(127.0.0.1:3306)/database?charset=utf8mb4&parseTime=True"
db, _ := sql.Open("mysql", dsn)
_, err := db.Query("CALL test_proc1()")
if err != nil { // err is not nil
log.Println(err.Error())
}
rows, err := db.Query("CALL test_proc2()")
if err != nil { // err is nil
panic(err.Error())
}
defer rows.Close()
for rows.Next() {
log.Println(rows.Columns())
}
for rows.NextResultSet() { // thread will be blocked when exec rs.Close()
for rows.Next() {
log.Println(rows.Columns())
}
}
Error log
2022/10/09 15:41:36 Error 10000: some error
2022/10/09 15:41:38 [1 2] <nil>
2022/10/09 15:41:38 [3 4] <nil>
Configuration
Driver version (or git SHA): 1.6.0
Go version: 1.18
Server version: MySQL 5.7
Server OS: Windows 10
Metadata
Metadata
Assignees
Labels
No labels