Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to go-based SQLite driver (colin) #128

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func BenchmarkLDBQueryBaseline(b *testing.B) {
defer os.RemoveAll(tmpDir)

ldbPath := filepath.Join(tmpDir, "tmp.db")
localDB, err := sql.Open("sqlite3", ldbPath)
localDB, err := sql.Open("sqlite", ldbPath)
if err != nil {
b.Fatalf("Unexpected error opening LDB: %v", err)
}
Expand Down Expand Up @@ -94,7 +94,7 @@ func BenchmarkGetRowByKey(b *testing.B) {
defer teardown()

ldbPath := filepath.Join(testTmpDir, "tmp.db")
localDB, err := sql.Open("sqlite3", ldbPath)
localDB, err := sql.Open("sqlite", ldbPath)
if err != nil {
b.Fatalf("Unexpected error opening LDB: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion ext_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE family1___table1 (
INSERT INTO family1___table1 VALUES('foo', 'bar');
`
ctx := context.Background()
db, err := sql.Open("sqlite3", ":memory:")
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
t.Fatalf("Unexpected error %+v", err)
}
Expand Down
18 changes: 16 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require (
github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5
github.com/fsnotify/fsnotify v1.5.1
github.com/go-sql-driver/mysql v1.4.1
github.com/google/go-cmp v0.5.8
github.com/google/uuid v1.1.2
github.com/google/go-cmp v0.5.9
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.7.3
github.com/julienschmidt/httprouter v1.2.0
github.com/maxbrunsfeld/counterfeiter/v6 v6.4.1
Expand All @@ -23,6 +23,7 @@ require (
github.com/segmentio/go-sqlite3 v1.12.0
github.com/segmentio/stats/v4 v4.6.2
github.com/stretchr/testify v1.8.1
modernc.org/sqlite v1.26.0
)

require (
Expand All @@ -43,11 +44,15 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.22.0 // indirect
github.com/aws/smithy-go v1.14.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mdlayher/genetlink v0.0.0-20190313224034-60417448a851 // indirect
github.com/mdlayher/netlink v0.0.0-20190313131330-258ea9dff42c // indirect
github.com/mdlayher/taskstats v0.0.0-20190313225729-7cbba52ee072 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e // indirect
github.com/segmentio/go-snakecase v1.1.0 // indirect
github.com/segmentio/objconv v1.0.1 // indirect
Expand All @@ -61,4 +66,13 @@ require (
gopkg.in/validator.v2 v2.0.0-20180514200540-135c24b11c19 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.40.0 // indirect
modernc.org/ccgo/v3 v3.16.13 // indirect
modernc.org/libc v1.24.1 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.6.0 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.1.3 // indirect
modernc.org/token v1.0.1 // indirect
)
43 changes: 40 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ github.com/aws/smithy-go v1.14.2/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
Expand All @@ -62,10 +64,12 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
Expand All @@ -75,9 +79,14 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
github.com/maxbrunsfeld/counterfeiter/v6 v6.4.1 h1:hZD/8vBuw7x1WqRXD/WGjVjipbbo/HcDBgySYYbrUSk=
github.com/maxbrunsfeld/counterfeiter/v6 v6.4.1/go.mod h1:DK1Cjkc0E49ShgRVs5jy5ASrM15svSnem3K/hiSGD8o=
github.com/mdlayher/genetlink v0.0.0-20190313224034-60417448a851 h1:QYJTEbSDJvDBQenHYMxoiBQPgZ4QUcm75vACe3dkW7o=
Expand All @@ -99,6 +108,9 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
github.com/segmentio/cli v0.5.1 h1:Xhtnmp0LrF+JHQTTV4Q58S79gG8JKXO4MMniyqc+XZs=
Expand Down Expand Up @@ -172,6 +184,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down Expand Up @@ -222,3 +235,27 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
lukechampine.com/uint128 v1.2.0 h1:mBi/5l91vocEN8otkC5bDLhi2KdCticRiwbdB0O+rjI=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.40.0 h1:P3g79IUS/93SYhtoeaHW+kRCIrYaxJ27MFPv+7kaTOw=
modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0=
modernc.org/ccgo/v3 v3.16.13 h1:Mkgdzl46i5F/CNR/Kj80Ri59hC8TKAhZrYSaqvkwzUw=
modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY=
modernc.org/ccorpus v1.11.6 h1:J16RXiiqiCgua6+ZvQot4yUuUy8zxgqbqEEUuGPlISk=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/libc v1.24.1 h1:uvJSeCKL/AgzBo2yYIPPTy82v21KgGnizcGYfBHaNuM=
modernc.org/libc v1.24.1/go.mod h1:FmfO1RLrU3MHJfyi9eYYmZBfi/R+tqZ6+hQ3yQQUkak=
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.6.0 h1:i6mzavxrE9a30whzMfwf7XWVODx2r5OYXvU46cirX7o=
modernc.org/memory v1.6.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.26.0 h1:SocQdLRSYlA8W99V8YH0NES75thx19d9sB/aFc4R8Lw=
modernc.org/sqlite v1.26.0/go.mod h1:FL3pVXie73rg3Rii6V/u5BoHlSoyeZeIgKZEgHARyCU=
modernc.org/strutil v1.1.3 h1:fNMm+oJklMGYfU9Ylcywl0CO5O6nTfaowNsh2wpPjzY=
modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
modernc.org/tcl v1.15.2 h1:C4ybAYCGJw968e+Me18oW55kD/FexcHbqH2xak1ROSY=
modernc.org/token v1.0.1 h1:A3qvTqOwexpfZZeyI0FeGPDlSWX5pjZu9hF4lU+EKWg=
modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.7.3 h1:zDJf6iHjrnB+WRD88stbXokugjyc0/pB91ri1gO6LZY=
5 changes: 3 additions & 2 deletions ldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import (
"sync"

"github.com/segmentio/ctlstore/pkg/ldb"
"github.com/segmentio/ctlstore/pkg/sqlite"
_ "modernc.org/sqlite" // gives us sqlite3 everywhere
// "github.com/segmentio/ctlstore/pkg/sqlite"
)

const (
Expand All @@ -31,7 +32,7 @@ func init() {
globalLDBVersioningDirPath = filepath.Join(envPath, defaultLDBVersioningSubdir)
globalCLPath = filepath.Join(envPath, DefaultChangelogFilename)
}
sqlite.InitDriver()
// sqlite.InitDriver()
}

// ReaderForPath opens an LDB at the provided path and returns an LDBReader
Expand Down
8 changes: 4 additions & 4 deletions ldb_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func TestLDBReaderEmptyFileHandling(t *testing.T) {
dbPath, teardown := ldb.NewLDBTmpPath(t)
defer teardown()

db, err := sql.Open("sqlite3", dbPath)
db, err := sql.Open("sqlite", dbPath)
if err != nil {
t.Fatalf("Couldn't open SQLite db, error %v", err)
}
Expand All @@ -415,7 +415,7 @@ func TestLDBReaderEmptyFileHandling(t *testing.T) {
t.Errorf("Expected %v, got %v", want, got)
}

db2, err := sql.Open("sqlite3", dbPath)
db2, err := sql.Open("sqlite", dbPath)
if err != nil {
t.Fatalf("Couldn't open SQLite db, error %v", err)
}
Expand Down Expand Up @@ -454,7 +454,7 @@ func TestLDBReaderPing(t *testing.T) {
dbPath, teardown := ldb.NewLDBTmpPath(t)
defer teardown()

db, err := sql.Open("sqlite3", dbPath)
db, err := sql.Open("sqlite", dbPath)
if err != nil {
t.Fatalf("Couldn't open SQLite db, error %v", err)
}
Expand Down Expand Up @@ -530,7 +530,7 @@ func generateVersionedLDB(t *testing.T, path string, timestamp int64) {
require.NoError(os.Mkdir(dirPath, 0755))

dbPath := filepath.Join(dirPath, "ldb.db")
db, err := sql.Open("sqlite3", dbPath)
db, err := sql.Open("sqlite", dbPath)
require.NoError(err)

// Initialize the ctlstore LDB tables:
Expand Down
4 changes: 2 additions & 2 deletions ldb_testing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestLDBTestUtilCreateTableAndInsertRows(t *testing.T) {

for i, testCase := range suite {
t.Run(fmt.Sprintf("[%d]%s", i, testCase.desc), func(t *testing.T) {
db, err := sql.Open("sqlite3", ":memory:")
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
t.Fatalf("Unexpected error: %+v", err)
}
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestLDBTestUtilCreateTableAndInsertRows(t *testing.T) {
}

func TestLDBTestUtilReset(t *testing.T) {
db, err := sql.Open("sqlite3", ":memory:")
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
t.Fatalf("Unexpected error: %+v", err)
}
Expand Down
37 changes: 37 additions & 0 deletions master.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
goos: darwin
goarch: amd64
pkg: github.com/segmentio/ctlstore
BenchmarkLDBQueryBaseline-8 51636 25530 ns/op
BenchmarkLDBQueryBaseline-8 46780 23614 ns/op
BenchmarkLDBQueryBaseline-8 50294 23006 ns/op
BenchmarkLDBQueryBaseline-8 52845 22155 ns/op
BenchmarkLDBQueryBaseline-8 53202 23052 ns/op
BenchmarkLDBQueryBaseline-8 48765 25969 ns/op
BenchmarkLDBQueryBaseline-8 51561 24321 ns/op
BenchmarkLDBQueryBaseline-8 52063 22644 ns/op
BenchmarkGetRowByKey-8 38980 32249 ns/op
BenchmarkGetRowByKey-8 37669 30814 ns/op
BenchmarkGetRowByKey-8 38571 34997 ns/op
BenchmarkGetRowByKey-8 38233 31320 ns/op
BenchmarkGetRowByKey-8 40298 31642 ns/op
BenchmarkGetRowByKey-8 37394 31976 ns/op
BenchmarkGetRowByKey-8 38244 31664 ns/op
BenchmarkGetRowByKey-8 40040 34356 ns/op
BenchmarkStructGetRowByKey-8 99262 12251 ns/op 1363 B/op 39 allocs/op
BenchmarkStructGetRowByKey-8 93758 12501 ns/op 1364 B/op 39 allocs/op
BenchmarkStructGetRowByKey-8 104388 11313 ns/op 1361 B/op 39 allocs/op
BenchmarkStructGetRowByKey-8 105907 11503 ns/op 1362 B/op 39 allocs/op
BenchmarkStructGetRowByKey-8 104948 11310 ns/op 1366 B/op 39 allocs/op
BenchmarkStructGetRowByKey-8 104775 11313 ns/op 1365 B/op 39 allocs/op
BenchmarkStructGetRowByKey-8 106152 11270 ns/op 1361 B/op 39 allocs/op
BenchmarkStructGetRowByKey-8 107226 11358 ns/op 1366 B/op 39 allocs/op
BenchmarkMapGetRowByKey-8 104768 11621 ns/op 1462 B/op 41 allocs/op
BenchmarkMapGetRowByKey-8 103082 11669 ns/op 1464 B/op 41 allocs/op
BenchmarkMapGetRowByKey-8 103173 11639 ns/op 1466 B/op 41 allocs/op
BenchmarkMapGetRowByKey-8 104032 11611 ns/op 1467 B/op 41 allocs/op
BenchmarkMapGetRowByKey-8 100960 11645 ns/op 1464 B/op 41 allocs/op
BenchmarkMapGetRowByKey-8 103995 11903 ns/op 1465 B/op 41 allocs/op
BenchmarkMapGetRowByKey-8 85936 12531 ns/op 1463 B/op 41 allocs/op
BenchmarkMapGetRowByKey-8 97444 12115 ns/op 1465 B/op 41 allocs/op
PASS
ok github.com/segmentio/ctlstore 50.610s
2 changes: 1 addition & 1 deletion pkg/executive/db_executive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func newCtlDBTestConnection(t *testing.T, dbType string) (*sql.DB, func()) {
schemaUp = testCtlDBSchemaUpForSQLite3
tmpDir, td := tests.WithTmpDir(t)
teardowns.Add(td)
db, err = sql.Open("sqlite3", filepath.Join(tmpDir, "ctldb.db"))
db, err = sql.Open("sqlite", filepath.Join(tmpDir, "ctldb.db"))
default:
t.Fatalf("unknown dbtype %q", dbType)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/executive/db_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/go-sql-driver/mysql"
mysql2 "github.com/segmentio/ctlstore/pkg/mysql"
"github.com/segmentio/ctlstore/pkg/schema"
sqlite2 "github.com/segmentio/ctlstore/pkg/sqlite"
sqlite "github.com/segmentio/go-sqlite3"
// sqlite2 "github.com/segmentio/ctlstore/pkg/sqlite"
// "modernc.org/sqlite"
)

type sqlDBInfo interface {
Expand All @@ -21,8 +21,8 @@ func getDBInfo(db *sql.DB) sqlDBInfo {
switch t := db.Driver().(type) {
case *mysql.MySQLDriver:
return &mysql2.MySQLDBInfo{Db: db}
case *sqlite.SQLiteDriver:
return &sqlite2.SqliteDBInfo{Db: db}
// case *sqlite.SQLiteDriver:
// return &sqlite2.SqliteDBInfo{Db: db}
default:
panic(fmt.Sprintf("Invalid driver type %T", t))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/executive/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"database/sql"
"strings"

_ "github.com/segmentio/go-sqlite3" // gives us sqlite3 everywhere
_ "modernc.org/sqlite" // gives us sqlite3 everywhere
)

// SQLDBClient allows generalizing several database/sql types
Expand Down
2 changes: 1 addition & 1 deletion pkg/executive/test_executive.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewTestExecutiveService(bindTo string) (*TestExecutiveService, error) {
return nil, err
}

db, err := sql.Open("sqlite3", filepath.Join(tmpDir, "ctldb.db"))
db, err := sql.Open("sqlite", filepath.Join(tmpDir, "ctldb.db"))
if err != nil {
return nil, err
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/ldb/ldbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@ func LDBForTest(t testing.TB) (res *sql.DB, teardown func()) {
}

func OpenLDB(path string, mode string) (*sql.DB, error) {
return sql.Open("sqlite3_with_autocheckpoint_off",
// TODO: sqlite3_with_autocheckpoint_off for modernc.org/sqlite
return sql.Open("sqlite",
fmt.Sprintf("file:%s?_journal_mode=wal&mode=%s", path, mode))
}

func OpenImmutableLDB(path string) (*sql.DB, error) {
return sql.Open("sqlite3_with_autocheckpoint_off", fmt.Sprintf("file:%s?immutable=true", path))
// TODO: sqlite3_with_autocheckpoint_off for modernc.org/sqlite
return sql.Open("sqlite", fmt.Sprintf("file:%s?immutable=true", path))
}

// Ensures the LDB is prepared for queries
Expand Down
2 changes: 1 addition & 1 deletion pkg/reflector/dml_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (u *sqlDmlSourceTestUtil) AddStatement(statement string) string {

func TestSqlDmlSource(t *testing.T) {
ctx := context.Background()
db, err := sql.Open("sqlite3", ":memory:")
db, err := sql.Open("sqlite", ":memory:")
require.NoError(t, err)

srcutil := &sqlDmlSourceTestUtil{db: db, t: t}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reflector/pipeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
func TestPipelineIntegration(t *testing.T) {
var err error
ctx := context.Background()
ldb, err := sql.Open("sqlite3", ":memory:")
ldb, err := sql.Open("sqlite", ":memory:")
if err != nil {
t.Fatalf("Couldn't open LDB, error: %+v", err)
}
ctldb, err := sql.Open("sqlite3", ":memory:")
ctldb, err := sql.Open("sqlite", ":memory:")
if err != nil {
t.Fatalf("Couldn't open ctldb, error: %+v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/reflector/reflector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ func TestShovelSequenceReset(t *testing.T) {
emptyLdbPath := filepath.Join(tmpPath, "emptyLdb.db")

upstreamSQL := ctldb.CtlDBSchemaByDriver["sqlite3"]
upstreamDB, err := sql.Open("sqlite3", upstreamDbPath)
upstreamDB, err := sql.Open("sqlite", upstreamDbPath)
require.NoError(t, err)
_, err = upstreamDB.Exec(upstreamSQL)
require.NoError(t, err)

ldbDB, err := sql.Open("sqlite3", emptyLdbPath)
ldbDB, err := sql.Open("sqlite", emptyLdbPath)
require.NoError(t, err)

defer ldbDB.Close()
Expand Down Expand Up @@ -126,7 +126,7 @@ func TestReflector(t *testing.T) {
changelogPath := filepath.Join(tmpPath, "changelog")

emptyLdbPath := filepath.Join(tmpPath, "emptyLdb.db")
ldbDB, err := sql.Open("sqlite3", emptyLdbPath)
ldbDB, err := sql.Open("sqlite", emptyLdbPath)
require.NoError(t, err)

defer ldbDB.Close()
Expand Down Expand Up @@ -158,7 +158,7 @@ func TestReflector(t *testing.T) {
}
ctx, cancel := context.WithCancel(context.Background())

upstreamDb, err := sql.Open("sqlite3", upstreamDbPath)
upstreamDb, err := sql.Open("sqlite", upstreamDbPath)
require.NoError(t, err)
defer upstreamDb.Close()

Expand Down
Loading
Loading