- Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Issue description
When connecting to a database using compress=true, any use of DB.Ping() seems to cause subsequent queries to not return rows.
Ping itself does not return an error.
Example code
package main import ( "database/sql""fmt" _ "github.com/go-sql-driver/mysql" ) funcmain(){db, err:=sql.Open("mysql", "root:mypw@tcp(127.0.0.1:3306)/?compress=1") iferr!=nil{panic(err) } deferdb.Close() iferr=db.Ping(); err!=nil{panic("Ping error: "+err.Error()) } varversionstringquery:="SELECT @@global.version"err=db.QueryRow(query).Scan(&version) iferr!=nil{panic("QueryRow error: "+err.Error()) } fmt.Println(version) }Error log
panic: QueryRow error: sql: no rows in result set If I replace the call to QueryRow with Query and a loop over rows, the loop does not execute (there are no rows, even though selecting a global variable should always result in 1 row).
If I change compress=1 to compress=0, the code works properly and prints the server version.
Alternatively, if I comment-out the Ping call, the code works properly.
Configuration
Driver version (or git SHA): 1.9.2
Go version:go version go1.24.4 darwin/arm64
Server version: Tested with both MySQL 8.0.40 and MariaDB 11.4.5, same behavior with both
Server OS: Linux (VM via Docker Desktop for Mac) - MySQL was on Oracle Linux, MariaDB was on Debian