From 00a88e67a0e5edd01952687c922a4655d96a3316 Mon Sep 17 00:00:00 2001 From: Subin Siby Date: Mon, 4 Dec 2023 01:15:01 +0530 Subject: [PATCH] Register the sqlite3 driver only once --- .gitignore | 1 + govarnam/symbol.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ac2e8fb..78ed586 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ install.sh govarnam.pc *.vst +a diff --git a/govarnam/symbol.go b/govarnam/symbol.go index a92cdd1..3f4cd05 100644 --- a/govarnam/symbol.go +++ b/govarnam/symbol.go @@ -41,16 +41,18 @@ type Token struct { character string // Non language character } +var sqlite3WithLimitDriverRegistered bool var sqlite3Conn *sqlite3.SQLiteConn func openDB(path string) (*sql.DB, error) { - if sqlite3Conn == nil { + if !sqlite3WithLimitDriverRegistered { sql.Register("sqlite3_with_limit", &sqlite3.SQLiteDriver{ ConnectHook: func(conn *sqlite3.SQLiteConn) error { sqlite3Conn = conn return nil }, }) + sqlite3WithLimitDriverRegistered = true } conn, err := sql.Open("sqlite3_with_limit", path)