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

Drop fork of go-sqlite3 #7

Merged
merged 3 commits into from Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/pull_requests.yml
Expand Up @@ -19,6 +19,11 @@ jobs:
- run: yarn
- run: yarn fmt
- run: ./scripts/fail_on_diff.sh
# Test examples
- run: go run main.go
working-directory: ./examples/connecthook
- run: go run main.go
working-directory: ./examples/basic

tests-ubuntu:
runs-on: ubuntu-latest
Expand Down
39 changes: 30 additions & 9 deletions README.md
Expand Up @@ -40,20 +40,41 @@ func main() {

fmt.Println(s)
}

```

# go.mod replace

Until https://github.com/mattn/go-sqlite3/pull/1046 is merged you'll
need to add the following to your go.mod:
Alternatively if you want to be able to add your own additional
extensions you can just use the `ConnectHook`:

```go
replace github.com/mattn/go-sqlite3 v1.14.13 => github.com/multiprocessio/go-sqlite3 v1.14.14-0.20220513213203-12637a65d5d7
```
package main

import (
"database/sql"
"fmt"

sqlite3 "github.com/mattn/go-sqlite3"
stdlib "github.com/multiprocessio/go-sqlite3-stdlib"
)

func main() {
sql.Register("sqlite3_ext",
&sqlite3.SQLiteDriver{
ConnectHook: stdlib.ConnectHook,
})
db, err := sql.Open("sqlite3_ext", ":memory:")
if err != nil {
panic(err)
}

This is low-risk because go-sqlite3 changes infrequently. As soon
as that PR is merged though you won't need to do this.
var s string
err = db.QueryRow("SELECT repeat('x', 2)").Scan(&s)
if err != nil {
panic(err)
}

fmt.Println(s)
}
```

# Functions

Expand Down
8 changes: 5 additions & 3 deletions examples/basic/go.mod
Expand Up @@ -2,14 +2,16 @@ module basic

go 1.18

replace github.com/mattn/go-sqlite3 v1.14.13 => github.com/multiprocessio/go-sqlite3 v1.14.14-0.20220513213203-12637a65d5d7
replace github.com/multiprocessio/go-sqlite3-stdlib v0.0.0-20220526202821-009799d2879d => ../../

require (
github.com/mattn/go-sqlite3 v1.14.13
github.com/multiprocessio/go-sqlite3-stdlib v0.0.0-20220515032354-f4fe715d8da1
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6
github.com/multiprocessio/go-sqlite3-stdlib v0.0.0-20220526202821-009799d2879d
)

require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
)
10 changes: 6 additions & 4 deletions examples/basic/go.sum
Expand Up @@ -3,18 +3,20 @@ github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoU
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/multiprocessio/go-sqlite3 v1.14.14-0.20220513213203-12637a65d5d7 h1:1OnwC0UiVssO2YVo/iU1eDXIha/WBXeK/CgFevo35KY=
github.com/multiprocessio/go-sqlite3 v1.14.14-0.20220513213203-12637a65d5d7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/multiprocessio/go-sqlite3-stdlib v0.0.0-20220515032354-f4fe715d8da1 h1:okMm3jc7dYXUz5eDh/FqJV8K25heAJqNAhuIbM4Sj88=
github.com/multiprocessio/go-sqlite3-stdlib v0.0.0-20220515032354-f4fe715d8da1/go.mod h1:CzeoFLGPKRgVlqqdus5LSlsxYWUktye2PJfg68oRPIM=
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6 h1:DrdOuBLZstTLMF5yv/IJhkb7q1cpgIE1b51dLnCznRE=
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
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/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 h1:SLP7Q4Di66FONjDJbCYrCRrh97focO6sLogHO7/g8F0=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 h1:n9HxLrNxWWtEb1cA950nuEEj3QnKbtsCJ6KjcgisNUs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E=
gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
17 changes: 17 additions & 0 deletions examples/connecthook/go.mod
@@ -0,0 +1,17 @@
module connecthook

go 1.18

replace github.com/multiprocessio/go-sqlite3-stdlib v0.0.0-20220526202821-009799d2879d => ../../

require (
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6
github.com/multiprocessio/go-sqlite3-stdlib v0.0.0-20220526202821-009799d2879d
)

require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
)
24 changes: 24 additions & 0 deletions examples/connecthook/go.sum
@@ -0,0 +1,24 @@
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA=
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6 h1:DrdOuBLZstTLMF5yv/IJhkb7q1cpgIE1b51dLnCznRE=
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
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/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898 h1:SLP7Q4Di66FONjDJbCYrCRrh97focO6sLogHO7/g8F0=
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20191002040644-a1355ae1e2c3 h1:n9HxLrNxWWtEb1cA950nuEEj3QnKbtsCJ6KjcgisNUs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gonum.org/v1/gonum v0.11.0 h1:f1IJhK4Km5tBJmaiJXtk/PkL4cdVX6J+tGiM187uT5E=
gonum.org/v1/gonum v0.11.0/go.mod h1:fSG4YDCxxUZQJ7rKsQrj0gMOg00Il0Z96/qMA4bVQhA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
28 changes: 28 additions & 0 deletions examples/connecthook/main.go
@@ -0,0 +1,28 @@
package main

import (
"database/sql"
"fmt"

sqlite3 "github.com/mattn/go-sqlite3"
stdlib "github.com/multiprocessio/go-sqlite3-stdlib"
)

func main() {
sql.Register("sqlite3_ext",
&sqlite3.SQLiteDriver{
ConnectHook: stdlib.ConnectHook,
})
db, err := sql.Open("sqlite3_ext", ":memory:")
if err != nil {
panic(err)
}

var s string
err = db.QueryRow("SELECT repeat('x', 2)").Scan(&s)
if err != nil {
panic(err)
}

fmt.Println(s)
}
4 changes: 1 addition & 3 deletions go.mod
Expand Up @@ -2,11 +2,9 @@ module github.com/multiprocessio/go-sqlite3-stdlib

go 1.18

replace github.com/mattn/go-sqlite3 v1.14.13 => github.com/multiprocessio/go-sqlite3 v1.14.14-0.20220513213203-12637a65d5d7

require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/mattn/go-sqlite3 v1.14.13
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6
github.com/stretchr/testify v1.7.1
golang.org/x/crypto v0.0.0-20220518034528-6f7dac969898
gonum.org/v1/gonum v0.11.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Expand Up @@ -3,8 +3,8 @@ github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoU
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/multiprocessio/go-sqlite3 v1.14.14-0.20220513213203-12637a65d5d7 h1:1OnwC0UiVssO2YVo/iU1eDXIha/WBXeK/CgFevo35KY=
github.com/multiprocessio/go-sqlite3 v1.14.14-0.20220513213203-12637a65d5d7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6 h1:DrdOuBLZstTLMF5yv/IJhkb7q1cpgIE1b51dLnCznRE=
github.com/mattn/go-sqlite3 v1.14.14-0.20220530010643-3ccccfb4c9c6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
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/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
Expand Down