-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathstats.go
More file actions
35 lines (30 loc) · 703 Bytes
/
stats.go
File metadata and controls
35 lines (30 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2012 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package odbc
import (
"fmt"
"sync"
"github.com/alexbrainman/odbc/api"
)
type Stats struct {
EnvCount int
ConnCount int
StmtCount int
mu sync.Mutex
}
func (s *Stats) updateHandleCount(handleType api.SQLSMALLINT, change int) error {
s.mu.Lock()
defer s.mu.Unlock()
switch handleType {
case api.SQL_HANDLE_ENV:
s.EnvCount += change
case api.SQL_HANDLE_DBC:
s.ConnCount += change
case api.SQL_HANDLE_STMT:
s.StmtCount += change
default:
return fmt.Errorf("unexpected handle type %d", handleType)
}
return nil
}