Skip to content

Commit 8eb68fb

Browse files
committed
Updated
1 parent a5c99af commit 8eb68fb

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

pkg/sqlite3/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,25 @@ for more information.
1111

1212
This module does not include a full
1313
copy of __sqlite__ as part of the build process, but expect a `pkgconfig`
14-
file called `sqlite.pc` to be present (and an existing set of header
14+
file called `sqlite3.pc` to be present (and an existing set of header
1515
files and libraries to be available to link against, of course).
1616

1717
In order to locate the __pkgconfig__ file in a non-standard location, use
18-
the `PKG_CONFIG_PATH` environment variable. For example, I have installed
19-
sqlite using `brew install sqlite` and this is how I run the tests:
18+
two environment variables:
19+
20+
* `PKG_CONFIG_PATH` is used for locating `sqlite3.pc`
21+
* `DYLD_LIBRARY_PATH` is used for locating the dynamic library when testing and/or running
22+
23+
On Macintosh with homebrew:
24+
sqlite using `` and this is how I run the tests:
2025

2126
```bash
27+
[bash] brew install sqlite3
2228
[bash] git clone git@github.com:djthorpe/go-sqlite.git
2329
[bash] cd go-sqlite
2430
[bash] go mod tidy
25-
[bash] PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig" go test -v ./pkg/sqlite3
31+
[bash] SQLITE_LIB="/usr/local/opt/sqlite/lib"
32+
[bash] PKG_CONFIG_PATH="${SQLITE_LIB}/pkgconfig" DYLD_LIBRARY_PATH="${SQLITE_LIB}" go test -v ./pkg/sqlite3
2633
```
2734

2835
There are some examples in the `cmd` folder of the main repository on how to use

pkg/sqlite3/pool.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ func (p *Pool) new() (*Conn, error) {
232232
return nil, ErrNotFound.Withf("No default schema %q found", defaultSchema)
233233
}
234234

235-
// Always allow memory databases to be created
235+
// Always allow memory databases to be created and read/write
236236
flags := p.Flags
237237
if defaultPath == defaultMemory {
238-
flags |= sqlite3.SQLITE_OPEN_CREATE
238+
flags |= (sqlite3.SQLITE_OPEN_CREATE | sqlite3.SQLITE_OPEN_READWRITE)
239239
}
240240

241241
// Perform the open

plugin/sqlite3/handlers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
type PingResponse struct {
3030
Version string `json:"version"`
31+
Modules []string `json:"modules"`
3132
Schemas []string `json:"schemas"`
3233
Pool PoolResponse `json:"pool"`
3334
}
@@ -123,9 +124,11 @@ func (p *plugin) ServePing(w http.ResponseWriter, req *http.Request) {
123124
// Populate response
124125
response := PingResponse{
125126
Schemas: []string{},
127+
Modules: []string{},
126128
}
127129
response.Version = sqlite3.Version()
128130
response.Schemas = append(response.Schemas, conn.Schemas()...)
131+
response.Modules = append(response.Schemas, conn.Modules()...)
129132
response.Pool = PoolResponse{Cur: p.Cur(), Max: p.Max()}
130133

131134
// Serve response

sys/sqlite3/connex.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import "C"
5151

5252
import (
5353
"errors"
54-
"fmt"
5554
"reflect"
5655
"sync"
5756
"time"
@@ -504,7 +503,6 @@ func go_authorizer_hook(userInfo unsafe.Pointer, op C.int, a1, a2, a3, a4 *C.cha
504503

505504
//export go_exec_handler
506505
func go_exec_handler(userInfo unsafe.Pointer, nargs C.int, row, cols **C.char) C.int {
507-
fmt.Println("nargs=", nargs, "row=", row, "cols=", cols)
508506
if c := cb.get(uintptr(userInfo)); c != nil && c.ExecFunc != nil {
509507
return C.int(boolToInt(c.ExecFunc(go_string_slice(int(nargs), row), go_string_slice(int(nargs), cols))))
510508
} else {

0 commit comments

Comments
 (0)