Skip to content

Commit c5dd6c3

Browse files
authored
Merge pull request #563 from GJRTimmer/update/options
Add Additional Features / Options
2 parents 29ac65f + 670bba5 commit c5dd6c3

17 files changed

+184
-95
lines changed

.travis.yml

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,125 +12,79 @@ env:
1212
matrix:
1313
- GOTAGS=
1414
- GOTAGS=libsqlite3
15-
- GOTAGS=trace
16-
- GOTAGS=vtable
15+
- GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth"
16+
- GOTAGS=sqlite_vacuum_full
17+
- GOTAGS=sqlite_vacuum_incr
18+
- GOTAGS=sqlite_vtable
1719

1820
go:
19-
- 1.7.x
2021
- 1.8.x
2122
- 1.9.x
2223
- 1.10.x
23-
- master
2424

2525
matrix:
26-
allow_failures:
27-
- go: master
28-
exclude:
29-
- os: osx
30-
go: 1.7.x
3126
include:
32-
- os: linux
33-
go: 1.7.x
34-
env: GOTAGS= GOOS=windows GOARCH=386
35-
- os: linux
36-
go: 1.7.x
37-
env: GOTAGS= GOOS=windows GOARCH=amd64
38-
- os: linux
39-
go: 1.7.x
40-
env: GOTAGS=libsqlite3 GOOS=windows GOARCH=386
41-
- os: linux
42-
go: 1.7.x
43-
env: GOTAGS=libsqlite3 GOOS=windows GOARCH=amd64
44-
- os: linux
45-
go: 1.7.x
46-
env: GOTAGS=trace GOOS=windows GOARCH=386
47-
- os: linux
48-
go: 1.7.x
49-
env: GOTAGS=trace GOOS=windows GOARCH=amd64
50-
- os: linux
51-
go: 1.7.x
52-
env: GOTAGS=vtable GOOS=windows GOARCH=386
53-
- os: linux
54-
go: 1.7.x
55-
env: GOTAGS=vtable GOOS=windows GOARCH=amd64
56-
- os: linux
57-
go: 1.8.x
58-
env: GOTAGS= GOOS=windows GOARCH=386
5927
- os: linux
6028
go: 1.8.x
6129
env: GOTAGS= GOOS=windows GOARCH=amd64
62-
- os: linux
63-
go: 1.8.x
64-
env: GOTAGS=libsqlite3 GOOS=windows GOARCH=386
6530
- os: linux
6631
go: 1.8.x
6732
env: GOTAGS=libsqlite3 GOOS=windows GOARCH=amd64
6833
- os: linux
6934
go: 1.8.x
70-
env: GOTAGS=trace GOOS=windows GOARCH=386
35+
env: GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth" GOOS=windows GOARCH=amd64
7136
- os: linux
7237
go: 1.8.x
73-
env: GOTAGS=trace GOOS=windows GOARCH=amd64
38+
env: GOTAGS=sqlite_vacuum_full GOOS=windows GOARCH=amd64
7439
- os: linux
7540
go: 1.8.x
76-
env: GOTAGS=vtable GOOS=windows GOARCH=386
41+
env: GOTAGS=sqlite_vacuum_incr GOOS=windows GOARCH=amd64
7742
- os: linux
7843
go: 1.8.x
79-
env: GOTAGS=vtable GOOS=windows GOARCH=amd64
80-
- os: linux
81-
go: 1.9.x
82-
env: GOTAGS= GOOS=windows GOARCH=386
44+
env: GOTAGS=sqlite_vtable GOOS=windows GOARCH=amd64
8345
- os: linux
8446
go: 1.9.x
8547
env: GOTAGS= GOOS=windows GOARCH=amd64
86-
- os: linux
87-
go: 1.9.x
88-
env: GOTAGS=libsqlite3 GOOS=windows GOARCH=386
8948
- os: linux
9049
go: 1.9.x
9150
env: GOTAGS=libsqlite3 GOOS=windows GOARCH=amd64
9251
- os: linux
9352
go: 1.9.x
94-
env: GOTAGS=trace GOOS=windows GOARCH=386
53+
env: GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth" GOOS=windows GOARCH=amd64
9554
- os: linux
9655
go: 1.9.x
97-
env: GOTAGS=trace GOOS=windows GOARCH=amd64
56+
env: GOTAGS=sqlite_vacuum_full GOOS=windows GOARCH=amd64
9857
- os: linux
9958
go: 1.9.x
100-
env: GOTAGS=vtable GOOS=windows GOARCH=386
59+
env: GOTAGS=sqlite_vacuum_incr GOOS=windows GOARCH=amd64
10160
- os: linux
10261
go: 1.9.x
103-
env: GOTAGS=vtable GOOS=windows GOARCH=amd64
104-
- os: linux
105-
go: 1.10.x
106-
env: GOTAGS= GOOS=windows GOARCH=386
62+
env: GOTAGS=sqlite_vtable GOOS=windows GOARCH=amd64
10763
- os: linux
10864
go: 1.10.x
10965
env: GOTAGS= GOOS=windows GOARCH=amd64
110-
- os: linux
111-
go: 1.10.x
112-
env: GOTAGS=libsqlite3 GOOS=windows GOARCH=386
11366
- os: linux
11467
go: 1.10.x
11568
env: GOTAGS=libsqlite3 GOOS=windows GOARCH=amd64
11669
- os: linux
11770
go: 1.10.x
118-
env: GOTAGS=trace GOOS=windows GOARCH=386
71+
env: GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth" GOOS=windows GOARCH=amd64
11972
- os: linux
12073
go: 1.10.x
121-
env: GOTAGS=trace GOOS=windows GOARCH=amd64
74+
env: GOTAGS=sqlite_vacuum_full GOOS=windows GOARCH=amd64
12275
- os: linux
12376
go: 1.10.x
124-
env: GOTAGS=vtable GOOS=windows GOARCH=386
77+
env: GOTAGS=sqlite_vacuum_incr GOOS=windows GOARCH=amd64
12578
- os: linux
12679
go: 1.10.x
127-
env: GOTAGS=vtable GOOS=windows GOARCH=amd64
80+
env: GOTAGS=sqlite_vtable GOOS=windows GOARCH=amd64
12881

