Files
gitea/models/db/driver_sqlite_mattn.go
wxiaoguang a39af1a829
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
refactor: use modernc sqlite driver as default (#37562)
The mattn driver is still kept, can be enabled by
TAGS="sqlite_mattn sqlite_unlock_notify"

---------

Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
2026-05-06 18:57:59 +00:00

32 lines
816 B
Go

//go:build sqlite_mattn && sqlite_unlock_notify
// Copyright 2026 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package db
import (
"fmt"
"strconv"
"strings"
_ "github.com/mattn/go-sqlite3"
)
func init() {
registerSQLiteConnStrMaker(makeSQLiteConnStrMattnCGO)
}
func makeSQLiteConnStrMattnCGO(opts SQLiteConnStrOptions) (string, string, error) {
var params []string
params = append(params, "cache=shared")
params = append(params, "mode=rwc")
params = append(params, "_busy_timeout="+strconv.Itoa(opts.BusyTimeout))
params = append(params, "_txlock=immediate")
if opts.JournalMode != "" {
params = append(params, "_journal_mode="+opts.JournalMode)
}
connStr := fmt.Sprintf("file:%s?%s", opts.FilePath, strings.Join(params, "&"))
return sqlDriverSQLite3, connStr, nil
}