Skip to content

Commit 6856a92

Browse files
authored
Register the sqlite3 driver only once (#57)
1 parent aa5022c commit 6856a92

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ install.sh
66
govarnam.pc
77

88
*.vst
9+
a

govarnam/symbol.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,18 @@ type Token struct {
4141
character string // Non language character
4242
}
4343

44+
var sqlite3WithLimitDriverRegistered bool
4445
var sqlite3Conn *sqlite3.SQLiteConn
4546

4647
func openDB(path string) (*sql.DB, error) {
47-
if sqlite3Conn == nil {
48+
if !sqlite3WithLimitDriverRegistered {
4849
sql.Register("sqlite3_with_limit", &sqlite3.SQLiteDriver{
4950
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
5051
sqlite3Conn = conn
5152
return nil
5253
},
5354
})
55+
sqlite3WithLimitDriverRegistered = true
5456
}
5557

5658
conn, err := sql.Open("sqlite3_with_limit", path)

0 commit comments

Comments
 (0)