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

Client unable to select from function when compression is enabled. #871

Closed
jnewmano opened this issue May 7, 2024 · 5 comments
Closed

Comments

@jnewmano
Copy link
Contributor

jnewmano commented May 7, 2024

Adding the following test to client/client_test.go results in an error. Selecting any computed function fails.

func (s *clientTestSuite) TestConn_Compress() {
	addr := fmt.Sprintf("%s:%s", *test_util.MysqlHost, s.port)
	conn, err := Connect(addr, *testUser, *testPassword, "", func(conn *Conn) {
		conn.SetCapability(mysql.CLIENT_COMPRESS)
	})
	require.NoError(s.T(), err)

	_, err = conn.Execute("SELECT VERSION()")
	require.NoError(s.T(), err)
}
$ go test -v ./client --user root --pass <redacted> --run TestClientSuite/TestConn_Compress
=== RUN   TestClientSuite
=== RUN   TestClientSuite/TestConn_Compress
    client_test.go:260: 
                Error Trace:    /Users/jason/go/src/github.com/jnewmano/go-mysql/client/client_test.go:260
                Error:          Received unexpected error:
                                invalid compressed sequence 2 != 1
                                github.com/go-mysql-org/go-mysql/packet.(*Conn).newCompressedPacketReader
                                        /Users/jason/go/src/github.com/jnewmano/go-mysql/packet/conn.go:152
                                github.com/go-mysql-org/go-mysql/packet.(*Conn).ReadPacketReuseMem
                                        /Users/jason/go/src/github.com/jnewmano/go-mysql/packet/conn.go:111
                                github.com/go-mysql-org/go-mysql/client.(*Conn).readResultColumns
                                        /Users/jason/go/src/github.com/jnewmano/go-mysql/client/resp.go:345
                                github.com/go-mysql-org/go-mysql/client.(*Conn).readResultset
                                        /Users/jason/go/src/github.com/jnewmano/go-mysql/client/resp.go:291
                                github.com/go-mysql-org/go-mysql/client.(*Conn).readResult
                                        /Users/jason/go/src/github.com/jnewmano/go-mysql/client/resp.go:236
                                github.com/go-mysql-org/go-mysql/client.(*Conn).exec
                                        /Users/jason/go/src/github.com/jnewmano/go-mysql/client/conn.go:468
                                github.com/go-mysql-org/go-mysql/client.(*Conn).Execute
                                        /Users/jason/go/src/github.com/jnewmano/go-mysql/client/conn.go:252
                                github.com/go-mysql-org/go-mysql/client.(*clientTestSuite).TestConn_Compress
                                        /Users/jason/go/src/github.com/jnewmano/go-mysql/client/client_test.go:259
                                reflect.Value.call
                                        /opt/homebrew/Cellar/go/1.22.1/libexec/src/reflect/value.go:596
                                reflect.Value.Call
                                        /opt/homebrew/Cellar/go/1.22.1/libexec/src/reflect/value.go:380
                                github.com/stretchr/testify/suite.Run.func1
                                        /Users/jason/go/pkg/mod/github.com/stretchr/[email protected]/suite/suite.go:197
                                testing.tRunner
                                        /opt/homebrew/Cellar/go/1.22.1/libexec/src/testing/testing.go:1689
                                runtime.goexit
                                        /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/asm_arm64.s:1222
                Test:           TestClientSuite/TestConn_Compress
--- FAIL: TestClientSuite (0.04s)
    --- FAIL: TestClientSuite/TestConn_Compress (0.01s)
FAIL
FAIL    github.com/go-mysql-org/go-mysql/client 0.176s
FAIL

Client compression with computed function select worked in PR #862 at commit 22dbb42, something in a later commit resulted in an error in these types of queries.

@dvilaverde
Copy link
Contributor

Thanks @jnewmano will take a look.

@dvilaverde
Copy link
Contributor

@jnewmano I've created a PR to fix this issue, #872.

I've also added your test case as well.

@lance6716
Copy link
Collaborator

Sorry for my code suggestion in the previous PR

@dvilaverde
Copy link
Contributor

Sorry for my code suggestion in the previous PR

It's quite alright it happens. I didn't realize that boolean had such an important role until this issue was reported. I added a comment thought to make it clear for the next person.

lance6716 pushed a commit that referenced this issue May 8, 2024
dvilaverde added a commit to dvilaverde/go-mysql that referenced this issue May 8, 2024
dvilaverde added a commit to dvilaverde/go-mysql that referenced this issue May 8, 2024
@dvilaverde
Copy link
Contributor

Please close this issue, this issue has been fixed. Thanks!

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