Skip to content

Commit

Permalink
PMM-12375 use Exec to select a database
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Tymchuk committed Aug 30, 2023
1 parent f58949e commit 7865feb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion agent/connectionchecker/connection_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,15 @@ func (cc *ConnectionChecker) checkProxySQLConnection(ctx context.Context, dsn st
res.Error = err.Error()
}

if _, err := db.ExecContext(ctx, "USE mysql"); err != nil {
res.Error = err.Error()
return &res
}

var version string
if err := db.QueryRowContext(
ctx,
"USE mysql; SELECT /* agent='connectionchecker' */ variable_value FROM global_variables WHERE variable_name = 'admin-version'").Scan(&version); err != nil { //nolint:lll
"SELECT /* agent='connectionchecker' */ variable_value FROM global_variables WHERE variable_name = 'admin-version'").Scan(&version); err != nil { //nolint:lll
res.Error = err.Error()
return &res
}
Expand Down
2 changes: 1 addition & 1 deletion managed/models/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ var databaseSchema = [][]string{
},
85: {
`ALTER TABLE services
ADD COLUMN version VARCHAR`,
ADD COLUMN version VARCHAR NOT NULL DEFAULT ''`,
},
}

Expand Down

0 comments on commit 7865feb

Please sign in to comment.