mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 15:52:26 -05:00
[chore/deps] Upgrade to go-sqlite 0.27.1 (#4334)
# Description This brings some performance improvements and SQLite 3.50.3. ## Checklist Please put an x inside each checkbox to indicate that you've read and followed it: `[ ]` -> `[x]` If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want). - [x] I/we have read the [GoToSocial contribution guidelines](https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/CONTRIBUTING.md). - [ ] I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat. - [x] I/we have not leveraged AI to create the proposed changes. - [ ] I/we have performed a self-review of added code. - [ ] I/we have written code that is legible and maintainable by others. - [ ] I/we have commented the added code, particularly in hard-to-understand areas. - [ ] I/we have made any necessary changes to documentation. - [ ] I/we have added tests that cover new code. - [x] I/we have run tests and they pass locally with the changes. - [ ] I/we have run `go fmt ./...` and `golangci-lint run`. Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4334 Co-authored-by: Daenney <git@noreply.sourcery.dny.nu> Co-committed-by: Daenney <git@noreply.sourcery.dny.nu>
This commit is contained in:
parent
a4b54aa935
commit
eb60081985
67 changed files with 662 additions and 261 deletions
12
vendor/github.com/ncruces/go-sqlite3/const.go
generated
vendored
12
vendor/github.com/ncruces/go-sqlite3/const.go
generated
vendored
|
|
@ -185,12 +185,12 @@ const (
|
|||
type FunctionFlag uint32
|
||||
|
||||
const (
|
||||
DETERMINISTIC FunctionFlag = 0x000000800
|
||||
DIRECTONLY FunctionFlag = 0x000080000
|
||||
INNOCUOUS FunctionFlag = 0x000200000
|
||||
SELFORDER1 FunctionFlag = 0x002000000
|
||||
// SUBTYPE FunctionFlag = 0x000100000
|
||||
// RESULT_SUBTYPE FunctionFlag = 0x001000000
|
||||
DETERMINISTIC FunctionFlag = 0x000000800
|
||||
DIRECTONLY FunctionFlag = 0x000080000
|
||||
SUBTYPE FunctionFlag = 0x000100000
|
||||
INNOCUOUS FunctionFlag = 0x000200000
|
||||
RESULT_SUBTYPE FunctionFlag = 0x001000000
|
||||
SELFORDER1 FunctionFlag = 0x002000000
|
||||
)
|
||||
|
||||
// StmtStatus name counter values associated with the [Stmt.Status] method.
|
||||
|
|
|
|||
8
vendor/github.com/ncruces/go-sqlite3/context.go
generated
vendored
8
vendor/github.com/ncruces/go-sqlite3/context.go
generated
vendored
|
|
@ -227,6 +227,14 @@ func (ctx Context) ResultError(err error) {
|
|||
}
|
||||
}
|
||||
|
||||
// ResultSubtype sets the subtype of the result of the function.
|
||||
//
|
||||
// https://sqlite.org/c3ref/result_subtype.html
|
||||
func (ctx Context) ResultSubtype(t uint) {
|
||||
ctx.c.call("sqlite3_result_subtype",
|
||||
stk_t(ctx.handle), stk_t(uint32(t)))
|
||||
}
|
||||
|
||||
// VTabNoChange may return true if a column is being fetched as part
|
||||
// of an update during which the column value will not change.
|
||||
//
|
||||
|
|
|
|||
6
vendor/github.com/ncruces/go-sqlite3/driver/driver.go
generated
vendored
6
vendor/github.com/ncruces/go-sqlite3/driver/driver.go
generated
vendored
|
|
@ -546,8 +546,8 @@ func (s *stmt) setupBindings(args []driver.NamedValue) (err error) {
|
|||
err = s.Stmt.BindTime(id, a, s.tmWrite)
|
||||
case util.JSON:
|
||||
err = s.Stmt.BindJSON(id, a.Value)
|
||||
case util.PointerUnwrap:
|
||||
err = s.Stmt.BindPointer(id, util.UnwrapPointer(a))
|
||||
case util.Pointer:
|
||||
err = s.Stmt.BindPointer(id, a.Value)
|
||||
case nil:
|
||||
err = s.Stmt.BindNull(id)
|
||||
default:
|
||||
|
|
@ -565,7 +565,7 @@ func (s *stmt) CheckNamedValue(arg *driver.NamedValue) error {
|
|||
switch arg.Value.(type) {
|
||||
case bool, int, int64, float64, string, []byte,
|
||||
time.Time, sqlite3.ZeroBlob,
|
||||
util.JSON, util.PointerUnwrap,
|
||||
util.JSON, util.Pointer,
|
||||
nil:
|
||||
return nil
|
||||
default:
|
||||
|
|
|
|||
2
vendor/github.com/ncruces/go-sqlite3/embed/README.md
generated
vendored
2
vendor/github.com/ncruces/go-sqlite3/embed/README.md
generated
vendored
|
|
@ -1,6 +1,6 @@
|
|||
# Embeddable Wasm build of SQLite
|
||||
|
||||
This folder includes an embeddable Wasm build of SQLite 3.50.2 for use with
|
||||
This folder includes an embeddable Wasm build of SQLite 3.50.3 for use with
|
||||
[`github.com/ncruces/go-sqlite3`](https://pkg.go.dev/github.com/ncruces/go-sqlite3).
|
||||
|
||||
The following optional features are compiled in:
|
||||
|
|
|
|||
2
vendor/github.com/ncruces/go-sqlite3/embed/exports.txt
generated
vendored
2
vendor/github.com/ncruces/go-sqlite3/embed/exports.txt
generated
vendored
|
|
@ -98,6 +98,7 @@ sqlite3_result_error_toobig
|
|||
sqlite3_result_int64
|
||||
sqlite3_result_null
|
||||
sqlite3_result_pointer_go
|
||||
sqlite3_result_subtype
|
||||
sqlite3_result_text_go
|
||||
sqlite3_result_value
|
||||
sqlite3_result_zeroblob64
|
||||
|
|
@ -126,6 +127,7 @@ sqlite3_value_int64
|
|||
sqlite3_value_nochange
|
||||
sqlite3_value_numeric_type
|
||||
sqlite3_value_pointer_go
|
||||
sqlite3_value_subtype
|
||||
sqlite3_value_text
|
||||
sqlite3_value_type
|
||||
sqlite3_vtab_collation
|
||||
|
|
|
|||
BIN
vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm
generated
vendored
BIN
vendor/github.com/ncruces/go-sqlite3/embed/sqlite3.wasm
generated
vendored
Binary file not shown.
10
vendor/github.com/ncruces/go-sqlite3/internal/util/pointer.go
generated
vendored
10
vendor/github.com/ncruces/go-sqlite3/internal/util/pointer.go
generated
vendored
|
|
@ -1,11 +1,3 @@
|
|||
package util
|
||||
|
||||
type Pointer[T any] struct{ Value T }
|
||||
|
||||
func (p Pointer[T]) unwrap() any { return p.Value }
|
||||
|
||||
type PointerUnwrap interface{ unwrap() any }
|
||||
|
||||
func UnwrapPointer(p PointerUnwrap) any {
|
||||
return p.unwrap()
|
||||
}
|
||||
type Pointer struct{ Value any }
|
||||
|
|
|
|||
4
vendor/github.com/ncruces/go-sqlite3/pointer.go
generated
vendored
4
vendor/github.com/ncruces/go-sqlite3/pointer.go
generated
vendored
|
|
@ -8,6 +8,6 @@ import "github.com/ncruces/go-sqlite3/internal/util"
|
|||
// [Value.Pointer], or [Context.ResultPointer].
|
||||
//
|
||||
// https://sqlite.org/bindptr.html
|
||||
func Pointer[T any](value T) any {
|
||||
return util.Pointer[T]{Value: value}
|
||||
func Pointer(value any) any {
|
||||
return util.Pointer{Value: value}
|
||||
}
|
||||
|
|
|
|||
1
vendor/github.com/ncruces/go-sqlite3/stmt.go
generated
vendored
1
vendor/github.com/ncruces/go-sqlite3/stmt.go
generated
vendored
|
|
@ -631,7 +631,6 @@ func (s *Stmt) ColumnValue(col int) Value {
|
|||
stk_t(s.handle), stk_t(col)))
|
||||
return Value{
|
||||
c: s.c,
|
||||
unprot: true,
|
||||
handle: ptr,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
vendor/github.com/ncruces/go-sqlite3/util/sql3util/wasm/sql3parse_table.wasm
generated
vendored
BIN
vendor/github.com/ncruces/go-sqlite3/util/sql3util/wasm/sql3parse_table.wasm
generated
vendored
Binary file not shown.
42
vendor/github.com/ncruces/go-sqlite3/value.go
generated
vendored
42
vendor/github.com/ncruces/go-sqlite3/value.go
generated
vendored
|
|
@ -15,15 +15,6 @@ import (
|
|||
type Value struct {
|
||||
c *Conn
|
||||
handle ptr_t
|
||||
unprot bool
|
||||
copied bool
|
||||
}
|
||||
|
||||
func (v Value) protected() stk_t {
|
||||
if v.unprot {
|
||||
panic(util.ValueErr)
|
||||
}
|
||||
return stk_t(v.handle)
|
||||
}
|
||||
|
||||
// Dup makes a copy of the SQL value and returns a pointer to that copy.
|
||||
|
|
@ -33,7 +24,6 @@ func (v Value) Dup() *Value {
|
|||
ptr := ptr_t(v.c.call("sqlite3_value_dup", stk_t(v.handle)))
|
||||
return &Value{
|
||||
c: v.c,
|
||||
copied: true,
|
||||
handle: ptr,
|
||||
}
|
||||
}
|
||||
|
|
@ -42,9 +32,6 @@ func (v Value) Dup() *Value {
|
|||
//
|
||||
// https://sqlite.org/c3ref/value_dup.html
|
||||
func (dup *Value) Close() error {
|
||||
if !dup.copied {
|
||||
panic(util.ValueErr)
|
||||
}
|
||||
dup.c.call("sqlite3_value_free", stk_t(dup.handle))
|
||||
dup.handle = 0
|
||||
return nil
|
||||
|
|
@ -54,14 +41,21 @@ func (dup *Value) Close() error {
|
|||
//
|
||||
// https://sqlite.org/c3ref/value_blob.html
|
||||
func (v Value) Type() Datatype {
|
||||
return Datatype(v.c.call("sqlite3_value_type", v.protected()))
|
||||
return Datatype(v.c.call("sqlite3_value_type", stk_t(v.handle)))
|
||||
}
|
||||
|
||||
// Type returns the numeric datatype of the value.
|
||||
// Subtype returns the subtype of the value.
|
||||
//
|
||||
// https://sqlite.org/c3ref/value_subtype.html
|
||||
func (v Value) Subtype() uint {
|
||||
return uint(uint32(v.c.call("sqlite3_value_subtype", stk_t(v.handle))))
|
||||
}
|
||||
|
||||
// NumericType returns the numeric datatype of the value.
|
||||
//
|
||||
// https://sqlite.org/c3ref/value_blob.html
|
||||
func (v Value) NumericType() Datatype {
|
||||
return Datatype(v.c.call("sqlite3_value_numeric_type", v.protected()))
|
||||
return Datatype(v.c.call("sqlite3_value_numeric_type", stk_t(v.handle)))
|
||||
}
|
||||
|
||||
// Bool returns the value as a bool.
|
||||
|
|
@ -85,14 +79,14 @@ func (v Value) Int() int {
|
|||
//
|
||||
// https://sqlite.org/c3ref/value_blob.html
|
||||
func (v Value) Int64() int64 {
|
||||
return int64(v.c.call("sqlite3_value_int64", v.protected()))
|
||||
return int64(v.c.call("sqlite3_value_int64", stk_t(v.handle)))
|
||||
}
|
||||
|
||||
// Float returns the value as a float64.
|
||||
//
|
||||
// https://sqlite.org/c3ref/value_blob.html
|
||||
func (v Value) Float() float64 {
|
||||
f := uint64(v.c.call("sqlite3_value_double", v.protected()))
|
||||
f := uint64(v.c.call("sqlite3_value_double", stk_t(v.handle)))
|
||||
return math.Float64frombits(f)
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +132,7 @@ func (v Value) Blob(buf []byte) []byte {
|
|||
//
|
||||
// https://sqlite.org/c3ref/value_blob.html
|
||||
func (v Value) RawText() []byte {
|
||||
ptr := ptr_t(v.c.call("sqlite3_value_text", v.protected()))
|
||||
ptr := ptr_t(v.c.call("sqlite3_value_text", stk_t(v.handle)))
|
||||
return v.rawBytes(ptr, 1)
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +142,7 @@ func (v Value) RawText() []byte {
|
|||
//
|
||||
// https://sqlite.org/c3ref/value_blob.html
|
||||
func (v Value) RawBlob() []byte {
|
||||
ptr := ptr_t(v.c.call("sqlite3_value_blob", v.protected()))
|
||||
ptr := ptr_t(v.c.call("sqlite3_value_blob", stk_t(v.handle)))
|
||||
return v.rawBytes(ptr, 0)
|
||||
}
|
||||
|
||||
|
|
@ -157,14 +151,14 @@ func (v Value) rawBytes(ptr ptr_t, nul int32) []byte {
|
|||
return nil
|
||||
}
|
||||
|
||||
n := int32(v.c.call("sqlite3_value_bytes", v.protected()))
|
||||
n := int32(v.c.call("sqlite3_value_bytes", stk_t(v.handle)))
|
||||
return util.View(v.c.mod, ptr, int64(n+nul))[:n]
|
||||
}
|
||||
|
||||
// Pointer gets the pointer associated with this value,
|
||||
// or nil if it has no associated pointer.
|
||||
func (v Value) Pointer() any {
|
||||
ptr := ptr_t(v.c.call("sqlite3_value_pointer_go", v.protected()))
|
||||
ptr := ptr_t(v.c.call("sqlite3_value_pointer_go", stk_t(v.handle)))
|
||||
return util.GetHandle(v.c.ctx, ptr)
|
||||
}
|
||||
|
||||
|
|
@ -194,7 +188,7 @@ func (v Value) JSON(ptr any) error {
|
|||
//
|
||||
// https://sqlite.org/c3ref/value_blob.html
|
||||
func (v Value) NoChange() bool {
|
||||
b := int32(v.c.call("sqlite3_value_nochange", v.protected()))
|
||||
b := int32(v.c.call("sqlite3_value_nochange", stk_t(v.handle)))
|
||||
return b != 0
|
||||
}
|
||||
|
||||
|
|
@ -202,7 +196,7 @@ func (v Value) NoChange() bool {
|
|||
//
|
||||
// https://sqlite.org/c3ref/value_blob.html
|
||||
func (v Value) FromBind() bool {
|
||||
b := int32(v.c.call("sqlite3_value_frombind", v.protected()))
|
||||
b := int32(v.c.call("sqlite3_value_frombind", stk_t(v.handle)))
|
||||
return b != 0
|
||||
}
|
||||
|
||||
|
|
|
|||
31
vendor/github.com/ncruces/go-sqlite3/vfs/memdb/memdb.go
generated
vendored
31
vendor/github.com/ncruces/go-sqlite3/vfs/memdb/memdb.go
generated
vendored
|
|
@ -2,7 +2,6 @@ package memdb
|
|||
|
||||
import (
|
||||
"io"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
|
@ -85,9 +84,10 @@ type memDB struct {
|
|||
// +checklocks:memoryMtx
|
||||
refs int32
|
||||
|
||||
shared int32 // +checklocks:lockMtx
|
||||
pending bool // +checklocks:lockMtx
|
||||
reserved bool // +checklocks:lockMtx
|
||||
shared int32 // +checklocks:lockMtx
|
||||
pending bool // +checklocks:lockMtx
|
||||
reserved bool // +checklocks:lockMtx
|
||||
waiter *sync.Cond // +checklocks:lockMtx
|
||||
|
||||
lockMtx sync.Mutex
|
||||
dataMtx sync.RWMutex
|
||||
|
|
@ -195,8 +195,6 @@ func (m *memFile) Size() (int64, error) {
|
|||
return m.size, nil
|
||||
}
|
||||
|
||||
const spinWait = 25 * time.Microsecond
|
||||
|
||||
func (m *memFile) Lock(lock vfs.LockLevel) error {
|
||||
if m.lock >= lock {
|
||||
return nil
|
||||
|
|
@ -228,13 +226,18 @@ func (m *memFile) Lock(lock vfs.LockLevel) error {
|
|||
m.pending = true
|
||||
}
|
||||
|
||||
for before := time.Now(); m.shared > 1; {
|
||||
if time.Since(before) > spinWait {
|
||||
return sqlite3.BUSY
|
||||
if m.shared > 1 {
|
||||
before := time.Now()
|
||||
if m.waiter == nil {
|
||||
m.waiter = sync.NewCond(&m.lockMtx)
|
||||
}
|
||||
defer time.AfterFunc(time.Millisecond, m.waiter.Broadcast).Stop()
|
||||
for m.shared > 1 {
|
||||
if time.Since(before) > time.Millisecond {
|
||||
return sqlite3.BUSY
|
||||
}
|
||||
m.waiter.Wait()
|
||||
}
|
||||
m.lockMtx.Unlock()
|
||||
runtime.Gosched()
|
||||
m.lockMtx.Lock()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -257,7 +260,9 @@ func (m *memFile) Unlock(lock vfs.LockLevel) error {
|
|||
m.pending = false
|
||||
}
|
||||
if lock < vfs.LOCK_SHARED {
|
||||
m.shared--
|
||||
if m.shared--; m.pending && m.shared <= 1 && m.waiter != nil {
|
||||
m.waiter.Broadcast()
|
||||
}
|
||||
}
|
||||
m.lock = lock
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue