File tree Expand file tree Collapse file tree 9 files changed +29
-34
lines changed Expand file tree Collapse file tree 9 files changed +29
-34
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,14 @@ go 1.21
44
55require (
66 github.com/ncruces/julianday v1.0.0
7+ github.com/ncruces/sort v0.1.2
78 github.com/psanford/httpreadat v0.1.0
8- github.com/tetratelabs/wazero v1.7.2
9+ github.com/tetratelabs/wazero v1.7.3
910 golang.org/x/crypto v0.24.0
1011 golang.org/x/sync v0.7.0
1112 golang.org/x/sys v0.21.0
1213 golang.org/x/text v0.16.0
1314 lukechampine.com/adiantum v1.1.1
1415)
1516
16- require github.com/ncruces/sort v0.1.2
17-
1817retract v0.4.0 // tagged from the wrong branch
Original file line number Diff line number Diff line change @@ -4,8 +4,8 @@ github.com/ncruces/sort v0.1.2 h1:zKQ9CA4fpHPF6xsUhRTfi5EEryspuBpe/QA4VWQOV1U=
44github.com/ncruces/sort v0.1.2 /go.mod h1:vEJUTBJtebIuCMmXD18GKo5GJGhsay+xZFOoBEIXFmE =
55github.com/psanford/httpreadat v0.1.0 h1:VleW1HS2zO7/4c7c7zNl33fO6oYACSagjJIyMIwZLUE =
66github.com/psanford/httpreadat v0.1.0 /go.mod h1:Zg7P+TlBm3bYbyHTKv/EdtSJZn3qwbPwpfZ/I9GKCRE =
7- github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc =
8- github.com/tetratelabs/wazero v1.7.2 /go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y =
7+ github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw =
8+ github.com/tetratelabs/wazero v1.7.3 /go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y =
99golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI =
1010golang.org/x/crypto v0.24.0 /go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM =
1111golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M =
Original file line number Diff line number Diff line change @@ -11,6 +11,6 @@ require (
1111 github.com/jinzhu/inflection v1.0.0 // indirect
1212 github.com/jinzhu/now v1.1.5 // indirect
1313 github.com/ncruces/julianday v1.0.0 // indirect
14- github.com/tetratelabs/wazero v1.7.2 // indirect
14+ github.com/tetratelabs/wazero v1.7.3 // indirect
1515 golang.org/x/sys v0.21.0 // indirect
1616)
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ github.com/ncruces/go-sqlite3 v0.16.1 h1:1wHv7s8y+fWK44UIliotJ42ZV41A5T0sjIAqGmn
66github.com/ncruces/go-sqlite3 v0.16.1 /go.mod h1:feFXbBcbLtxNk6XWG1ROt8MS9+E45yCW3G8o4ixIqZ8 =
77github.com/ncruces/julianday v1.0.0 h1:fH0OKwa7NWvniGQtxdJRxAgkBMolni2BjDHaWTxqt7M =
88github.com/ncruces/julianday v1.0.0 /go.mod h1:Dusn2KvZrrovOMJuOt0TNXL6tB7U2E8kvza5fFc9G7g =
9- github.com/tetratelabs/wazero v1.7.2 h1:1+z5nXJNwMLPAWaTePFi49SSTL0IMx/i3Fg8Yc25GDc =
10- github.com/tetratelabs/wazero v1.7.2 /go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y =
9+ github.com/tetratelabs/wazero v1.7.3 h1:PBH5KVahrt3S2AHgEjKu4u+LlDbbk+nsGE3KLucy6Rw =
10+ github.com/tetratelabs/wazero v1.7.3 /go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y =
1111golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws =
1212golang.org/x/sys v0.21.0 /go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA =
1313golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4 =
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ func (j JSON) Scan(value any) error {
2626 buf = v .AppendFormat (buf , time .RFC3339Nano )
2727 buf = append (buf , '"' )
2828 case nil :
29- buf = append ( buf , "null" ... )
29+ buf = [] byte ( "null" )
3030 default :
3131 panic (AssertErr ())
3232 }
Original file line number Diff line number Diff line change @@ -564,7 +564,7 @@ func (s *Stmt) ColumnJSON(col int, ptr any) error {
564564 var data []byte
565565 switch s .ColumnType (col ) {
566566 case NULL :
567- data = append ( data , "null" ... )
567+ data = [] byte ( "null" )
568568 case TEXT :
569569 data = s .ColumnRawText (col )
570570 case BLOB :
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ func (v Value) JSON(ptr any) error {
177177 var data []byte
178178 switch v .Type () {
179179 case NULL :
180- data = append ( data , "null" ... )
180+ data = [] byte ( "null" )
181181 case TEXT :
182182 data = v .RawText ()
183183 case BLOB :
Original file line number Diff line number Diff line change @@ -75,11 +75,6 @@ func (memVFS) FullPathname(name string) (string, error) {
7575type memDB struct {
7676 name string
7777
78- // +checklocks:lockMtx
79- pending * memFile
80- // +checklocks:lockMtx
81- reserved * memFile
82-
8378 // +checklocks:dataMtx
8479 data []* [sectorSize ]byte
8580
@@ -88,6 +83,10 @@ type memDB struct {
8883
8984 // +checklocks:lockMtx
9085 shared int
86+ // +checklocks:lockMtx
87+ reserved bool
88+ // +checklocks:lockMtx
89+ pending bool
9190
9291 // +checklocks:memoryMtx
9392 refs int
@@ -214,24 +213,24 @@ func (m *memFile) Lock(lock vfs.LockLevel) error {
214213
215214 switch lock {
216215 case vfs .LOCK_SHARED :
217- if m .pending != nil {
216+ if m .pending {
218217 return sqlite3 .BUSY
219218 }
220219 m .shared ++
221220
222221 case vfs .LOCK_RESERVED :
223- if m .reserved != nil {
222+ if m .reserved {
224223 return sqlite3 .BUSY
225224 }
226- m .reserved = m
225+ m .reserved = true
227226
228227 case vfs .LOCK_EXCLUSIVE :
229228 if m .lock < vfs .LOCK_PENDING {
230- if m .pending != nil {
229+ if m .pending {
231230 return sqlite3 .BUSY
232231 }
233232 m .lock = vfs .LOCK_PENDING
234- m .pending = m
233+ m .pending = true
235234 }
236235
237236 for before := time .Now (); m .shared > 1 ; {
@@ -256,11 +255,11 @@ func (m *memFile) Unlock(lock vfs.LockLevel) error {
256255 m .lockMtx .Lock ()
257256 defer m .lockMtx .Unlock ()
258257
259- if m .pending == m {
260- m .pending = nil
258+ if m .pending && m . lock >= vfs . LOCK_PENDING {
259+ m .pending = false
261260 }
262- if m .reserved == m {
263- m .reserved = nil
261+ if m .reserved && m . lock >= vfs . LOCK_RESERVED {
262+ m .reserved = false
264263 }
265264 if lock < vfs .LOCK_SHARED {
266265 m .shared --
@@ -275,7 +274,7 @@ func (m *memFile) CheckReservedLock() (bool, error) {
275274 }
276275 m .lockMtx .Lock ()
277276 defer m .lockMtx .Unlock ()
278- return m .reserved != nil , nil
277+ return m .reserved , nil
279278}
280279
281280func (m * memFile ) SectorSize () int {
Original file line number Diff line number Diff line change @@ -101,13 +101,13 @@ func (s *vfsShm) shmOpen() (rc _ErrorCode) {
101101 return _OK
102102 }
103103
104- // Open file read-write, as it will be shared.
104+ // Always open file read-write, as it will be shared.
105105 f , err := os .OpenFile (s .path ,
106106 unix .O_RDWR | unix .O_CREAT | unix .O_NOFOLLOW , 0666 )
107107 if err != nil {
108108 return _CANTOPEN
109109 }
110- // Close if file if it's not nil.
110+ // Closes file if it's not nil.
111111 defer func () { f .Close () }()
112112
113113 fi , err := f .Stat ()
@@ -145,17 +145,14 @@ func (s *vfsShm) shmOpen() (rc _ErrorCode) {
145145 info : fi ,
146146 refs : 1 ,
147147 }
148- f = nil
149- add := true
148+ f = nil // Don't close the file.
150149 for i , g := range vfsShmFiles {
151150 if g == nil {
152151 vfsShmFiles [i ] = s .vfsShmFile
153- add = false
152+ return rc
154153 }
155154 }
156- if add {
157- vfsShmFiles = append (vfsShmFiles , s .vfsShmFile )
158- }
155+ vfsShmFiles = append (vfsShmFiles , s .vfsShmFile )
159156 return rc
160157}
161158
You can’t perform that action at this time.
0 commit comments