12982

13083
before_install:
13184
- |
13285
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
13386
brew update
87+
brew upgrade icu4c
13488
fi
13589
- |
13690
if [[ "${GOOS}" != "windows" ]]; then

README.md

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@ go-sqlite3
66
[![Coverage Status](https://coveralls.io/repos/mattn/go-sqlite3/badge.svg?branch=master)](https://coveralls.io/r/mattn/go-sqlite3?branch=master)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-sqlite3)](https://goreportcard.com/report/github.com/mattn/go-sqlite3)
88

9-
Description
10-
-----------
9+
# Description
1110

1211
sqlite3 driver conforming to the built-in database/sql interface
1312

14-
Installation
15-
------------
13+
### Overview
14+
15+
- [Installation](#installation)
16+
- [API Reference](#api-reference)
17+
- [Features](#features)
18+
- [FAQ](#faq)
19+
- [License](#license)
20+
21+
# Installation
1622

1723
This package can be installed with the go get command:
1824

@@ -22,56 +28,80 @@ _go-sqlite3_ is *cgo* package.
2228
If you want to build your app using go-sqlite3, you need gcc.
2329
However, after you have built and installed _go-sqlite3_ with `go install github.com/mattn/go-sqlite3` (which requires gcc), you can build your app without relying on gcc in future.
2430

25-
Documentation
26-
-------------
31+
# API Reference
2732

2833
API documentation can be found here: http://godoc.org/github.com/mattn/go-sqlite3
2934

30-
Examples can be found under the `./_example` directory
35+
Examples can be found under the [examples](./_example) directory
36+
37+
# Features
38+
39+
This package allows additional configuration of features available within SQLite3 to be enabled or disabled by golang build constraints also known as build `tags`.
3140

32-
FAQ
33-
---
41+
[Click here for more information about build tags / constraints.](https://golang.org/pkg/go/build/#hdr-Build_Constraints)
3442

35-
* Want to build go-sqlite3 with libsqlite3 on my linux.
43+
| Extension | Build Tag | Description |
44+
|-----------|-----------|-------------|
45+
| Additional Statistics | sqlite_stat4 | This option adds additional logic to the ANALYZE command and to the query planner that can help SQLite to chose a better query plan under certain situations. The ANALYZE command is enhanced to collect histogram data from all columns of every index and store that data in the sqlite_stat4 table.<br><br>The query planner will then use the histogram data to help it make better index choices. The downside of this compile-time option is that it violates the query planner stability guarantee making it more difficult to ensure consistent performance in mass-produced applications.<br><br>SQLITE_ENABLE_STAT4 is an enhancement of SQLITE_ENABLE_STAT3. STAT3 only recorded histogram data for the left-most column of each index whereas the STAT4 enhancement records histogram data from all columns of each index.<br><br>The SQLITE_ENABLE_STAT3 compile-time option is a no-op and is ignored if the SQLITE_ENABLE_STAT4 compile-time option is used |
46+
| Allow URI Authority | sqlite_allow_uri_authority | URI filenames normally throws an error if the authority section is not either empty or "localhost".<br><br>However, if SQLite is compiled with the SQLITE_ALLOW_URI_AUTHORITY compile-time option, then the URI is converted into a Uniform Naming Convention (UNC) filename and passed down to the underlying operating system that way |
47+
| App Armor | sqlite_app_armor | When defined, this C-preprocessor macro activates extra code that attempts to detect misuse of the SQLite API, such as passing in NULL pointers to required parameters or using objects after they have been destroyed. <br><br>App Armor is not available under `Windows`. |
48+
| Disable Load Extensions | sqlite_omit_load_extension | Loading of external extensions is enabled by default.<br><br>To disable extension loading add the build tag `sqlite_omit_load_extension`. |
49+
| Foreign Keys | sqlite_foreign_keys | This macro determines whether enforcement of foreign key constraints is enabled or disabled by default for new database connections.<br><br>Each database connection can always turn enforcement of foreign key constraints on and off and run-time using the foreign_keys pragma.<br><br>Enforcement of foreign key constraints is normally off by default, but if this compile-time parameter is set to 1, enforcement of foreign key constraints will be on by default |
50+
| Full Auto Vacuum | sqlite_vacuum_full | Set the default auto vacuum to full |
51+
| Incremental Auto Vacuum | sqlite_vacuum_incr | Set the default auto vacuum to incremental |
52+
| Full Text Search Engine | sqlite_fts5 | When this option is defined in the amalgamation, versions 5 of the full-text search engine (fts5) is added to the build automatically |
53+
| International Components for Unicode | sqlite_icu | This option causes the International Components for Unicode or "ICU" extension to SQLite to be added to the build |
54+
| Introspect PRAGMAS | sqlite_introspect | This option adds some extra PRAGMA statements. <ul><li>PRAGMA function_list</li><li>PRAGMA module_list</li><li>PRAGMA pragma_list</li></ul> |
55+
| JSON SQL Functions | sqlite_json | When this option is defined in the amalgamation, the JSON SQL functions are added to the build automatically |
56+
| Secure Delete | sqlite_secure_delete | This compile-time option changes the default setting of the secure_delete pragma.<br><br>When this option is not used, secure_delete defaults to off. When this option is present, secure_delete defaults to on.<br><br>The secure_delete setting causes deleted content to be overwritten with zeros. There is a small performance penalty since additional I/O must occur.<br><br>On the other hand, secure_delete can prevent fragments of sensitive information from lingering in unused parts of the database file after it has been deleted. See the documentation on the secure_delete pragma for additional information |
57+
| Tracing / Debug | sqlite_trace | Activate trace functions |
58+
59+
# FAQ
60+
61+
- Want to build go-sqlite3 with libsqlite3 on my linux.
3662

3763
Use `go build --tags "libsqlite3 linux"`
3864

39-
* Want to build go-sqlite3 with libsqlite3 on OS X.
65+
- Want to build go-sqlite3 with libsqlite3 on OS X.
4066

4167
Install sqlite3 from homebrew: `brew install sqlite3`
4268

4369
Use `go build --tags "libsqlite3 darwin"`
4470

45-
* Want to build go-sqlite3 with icu extension.
71+
- Want to build go-sqlite3 with additional extensions / features.
72+
73+
Use `go build --tags "<FEATURE>"`
74+
75+
When using multiple build tags, all the different tags should be space delimted.
4676

47-
Use `go build --tags "icu"`
77+
For available features / extensions see [Features](#features).
4878

49-
Available extensions: `json1`, `fts5`, `icu`
79+
Example building multiple features: `go build --tags "icu json1 fts5 secure_delete"`
5080

51-
* Can't build go-sqlite3 on windows 64bit.
81+
- Can't build go-sqlite3 on windows 64bit.
5282

5383
> Probably, you are using go 1.0, go1.0 has a problem when it comes to compiling/linking on windows 64bit.
5484
> See: [#27](https://github.com/mattn/go-sqlite3/issues/27)
5585
56-
* Getting insert error while query is opened.
86+
- Getting insert error while query is opened.
5787

5888
> You can pass some arguments into the connection string, for example, a URI.
5989
> See: [#39](https://github.com/mattn/go-sqlite3/issues/39)
6090
61-
* Do you want to cross compile? mingw on Linux or Mac?
91+
- Do you want to cross compile? mingw on Linux or Mac?
6292

6393
> See: [#106](https://github.com/mattn/go-sqlite3/issues/106)
6494
> See also: http://www.limitlessfx.com/cross-compile-golang-app-for-windows-from-linux.html
6595
66-
* Want to get time.Time with current locale
96+
- Want to get time.Time with current locale
6797

6898
Use `_loc=auto` in SQLite3 filename schema like `file:foo.db?_loc=auto`.
6999

70-
* Can I use this in multiple routines concurrently?
100+
- Can I use this in multiple routines concurrently?
71101

72102
Yes for readonly. But, No for writable. See [#50](https://github.com/mattn/go-sqlite3/issues/50), [#51](https://github.com/mattn/go-sqlite3/issues/51), [#209](https://github.com/mattn/go-sqlite3/issues/209), [#274](https://github.com/mattn/go-sqlite3/issues/274).
73103

74-
* Why is it racy if I use a `sql.Open("sqlite3", ":memory:")` database?
104+
- Why is it racy if I use a `sql.Open("sqlite3", ":memory:")` database?
75105

76106
Each connection to :memory: opens a brand new in-memory sql database, so if
77107
the stdlib's sql engine happens to open another connection and you've only
@@ -80,8 +110,7 @@ FAQ
80110
connection to this string will point to the same in-memory database. See
81111
[#204](https://github.com/mattn/go-sqlite3/issues/204) for more info.
82112

83-
License
84-
-------
113+
# License
85114

86115
MIT: http://mattn.mit-license.org/2012
87116

@@ -91,7 +120,6 @@ The -binding suffix was added to avoid build failures under gccgo.
91120

92121
In this repository, those files are an amalgamation of code that was copied from SQLite3. The license of that code is the same as the license of SQLite3.
93122

94-
Author
95-
------
123+
# Author
96124

97125
Yasuhiro Matsumoto (a.k.a mattn)

sqlite3_opt_allow_uri_authority.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file.
5+
// +build sqlite_allow_uri_authority
6+
7+
package sqlite3
8+
9+
/*
10+
#cgo CFLAGS: -DSQLITE_ALLOW_URI_AUTHORITY
11+
#cgo LDFLAGS: -lm
12+
*/
13+
import "C"

sqlite3_opt_app_armor.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file.
5+
// +build !windows
6+
// +build sqlite_app_armor
7+
8+
package sqlite3
9+
10+
/*
11+
#cgo CFLAGS: -DSQLITE_ENABLE_API_ARMOR
12+
#cgo LDFLAGS: -lm
13+
*/
14+
import "C"

sqlite3_opt_foreign_keys.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file.
5+
// +build sqlite_foreign_keys
6+
7+
package sqlite3
8+
9+
/*
10+
#cgo CFLAGS: -DSQLITE_DEFAULT_FOREIGN_KEYS=1
11+
#cgo LDFLAGS: -lm
12+
*/
13+
import "C"
File renamed without changes.

sqlite3_fts5.go renamed to sqlite3_opt_fts5.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Use of this source code is governed by an MIT-style
44
// license that can be found in the LICENSE file.
5-
// +build fts5
5+
// +build sqlite_fts5 fts5
66

77
package sqlite3
88

sqlite3_opt_icu.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file.
5+
// +build sqlite_icu icu
6+
7+
package sqlite3
8+
9+
/*
10+
#cgo LDFLAGS: -licuuc -licui18n
11+
#cgo CFLAGS: -DSQLITE_ENABLE_ICU
12+
#cgo darwin CFLAGS: -I/usr/local/opt/icu4c/include
13+
#cgo darwin LDFLAGS: -L/usr/local/opt/icu4c/lib
14+
*/
15+
import "C"

sqlite3_opt_introspect.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (C) 2014 Yasuhiro Matsumoto <[email protected]>.
2+
//
3+
// Use of this source code is governed by an MIT-style
4+
// license that can be found in the LICENSE file.
5+
// +build sqlite_introspect
6+
7+
package sqlite3
8+
9+
/*
10+
#cgo CFLAGS: -DSQLITE_INTROSPECTION_PRAGMAS
11+
#cgo LDFLAGS: -lm
12+
*/
13+
import "C"

sqlite3_json1.go renamed to sqlite3_opt_json1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Use of this source code is governed by an MIT-style
44
// license that can be found in the LICENSE file.
5-
// +build json1
5+
// +build sqlite_json sqlite_json1 json1
66

77
package sqlite3
88

0 commit comments

Comments
 (0)