Commit e662a135 authored by cznic's avatar cznic

release 1.4.0

parent 43c865ce
......@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
.PHONY: all clean cover cpu editor internalError later mem nuke todo edit tcl
.PHONY: all clean cover cpu editor internalError later mem nuke todo edit tcl extraquick full
grep=--include=*.go --include=*.l --include=*.y --include=*.yy
ngrep='TODOOK\|internal\/vfs\|internal\/bin\|internal\/mptest\|.*stringer.*\.go'
......@@ -13,24 +13,31 @@ all: editor
./unconvert.sh
gofmt -l -s -w *.go
go test -i
go test 2>&1 -timeout 1h | tee -a log
#TODO GOOS=linux GOARCH=arm go build
#TODO GOOS=linux GOARCH=arm64 go build
#TODO GOOS=linux GOARCH=386 go build
GOOS=linux GOARCH=amd64 go build
#TODO GOOS=windows GOARCH=386 go build
#TODO GOOS=windows GOARCH=amd64 go build
go vet 2>&1 | grep -v $(ngrep) || true
go test -v 2>&1 -timeout 1h | tee -a log
go run speedtest1/main_$(shell go env GOOS)_$(shell go env GOARCH).go
#TODO GOOS=linux GOARCH=arm go build -v ./...
#TODO GOOS=linux GOARCH=arm64 go build -v ./...
#TODO GOOS=linux GOARCH=386 go build -v ./...
GOOS=linux GOARCH=amd64 go build -v ./...
#TODO GOOS=windows GOARCH=386 go build -v ./...
#TODO GOOS=windows GOARCH=amd64 go build -v ./...
golint 2>&1 | grep -v $(ngrep) || true
make todo
misspell *.go
staticcheck | grep -v 'lexer\.go\|parser\.go' || true
staticcheck || true
maligned || true
git diff --unified=0 testdata *.golden
grep -n 'FAIL\|PASS' log
go version
date 2>&1 | tee -a log
extraquick:
go test -timeout 24h -v -run Tcl -suite extraquick -maxerror 1 2>&1 | tee log-extraquick
date
full:
go test -timeout 24h -v -run Tcl -suite full 2>&1 | tee log-full
date
clean:
go clean
rm -f *~ *.test *.out test.db* tt4-test*.db* test_sv.* testdb-*
......
# sqlite
Package sqlite is an in-process implementation of a self-contained, serverless, zero-configuration, transactional SQL database engine. (Work In Progress)
Package sqlite is an in-process implementation of a self-contained, serverless, zero-configuration, transactional SQL database engine.
Installation
......
......@@ -21,13 +21,10 @@ import (
"strconv"
"strings"
"sync"
"sync/atomic"
"testing"
"time"
"modernc.org/mathutil"
"modernc.org/sqlite/internal/testfixture"
"modernc.org/tcl"
)
func caller(s string, va ...interface{}) {
......@@ -55,54 +52,63 @@ func dbg(s string, va ...interface{}) {
os.Stderr.Sync()
}
var traceLevel int32
func stack() string { return string(debug.Stack()) }
func trace() func() {
return func() {}
n := atomic.AddInt32(&traceLevel, 1)
pc, file, line, _ := runtime.Caller(1)
s := strings.Repeat("· ", int(n)-1)
fn := runtime.FuncForPC(pc)
fmt.Fprintf(os.Stderr, "%s# trace %s:%d:%s: in\n", s, path.Base(file), line, fn.Name())
os.Stderr.Sync()
return func() {
atomic.AddInt32(&traceLevel, -1)
fmt.Fprintf(os.Stderr, "%s# trace %s:%d:%s: out\n", s, path.Base(file), line, fn.Name())
os.Stderr.Sync()
}
}
func use(...interface{}) {}
func TODO(...interface{}) string { //TODOOK
_, fn, fl, _ := runtime.Caller(1)
return fmt.Sprintf("# TODO: %s:%d:\n", path.Base(fn), fl) //TODOOK
func init() {
use(caller, dbg, stack, todo, trc) //TODOOK
}
func stack() string { return string(debug.Stack()) }
func origin(skip int) string {
pc, fn, fl, _ := runtime.Caller(skip)
f := runtime.FuncForPC(pc)
var fns string
if f != nil {
fns = f.Name()
if x := strings.LastIndex(fns, "."); x > 0 {
fns = fns[x+1:]
}
}
return fmt.Sprintf("%s:%d:%s", fn, fl, fns)
}
func use(...interface{}) {}
func todo(s string, args ...interface{}) string { //TODO-
switch {
case s == "":
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
default:
s = fmt.Sprintf(s, args...)
}
r := fmt.Sprintf("%s: TODOTODO %s", origin(2), s) //TODOOK
fmt.Fprintf(os.Stdout, "%s\n", r)
os.Stdout.Sync()
return r
}
func init() {
use(caller, dbg, TODO, trace, stack) //TODOOK
func trc(s string, args ...interface{}) string { //TODO-
switch {
case s == "":
s = fmt.Sprintf(strings.Repeat("%v ", len(args)), args...)
default:
s = fmt.Sprintf(s, args...)
}
r := fmt.Sprintf("\n%s: TRC %s", origin(2), s)
fmt.Fprintf(os.Stdout, "%s\n", r)
os.Stdout.Sync()
return r
}
// ============================================================================
var (
oMaxError = flag.Uint("maxerror", 0, "argument of -maxerror passed to the Tcl test suite")
oStart = flag.String("start", "", "argument of -start passed to the Tcl test suite (--start=[$permutation:]$testfile)")
oTcl = flag.Bool("tcl", true, "enable Tcl tests")
oVerbose = flag.String("verbose", "0", "argument of -verbose passed to the Tcl test suite, must be set to a boolean (0, 1) or to \"file\"")
oRecsPerSec = flag.Bool("recs_per_sec_as_mbps", false, "Show records per second as MB/s.")
oXTags = flag.String("xtags", "", "passed to go build of testfixture in TestTclTest")
)
func TestMain(m *testing.M) {
oTestFixture := flag.Bool("testfixture", false, "emulate running the testfixture binary produced by sqlite3 '$ make tcltest'")
flag.Parse()
if !*oTestFixture {
os.Exit(m.Run())
}
tclTestMain()
os.Exit(m.Run())
}
func tempDB(t testing.TB) (string, *sql.DB) {
......@@ -527,7 +533,12 @@ func TestConcurrentProcesses(t *testing.T) {
}
}
out, err := exec.Command("go", "build", "-o", filepath.Join(dir, "mptest"), "modernc.org/sqlite/internal/mptest").CombinedOutput()
args := []string{"build", "-o", filepath.Join(dir, "mptest")}
if s := *oXTags; s != "" {
args = append(args, "-tags", s)
}
args = append(args, "modernc.org/sqlite/internal/mptest")
out, err := exec.Command("go", args...).CombinedOutput()
if err != nil {
t.Fatalf("%s\n%v", out, err)
}
......@@ -786,153 +797,3 @@ func TestNoRows(t *testing.T) {
t.Fatal(err)
}
}
func TestTclTest(t *testing.T) {
if !*oTcl {
t.Skip("Not enabled")
}
blacklist := []string{
//TODO crashers
"misc1.test",
"quota2.test",
"zipfile.test",
//TODO needs fork
"exists.test",
"multiplex2.test",
"pager1.test",
"rowallock.test",
"savepoint.test",
"schema3.test",
"shared2.test",
"superlock.test",
"syscall.test",
"tkt-5d863f876e.test",
"tkt-fc62af4523.test",
"unixexcl.test",
"wal.test",
"wal5.test",
"walro.test",
"walro2.test",
"walsetlk.test",
//TODO exits tests
"index.test",
//TODO OOM
"csv01.test",
}
if testing.Short() {
blacklist = append(blacklist, []string{
"altermalloc.test",
"altermalloc2.test",
"attachmalloc.test",
"backup_ioerr.test",
"backup_malloc.test",
"corruptC.test",
"e_walckpt.test",
"fkey_malloc.test",
"fuzz.test",
"fuzz3.test",
"incrvacuum_ioerr.test",
"pagerfault2.test",
"savepoint6.test",
"savepointfault.test",
"securedel2.test",
"shared_err.test",
"sort3.test",
"tempfault.test",
"vacuum3.test",
"vtab_err.test",
"walprotocol.test",
}...)
}
m, err := filepath.Glob(filepath.FromSlash("testdata/tcl/*"))
if err != nil {
t.Fatal(err)
}
dir, err := ioutil.TempDir("", "sqlite-test-")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
wd, err := os.Getwd()
if err != nil {
t.Fatal(err)
}
defer os.Chdir(wd)
if err := os.Chdir(dir); err != nil {
t.Fatal(err)
}
blacklisted := map[string]struct{}{}
for _, v := range blacklist {
blacklisted[v] = struct{}{}
}
for _, v := range m {
if _, ok := blacklisted[filepath.Base(v)]; ok {
continue
}
s := filepath.Join(wd, v)
d := filepath.Join(dir, filepath.Base(v))
f, err := ioutil.ReadFile(s)
if err != nil {
t.Fatal(err)
}
if err := ioutil.WriteFile(d, f, 0660); err != nil {
t.Fatal(err)
}
}
library := filepath.Join(dir, "library")
if err := tcl.Library(library); err != nil {
t.Fatal(err)
}
os.Setenv("TCL_LIBRARY", library)
//TODO f, err := os.Create(filepath.Join(wd, "testdata", filepath.Join("testdata", fmt.Sprintf("testfixture_%s_%s.golden", runtime.GOOS, runtime.GOARCH))))
//TODO if err != nil {
//TODO t.Fatal(err)
//TODO }
//TODO defer f.Close()
//TODO args := []string{"-testfixture", "all.test"}
args := []string{"-testfixture", "permutations.test", "extraquick"}
if *oVerbose != "" {
args = append(args, fmt.Sprintf("-verbose=%s", *oVerbose))
}
if *oMaxError != 0 {
args = append(args, fmt.Sprintf("-maxerror=%d", *oMaxError))
}
if *oStart != "" {
args = append(args, fmt.Sprintf("-start=%s", *oStart))
}
cmd := exec.Command(os.Args[0], args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
t.Fatal(err)
}
}
func tclTestMain() {
var argv []string
for _, v := range os.Args {
if !strings.HasPrefix(v, "-test.") && v != "-testfixture" {
argv = append(argv, v)
}
}
os.Args = argv
fmt.Printf("testfixture %q\n", os.Args)
testfixture.Main()
panic("unreachable")
}
......@@ -3,10 +3,31 @@
// license that can be found in the LICENSE file.
// Package sqlite is an in-process implementation of a self-contained,
// serverless, zero-configuration, transactional SQL database engine. (Work In Progress)
// serverless, zero-configuration, transactional SQL database engine.
//
// Changelog
//
// 2020-08-26 v1.4.0:
//
// First stable release for linux/amd64. The database/sql driver and its tests
// are CGo free. Tests of the translated sqlite3.c library still require CGo.
//
// $ make full
//
// ...
//
// SQLite 2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f
// 0 errors out of 928271 tests on 3900x Linux 64-bit little-endian
// WARNING: Multi-threaded tests skipped: Linked against a non-threadsafe Tcl build
// All memory allocations freed - no leaks
// Maximum memory usage: 9156360 bytes
// Current memory usage: 0 bytes
// Number of malloc() : -1 calls
// --- PASS: TestTclTest (1785.04s)
// PASS
// ok modernc.org/sqlite 1785.041s
// $
//
// 2020-07-26 v1.4.0-beta1:
//
// The project has reached beta status while supporting linux/amd64 only at the
......@@ -56,9 +77,10 @@
//
// ...
//
//
// Supported platforms and architectures
//
// These combinations of GOOS and GOARCH are currently supported
//
// linux amd64
//
// Planned platforms and architectures
......@@ -69,6 +91,21 @@
// windows 386
// windows amd64
//
// Debug and development versions
//
// A comma separated list of options can be passed to `go generate` via the
// environment variable GO_GENERATE. Some useful options include for example:
//
// -DSQLITE_DEBUG
// -DSQLITE_MEM_DEBUG
// -ccgo-verify-structs
//
// To create a debug/development version, issue for example:
//
// $ GO_GENERATE=-DSQLITE_DEBUG,-DSQLITE_MEM_DEBUG go generate
//
// Note: To run `go generate` you need to have modernc.org/ccgo/v3 installed.
//
// Sqlite documentation
//
// See https://sqlite.org/docs.html
......
This diff is collapsed.
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237 h1:HQagqIiBmr8YXawX/le3+O26N+vPPC1PtjaF3mwnook=
github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
modernc.org/cc/v3 v3.23.0/go.mod h1:NZ//ji5AVKCoutHdl35YtsWflZrIWMQAMgDtmKq2eyA=
modernc.org/crt/v3 v3.25.0 h1:bWKB9DcoobH2zFENYzyIiRHkGx7aVpan3S/6FHIyUCU=
modernc.org/crt/v3 v3.25.0/go.mod h1:9MujA+beChvPpq95k1rjNyLndmCbDO6Ei8QTcdUb5gI=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6 h1:DvY3Zkh7KabQE/kfzMvYvKirSiguP9Q/veMtkYyf0o8=
golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
modernc.org/httpfs v1.0.0 h1:LtuKNg6JMiaBKVQHKd6Phhvk+2GFp+pUcmDQgRjrds0=
modernc.org/httpfs v1.0.0/go.mod h1:BSkfoMUcahSijQD5J/Vu4UMOxzmEf5SNRwyXC4PJBEw=
modernc.org/mathutil v1.0.0 h1:93vKjrJopTPrtTNpZ8XIovER7iCIH1QU7wNbOQXC60I=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
modernc.org/libc v1.0.0 h1:MgQgjhJDgugN7makTrP2K503x+vKBy0EIv1o8uSuG0k=
modernc.org/libc v1.0.0/go.mod h1:iulSAj8W71uuiT8V3cOzJfRvrhNMz2kawtuJy18EEE4=
modernc.org/mathutil v1.1.1 h1:FeylZSVX8S+58VsyJlkEj2bcpdytmp9MmDKZkKx8OIE=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.0.0 h1:Tm1p6vBp/U/SGR9/EeFhMvGzaVpUWeePopZhhIpW2YE=
modernc.org/memory v1.0.0/go.mod h1:TXr4iJDvK3g0hW+sV+Kohu7BoeHfqw7QEFZWkBExdZc=
modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/tcl v1.0.3-beta1 h1:SH2ETLWydXIPvEFNcFZGF+Nkf1fHlWkBmrj1AwdjiWY=
modernc.org/tcl v1.0.3-beta1/go.mod h1:yJlqAkS0OyMvXS7Ro8tZ07QXxyjVm8tGz0FmU1xYxFk=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/tcl v1.1.0 h1:rOb4Dtcf0aidHBu8Ctz3FkW+PQpgCrChEIQ9+LUPst0=
modernc.org/tcl v1.1.0/go.mod h1:8qvhdwj80wWqMugFAW2sduRIsdWBKOmxu+VwCXfE1X4=
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package crt2 // import "modernc.org/sqlite/internal/crt2"
package libc2 // import "modernc.org/sqlite/internal/libc2"
import (
"fmt"
......
......@@ -2,11 +2,9 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package crt2 // import "modernc.org/sqlite/internal/crt2"
package libc2 // import "modernc.org/sqlite/internal/libc2"
var CAPI = map[string]struct{}{
"ferror": {},
"fstat": {},
"pthread_cond_broadcast": {},
"pthread_cond_destroy": {},
"pthread_cond_init": {},
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package crt2 // import "modernc.org/sqlite/internal/crt2"
package libc2 // import "modernc.org/sqlite/internal/libc2"
import (
"fmt"
......@@ -10,7 +10,8 @@ import (
"runtime"
"strings"
"modernc.org/crt/v3"
"modernc.org/libc"
"modernc.org/libc/sys/types"
)
func todo(s string, args ...interface{}) string { //TODO-
......@@ -50,81 +51,66 @@ func trc(s string, args ...interface{}) string { //TODO-
}
// int sched_yield(void);
func Xsched_yield(tls *crt.TLS) int32 {
func Xsched_yield(tls *libc.TLS) int32 {
panic(todo(""))
}
// int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg);
func Xpthread_create(tls *crt.TLS, thread, attr, start_routine, arg uintptr) int32 {
func Xpthread_create(tls *libc.TLS, thread, attr, start_routine, arg uintptr) int32 {
panic(todo(""))
}
// int pthread_detach(pthread_t thread);
func Xpthread_detach(tls *crt.TLS, thread crt.Size_t) int32 {
func Xpthread_detach(tls *libc.TLS, thread types.Size_t) int32 {
panic(todo(""))
}
// int ferror(FILE *stream);
func Xferror(tls *crt.TLS, stream uintptr) int32 {
panic(todo(""))
}
// int fstat(int fd, struct stat *statbuf);
func Xfstat(tls *crt.TLS, fd int32, statbuf uintptr) int32 {
panic(todo(""))
}
// // int rename(const char *oldpath, const char *newpath);
// func Xrename(tls *crt.TLS, oldpath, newpath uintptr) int32 {
// panic(todo(""))
// }
// int pthread_mutex_lock(pthread_mutex_t *mutex);
func Xpthread_mutex_lock(tls *crt.TLS, mutex uintptr) int32 {
func Xpthread_mutex_lock(tls *libc.TLS, mutex uintptr) int32 {
panic(todo(""))
}
// int pthread_cond_signal(pthread_cond_t *cond);
func Xpthread_cond_signal(tls *crt.TLS, cond uintptr) int32 {
func Xpthread_cond_signal(tls *libc.TLS, cond uintptr) int32 {
panic(todo(""))
}
// int pthread_mutex_unlock(pthread_mutex_t *mutex);
func Xpthread_mutex_unlock(tls *crt.TLS, mutex uintptr) int32 {
func Xpthread_mutex_unlock(tls *libc.TLS, mutex uintptr) int32 {
panic(todo(""))
}
// int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr);
func Xpthread_mutex_init(tls *crt.TLS, mutex, attr uintptr) int32 {
func Xpthread_mutex_init(tls *libc.TLS, mutex, attr uintptr) int32 {
panic(todo(""))
}
// int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr);
func Xpthread_cond_init(tls *crt.TLS, cond, attr uintptr) int32 {
func Xpthread_cond_init(tls *libc.TLS, cond, attr uintptr) int32 {
panic(todo(""))
}
// int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex);
func Xpthread_cond_wait(tls *crt.TLS, cond, mutex uintptr) int32 {
func Xpthread_cond_wait(tls *libc.TLS, cond, mutex uintptr) int32 {
panic(todo(""))
}
// int pthread_cond_destroy(pthread_cond_t *cond);
func Xpthread_cond_destroy(tls *crt.TLS, cond uintptr) int32 {
func Xpthread_cond_destroy(tls *libc.TLS, cond uintptr) int32 {
panic(todo(""))
}
// int pthread_mutex_destroy(pthread_mutex_t *mutex);
func Xpthread_mutex_destroy(tls *crt.TLS, mutex uintptr) int32 {
func Xpthread_mutex_destroy(tls *libc.TLS, mutex uintptr) int32 {
panic(todo(""))
}
// int pthread_mutex_trylock(pthread_mutex_t *mutex);
func Xpthread_mutex_trylock(tls *crt.TLS, mutex uintptr) int32 {
func Xpthread_mutex_trylock(tls *libc.TLS, mutex uintptr) int32 {
panic(todo(""))
}
// int pthread_cond_broadcast(pthread_cond_t *cond);
func Xpthread_cond_broadcast(tls *crt.TLS, cond uintptr) int32 {