Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 6 additions & 5 deletions internal/cmd/vet.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"runtime/trace"
"slices"
"strings"
"sync"
"time"

_ "github.com/go-sql-driver/mysql"
Expand Down Expand Up @@ -386,6 +387,7 @@ type checker struct {
Stderr io.Writer
OnlyManagedDB bool
Client dbmanager.Client
clientOnce sync.Once
Replacer *shfmt.Replacer
}

Expand All @@ -402,11 +404,10 @@ func (c *checker) fetchDatabaseUri(ctx context.Context, s config.SQL) (string, f
return uri, cleanup, err
}

if c.Client == nil {
// FIXME: Eventual race condition
client := dbmanager.NewClient(c.Conf.Servers)
c.Client = client
}
// Initialize the client exactly once, even if called concurrently
c.clientOnce.Do(func() {
c.Client = dbmanager.NewClient(c.Conf.Servers)
})

var ddl []string
files, err := sqlpath.Glob(s.Schema)
Expand Down
2 changes: 1 addition & 1 deletion internal/sql/ast/create_function_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type CreateFunctionStmt struct {
Params *List
ReturnType *TypeName
Func *FuncName
// TODO: Undertand these two fields
// TODO: Understand these two fields
Options *List
WithClause *List
}
Expand Down
Loading