Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse multiple result sets will be block when use NextResultSet() #1361

Closed
jxxl1203 opened this issue Oct 9, 2022 · 2 comments
Closed

Parse multiple result sets will be block when use NextResultSet() #1361

jxxl1203 opened this issue Oct 9, 2022 · 2 comments

Comments

@jxxl1203
Copy link

jxxl1203 commented Oct 9, 2022

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

@ChaimHong
Copy link

ChaimHong commented Feb 11, 2023

#1055
@methane @shogo82148
Review please

@methane
Copy link
Member

methane commented Apr 11, 2023

@ChaimHong Please create a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants