Skip to content

Commit

Permalink
go.mod: fix incorrect v2 go-sqlite package
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraettinger committed Jan 11, 2025
1 parent e38f044 commit e8ed2ce
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
57 changes: 31 additions & 26 deletions consumer/store-sqlite/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"time"
"unsafe"

"github.com/jgraettinger/gorocksdb"
"github.com/mattn/go-sqlite3"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/jgraettinger/gorocksdb"
"go.gazette.dev/core/broker/client"
"go.gazette.dev/core/consumer"
pc "go.gazette.dev/core/consumer/protocol"
Expand Down Expand Up @@ -168,21 +168,20 @@ func NewStore(recorder *recoverylog.Recorder) (*Store, error) {
// The "gazette_checkpoint" table is then created, and any provided statements
// are prepared and added to Store.Stmts in the same order as provided to Open.
//
// store.Open(
// // Create myTable if it doesn't yet exist:
// `CREATE TABLE IF NOT EXISTS myTable (
// id BLOB PRIMARY KEY NOT NULL,
// valueOne INTEGER,
// valueTwo TEXT
// );`,
// // Statement for querying on valueOne:
// `SELECT id, valueTwo FROM myTable WHERE valueOne > ?;`,
// // Statement for upserting into myTable:
// `INSERT INTO myTable(id, valueOne, valueTwo) VALUES(:id, :one, :two)
// ON CONFLICT(id) DO UPDATE SET valueOne = valueOne + :one, valueTwo = :two`,
// )
// // store.Stmts[0] is now prepared for queries, and store.Stmts[1] for upserts.
//
// store.Open(
// // Create myTable if it doesn't yet exist:
// `CREATE TABLE IF NOT EXISTS myTable (
// id BLOB PRIMARY KEY NOT NULL,
// valueOne INTEGER,
// valueTwo TEXT
// );`,
// // Statement for querying on valueOne:
// `SELECT id, valueTwo FROM myTable WHERE valueOne > ?;`,
// // Statement for upserting into myTable:
// `INSERT INTO myTable(id, valueOne, valueTwo) VALUES(:id, :one, :two)
// ON CONFLICT(id) DO UPDATE SET valueOne = valueOne + :one, valueTwo = :two`,
// )
// // store.Stmts[0] is now prepared for queries, and store.Stmts[1] for upserts.
func (s *Store) Open(bootstrapSQL string, statements ...string) error {
// Finish initialization and open page DB.
s.PageDBOptions.SetEnv(s.PageDBEnv)
Expand Down Expand Up @@ -253,8 +252,9 @@ func (s *Store) Open(bootstrapSQL string, statements ...string) error {
// database name (which is held constant across Store recoveries) to a URI
// specific to this *Store instance and which is suited for ATTACH-ing to the
// primary database. Eg:
// URIForDB("sept_2019.db") =>
// "file:sept_2019.db?_journal_mode=WAL&other-setting=bar&vfs=store-123456&..."
//
// URIForDB("sept_2019.db") =>
// "file:sept_2019.db?_journal_mode=WAL&other-setting=bar&vfs=store-123456&..."
func (s *Store) URIForDB(name string) string {
return "file:" + name + "?" + s.SQLiteURIValues.Encode()
}
Expand Down Expand Up @@ -339,6 +339,12 @@ func (s *Store) Destroy() {
C.recFSFree(s.vfs)
}

// Column family handles must be closed before the DB is.
for _, c := range s.PageDBColumns {
c.Destroy()
}
s.PageDBColumns = nil

if s.pages != nil {
s.pages.Close()
}
Expand All @@ -362,14 +368,13 @@ func (s *Store) pageDBPath() string {
// the linked SQLite library was built with. See https://www.sqlite.org/compile.html
// for a full listing. Note the "SQLITE_" prefix is dropped in the returned set:
//
// map[string]struct{
// "COMPILER=gcc-8.3.0": {},
// "ENABLE_BATCH_ATOMIC_WRITE": {},
// "ENABLE_COLUMN_METADATA": {},
// "ENABLE_DBSTAT_VTAB": {},
// ... etc ...
// }
//
// map[string]struct{
// "COMPILER=gcc-8.3.0": {},
// "ENABLE_BATCH_ATOMIC_WRITE": {},
// "ENABLE_COLUMN_METADATA": {},
// "ENABLE_DBSTAT_VTAB": {},
// ... etc ...
// }
func SQLiteCompiledOptions() (map[string]struct{}, error) {
var db, err = sql.Open("sqlite3", ":memory:")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/jgraettinger/urkel v0.1.2
github.com/klauspost/compress v1.13.5
github.com/lib/pq v1.10.2
github.com/mattn/go-sqlite3 v2.0.3+incompatible
github.com/mattn/go-sqlite3 v1.14.24
github.com/olekukonko/tablewriter v0.0.5
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down

0 comments on commit e8ed2ce

Please sign in to comment.