We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When I investing #1390, I found XORM used sql.RawBytes for ScanType. It was XORM bug. But we have same bug!
sql.RawBytes
mysql/fields.go
Lines 190 to 195 in cffc85c
https://github.com/methane/notes/blob/master/2023/go-mysql-race/main.go
$ go run -race . Hello, 0 Hello, 0 Hello, 0 Hello, 0 Hello, 0 ================== WARNING: DATA RACE Read at 0x00c000166040 by goroutine 8: runtime.slicebytetostring() /opt/homebrew/Cellar/go/1.20.3/libexec/src/runtime/string.go:81 +0x0 main.main.func1() /Users/inada-n/notes/2023/go-mysql-race/main.go:46 +0x64 main.main.func3() /Users/inada-n/notes/2023/go-mysql-race/main.go:52 +0x78 Previous write at 0x00c000166040 by main goroutine: runtime.racewriterange() <autogenerated>:1 +0x14 internal/poll.ignoringEINTRIO() /opt/homebrew/Cellar/go/1.20.3/libexec/src/internal/poll/fd_unix.go:794 +0x2ec internal/poll.(*FD).Read() /opt/homebrew/Cellar/go/1.20.3/libexec/src/internal/poll/fd_unix.go:163 +0x20 net.(*netFD).Read() /opt/homebrew/Cellar/go/1.20.3/libexec/src/net/fd_posix.go:55 +0x44 net.(*conn).Read() /opt/homebrew/Cellar/go/1.20.3/libexec/src/net/net.go:183 +0x84 net.(*TCPConn).Read() <autogenerated>:1 +0x4c github.com/go-sql-driver/mysql.(*buffer).fill() /Users/inada-n/go/pkg/mod/github.com/go-sql-driver/[email protected]/buffer.go:90 +0x33c github.com/go-sql-driver/mysql.(*buffer).readNext() /Users/inada-n/go/pkg/mod/github.com/go-sql-driver/[email protected]/buffer.go:119 +0x54 github.com/go-sql-driver/mysql.(*mysqlConn).readPacket() /Users/inada-n/go/pkg/mod/github.com/go-sql-driver/[email protected]/packets.go:32 +0xa4 github.com/go-sql-driver/mysql.(*mysqlStmt).readPrepareResultPacket() /Users/inada-n/go/pkg/mod/github.com/go-sql-driver/[email protected]/packets.go:830 +0x38 github.com/go-sql-driver/mysql.(*mysqlConn).Prepare() /Users/inada-n/go/pkg/mod/github.com/go-sql-driver/[email protected]/connection.go:182 +0x2e8 github.com/go-sql-driver/mysql.(*mysqlConn).PrepareContext() /Users/inada-n/go/pkg/mod/github.com/go-sql-driver/[email protected]/connection.go:533 +0x58 database/sql.ctxDriverPrepare() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/ctxutil.go:15 +0x11c database/sql.(*DB).queryDC.func2() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/sql.go:1770 +0x88 database/sql.withLock() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/sql.go:3405 +0x84 database/sql.(*DB).queryDC() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/sql.go:1769 +0x25c database/sql.(*DB).query() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/sql.go:1726 +0xf0 database/sql.(*DB).QueryContext.func1() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/sql.go:1704 +0x9c database/sql.(*DB).retry() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/sql.go:1538 +0x4c database/sql.(*DB).QueryContext() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/sql.go:1703 +0xc8 database/sql.(*DB).Query() /opt/homebrew/Cellar/go/1.20.3/libexec/src/database/sql/sql.go:1717 +0x144 main.main() /Users/inada-n/notes/2023/go-mysql-race/main.go:28 +0xf0 Goroutine 8 (running) created at: main.main() /Users/inada-n/notes/2023/go-mysql-race/main.go:43 +0x180 ==================
Driver version (or git SHA):
Go version: run go version in your console
go version
Server version: E.g. MySQL 5.6, MariaDB 10.0.20
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
The text was updated successfully, but these errors were encountered:
Add sample code for go-sql-driver/mysql#1423
3acd731
ColumnTypeScanType() returns []byte or string
89de731
It returned sql.RawBytes but it was dangoerous. Fixes go-sql-driver#1423
ColumnTypeScanType()
Stop ColumnTypeScanType() from returning sql.RawBytes (#1424)
736b6fa
ColumnTypeScanType() returns []byte, string, or sql.NullString. It returned sql.RawBytes but it was dangoerous. Fixes #1423
Successfully merging a pull request may close this issue.
Issue description
When I investing #1390, I found XORM used
sql.RawBytes
for ScanType. It was XORM bug.But we have same bug!
mysql/fields.go
Lines 190 to 195 in cffc85c
Example code
https://github.com/methane/notes/blob/master/2023/go-mysql-race/main.go
Error log
Configuration
Driver version (or git SHA):
Go version: run
go version
in your consoleServer version: E.g. MySQL 5.6, MariaDB 10.0.20
Server OS: E.g. Debian 8.1 (Jessie), Windows 10
The text was updated successfully, but these errors were encountered: