#136: Start working on database persistence

This commit is contained in:
TwinProduction
2021-07-12 00:56:30 -04:00
committed by Chris
parent e6335da94f
commit bd1eb7c61b
657 changed files with 2190821 additions and 82 deletions

17
vendor/modernc.org/sqlite/AUTHORS generated vendored Normal file
View File

@ -0,0 +1,17 @@
# This file lists authors for copyright purposes. This file is distinct from
# the CONTRIBUTORS files. See the latter for an explanation.
#
# Names should be added to this file as:
# Name or Organization <email address>
#
# The email address is not required for organizations.
#
# Please keep the list sorted.
Dan Peterson <danp@danp.net>
Davsk Ltd Co <skinner.david@gmail.com>
Jaap Aarts <jaap.aarts1@gmail.com>
Jan Mercl <0xjnml@gmail.com>
Ross Light <ross@zombiezen.com>
Steffen Butzer <steffen(dot)butzer@outlook.com>
Saed SayedAhmed <saadmtsa@gmail.com>

17
vendor/modernc.org/sqlite/CONTRIBUTORS generated vendored Normal file
View File

@ -0,0 +1,17 @@
# This file lists people who contributed code to this repository. The AUTHORS
# file lists the copyright holders; this file lists people.
#
# Names should be added to this file like so:
# Name <email address>
#
# Please keep the list sorted.
Alexander Menzhinsky <amenzhinsky@gmail.com>
Dan Peterson <danp@danp.net>
David Skinner <skinner.david@gmail.com>
Jaap Aarts <jaap.aarts1@gmail.com>
Jan Mercl <0xjnml@gmail.com>
Ross Light <ross@zombiezen.com>
Steffen Butzer <steffen(dot)butzer@outlook.com>
Yaacov Akiba Slama <ya@slamail.org>
Saed SayedAhmed <saadmtsa@gmail.com>

26
vendor/modernc.org/sqlite/LICENSE generated vendored Normal file
View File

@ -0,0 +1,26 @@
Copyright (c) 2017 The Sqlite Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

193
vendor/modernc.org/sqlite/Makefile generated vendored Normal file
View File

@ -0,0 +1,193 @@
# Copyright 2017 The Sqlite Authors. All rights reserved.
# 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 extraquick full
grep=--include=*.go --include=*.l --include=*.y --include=*.yy
ngrep='TODOOK\|internal\/vfs\|internal\/bin\|internal\/mptest\|.*stringer.*\.go'
host=$(shell go env GOOS)-$(shell go env GOARCH)
testlog=testdata/testlog-$(shell echo $$GOOS)-$(shell echo $$GOARCH)$(shell echo $$SQLITE_TEST_SUFFIX)
all: editor
date
go version 2>&1 | tee log
./unconvert.sh
gofmt -l -s -w *.go
go test -i
go test -v 2>&1 -timeout 24h | tee -a log
go run speedtest1/main_$(shell go env GOOS)_$(shell go env GOARCH).go
GOOS=linux GOARCH=386 go build -v ./...
GOOS=linux GOARCH=386 go build -v ./...
GOOS=linux GOARCH=amd64 go build -v ./...
GOOS=linux GOARCH=amd64 go build -v ./...
GOOS=linux GOARCH=arm go build -v ./...
GOOS=linux GOARCH=arm64 go build -v ./...
GOOS=windows GOARCH=386 go build -v ./...
GOOS=windows GOARCH=amd64 go build -v ./...
golint 2>&1 | grep -v $(ngrep) || true
misspell *.go
staticcheck || true
maligned || true
git diff --unified=0 testdata *.golden
grep -n --color=always 'FAIL\|PASS' log
go version
date 2>&1 | tee -a log
build_all_targets:
GOOS=darwin GOARCH=amd64 go build -v ./...
GOOS=darwin GOARCH=arm64 go build -v ./...
GOOS=linux GOARCH=386 go build -v ./...
GOOS=linux GOARCH=amd64 go build -v ./...
GOOS=linux GOARCH=arm go build -v ./...
GOOS=linux GOARCH=arm64 go build -v ./...
#TODO GOOS=linux GOARCH=s390x go build -v ./...
GOOS=windows GOARCH=386 go build -v ./...
GOOS=windows GOARCH=amd64 go build -v ./...
echo done
darwin_amd64:
TARGET_GOOS=darwin TARGET_GOARCH=amd64 go generate 2>&1 | tee /tmp/log-generate-sqlite-darwin-amd64
GOOS=darwin GOARCH=amd64 go build -v ./...
darwin_arm64:
TARGET_GOOS=darwin TARGET_GOARCH=arm64 go generate 2>&1 | tee /tmp/log-generate-sqlite-darwin-arm64
GOOS=darwin GOARCH=arm64 go build -v ./...
linux_amd64:
TARGET_GOOS=linux TARGET_GOARCH=amd64 go generate 2>&1 | tee /tmp/log-generate-sqlite-linux-amd64
GOOS=linux GOARCH=amd64 go build -v ./...
linux_386:
CCGO_CPP=i686-linux-gnu-cpp TARGET_GOARCH=386 TARGET_GOOS=linux go generate 2>&1 | tee /tmp/log-generate-sqlite-linux-386
GOOS=linux GOARCH=386 go build -v ./...
linux_arm:
CCGO_CPP=arm-linux-gnueabi-cpp-8 TARGET_GOARCH=arm TARGET_GOOS=linux go generate 2>&1 | tee /tmp/log-generate-sqlite-linux-arm
GOOS=linux GOARCH=arm go build -v ./...
linux_arm64:
CCGO_CPP=aarch64-linux-gnu-cpp-8 TARGET_GOARCH=arm64 TARGET_GOOS=linux go generate 2>&1 | tee /tmp/log-generate-sqlite-linux-arm64
GOOS=linux GOARCH=arm64 go build -v ./...
linux_s390x:
CCGO_CPP=s390x-linux-gnu-cpp TARGET_GOARCH=s390x TARGET_GOOS=linux go generate 2>&1 | tee /tmp/log-generate-sqlite-linux-s390x
GOOS=linux GOARCH=s390x go build -v ./...
windows_amd64:
CCGO_CPP=x86_64-w64-mingw32-cpp TARGET_GOOS=windows TARGET_GOARCH=amd64 go generate 2>&1 | tee /tmp/log-generate-sqlite-windows-amd64
GOOS=windows GOARCH=amd64 go build -v ./...
windows_386:
CCGO_CPP=i686-w64-mingw32-cpp TARGET_GOOS=windows TARGET_GOARCH=386 go generate 2>&1 | tee /tmp/log-generate-sqlite-windows-386
GOOS=windows GOARCH=386 go build -v ./...
all_targets: linux_amd64 linux_386 linux_arm linux_arm64 linux_s390x windows_amd64 windows_386
gofmt -l -s -w .
echo done
test:
go version | tee $(testlog)
uname -a | tee -a $(testlog)
go test -v -timeout 24h | tee -a $(testlog)
grep -ni fail $(testlog) | tee -a $(testlog) || true
LC_ALL=C date | tee -a $(testlog)
grep -ni --color=always fail $(testlog) || true
test_darwin_amd64:
GOOS=darwin GOARCH=amd64 make test
test_darwin_arm64:
GOOS=darwin GOARCH=arm64 make test
test_linux_amd64:
GOOS=linux GOARCH=amd64 make test
test_linux_386:
GOOS=linux GOARCH=386 make test
test_linux_386_hosted:
GOOS=linux GOARCH=386 SQLITE_TEST_SUFFIX=-hosted-$(host) make test
test_linux_arm:
GOOS=linux GOARCH=arm make test
test_linux_arm64:
GOOS=linux GOARCH=arm64 make test
test_linux_s390x:
GOOS=linux GOARCH=s390x make test
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-*
cover:
t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t
cpu: clean
go test -run @ -bench . -cpuprofile cpu.out
go tool pprof -lines *.test cpu.out
edit:
@touch log
@if [ -f "Session.vim" ]; then gvim -S & else gvim -p Makefile *.go & fi
editor:
gofmt -l -s -w *.go
GO111MODULE=off go install -v ./...
internalError:
egrep -ho '"internal error.*"' *.go | sort | cat -n
later:
@grep -n $(grep) LATER * || true
@grep -n $(grep) MAYBE * || true
mem: clean
go test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h
go tool pprof -lines -web -alloc_space *.test mem.out
memgrind:
go test -v -timeout 24h -tags libc.memgrind,cgobench -bench . -suite extraquick -xtags=libc.memgrind
regression_base_release:
GO111MODULE=on go test -v -timeout 24h -tags=cgobench -run @ -bench '(Reading1|InsertComparative)/sqlite[^3]' -recs_per_sec_as_mbps 2>&1 | tee log-regression-base
regression_base_master:
GO111MODULE=off go test -v -timeout 24h -tags=cgobench -run @ -bench '(Reading1|InsertComparative)/sqlite[^3]' -recs_per_sec_as_mbps 2>&1 | tee log-regression-base
regression_check:
GO111MODULE=off go test -v -timeout 24h -tags=cgobench -run @ -bench '(Reading1|InsertComparative)/sqlite[^3]' -recs_per_sec_as_mbps 2>&1 | tee log-regression
benchcmp -changed -mag log-regression-base log-regression
nuke: clean
go clean -i
todo:
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true
@grep -nr $(grep) TODO * | grep -v $(ngrep) || true
@grep -nr $(grep) BUG * | grep -v $(ngrep) || true
@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true
tcl:
cp log log-0
go test -run Tcl$$ 2>&1 -timeout 24h -trc | tee log
grep -c '\.\.\. \?Ok' log || true
grep -c '^!' log || true
# grep -c 'Error:' log || true
tclshort:
cp log log-0
go test -run Tcl$$ -short 2>&1 -timeout 24h -trc | tee log
grep -c '\.\.\. \?Ok' log || true
grep -c '^!' log || true
# grep -c 'Error:' log || true

14
vendor/modernc.org/sqlite/README.md generated vendored Normal file
View File

@ -0,0 +1,14 @@
# sqlite
Package sqlite is a CGo-free port of SQLite.
SQLite is an in-process implementation of a self-contained, serverless,
zero-configuration, transactional SQL database engine.
Installation
$ go get modernc.org/sqlite
Documentation: [godoc.org/modernc.org/sqlite](http://godoc.org/modernc.org/sqlite)
Builders: [modern-c.appspot.com/-/builder/?importpath=modernc.org%2fsqlite](https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fsqlite)

25
vendor/modernc.org/sqlite/SQLITE-LICENSE generated vendored Normal file
View File

@ -0,0 +1,25 @@
SQLite Is Public Domain
All of the code and documentation in SQLite has been dedicated to the public
domain by the authors. All code authors, and representatives of the companies
they work for, have signed affidavits dedicating their contributions to the
public domain and originals of those signed affidavits are stored in a firesafe
at the main offices of Hwaci. Anyone is free to copy, modify, publish, use,
compile, sell, or distribute the original SQLite code, either in source code
form or as a compiled binary, for any purpose, commercial or non-commercial,
and by any means.
The previous paragraph applies to the deliverable code and documentation in
SQLite - those parts of the SQLite library that you actually bundle and ship
with a larger application. Some scripts used as part of the build process (for
example the "configure" scripts generated by autoconf) might fall under other
open-source licenses. Nothing from these build scripts ever reaches the final
deliverable SQLite library, however, and so the licenses associated with those
scripts should not be a factor in assessing your rights to copy and use the
SQLite library.
All of the deliverable code in SQLite has been written from scratch. No code
has been taken from other projects or from the open internet. Every line of
code can be traced back to its original author, and all of those authors have
public domain dedications on file. So the SQLite code base is clean and is
uncontaminated with licensed code from other projects.

160
vendor/modernc.org/sqlite/doc.go generated vendored Normal file
View File

@ -0,0 +1,160 @@
// Copyright 2017 The Sqlite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package sqlite is a CGo-free port of SQLite.
//
// SQLite is an in-process implementation of a self-contained, serverless,
// zero-configuration, transactional SQL database engine.
//
// Builders
//
// Builder results available at
//
// https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fsqlite
//
// Changelog
//
// 2021-06-23 v1.11.0:
//
// Upgrade to use sqlite 3.36.0, release notes at https://www.sqlite.org/releaselog/3_36_0.html.
//
// 2021-05-06 v1.10.6:
//
// Fixes a memory corruption issue
// (https://gitlab.com/cznic/sqlite/-/issues/53). Versions since v1.8.6 were
// affected and should be updated to v1.10.6.
//
// 2021-03-14 v1.10.0:
//
// Update to use sqlite 3.35.0, release notes at https://www.sqlite.org/releaselog/3_35_0.html.
//
// 2021-03-11 v1.9.0:
//
// Support darwin/arm64.
//
// 2021-01-08 v1.8.0:
//
// Support darwin/amd64.
//
// 2020-09-13 v1.7.0:
//
// Support linux/arm and linux/arm64.
//
// 2020-09-08 v1.6.0:
//
// Support linux/386.
//
// 2020-09-03 v1.5.0:
//
// This project is now completely CGo-free, including the Tcl tests.
//
// 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
// moment. The 'extraquick' Tcl testsuite reports
//
// 630 errors out of 200177 tests on Linux 64-bit little-endian
//
// and some memory leaks
//
// Unfreed memory: 698816 bytes in 322 allocations
//
// 2019-12-28 v1.2.0-alpha.3: Third alpha fixes issue #19.
//
// It also bumps the minor version as the repository was wrongly already tagged
// with v1.1.0 before. Even though the tag was deleted there are proxies that
// cached that tag. Thanks /u/garaktailor for detecting the problem and
// suggesting this solution.
//
// 2019-12-26 v1.1.0-alpha.2: Second alpha release adds support for accessing a
// database concurrently by multiple goroutines and/or processes. v1.1.0 is now
// considered feature-complete. Next planed release should be a beta with a
// proper test suite.
//
// 2019-12-18 v1.1.0-alpha.1: First alpha release using the new cc/v3, gocc,
// qbe toolchain. Some primitive tests pass on linux_{amd64,386}. Not yet safe
// for concurrent access by multiple goroutines. Next alpha release is planed
// to arrive before the end of this year.
//
// 2017-06-10 Windows/Intel no more uses the VM (thanks Steffen Butzer).
//
// 2017-06-05 Linux/Intel no more uses the VM (cznic/virtual).
//
// Connecting to a database
//
// To access a Sqlite database do something like
//
// import (
// "database/sql"
//
// _ "modernc.org/sqlite"
// )
//
// ...
//
//
// db, err := sql.Open("sqlite", dsnURI)
//
// ...
//
// Supported platforms and architectures
//
// These combinations of GOOS and GOARCH are currently supported
//
// darwin amd64
// darwin arm64
// linux 386
// linux amd64
// linux arm
// linux arm64
// windows amd64
//
// The windows/amd64 has currently experimental/preview status. Tcl tests
// report an unresolved yet memory leak, see
// https://gitlab.com/cznic/sqlite/-/issues/23 for more details.
//
// Planned platforms and architectures
//
// windows 386
//
// 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
package sqlite // import "modernc.org/sqlite"

730
vendor/modernc.org/sqlite/generator.go generated vendored Normal file
View File

@ -0,0 +1,730 @@
// Copyright 2017 The Sqlite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build generator
package main
import (
"archive/zip"
"bufio"
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"modernc.org/ccgo/v3/lib"
)
// gcc
// -g
// -O2
// -DSQLITE_OS_UNIX=1
// -I.
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/rtree
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/icu
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts3
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/async
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/session
// -I/home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/userauth
// -D_HAVE_SQLITE_CONFIG_H
// -DBUILD_sqlite
// -DNDEBUG
// -I/usr/include/tcl8.6
// -DSQLITE_THREADSAFE=1
// -DSQLITE_HAVE_ZLIB=1
// -DSQLITE_NO_SYNC=1
// -DSQLITE_TEMP_STORE=1
// -DSQLITE_TEST=1
// -DSQLITE_CRASH_TEST=1
// -DTCLSH_INIT_PROC=sqlite3TestInit
// -DSQLITE_SERVER=1
// -DSQLITE_PRIVATE=
// -DSQLITE_CORE
// -DBUILD_sqlite
// -DSQLITE_SERIES_CONSTRAINT_VERIFY=1
// -DSQLITE_DEFAULT_PAGE_SIZE=1024
// -DSQLITE_ENABLE_STMTVTAB
// -DSQLITE_ENABLE_DBPAGE_VTAB
// -DSQLITE_ENABLE_BYTECODE_VTAB
// -DSQLITE_ENABLE_DESERIALIZE
// -o testfixture
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test1.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test2.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test3.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test4.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test5.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test6.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test7.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test8.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test9.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_autoext.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_async.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_backup.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_bestindex.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_blob.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_btree.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_config.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_delete.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_demovfs.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_devsym.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_fs.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_func.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_hexio.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_init.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_intarray.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_journal.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_malloc.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_md5.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_multiplex.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_mutex.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_onefile.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_osinst.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_pcache.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_quota.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_rtree.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_schema.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_server.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_superlock.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_syscall.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_tclsh.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_tclvar.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_thread.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_vdbecov.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_vfs.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_windirent.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_window.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/test_wsd.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts3/fts3_term.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts3/fts3_test.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/session/test_session.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/rbu/test_rbu.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/expert/sqlite3expert.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/expert/test_expert.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/amatch.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/carray.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/closure.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/csv.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/decimal.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/eval.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/explain.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/fileio.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/fuzzer.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts5/fts5_tcl.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts5/fts5_test_mi.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/fts5/fts5_test_tok.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/ieee754.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/mmapwarm.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/nextchar.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/normalize.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/percentile.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/prefixes.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/regexp.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/remember.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/series.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/spellfix.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/totype.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/unionvtab.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/wholenumber.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/misc/zipfile.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/ext/userauth/userauth.c
// /home/jnml/src/modernc.org/sqlite/testdata/SQLite-3c5e63c2/src/tclsqlite.c
// sqlite3.c
// -L/usr/lib/x86_64-linux-gnu
// -ltcl8.6
// -ldl
// -lz
// -lpthread
const (
volatiles = "-volatile=sqlite3_io_error_pending,sqlite3_open_file_count,sqlite3_pager_readdb_count,sqlite3_pager_writedb_count,sqlite3_pager_writej_count,sqlite3_search_count,sqlite3_sort_count,saved_cnt"
)
var (
configProduction = []string{
"-DHAVE_USLEEP",
"-DLONGDOUBLE_TYPE=double",
"-DSQLITE_CORE",
"-DSQLITE_ENABLE_COLUMN_METADATA",
"-DSQLITE_ENABLE_FTS5",
"-DSQLITE_ENABLE_GEOPOLY",
"-DSQLITE_ENABLE_JSON1",
"-DSQLITE_ENABLE_MEMORY_MANAGEMENT",
"-DSQLITE_ENABLE_OFFSET_SQL_FUNC",
"-DSQLITE_ENABLE_PREUPDATE_HOOK",
"-DSQLITE_ENABLE_RBU",
"-DSQLITE_ENABLE_RTREE",
"-DSQLITE_ENABLE_SNAPSHOT",
"-DSQLITE_ENABLE_STAT4",
"-DSQLITE_ENABLE_UNLOCK_NOTIFY", // Adds sqlite3_unlock_notify().
"-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
"-DSQLITE_MUTEX_APPDEF=1",
"-DSQLITE_SOUNDEX",
"-DSQLITE_THREADSAFE=1",
//DONT "-DNDEBUG", // To enable GO_GENERATE=-DSQLITE_DEBUG
//DONT "-DSQLITE_DQS=0", // testfixture
//DONT "-DSQLITE_ENABLE_SESSION", // Needs UTF16
//DONT "-DSQLITE_NO_SYNC=1",
//DONT "-DSQLITE_OMIT_DECLTYPE", // testfixture
//DONT "-DSQLITE_OMIT_DEPRECATED", // mptest
//DONT "-DSQLITE_OMIT_LOAD_EXTENSION", // mptest
//DONT "-DSQLITE_OMIT_SHARED_CACHE",
//DONT "-DSQLITE_USE_ALLOCA",
//TODO "-DHAVE_MALLOC_USABLE_SIZE"
//TODO "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", //TODO report bug
//TODO "-DSQLITE_ENABLE_FTS3",
//TODO "-DSQLITE_ENABLE_FTS3_PARENTHESIS",
//TODO "-DSQLITE_ENABLE_FTS3_TOKENIZER",
//TODO "-DSQLITE_ENABLE_FTS4",
//TODO "-DSQLITE_ENABLE_ICU",
//TODO "-DSQLITE_MAX_EXPR_DEPTH=0", // bug reported https://sqlite.org/forum/forumpost/87b9262f66, fixed in https://sqlite.org/src/info/5f58dd3a19605b6f
//TODO "-DSQLITE_MAX_MMAP_SIZE=8589934592", // testfixture, bug reported https://sqlite.org/forum/forumpost/34380589f7, fixed in https://sqlite.org/src/info/d8e47382160e98be
//TODO- "-DSQLITE_DEBUG",
//TODO- "-DSQLITE_ENABLE_API_ARMOR",
//TODO- "-DSQLITE_MEMDEBUG",
}
configTest = []string{
"-DHAVE_USLEEP",
"-DLONGDOUBLE_TYPE=double",
"-DSQLITE_CKSUMVFS_STATIC",
"-DSQLITE_CORE", // testfixture
"-DSQLITE_DEFAULT_MEMSTATUS=0", // bug reported https://sqlite.org/forum/info/d8dfd4771689be35, fixed in https://sqlite.org/src/info/3c5e63c22ffbfeb6
"-DSQLITE_DEFAULT_PAGE_SIZE=1024", // testfixture, hardcoded. See file_pages in autovacuum.test.
"-DSQLITE_ENABLE_BYTECODE_VTAB", // testfixture
"-DSQLITE_ENABLE_COLUMN_METADATA",
"-DSQLITE_ENABLE_DBPAGE_VTAB", // testfixture
"-DSQLITE_ENABLE_DBSTAT_VTAB",
"-DSQLITE_ENABLE_DESERIALIZE", // testfixture
"-DSQLITE_ENABLE_EXPLAIN_COMMENTS",
"-DSQLITE_ENABLE_FTS5",
"-DSQLITE_ENABLE_GEOPOLY",
"-DSQLITE_ENABLE_JSON1",
"-DSQLITE_ENABLE_MEMORY_MANAGEMENT",
"-DSQLITE_ENABLE_OFFSET_SQL_FUNC",
"-DSQLITE_ENABLE_PREUPDATE_HOOK",
"-DSQLITE_ENABLE_RBU",
"-DSQLITE_ENABLE_RTREE",
"-DSQLITE_ENABLE_SNAPSHOT",
"-DSQLITE_ENABLE_STAT4",
"-DSQLITE_ENABLE_STMTVTAB", // testfixture
"-DSQLITE_ENABLE_UNLOCK_NOTIFY", // Adds sqlite3_unlock_notify().
"-DSQLITE_HAVE_ZLIB=1", // testfixture
"-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
"-DSQLITE_MUTEX_APPDEF=1",
"-DSQLITE_SOUNDEX",
"-DSQLITE_TEMP_STORE=1", // testfixture
"-DSQLITE_TEST",
"-DSQLITE_THREADSAFE=1",
//DONT "-DNDEBUG", // To enable GO_GENERATE=-DSQLITE_DEBUG
//DONT "-DSQLITE_DQS=0", // testfixture
//DONT "-DSQLITE_ENABLE_SESSION", // Needs UTF16
//DONT "-DSQLITE_NO_SYNC=1",
//DONT "-DSQLITE_OMIT_DECLTYPE", // testfixture
//DONT "-DSQLITE_OMIT_DEPRECATED", // mptest
//DONT "-DSQLITE_OMIT_LOAD_EXTENSION", // mptest
//DONT "-DSQLITE_OMIT_SHARED_CACHE",
//DONT "-DSQLITE_USE_ALLOCA",
//TODO "-DHAVE_MALLOC_USABLE_SIZE"
//TODO "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", //TODO report bug
//TODO "-DSQLITE_ENABLE_FTS3",
//TODO "-DSQLITE_ENABLE_FTS3_PARENTHESIS",
//TODO "-DSQLITE_ENABLE_FTS3_TOKENIZER",
//TODO "-DSQLITE_ENABLE_FTS4",
//TODO "-DSQLITE_ENABLE_ICU",
//TODO "-DSQLITE_MAX_EXPR_DEPTH=0", // bug reported https://sqlite.org/forum/forumpost/87b9262f66, fixed in https://sqlite.org/src/info/5f58dd3a19605b6f
//TODO "-DSQLITE_MAX_MMAP_SIZE=8589934592", // testfixture, bug reported https://sqlite.org/forum/forumpost/34380589f7, fixed in https://sqlite.org/src/info/d8e47382160e98be
//TODO- "-DSQLITE_DEBUG",
//TODO- "-DSQLITE_ENABLE_API_ARMOR",
//TODO- "-DSQLITE_MEMDEBUG",
}
downloads = []struct {
dir, url string
sz int
dev bool
}{
{sqliteDir, "https://www.sqlite.org/2021/sqlite-amalgamation-3360000.zip", 2457, false},
{sqliteSrcDir, "https://www.sqlite.org/2021/sqlite-src-3360000.zip", 12814, false},
}
sqliteDir = filepath.FromSlash("testdata/sqlite-amalgamation-3360000")
sqliteSrcDir = filepath.FromSlash("testdata/sqlite-src-3360000")
)
func download() {
tmp, err := ioutil.TempDir("", "")
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
return
}
defer os.RemoveAll(tmp)
for _, v := range downloads {
dir := filepath.FromSlash(v.dir)
root := filepath.Dir(v.dir)
fi, err := os.Stat(dir)
switch {
case err == nil:
if !fi.IsDir() {
fmt.Fprintf(os.Stderr, "expected %s to be a directory\n", dir)
}
continue
default:
if !os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "%s", err)
continue
}
}
if err := func() error {
fmt.Printf("Downloading %v MB from %s\n", float64(v.sz)/1000, v.url)
resp, err := http.Get(v.url)
if err != nil {
return err
}
defer resp.Body.Close()
base := filepath.Base(v.url)
name := filepath.Join(tmp, base)
f, err := os.Create(name)
if err != nil {
return err
}
defer os.Remove(name)
n, err := io.Copy(f, resp.Body)
if err != nil {
return err
}
if _, err := f.Seek(0, io.SeekStart); err != nil {
return err
}
switch {
case strings.HasSuffix(base, ".zip"):
r, err := zip.NewReader(f, n)
if err != nil {
return err
}
for _, f := range r.File {
fi := f.FileInfo()
if fi.IsDir() {
if err := os.MkdirAll(filepath.Join(root, f.Name), 0770); err != nil {
return err
}
continue
}
if err := func() error {
rc, err := f.Open()
if err != nil {
return err
}
defer rc.Close()
file, err := os.OpenFile(filepath.Join(root, f.Name), os.O_CREATE|os.O_WRONLY, fi.Mode())
if err != nil {
return err
}
w := bufio.NewWriter(file)
if _, err = io.Copy(w, rc); err != nil {
return err
}
if err := w.Flush(); err != nil {
return err
}
return file.Close()
}(); err != nil {
return err
}
}
return nil
}
panic("internal error") //TODOOK
}(); err != nil {
fmt.Fprintln(os.Stderr, err)
}
}
}
func fail(s string, args ...interface{}) {
fmt.Fprintf(os.Stderr, s, args...)
os.Exit(1)
}
func main() {
env := os.Getenv("GO_GENERATE")
goarch := runtime.GOARCH
goos := runtime.GOOS
if s := os.Getenv("TARGET_GOOS"); s != "" {
goos = s
}
if s := os.Getenv("TARGET_GOARCH"); s != "" {
goarch = s
}
var more []string
if env != "" {
more = strings.Split(env, ",")
}
ndebug := []string{"-DNDEBUG"}
for _, v := range more {
if v == "-DSQLITE_DEBUG" {
ndebug = nil
}
}
more = append(more, ndebug...)
download()
// experimental pthreads support currently only on linux/amd64
if goos != "linux" || goarch != "amd64" {
configProduction = append(configProduction, "-DSQLITE_MUTEX_NOOP")
configTest = append(configTest, "-DSQLITE_MUTEX_NOOP")
}
switch goos {
case "linux":
configProduction = append(configProduction, "-DSQLITE_OS_UNIX=1")
case "darwin":
configProduction = append(configProduction,
"-DSQLITE_OS_UNIX=1",
"-DSQLITE_WITHOUT_ZONEMALLOC",
)
configTest = append(configTest,
"-DSQLITE_OS_UNIX=1",
"-DSQLITE_WITHOUT_ZONEMALLOC",
)
case "windows":
configProduction = append(configProduction,
"-DSQLITE_OS_WIN=1",
"-D_MSC_VER=1900",
)
configTest = append(configTest,
"-DSQLITE_OS_WIN=1",
"-D_MSC_VER=1900",
)
default:
fail("unknows/unsupported os: %s\n", goos)
}
makeSqliteProduction(goos, goarch, more)
makeSqliteTest(goos, goarch, more)
makeMpTest(goos, goarch, more)
makeSpeedTest(goos, goarch, more)
makeTestfixture(goos, goarch, more)
ccgo.MustCopyDir(true, "testdata/tcl", sqliteSrcDir+"/test", nil)
ccgo.MustCopyDir(true, "testdata/tcl", "testdata/overlay", nil)
}
func configure(goos, goarch string) {
wd, err := os.Getwd()
if err != nil {
fail("%s", err)
}
defer os.Chdir(wd)
if err := os.Chdir(sqliteSrcDir); err != nil {
fail("%s", err)
}
cmd := newCmd("make", "distclean")
cmd.Run()
var args []string
switch goos {
case "linux":
// nop
case "darwin":
args = append(args, "--with-tcl=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Tcl.framework")
case "windows":
switch goarch {
case "amd64":
args = append(args, "--host=x86_64-w64-mingw32")
case "386":
args = append(args, "--host=i686-w64-mingw32")
default:
fail("unknown/unsupported os/arch: %s/%s\n", goos, goarch)
}
default:
fail("unknown/unsupported os/arch: %s/%s\n", goos, goarch)
}
cmd = newCmd("./configure", args...)
if err = cmd.Run(); err != nil {
fail("%s\n", err)
}
cmd = newCmd("make", "parse.h", "opcodes.h")
if err = cmd.Run(); err != nil {
fail("%s\n", err)
}
}
func newCmd(bin string, args ...string) *exec.Cmd {
fmt.Printf("==== newCmd %s\n", bin)
for _, v := range args {
fmt.Printf("\t%v\n", v)
}
r := exec.Command(bin, args...)
r.Stdout = os.Stdout
r.Stderr = os.Stderr
return r
}
func makeTestfixture(goos, goarch string, more []string) {
dir := filepath.FromSlash(fmt.Sprintf("internal/testfixture"))
files := []string{
"ext/expert/sqlite3expert.c",
"ext/expert/test_expert.c",
"ext/fts3/fts3_term.c",
"ext/fts3/fts3_test.c",
"ext/fts5/fts5_tcl.c",
"ext/fts5/fts5_test_mi.c",
"ext/fts5/fts5_test_tok.c",
"ext/misc/appendvfs.c",
"ext/misc/amatch.c",
"ext/misc/carray.c",
"ext/misc/cksumvfs.c",
"ext/misc/closure.c",
"ext/misc/csv.c",
"ext/misc/decimal.c",
"ext/misc/eval.c",
"ext/misc/explain.c",
"ext/misc/fileio.c",
"ext/misc/fuzzer.c",
"ext/misc/ieee754.c",
"ext/misc/mmapwarm.c",
"ext/misc/nextchar.c",
"ext/misc/normalize.c",
"ext/misc/percentile.c",
"ext/misc/prefixes.c",
"ext/misc/regexp.c",
"ext/misc/remember.c",
"ext/misc/series.c",
"ext/misc/spellfix.c",
"ext/misc/totype.c",
"ext/misc/unionvtab.c",
"ext/misc/wholenumber.c",
"ext/misc/zipfile.c",
"ext/rbu/test_rbu.c",
// "ext/session/test_session.c", // Needs UTF16
"ext/userauth/userauth.c",
"src/tclsqlite.c",
"src/test1.c",
"src/test2.c",
"src/test3.c",
"src/test4.c",
"src/test5.c",
"src/test6.c",
"src/test7.c",
"src/test8.c",
"src/test9.c",
"src/test_async.c",
"src/test_autoext.c",
"src/test_backup.c",
"src/test_bestindex.c",
"src/test_blob.c",
"src/test_btree.c",
"src/test_config.c",
"src/test_delete.c",
"src/test_demovfs.c",
"src/test_devsym.c",
"src/test_fs.c",
"src/test_func.c",
"src/test_hexio.c",
"src/test_init.c",
"src/test_intarray.c",
"src/test_journal.c",
"src/test_malloc.c",
"src/test_md5.c",
"src/test_multiplex.c",
"src/test_mutex.c",
"src/test_onefile.c",
"src/test_osinst.c",
"src/test_pcache.c",
"src/test_quota.c",
"src/test_rtree.c",
"src/test_schema.c",
"src/test_server.c",
"src/test_superlock.c",
"src/test_syscall.c",
"src/test_tclsh.c",
"src/test_tclvar.c",
"src/test_thread.c",
"src/test_vdbecov.c",
"src/test_vfs.c",
"src/test_windirent.c",
"src/test_window.c",
"src/test_wsd.c",
}
for i, v := range files {
files[i] = filepath.Join(sqliteSrcDir, filepath.FromSlash(v))
}
configure(goos, goarch)
args := join(
[]string{
"ccgo",
"-DSQLITE_OMIT_LOAD_EXTENSION",
"-DSQLITE_SERIES_CONSTRAINT_VERIFY=1",
"-DSQLITE_SERVER=1",
"-DTCLSH_INIT_PROC=sqlite3TestInit",
"-D_HAVE_SQLITE_CONFIG_H",
"-I/usr/include/tcl8.6", //TODO should not be hardcoded
"-export-defines", "",
"-export-fields", "F",
"-trace-translation-units",
volatiles,
"-lmodernc.org/sqlite/libtest",
"-lmodernc.org/tcl/lib",
"-lmodernc.org/z/lib",
"-o", filepath.Join(dir, fmt.Sprintf("testfixture_%s_%s.go", goos, goarch)),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/async"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/fts3"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/icu"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/rtree"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/session"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/userauth"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("src"))),
fmt.Sprintf("-I%s", sqliteDir),
fmt.Sprintf("-I%s", sqliteSrcDir),
},
files,
more,
configTest,
)
// experimental pthreads support currently only on linux/amd64
if goos != "linux" || goarch != "amd64" {
args = append(args, "-lmodernc.org/sqlite/internal/libc2")
}
task := ccgo.NewTask(args, nil, nil)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
}
func makeSpeedTest(goos, goarch string, more []string) {
task := ccgo.NewTask(
join(
[]string{
"ccgo",
"-export-defines", "",
"-o", filepath.FromSlash(fmt.Sprintf("speedtest1/main_%s_%s.go", goos, goarch)),
"-trace-translation-units",
filepath.Join(sqliteSrcDir, "test", "speedtest1.c"),
fmt.Sprintf("-I%s", sqliteDir),
"-l", "modernc.org/sqlite/lib",
},
more,
configProduction,
),
nil,
nil,
)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
}
func makeMpTest(goos, goarch string, more []string) {
task := ccgo.NewTask(
join(
[]string{
"ccgo",
"-export-defines", "",
"-o", filepath.FromSlash(fmt.Sprintf("internal/mptest/main_%s_%s.go", goos, goarch)),
"-trace-translation-units",
filepath.Join(sqliteSrcDir, "mptest", "mptest.c"),
fmt.Sprintf("-I%s", sqliteDir),
"-l", "modernc.org/sqlite/lib",
},
more,
configProduction,
),
nil,
nil,
)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
}
func makeSqliteProduction(goos, goarch string, more []string) {
task := ccgo.NewTask(
join(
[]string{
"ccgo",
"-DSQLITE_PRIVATE=",
"-export-defines", "",
"-export-enums", "",
"-export-externs", "X",
"-export-fields", "F",
"-export-typedefs", "",
"-pkgname", "sqlite3",
"-o", filepath.FromSlash(fmt.Sprintf("lib/sqlite_%s_%s.go", goos, goarch)),
"-trace-translation-units",
filepath.Join(sqliteDir, "sqlite3.c"),
},
more,
configProduction,
),
nil,
nil,
)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
}
func makeSqliteTest(goos, goarch string, more []string) {
task := ccgo.NewTask(
join(
[]string{
"ccgo",
"-DSQLITE_PRIVATE=",
"-export-defines", "",
"-export-enums", "",
"-export-externs", "X",
"-export-fields", "F",
"-export-typedefs", "",
"-pkgname", "sqlite3",
"-o", filepath.FromSlash(fmt.Sprintf("libtest/sqlite_%s_%s.go", goos, goarch)),
"-trace-translation-units",
volatiles,
filepath.Join(sqliteDir, "sqlite3.c"),
},
more,
configTest,
),
nil,
nil,
)
if err := task.Main(); err != nil {
fail("%s\n", err)
}
}
func join(a ...[]string) (r []string) {
n := 0
for _, v := range a {
n += len(v)
}
r = make([]string, 0, n)
for _, v := range a {
r = append(r, v...)
}
return r
}

12
vendor/modernc.org/sqlite/go.mod generated vendored Normal file
View File

@ -0,0 +1,12 @@
module modernc.org/sqlite
go 1.15
require (
github.com/mattn/go-sqlite3 v1.14.6
modernc.org/ccgo/v3 v3.9.5
modernc.org/libc v1.9.11
modernc.org/mathutil v1.4.0
modernc.org/tcl v1.5.5
modernc.org/z v1.0.1
)

69
vendor/modernc.org/sqlite/go.sum generated vendored Normal file
View File

@ -0,0 +1,69 @@
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
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/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 h1:M8tBwCtWD/cZV9DZpFYRUgaymAYAr+aIUTWzDaM3uPs=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.33.6 h1:r63dgSzVzRxUpAJFPQWHy1QeZeY1ydNENUDaBx1GqYc=
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
modernc.org/ccgo/v3 v3.9.5 h1:dEuUSf8WN51rDkprFuAqjfchKEzN0WttP/Py3enBwjk=
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.9.11 h1:QUxZMs48Ahg2F7SN41aERvMfGLY2HU/ADnB9DC4Yts8=
modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.4.0 h1:GCjoRaBew8ECCKINQA2nYjzvufFW9YiEuuB+rQ9bn2E=
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM=
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
modernc.org/tcl v1.5.5 h1:N03RwthgTR/l/eQvz3UjfYnvVVj1G2sZqzFGfoD4HE4=
modernc.org/tcl v1.5.5/go.mod h1:ADkaTUuwukkrlhqwERyq0SM8OvyXo7+TjFz7yAF56EI=
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.0.1 h1:WyIDpEpAIx4Hel6q/Pcgj/VhaQV5XPJ2I6ryIYbjnpc=
modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=

1258
vendor/modernc.org/sqlite/lib/capi_darwin_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1258
vendor/modernc.org/sqlite/lib/capi_darwin_arm64.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1258
vendor/modernc.org/sqlite/lib/capi_linux_386.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1259
vendor/modernc.org/sqlite/lib/capi_linux_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1258
vendor/modernc.org/sqlite/lib/capi_linux_arm.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1258
vendor/modernc.org/sqlite/lib/capi_linux_arm64.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1247
vendor/modernc.org/sqlite/lib/capi_linux_s390x.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1246
vendor/modernc.org/sqlite/lib/capi_windows_386.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

1277
vendor/modernc.org/sqlite/lib/capi_windows_amd64.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

14
vendor/modernc.org/sqlite/lib/hooks.go generated vendored Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2019 The Sqlite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlite3
import (
"modernc.org/libc"
)
// Format and write a message to the log if logging is enabled.
func X__ccgo_sqlite3_log(t *libc.TLS, iErrCode int32, zFormat uintptr, va uintptr) { /* sqlite3.c:29405:17: */
libc.X__ccgo_sqlite3_log(t, iErrCode, zFormat, va)
}

341
vendor/modernc.org/sqlite/lib/mutex.go generated vendored Normal file
View File

@ -0,0 +1,341 @@
// Copyright 2021 The Sqlite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlite3
import (
"fmt"
"runtime"
"sync"
"sync/atomic"
"unsafe"
"modernc.org/libc"
"modernc.org/libc/sys/types"
)
func init() {
tls := libc.NewTLS()
if Xsqlite3_threadsafe(tls) == 0 {
panic(fmt.Errorf("sqlite: thread safety configuration error"))
}
varArgs := libc.Xmalloc(tls, types.Size_t(unsafe.Sizeof(uintptr(0))))
if varArgs == 0 {
panic(fmt.Errorf("cannot allocate memory"))
}
// experimental pthreads support currently only on linux/amd64
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
// int sqlite3_config(int, ...);
if rc := Xsqlite3_config(tls, SQLITE_CONFIG_MUTEX, libc.VaList(varArgs, uintptr(unsafe.Pointer(&mutexMethods)))); rc != SQLITE_OK {
p := Xsqlite3_errstr(tls, rc)
str := libc.GoString(p)
panic(fmt.Errorf("sqlite: failed to configure mutex methods: %v", str))
}
}
libc.Xfree(tls, varArgs)
tls.Close()
}
var (
mutexMethods = Sqlite3_mutex_methods{
FxMutexInit: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{mutexInit})),
FxMutexEnd: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS) int32 }{mutexEnd})),
FxMutexAlloc: *(*uintptr)(unsafe.Pointer(&struct {
f func(*libc.TLS, int32) uintptr
}{mutexAlloc})),
FxMutexFree: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{mutexFree})),
FxMutexEnter: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{mutexEnter})),
FxMutexTry: *(*uintptr)(unsafe.Pointer(&struct {
f func(*libc.TLS, uintptr) int32
}{mutexTry})),
FxMutexLeave: *(*uintptr)(unsafe.Pointer(&struct{ f func(*libc.TLS, uintptr) }{mutexLeave})),
FxMutexHeld: *(*uintptr)(unsafe.Pointer(&struct {
f func(*libc.TLS, uintptr) int32
}{mutexHeld})),
FxMutexNotheld: *(*uintptr)(unsafe.Pointer(&struct {
f func(*libc.TLS, uintptr) int32
}{mutexNotheld})),
}
mutexApp1 mutex
mutexApp2 mutex
mutexApp3 mutex
mutexLRU mutex
mutexMaster mutex
mutexMem mutex
mutexOpen mutex
mutexPMem mutex
mutexPRNG mutex
mutexVFS1 mutex
mutexVFS2 mutex
mutexVFS3 mutex
)
type mutex struct {
cnt int32
id int32
sync.Mutex
wait sync.Mutex
recursive bool
}
func (m *mutex) enter(id int32) {
if !m.recursive {
m.Lock()
m.id = id
return
}
for {
m.Lock()
switch m.id {
case 0:
m.cnt = 1
m.id = id
m.wait.Lock()
m.Unlock()
return
case id:
m.cnt++
m.Unlock()
return
}
m.Unlock()
m.wait.Lock()
//lint:ignore SA2001 TODO report staticcheck issue
m.wait.Unlock()
}
}
func (m *mutex) try(id int32) int32 {
if !m.recursive {
return SQLITE_BUSY
}
m.Lock()
switch m.id {
case 0:
m.cnt = 1
m.id = id
m.wait.Lock()
m.Unlock()
return SQLITE_OK
case id:
m.cnt++
m.Unlock()
return SQLITE_OK
}
m.Unlock()
return SQLITE_BUSY
}
func (m *mutex) leave(id int32) {
if !m.recursive {
m.id = 0
m.Unlock()
return
}
m.Lock()
m.cnt--
if m.cnt == 0 {
m.id = 0
m.wait.Unlock()
}
m.Unlock()
}
// int (*xMutexInit)(void);
//
// The xMutexInit method defined by this structure is invoked as part of system
// initialization by the sqlite3_initialize() function. The xMutexInit routine
// is called by SQLite exactly once for each effective call to
// sqlite3_initialize().
//
// The xMutexInit() method must be threadsafe. It must be harmless to invoke
// xMutexInit() multiple times within the same process and without intervening
// calls to xMutexEnd(). Second and subsequent calls to xMutexInit() must be
// no-ops. xMutexInit() must not use SQLite memory allocation (sqlite3_malloc()
// and its associates).
//
// If xMutexInit fails in any way, it is expected to clean up after itself
// prior to returning.
func mutexInit(tls *libc.TLS) int32 { return SQLITE_OK }
// int (*xMutexEnd)(void);
func mutexEnd(tls *libc.TLS) int32 { return SQLITE_OK }
// sqlite3_mutex *(*xMutexAlloc)(int);
//
// The sqlite3_mutex_alloc() routine allocates a new mutex and returns a
// pointer to it. The sqlite3_mutex_alloc() routine returns NULL if it is
// unable to allocate the requested mutex. The argument to
// sqlite3_mutex_alloc() must one of these integer constants:
//
// SQLITE_MUTEX_FAST
// SQLITE_MUTEX_RECURSIVE
// SQLITE_MUTEX_STATIC_MASTER
// SQLITE_MUTEX_STATIC_MEM
// SQLITE_MUTEX_STATIC_OPEN
// SQLITE_MUTEX_STATIC_PRNG
// SQLITE_MUTEX_STATIC_LRU
// SQLITE_MUTEX_STATIC_PMEM
// SQLITE_MUTEX_STATIC_APP1
// SQLITE_MUTEX_STATIC_APP2
// SQLITE_MUTEX_STATIC_APP3
// SQLITE_MUTEX_STATIC_VFS1
// SQLITE_MUTEX_STATIC_VFS2
// SQLITE_MUTEX_STATIC_VFS3
//
// The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) cause
// sqlite3_mutex_alloc() to create a new mutex. The new mutex is recursive when
// SQLITE_MUTEX_RECURSIVE is used but not necessarily so when SQLITE_MUTEX_FAST
// is used. The mutex implementation does not need to make a distinction
// between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does not want to.
// SQLite will only request a recursive mutex in cases where it really needs
// one. If a faster non-recursive mutex implementation is available on the host
// platform, the mutex subsystem might return such a mutex in response to
// SQLITE_MUTEX_FAST.
//
// The other allowed parameters to sqlite3_mutex_alloc() (anything other than
// SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return a pointer to a
// static preexisting mutex. Nine static mutexes are used by the current
// version of SQLite. Future versions of SQLite may add additional static
// mutexes. Static mutexes are for internal use by SQLite only. Applications
// that use SQLite mutexes should use only the dynamic mutexes returned by
// SQLITE_MUTEX_FAST or SQLITE_MUTEX_RECURSIVE.
//
// Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST or
// SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() returns a
// different mutex on every call. For the static mutex types, the same mutex is
// returned on every call that has the same type number.
func mutexAlloc(tls *libc.TLS, typ int32) uintptr {
defer func() {
}()
switch typ {
case SQLITE_MUTEX_FAST:
return libc.Xcalloc(tls, 1, types.Size_t(unsafe.Sizeof(mutex{})))
case SQLITE_MUTEX_RECURSIVE:
p := libc.Xcalloc(tls, 1, types.Size_t(unsafe.Sizeof(mutex{})))
(*mutex)(unsafe.Pointer(p)).recursive = true
return p
case SQLITE_MUTEX_STATIC_MASTER:
return uintptr(unsafe.Pointer(&mutexMaster))
case SQLITE_MUTEX_STATIC_MEM:
return uintptr(unsafe.Pointer(&mutexMem))
case SQLITE_MUTEX_STATIC_OPEN:
return uintptr(unsafe.Pointer(&mutexOpen))
case SQLITE_MUTEX_STATIC_PRNG:
return uintptr(unsafe.Pointer(&mutexPRNG))
case SQLITE_MUTEX_STATIC_LRU:
return uintptr(unsafe.Pointer(&mutexLRU))
case SQLITE_MUTEX_STATIC_PMEM:
return uintptr(unsafe.Pointer(&mutexPMem))
case SQLITE_MUTEX_STATIC_APP1:
return uintptr(unsafe.Pointer(&mutexApp1))
case SQLITE_MUTEX_STATIC_APP2:
return uintptr(unsafe.Pointer(&mutexApp2))
case SQLITE_MUTEX_STATIC_APP3:
return uintptr(unsafe.Pointer(&mutexApp3))
case SQLITE_MUTEX_STATIC_VFS1:
return uintptr(unsafe.Pointer(&mutexVFS1))
case SQLITE_MUTEX_STATIC_VFS2:
return uintptr(unsafe.Pointer(&mutexVFS2))
case SQLITE_MUTEX_STATIC_VFS3:
return uintptr(unsafe.Pointer(&mutexVFS3))
default:
return 0
}
}
// void (*xMutexFree)(sqlite3_mutex *);
func mutexFree(tls *libc.TLS, m uintptr) { libc.Xfree(tls, m) }
// The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt to enter
// a mutex. If another thread is already within the mutex,
// sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
// SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK upon
// successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can be
// entered multiple times by the same thread. In such cases, the mutex must be
// exited an equal number of times before another thread can enter. If the same
// thread tries to enter any mutex other than an SQLITE_MUTEX_RECURSIVE more
// than once, the behavior is undefined.
//
// If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
// sqlite3_mutex_leave() is a NULL pointer, then all three routines behave as
// no-ops.
// void (*xMutexEnter)(sqlite3_mutex *);
func mutexEnter(tls *libc.TLS, m uintptr) {
if m == 0 {
return
}
(*mutex)(unsafe.Pointer(m)).enter(tls.ID)
}
// int (*xMutexTry)(sqlite3_mutex *);
func mutexTry(tls *libc.TLS, m uintptr) int32 {
if m == 0 {
return SQLITE_OK
}
return (*mutex)(unsafe.Pointer(m)).try(tls.ID)
}
// void (*xMutexLeave)(sqlite3_mutex *);
func mutexLeave(tls *libc.TLS, m uintptr) {
if m == 0 {
return
}
(*mutex)(unsafe.Pointer(m)).leave(tls.ID)
}
// The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines are intended
// for use inside assert() statements. The SQLite core never uses these
// routines except inside an assert() and applications are advised to follow
// the lead of the core. The SQLite core only provides implementations for
// these routines when it is compiled with the SQLITE_DEBUG flag. External
// mutex implementations are only required to provide these routines if
// SQLITE_DEBUG is defined and if NDEBUG is not defined.
//
// These routines should return true if the mutex in their argument is held or
// not held, respectively, by the calling thread.
//
// The implementation is not required to provide versions of these routines
// that actually work. If the implementation does not provide working versions
// of these routines, it should at least provide stubs that always return true
// so that one does not get spurious assertion failures.
//
// If the argument to sqlite3_mutex_held() is a NULL pointer then the routine
// should return 1. This seems counter-intuitive since clearly the mutex cannot
// be held if it does not exist. But the reason the mutex does not exist is
// because the build is not using mutexes. And we do not want the assert()
// containing the call to sqlite3_mutex_held() to fail, so a non-zero return is
// the appropriate thing to do. The sqlite3_mutex_notheld() interface should
// also return 1 when given a NULL pointer.
// int (*xMutexHeld)(sqlite3_mutex *);
func mutexHeld(tls *libc.TLS, m uintptr) int32 {
if m == 0 {
return 1
}
return libc.Bool32(atomic.LoadInt32(&(*mutex)(unsafe.Pointer(m)).id) == tls.ID)
}
// int (*xMutexNotheld)(sqlite3_mutex *);
func mutexNotheld(tls *libc.TLS, m uintptr) int32 {
if m == 0 {
return 1
}
return libc.Bool32(atomic.LoadInt32(&(*mutex)(unsafe.Pointer(m)).id) != tls.ID)
}

201486
vendor/modernc.org/sqlite/lib/sqlite_darwin_amd64.go generated vendored Normal file

File diff suppressed because one or more lines are too long

200111
vendor/modernc.org/sqlite/lib/sqlite_darwin_arm64.go generated vendored Normal file

File diff suppressed because one or more lines are too long

185384
vendor/modernc.org/sqlite/lib/sqlite_linux_386.go generated vendored Normal file

File diff suppressed because one or more lines are too long

187006
vendor/modernc.org/sqlite/lib/sqlite_linux_amd64.go generated vendored Normal file

File diff suppressed because one or more lines are too long

185562
vendor/modernc.org/sqlite/lib/sqlite_linux_arm.go generated vendored Normal file

File diff suppressed because one or more lines are too long

185751
vendor/modernc.org/sqlite/lib/sqlite_linux_arm64.go generated vendored Normal file

File diff suppressed because one or more lines are too long

185313
vendor/modernc.org/sqlite/lib/sqlite_linux_s390x.go generated vendored Normal file

File diff suppressed because one or more lines are too long

229849
vendor/modernc.org/sqlite/lib/sqlite_windows_386.go generated vendored Normal file

File diff suppressed because one or more lines are too long

230933
vendor/modernc.org/sqlite/lib/sqlite_windows_amd64.go generated vendored Normal file

File diff suppressed because one or more lines are too long

23
vendor/modernc.org/sqlite/mutex.go generated vendored Normal file
View File

@ -0,0 +1,23 @@
// Copyright 2019 The Sqlite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package sqlite // import "modernc.org/sqlite"
import (
"sync"
"unsafe"
"modernc.org/libc"
"modernc.org/libc/sys/types"
)
type mutex struct {
sync.Mutex
}
func mutexAlloc(tls *libc.TLS) uintptr {
return libc.Xcalloc(tls, 1, types.Size_t(unsafe.Sizeof(mutex{})))
}
func mutexFree(tls *libc.TLS, m uintptr) { libc.Xfree(tls, m) }

1305
vendor/modernc.org/sqlite/sqlite.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

48
vendor/modernc.org/sqlite/sqlite_go18.go generated vendored Normal file
View File

@ -0,0 +1,48 @@
// Copyright 2017 The Sqlite Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build go1.8
package sqlite // import "modernc.org/sqlite"
import (
"context"
"database/sql/driver"
)
// Ping implements driver.Pinger
func (c *conn) Ping(ctx context.Context) error {
_, err := c.ExecContext(ctx, "select 1", nil)
return err
}
// BeginTx implements driver.ConnBeginTx
func (c *conn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
return c.begin(ctx, opts)
}
// PrepareContext implements driver.ConnPrepareContext
func (c *conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
return c.prepare(ctx, query)
}
// ExecContext implements driver.ExecerContext
func (c *conn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
return c.exec(ctx, query, args)
}
// QueryContext implements driver.QueryerContext
func (c *conn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) {
return c.query(ctx, query, args)
}
// ExecContext implements driver.StmtExecContext
func (s *stmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
return s.exec(ctx, args)
}
// QueryContext implements driver.StmtQueryContext
func (s *stmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
return s.query(ctx, args)
}

4
vendor/modernc.org/sqlite/unconvert.sh generated vendored Normal file
View File

@ -0,0 +1,4 @@
until unconvert -fastmath . &> /dev/null
do
unconvert -fastmath -apply . &> /dev/null
done