Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const (
// GetCurrentCatalog implements driverbase.CurrentNamespacer.
func (c *mysqlConnectionImpl) GetCurrentCatalog() (string, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should call c.ClearPending() at the start of these connection-level SQL methods (GetCurrentCatalog, SetCurrentCatalog, PrepareDriverInfo, GetTableSchema, GetObjects), since they can run while another reader is still active on the same session and hit busy-connection / out-of-sync errors. That is already the pattern sqlwrapper uses for statement execution before reusing the dedicated connection. See adbc-drivers/driverbase-go#56

var database string
err := c.Db.QueryRowContext(context.Background(), "SELECT DATABASE()").Scan(&database)
err := c.Conn.QueryRowContext(context.Background(), "SELECT DATABASE()").Scan(&database)
if err != nil {
return "", c.ErrorHelper.WrapIO(err, "failed to get current database")
}
Expand All @@ -55,7 +55,7 @@ func (c *mysqlConnectionImpl) GetCurrentDbSchema() (string, error) {

// SetCurrentCatalog implements driverbase.CurrentNamespacer.
func (c *mysqlConnectionImpl) SetCurrentCatalog(catalog string) error {
_, err := c.Db.ExecContext(context.Background(), "USE "+quoteIdentifier(catalog))
_, err := c.Conn.ExecContext(context.Background(), "USE "+quoteIdentifier(catalog))
return err
}

Expand Down
Loading
Loading