Philio / GoMySQL

The most complete and stable MySQL client library written completely in Go. For discussion, ideas, suggestions, feature requests etc, please visit the GoMySQL Google Group (link below). For any issues/bugs or need some help, please post an issue on Github.
https://groups.google.com/group/gomysql
Other
189 stars 37 forks source link

mysql.Query consistently errors from valid input #21

Closed kevinm416 closed 13 years ago

kevinm416 commented 13 years ago

I'm using Ubuntu 10.10 x64 MySQL version 5.1.49-1ubuntu8.1 (mysql-server)

The small test script I'm using as an example is below:

package main
import (
    "fmt"
    "mysql"
)
func main() {
    db := mysql.New()
    err := db.Connect("localhost", "root", "password", "db_name")
    if err != nil { panic(err) }
    res, err := db.Query("SET NAMES utf8") 
    if err != nil { panic(err) }
    res, err = db.Query("SELECT * FROM S_A")
    if err != nil { panic(err) }
    fmt.Printf("selected %v", res)
}

And the output after enabling mysql.Logging is below. The number of rows I was expecting to receive was 2807. GoMySQL consistently gives an error after ~100-200 row data packets for any table that I try to query. The error corresponds to mysql.go line 559.

2010/12/18 13:58:18 Connect called
2010/12/18 13:58:18 Connected using unix socket
2010/12/18 13:58:18 [0] Received init packet from server
2010/12/18 13:58:18 [1] Sent auth packet to server
2010/12/18 13:58:18 [2] Received ok packet from server
2010/12/18 13:58:18 Current result set saved
2010/12/18 13:58:18 Query called with SQL: SET NAMES utf8
2010/12/18 13:58:18 [0] Sent query command to server
2010/12/18 13:58:18 [1] Received ok packet from server
2010/12/18 13:58:18 Current result set saved
2010/12/18 13:58:18 Query called with SQL: SELECT * FROM S_A
2010/12/18 13:58:18 [0] Sent query command to server
2010/12/18 13:58:18 [1] Received result set packet from server
2010/12/18 13:58:18 [2] Received field packet from server
2010/12/18 13:58:18 [3] Received field packet from server
2010/12/18 13:58:18 [4] Received field packet from server
2010/12/18 13:58:18 [5] Received field packet from server
2010/12/18 13:58:18 [6] Received field packet from server
2010/12/18 13:58:18 [7] Received eof packet from server
2010/12/18 13:58:18 End of field packets
2010/12/18 13:58:18 [8] Received row data packet from server
2010/12/18 13:58:18 [9] Received row data packet from server
2010/12/18 13:58:18 [10] Received row data packet from server
2010/12/18 13:58:18 [11] Received row data packet from server
2010/12/18 13:58:18 [12] Received row data packet from server
....
2010/12/18 13:58:18 [174] Received row data packet from server
2010/12/18 13:58:18 [175] Received row data packet from server
2010/12/18 13:58:18 [176] Received row data packet from server
2010/12/18 13:58:18 [177] Received row data packet from server
panic: An error occured receiving packet from MySQL 2

panic PC=0x7f3b304ecfe8
runtime.panic+0xa7 /home/kevin/go/src/pkg/runtime/proc.c:1032
    runtime.panic(0x492bf0, 0x7f3b305e42f0)
main.main+0x28d /home/kevin/Desktop/sqltest.go:16
    main.main()
runtime.mainstart+0xf /home/kevin/go/src/pkg/runtime/amd64/asm.s:77
    runtime.mainstart()
runtime.goexit /home/kevin/go/src/pkg/runtime/proc.c:148
    runtime.goexit()

goroutine 2 [3]:
runtime.entersyscall+0x28 /home/kevin/go/src/pkg/runtime/proc.c:572
    runtime.entersyscall()
syscall.Syscall6+0x5 /home/kevin/go/src/pkg/syscall/asm_linux_amd64.s:40
    syscall.Syscall6()
syscall.EpollWait+0x8d /home/kevin/go/src/pkg/syscall/zsyscall_linux_amd64.go:188
    syscall.EpollWait(0x7f3b00000006, 0x7f3b30530450, 0x100000001, 0xffffffff, 0xc, ...)
net.*pollster·WaitFD+0xfe /home/kevin/go/src/pkg/net/fd_linux.go:116
    net.*pollster·WaitFD(0x7f3b30530340, 0x0, 0x7f3b00000072, 0x0, 0x0, ...)
net.*pollServer·Run+0xa3 /home/kevin/go/src/pkg/net/fd.go:207
    net.*pollServer·Run(0x7f3b304fb740, 0x0)
runtime.goexit /home/kevin/go/src/pkg/runtime/proc.c:148
    runtime.goexit()
Philio commented 13 years ago

Any chance you could provide a copy of the database, or at least the schemas?

kevinm416 commented 13 years ago

I put together a go program to create a database and try to query from it that consistently reproduces the bug that I described above. The files are here: http://dl.dropbox.com/u/59235/sql.zip. There's a readme inside.

Philio commented 13 years ago

Thanks for posting this, will give it a try later and see if I can resolve.

Philio commented 13 years ago

Tested and working with latest release. Please reopen if you're still experiencing issues.