Skip to content

Commit 8d450f8

Browse files
committed
Remove init.
1 parent 64b77f1 commit 8d450f8

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

driver/driver.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func init() {
7373
// The [sqlite3.Conn] can be used to execute queries, register functions, etc.
7474
// Any error returned closes the connection and is returned to [database/sql].
7575
func Open(dataSourceName string, init func(*sqlite3.Conn) error) (*sql.DB, error) {
76-
c, err := (&SQLite{Init: init}).OpenConnector(dataSourceName)
76+
c, err := (&SQLite{init}).OpenConnector(dataSourceName)
7777
if err != nil {
7878
return nil, err
7979
}
@@ -82,10 +82,7 @@ func Open(dataSourceName string, init func(*sqlite3.Conn) error) (*sql.DB, error
8282

8383
// SQLite implements [database/sql/driver.Driver].
8484
type SQLite struct {
85-
// Init function is called by the driver on new connections.
86-
// The [sqlite3.Conn] can be used to execute queries, register functions, etc.
87-
// Any error returned closes the connection and is returned to [database/sql].
88-
Init func(*sqlite3.Conn) error
85+
init func(*sqlite3.Conn) error
8986
}
9087

9188
// Open implements [database/sql/driver.Driver].
@@ -176,18 +173,18 @@ func (n *connector) Connect(ctx context.Context) (_ driver.Conn, err error) {
176173
defer c.Conn.SetInterrupt(old)
177174

178175
if !n.pragmas {
179-
err = c.Conn.BusyTimeout(60 * time.Second)
176+
err = c.Conn.BusyTimeout(time.Minute)
180177
if err != nil {
181178
return nil, err
182179
}
183180
}
184-
if n.driver.Init != nil {
185-
err = n.driver.Init(c.Conn)
181+
if n.driver.init != nil {
182+
err = n.driver.init(c.Conn)
186183
if err != nil {
187184
return nil, err
188185
}
189186
}
190-
if n.pragmas || n.driver.Init != nil {
187+
if n.pragmas || n.driver.init != nil {
191188
s, _, err := c.Conn.Prepare(`PRAGMA query_only`)
192189
if err != nil {
193190
return nil, err
@@ -326,6 +323,8 @@ func (c *conn) ExecContext(ctx context.Context, query string, args []driver.Name
326323
}
327324

328325
func (c *conn) CheckNamedValue(arg *driver.NamedValue) error {
326+
// Fast path: short circuit argument verification.
327+
// Arguments will be rejected by conn.ExecContext.
329328
return nil
330329
}
331330

0 commit comments

Comments
 (0)