mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Fix #335.
This commit is contained in:
@@ -263,10 +263,8 @@ func (n *connector) Connect(ctx context.Context) (ret driver.Conn, err error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer s.Close()
|
defer s.Close()
|
||||||
if s.Step() && s.ColumnBool(0) {
|
if s.Step() {
|
||||||
c.readOnly = '1'
|
c.readOnly = s.ColumnBool(0)
|
||||||
} else {
|
|
||||||
c.readOnly = '0'
|
|
||||||
}
|
}
|
||||||
err = s.Close()
|
err = s.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -322,7 +320,7 @@ type conn struct {
|
|||||||
txReset string
|
txReset string
|
||||||
tmRead sqlite3.TimeFormat
|
tmRead sqlite3.TimeFormat
|
||||||
tmWrite sqlite3.TimeFormat
|
tmWrite sqlite3.TimeFormat
|
||||||
readOnly byte
|
readOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -358,9 +356,9 @@ func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, e
|
|||||||
|
|
||||||
c.txReset = ``
|
c.txReset = ``
|
||||||
txBegin := `BEGIN ` + txLock
|
txBegin := `BEGIN ` + txLock
|
||||||
if opts.ReadOnly {
|
if opts.ReadOnly && !c.readOnly {
|
||||||
txBegin += ` ; PRAGMA query_only=on`
|
txBegin += ` ; PRAGMA query_only=on`
|
||||||
c.txReset = `; PRAGMA query_only=` + string(c.readOnly)
|
c.txReset = `; PRAGMA query_only=off`
|
||||||
}
|
}
|
||||||
|
|
||||||
if old := c.Conn.SetInterrupt(ctx); old != ctx {
|
if old := c.Conn.SetInterrupt(ctx); old != ctx {
|
||||||
|
|||||||
Reference in New Issue
Block a user