From 7da194ad69efa0e4cc3992f860ecb92550482d62 Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Tue, 24 Oct 2023 09:56:33 -0700 Subject: [PATCH 1/2] Minor tweaks to logging; changing Handler to pass mysql.PrepareData when calling ComPrepare so that we can log the params count with GMS. --- go/mysql/conn.go | 4 +++- go/mysql/server.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/go/mysql/conn.go b/go/mysql/conn.go index 1af086e52d5..439ff282608 100644 --- a/go/mysql/conn.go +++ b/go/mysql/conn.go @@ -1088,6 +1088,7 @@ func (c *Conn) handleNextCommand(handler Handler) error { parserOptions, err := handler.ParserOptionsForConnection(c) if err != nil { + log.Errorf("unable to determine parser options for current connection: %s", err.Error()) return err } @@ -1139,8 +1140,9 @@ func (c *Conn) handleNextCommand(handler Handler) error { c.PrepareData[c.StatementID] = prepare - fld, err := handler.ComPrepare(c, query) + fld, err := handler.ComPrepare(c, query, prepare) if err != nil { + log.Errorf("unable to prepare query: %s", err.Error()) if werr := c.writeErrorPacketFromError(err); werr != nil { // If we can't even write the error, we're done. log.Error("Error writing query error to client %v: %v", c.ConnectionID, werr) diff --git a/go/mysql/server.go b/go/mysql/server.go index 959d7c48efa..2f0129c1e0e 100644 --- a/go/mysql/server.go +++ b/go/mysql/server.go @@ -115,7 +115,7 @@ type Handler interface { // ComPrepare is called when a connection receives a prepared // statement query. - ComPrepare(c *Conn, query string) ([]*querypb.Field, error) + ComPrepare(c *Conn, query string, prepare *PrepareData) ([]*querypb.Field, error) // ComStmtExecute is called when a connection receives a statement // execute query. From f475795064f63348ae131ba12cf1a0f53ee7614f Mon Sep 17 00:00:00 2001 From: Jason Fulghum Date: Tue, 24 Oct 2023 10:06:15 -0700 Subject: [PATCH 2/2] Updating testHandler's ComPrepare signature --- go/mysql/server_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/mysql/server_test.go b/go/mysql/server_test.go index f347a0dda57..d7a7182f61b 100644 --- a/go/mysql/server_test.go +++ b/go/mysql/server_test.go @@ -225,7 +225,7 @@ func (th *testHandler) ComParsedQuery(c *Conn, query string, parsed sqlparser.St return th.ComQuery(c, query, callback) } -func (th *testHandler) ComPrepare(c *Conn, query string) ([]*querypb.Field, error) { +func (th *testHandler) ComPrepare(c *Conn, query string, prepare *PrepareData) ([]*querypb.Field, error) { return nil, nil }