refactor: remove unnecessary prepared statement allocation (#6374)

This commit is contained in:
Lev Zakharov
2023-06-05 11:23:17 +03:00
committed by GitHub
parent c1ea730367
commit 7a76c042e6
2 changed files with 33 additions and 24 deletions
+9
View File
@@ -21,6 +21,15 @@ type PreparedStmtDB struct {
ConnPool
}
func NewPreparedStmtDB(connPool ConnPool) *PreparedStmtDB {
return &PreparedStmtDB{
ConnPool: connPool,
Stmts: make(map[string]*Stmt),
Mux: &sync.RWMutex{},
PreparedSQL: make([]string, 0, 100),
}
}
func (db *PreparedStmtDB) GetDBConn() (*sql.DB, error) {
if dbConnector, ok := db.ConnPool.(GetDBConnector); ok && dbConnector != nil {
return dbConnector.GetDBConn()