Skip to content

Commit

Permalink
pre-check use statement (#144)
Browse files Browse the repository at this point in the history
Co-authored-by: Yee <[email protected]>
  • Loading branch information
HarrisChu and yixinglu authored Jun 22, 2021
1 parent 765dda1 commit 4767de5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/client/clientpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,19 @@ func (p *ClientPool) Close() {
}

func (p *ClientPool) Init() error {
i := p.getActiveConnIdx()
if i == -1 {
return fmt.Errorf("no available session.")
}
if p.postStart != nil && p.postStart.Commands != nil {
if i := p.getActiveConnIdx(); i != -1 {
if err := p.exec(i, *p.postStart.Commands); err != nil {
return err
}
if err := p.exec(i, *p.postStart.Commands); err != nil {
return err
}
}
// pre-check for use space statement
if err := p.exec(i, fmt.Sprintf("USE `%s`;", p.space)); err != nil {
return err
}

for i := 0; i < p.concurrency; i++ {
go func(i int) {
Expand Down

0 comments on commit 4767de5

Please sign in to comment.