refactor: use modernc sqlite driver as default (#37562)
cache-seeder / gobuild (push) Failing after 20m23s
cache-seeder / lint (lint-backend, bindata, lint-backend) (push) Failing after 29m29s
cache-seeder / lint (lint-go-gogit, bindata gogit, lint-go) (push) Failing after 29m38s
cache-seeder / lint (lint-go-windows, bindata, lint-go-windows) (push) Failing after 29m39s
cron-translations / crowdin-pull (push) Has been skipped
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
cache-seeder / gobuild (push) Failing after 20m23s
cache-seeder / lint (lint-backend, bindata, lint-backend) (push) Failing after 29m29s
cache-seeder / lint (lint-go-gogit, bindata gogit, lint-go) (push) Failing after 29m38s
cache-seeder / lint (lint-go-windows, bindata, lint-go-windows) (push) Failing after 29m39s
cron-translations / crowdin-pull (push) Has been skipped
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
The mattn driver is still kept, can be enabled by TAGS="sqlite_mattn sqlite_unlock_notify" --------- Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
This commit is contained in:
+17
-3
@@ -10,6 +10,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
@@ -31,7 +32,9 @@ type ConnOptions struct {
|
||||
}
|
||||
|
||||
type SQLiteConnStrOptions struct {
|
||||
FilePath string
|
||||
FilePath string
|
||||
// how long a concurrent query can wait for others (milliseconds),
|
||||
// if timeout is reached, the error is something like "database is locked (SQLITE_BUSY)"
|
||||
BusyTimeout int
|
||||
JournalMode string
|
||||
}
|
||||
@@ -52,10 +55,21 @@ func GlobalConnOptions() ConnOptions {
|
||||
}
|
||||
}
|
||||
|
||||
const sqlDriverPostgresSchema = "postgresschema"
|
||||
const (
|
||||
sqlDriverPostgresSchema = "postgresschema"
|
||||
sqlDriverSQLite3 = "sqlite3" // although database type also has "sqlite3", they are different, for different purposes
|
||||
)
|
||||
|
||||
var makeSQLiteConnStr = func(opts SQLiteConnStrOptions) (string, string, error) {
|
||||
return "", "", errors.New(`this Gitea binary was not built with SQLite3 support, get an official release or rebuild with: -tags sqlite,sqlite_unlock_notify`)
|
||||
return "", "", errors.New(`this Gitea binary was not built with SQLite3 support, get an official release or rebuild with correct "-tags"`)
|
||||
}
|
||||
|
||||
func registerSQLiteConnStrMaker(fn func(opts SQLiteConnStrOptions) (string, string, error)) {
|
||||
if slices.Contains(setting.SupportedDatabaseTypes, setting.DatabaseTypeSQLite3) {
|
||||
panic("another sqlite3 driver has been registered")
|
||||
}
|
||||
setting.SupportedDatabaseTypes = append(setting.SupportedDatabaseTypes, setting.DatabaseTypeSQLite3)
|
||||
makeSQLiteConnStr = fn
|
||||
}
|
||||
|
||||
func ConnStrDefaultDatabase(opts ConnOptions) (string, string, error) {
|
||||
|
||||
Reference in New Issue
Block a user