linux/amd64: enable pthreads

This commit is contained in:
Jan Mercl
2021-03-23 00:17:08 +01:00
parent 188cc2d36d
commit fae63b194d
57 changed files with 28116 additions and 7355 deletions

View File

@@ -166,7 +166,6 @@ var (
"-DSQLITE_ENABLE_UNLOCK_NOTIFY", // Adds sqlite3_unlock_notify(). "-DSQLITE_ENABLE_UNLOCK_NOTIFY", // Adds sqlite3_unlock_notify().
"-DSQLITE_LIKE_DOESNT_MATCH_BLOBS", "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
"-DSQLITE_MUTEX_APPDEF=1", "-DSQLITE_MUTEX_APPDEF=1",
"-DSQLITE_MUTEX_NOOP",
"-DSQLITE_SOUNDEX", "-DSQLITE_SOUNDEX",
"-DSQLITE_THREADSAFE=1", "-DSQLITE_THREADSAFE=1",
//DONT "-DNDEBUG", // To enable GO_GENERATE=-DSQLITE_DEBUG //DONT "-DNDEBUG", // To enable GO_GENERATE=-DSQLITE_DEBUG
@@ -220,7 +219,6 @@ var (
"-DSQLITE_HAVE_ZLIB=1", // testfixture "-DSQLITE_HAVE_ZLIB=1", // testfixture
"-DSQLITE_LIKE_DOESNT_MATCH_BLOBS", "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS",
"-DSQLITE_MUTEX_APPDEF=1", "-DSQLITE_MUTEX_APPDEF=1",
"-DSQLITE_MUTEX_NOOP",
"-DSQLITE_SOUNDEX", "-DSQLITE_SOUNDEX",
"-DSQLITE_TEMP_STORE=1", // testfixture "-DSQLITE_TEMP_STORE=1", // testfixture
"-DSQLITE_TEST", "-DSQLITE_TEST",
@@ -394,6 +392,11 @@ func main() {
} }
more = append(more, ndebug...) more = append(more, ndebug...)
download() 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 { switch goos {
case "linux": case "linux":
configProduction = append(configProduction, "-DSQLITE_OS_UNIX=1") configProduction = append(configProduction, "-DSQLITE_OS_UNIX=1")
@@ -423,34 +426,8 @@ func main() {
makeMpTest(goos, goarch, more) makeMpTest(goos, goarch, more)
makeSpeedTest(goos, goarch, more) makeSpeedTest(goos, goarch, more)
makeTestfixture(goos, goarch, more) makeTestfixture(goos, goarch, more)
ccgo.MustCopyDir(true, "testdata/tcl", sqliteSrcDir+"/test", nil)
dst := filepath.FromSlash("testdata/tcl") ccgo.MustCopyDir(true, "testdata/tcl", "testdata/overlay", nil)
if err := os.MkdirAll(dst, 0770); err != nil {
fail("cannot create %q: %v", dst, err)
}
m, err := filepath.Glob(filepath.Join(sqliteSrcDir, "test/*.test"))
if err != nil {
fail("cannot glob *.test: %v", err)
}
m2, err := filepath.Glob(filepath.Join(sqliteSrcDir, "test/*.tcl"))
if err != nil {
fail("cannot glob *.tcl: %v", err)
}
m = join(m, m2)
for _, v := range m {
f, err := ioutil.ReadFile(v)
if err != nil {
fail("cannot read %v: %v", v, err)
}
fn := filepath.Join(dst, filepath.Base(v))
if err := ioutil.WriteFile(fn, f, 0660); err != nil {
fail("cannot write %v: %v", fn, err)
}
}
} }
func configure(goos, goarch string) { func configure(goos, goarch string) {
@@ -598,42 +575,42 @@ func makeTestfixture(goos, goarch string, more []string) {
} }
configure(goos, goarch) configure(goos, goarch)
task := ccgo.NewTask( args := join(
join( []string{
[]string{ "ccgo",
"ccgo", "-DSQLITE_OMIT_LOAD_EXTENSION",
"-DSQLITE_OMIT_LOAD_EXTENSION", "-DSQLITE_SERIES_CONSTRAINT_VERIFY=1",
"-DSQLITE_SERIES_CONSTRAINT_VERIFY=1", "-DSQLITE_SERVER=1",
"-DSQLITE_SERVER=1", "-DTCLSH_INIT_PROC=sqlite3TestInit",
"-DTCLSH_INIT_PROC=sqlite3TestInit", "-D_HAVE_SQLITE_CONFIG_H",
"-D_HAVE_SQLITE_CONFIG_H", "-I/usr/include/tcl8.6", //TODO should not be hardcoded
"-I/usr/include/tcl8.6", //TODO should not be hardcoded "-export-defines", "",
"-export-defines", "", "-export-fields", "F",
"-export-fields", "F", "-trace-translation-units",
"-trace-translation-units", volatiles,
volatiles, "-lmodernc.org/sqlite/libtest",
"-lmodernc.org/sqlite/internal/libc2", "-lmodernc.org/tcl/lib",
"-lmodernc.org/sqlite/libtest", "-lmodernc.org/z/lib",
"-lmodernc.org/tcl/lib", "-o", filepath.Join(dir, fmt.Sprintf("testfixture_%s_%s.go", goos, goarch)),
"-lmodernc.org/z/lib", fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/async"))),
"-o", filepath.Join(dir, fmt.Sprintf("testfixture_%s_%s.go", goos, goarch)), fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/fts3"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/async"))), fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/icu"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/fts3"))), fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/rtree"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/icu"))), fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/session"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/rtree"))), fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/userauth"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/session"))), fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("src"))),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("ext/userauth"))), fmt.Sprintf("-I%s", sqliteDir),
fmt.Sprintf("-I%s", filepath.Join(sqliteSrcDir, filepath.FromSlash("src"))), fmt.Sprintf("-I%s", sqliteSrcDir),
fmt.Sprintf("-I%s", sqliteDir), },
fmt.Sprintf("-I%s", sqliteSrcDir), files,
}, more,
files, configTest,
more,
configTest,
),
nil,
nil,
) )
// 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 { if err := task.Main(); err != nil {
fail("%s\n", err) fail("%s\n", err)
} }

6
go.mod
View File

@@ -4,9 +4,9 @@ go 1.15
require ( require (
github.com/mattn/go-sqlite3 v1.14.6 github.com/mattn/go-sqlite3 v1.14.6
modernc.org/ccgo/v3 v3.0.0-20210318155153-2eedd9598652 modernc.org/ccgo/v3 v3.0.0-20210322225857-402b1f694ef6
modernc.org/libc v1.8.1 modernc.org/libc v1.9.0
modernc.org/mathutil v1.2.2 modernc.org/mathutil v1.2.2
modernc.org/tcl v1.5.0 modernc.org/tcl v0.0.0-20210322230939-c46fc051675e
modernc.org/z v1.0.1 modernc.org/z v1.0.1
) )

13
go.sum
View File

@@ -41,13 +41,14 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1N
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
modernc.org/cc/v3 v3.0.0-20210318154801-be1b88075ae3 h1:5dQjtXRCemSp1ScrwyDEe4qxr35S0KAXE7zzaPuWR44= modernc.org/cc/v3 v3.0.0-20210318154801-be1b88075ae3 h1:5dQjtXRCemSp1ScrwyDEe4qxr35S0KAXE7zzaPuWR44=
modernc.org/cc/v3 v3.0.0-20210318154801-be1b88075ae3/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878= modernc.org/cc/v3 v3.0.0-20210318154801-be1b88075ae3/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878=
modernc.org/ccgo/v3 v3.0.0-20210318155153-2eedd9598652 h1:Z5SzC2VoRwptt0YcRx98c0qIcAx1P2sHAtxUSTf5ffw= modernc.org/ccgo/v3 v3.0.0-20210322225857-402b1f694ef6 h1:W6haZmjXtVsnOHw24CZd9V+UIf3OJ4vlRCq9Xxvj6Y0=
modernc.org/ccgo/v3 v3.0.0-20210318155153-2eedd9598652/go.mod h1:3/m/VJZPEdYtCBjd+Qa49CIhiwz3C8jsBzO9VSdql1o= modernc.org/ccgo/v3 v3.0.0-20210322225857-402b1f694ef6/go.mod h1:UVRg1fK+1MsYtWMVT0x6r6jd/qZ8zi00GYgS8Icswcs=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM= modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM= modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v0.0.0-20210322225427-1ae588a1420f/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.8.1 h1:y9oPIhwcaFXxX7kMp6Qb2ZLKzr0mDkikWN3CV5GS63o= modernc.org/libc v1.9.0 h1:1dV/xAUWrSc9zi3WI6adIzv9+1PHnfC4Z3DMfxwZcHQ=
modernc.org/libc v1.8.1/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w= modernc.org/libc v1.9.0/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY= modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
@@ -57,8 +58,8 @@ modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0= modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc= modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc=
modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/tcl v1.5.0 h1:euZSUNfE0Fd4W8VqXI1Ly1v7fqDJoBuAV88Ea+SnaSs= modernc.org/tcl v0.0.0-20210322230939-c46fc051675e h1:l+vheikvjX9hzOv3l/BTiw4vc8gLMav51xmLCQP/RBY=
modernc.org/tcl v1.5.0/go.mod h1:gb57hj4pO8fRrK54zveIfFXBaMHK3SKJNWcmRw1cRzc= modernc.org/tcl v0.0.0-20210322230939-c46fc051675e/go.mod h1:kdkmU+eikjfvJ++opaSDQG/YrWV7o2Al2m+Bfp12+BQ=
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk= modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.0.1-0.20210308123920-1f282aa71362 h1:xUpazXgMcN3whs6DGzAUHVlZyQl4sahj6Lvv2kFj73w= modernc.org/z v1.0.1-0.20210308123920-1f282aa71362 h1:xUpazXgMcN3whs6DGzAUHVlZyQl4sahj6Lvv2kFj73w=

View File

@@ -1,4 +1,4 @@
// Code generated by 'ccgo -export-defines "" -o internal/mptest/main_linux_amd64.go -trace-translation-units testdata/sqlite-src-3350000/mptest/mptest.c -Itestdata/sqlite-amalgamation-3350000 -l modernc.org/sqlite/lib -DNDEBUG -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 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT. // Code generated by 'ccgo -export-defines "" -o internal/mptest/main_linux_amd64.go -trace-translation-units testdata/sqlite-src-3350000/mptest/mptest.c -Itestdata/sqlite-amalgamation-3350000 -l modernc.org/sqlite/lib -DNDEBUG -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 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT.
package main package main
@@ -494,7 +494,6 @@ const (
SQLITE_MISUSE = 21 SQLITE_MISUSE = 21
SQLITE_MUTEX_APPDEF = 1 SQLITE_MUTEX_APPDEF = 1
SQLITE_MUTEX_FAST = 0 SQLITE_MUTEX_FAST = 0
SQLITE_MUTEX_NOOP = 1
SQLITE_MUTEX_RECURSIVE = 1 SQLITE_MUTEX_RECURSIVE = 1
SQLITE_MUTEX_STATIC_APP1 = 8 SQLITE_MUTEX_STATIC_APP1 = 8
SQLITE_MUTEX_STATIC_APP2 = 9 SQLITE_MUTEX_STATIC_APP2 = 9
@@ -685,14 +684,11 @@ const (
X_BITS_ERRNO_H = 1 X_BITS_ERRNO_H = 1
X_BITS_FLOATN_COMMON_H = 0 X_BITS_FLOATN_COMMON_H = 0
X_BITS_FLOATN_H = 0 X_BITS_FLOATN_H = 0
X_BITS_G_CONFIG_H = 1
X_BITS_LIBIO_H = 1
X_BITS_POSIX_OPT_H = 1 X_BITS_POSIX_OPT_H = 1
X_BITS_PTHREADTYPES_ARCH_H = 1 X_BITS_PTHREADTYPES_ARCH_H = 1
X_BITS_PTHREADTYPES_COMMON_H = 1 X_BITS_PTHREADTYPES_COMMON_H = 1
X_BITS_STDINT_INTN_H = 1 X_BITS_STDINT_INTN_H = 1
X_BITS_STDIO_LIM_H = 1 X_BITS_STDIO_LIM_H = 1
X_BITS_SYSMACROS_H = 1
X_BITS_TYPESIZES_H = 1 X_BITS_TYPESIZES_H = 1
X_BITS_TYPES_H = 1 X_BITS_TYPES_H = 1
X_BITS_TYPES_LOCALE_T_H = 1 X_BITS_TYPES_LOCALE_T_H = 1
@@ -711,62 +707,11 @@ const (
X_GCC_WCHAR_T = 0 X_GCC_WCHAR_T = 0
X_GETOPT_CORE_H = 1 X_GETOPT_CORE_H = 1
X_GETOPT_POSIX_H = 1 X_GETOPT_POSIX_H = 1
X_G_BUFSIZ = 8192
X_G_HAVE_MMAP = 1
X_G_HAVE_MREMAP = 1
X_G_HAVE_ST_BLKSIZE = 0
X_G_IO_IO_FILE_VERSION = 0x20001
X_IOFBF = 0 X_IOFBF = 0
X_IOLBF = 1 X_IOLBF = 1
X_IONBF = 2 X_IONBF = 2
X_IOS_APPEND = 8 X_IO_EOF_SEEN = 0x0010
X_IOS_ATEND = 4 X_IO_ERR_SEEN = 0x0020
X_IOS_BIN = 128
X_IOS_INPUT = 1
X_IOS_NOCREATE = 32
X_IOS_NOREPLACE = 64
X_IOS_OUTPUT = 2
X_IOS_TRUNC = 16
X_IO_BAD_SEEN = 0x4000
X_IO_BOOLALPHA = 0200000
X_IO_BUFSIZ = 8192
X_IO_CURRENTLY_PUTTING = 0x800
X_IO_DEC = 020
X_IO_DELETE_DONT_CLOSE = 0x40
X_IO_DONT_CLOSE = 0100000
X_IO_EOF_SEEN = 0x10
X_IO_ERR_SEEN = 0x20
X_IO_FIXED = 010000
X_IO_FLAGS2_MMAP = 1
X_IO_FLAGS2_NOTCANCEL = 2
X_IO_FLAGS2_USER_WBUF = 8
X_IO_HAVE_ST_BLKSIZE = 0
X_IO_HEX = 0100
X_IO_INTERNAL = 010
X_IO_IN_BACKUP = 0x100
X_IO_IS_APPENDING = 0x1000
X_IO_IS_FILEBUF = 0x2000
X_IO_LEFT = 02
X_IO_LINE_BUF = 0x200
X_IO_LINKED = 0x80
X_IO_MAGIC = 0xFBAD0000
X_IO_MAGIC_MASK = 0xFFFF0000
X_IO_NO_READS = 4
X_IO_NO_WRITES = 8
X_IO_OCT = 040
X_IO_RIGHT = 04
X_IO_SCIENTIFIC = 04000
X_IO_SHOWBASE = 0200
X_IO_SHOWPOINT = 0400
X_IO_SHOWPOS = 02000
X_IO_SKIPWS = 01
X_IO_STDIO = 040000
X_IO_TIED_PUT_GET = 0x400
X_IO_UNBUFFERED = 2
X_IO_UNIFIED_JUMPTABLES = 1
X_IO_UNITBUF = 020000
X_IO_UPPERCASE = 01000
X_IO_USER_BUF = 1
X_IO_USER_LOCK = 0x8000 X_IO_USER_LOCK = 0x8000
X_LFS64_ASYNCHRONOUS_IO = 1 X_LFS64_ASYNCHRONOUS_IO = 1
X_LFS64_LARGEFILE = 1 X_LFS64_LARGEFILE = 1
@@ -774,7 +719,6 @@ const (
X_LFS_ASYNCHRONOUS_IO = 1 X_LFS_ASYNCHRONOUS_IO = 1
X_LFS_LARGEFILE = 1 X_LFS_LARGEFILE = 1
X_LP64 = 1 X_LP64 = 1
X_OLD_STDIO_MAGIC = 0xFABC0000
X_POSIX2_CHAR_TERM = 200809 X_POSIX2_CHAR_TERM = 200809
X_POSIX2_C_BIND = 200809 X_POSIX2_C_BIND = 200809
X_POSIX2_C_DEV = 200809 X_POSIX2_C_DEV = 200809
@@ -851,7 +795,6 @@ const (
X_STDARG_H = 0 X_STDARG_H = 0
X_STDC_PREDEF_H = 1 X_STDC_PREDEF_H = 1
X_STDIO_H = 1 X_STDIO_H = 1
X_STDIO_USES_IOSTREAM = 0
X_STDLIB_H = 1 X_STDLIB_H = 1
X_STRINGS_H = 1 X_STRINGS_H = 1
X_STRING_H = 1 X_STRING_H = 1
@@ -859,7 +802,6 @@ const (
X_SYS_CDEFS_H = 1 X_SYS_CDEFS_H = 1
X_SYS_SELECT_H = 1 X_SYS_SELECT_H = 1
X_SYS_SIZE_T_H = 0 X_SYS_SIZE_T_H = 0
X_SYS_SYSMACROS_H = 1
X_SYS_TYPES_H = 1 X_SYS_TYPES_H = 1
X_THREAD_SHARED_TYPES_H = 1 X_THREAD_SHARED_TYPES_H = 1
X_T_SIZE = 0 X_T_SIZE = 0
@@ -879,7 +821,6 @@ const (
X_WCHAR_T_H = 0 X_WCHAR_T_H = 0
X_XBS5_LP64_OFF64 = 1 X_XBS5_LP64_OFF64 = 1
X_XBS5_LPBIG_OFFBIG = -1 X_XBS5_LPBIG_OFFBIG = -1
X_XOPEN_CRYPT = 1
X_XOPEN_ENH_I18N = 1 X_XOPEN_ENH_I18N = 1
X_XOPEN_LEGACY = 1 X_XOPEN_LEGACY = 1
X_XOPEN_REALTIME = 1 X_XOPEN_REALTIME = 1
@@ -1406,14 +1347,6 @@ const ( /* confname.h:71:1: */
_SC_THREAD_ROBUST_PRIO_PROTECT = 248 _SC_THREAD_ROBUST_PRIO_PROTECT = 248
) )
// This is the structure from the libstdc++ codecvt class.
const ( /* libio.h:180:1: */
__codecvt_ok = 0
__codecvt_partial = 1
__codecvt_error = 2
__codecvt_noconv = 3
)
// In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
// are already defined. // are already defined.
// BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here.
@@ -3555,7 +3488,49 @@ type fts5_api1 = struct {
// FTS5 EXTENSION REGISTRATION API // FTS5 EXTENSION REGISTRATION API
type fts5_api = fts5_api1 /* sqlite3.h:12223:25 */ type fts5_api = fts5_api1 /* sqlite3.h:12223:25 */
type _IO_FILE1 = struct { // The tag name of this struct is _G_fpos_t to preserve historic
// C++ mangled names for functions taking fpos_t arguments.
// That name should not be used in new code.
type _G_fpos_t = struct {
__pos int64
__state struct {
__count int32
__value struct{ __wch uint32 }
}
} /* __fpos_t.h:10:9 */
// bits/types.h -- definitions of __*_t types underlying *_t types.
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
// This file is part of the GNU C Library.
//
// The GNU C Library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// The GNU C Library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with the GNU C Library; if not, see
// <http://www.gnu.org/licenses/>.
// Never include this file directly; use <sys/types.h> instead.
// The tag name of this struct is _G_fpos64_t to preserve historic
// C++ mangled names for functions taking fpos_t and/or fpos64_t
// arguments. That name should not be used in new code.
type _G_fpos64_t = struct {
__pos int64
__state struct {
__count int32
__value struct{ __wch uint32 }
}
} /* __fpos64_t.h:10:9 */
type _IO_FILE = struct {
_flags int32 _flags int32
_ [4]byte _ [4]byte
_IO_read_ptr uintptr _IO_read_ptr uintptr
@@ -3580,50 +3555,28 @@ type _IO_FILE1 = struct {
_ [4]byte _ [4]byte
_lock uintptr _lock uintptr
_offset int64 _offset int64
__pad1 uintptr _codecvt uintptr
__pad2 uintptr _wide_data uintptr
__pad3 uintptr _freeres_list uintptr
__pad4 uintptr _freeres_buf uintptr
__pad5 size_t __pad5 size_t
_mode int32 _mode int32
_unused2 [20]int8 _unused2 [20]int8
} /* __FILE.h:4:1 */ } /* __FILE.h:4:1 */
// The opaque type of streams. This is the definition used elsewhere. // The opaque type of streams. This is the definition used elsewhere.
type FILE = _IO_FILE1 /* FILE.h:7:25 */ type FILE = _IO_FILE /* FILE.h:7:25 */
type _G_fpos_t = struct { // These macros are used by bits/stdio.h and internal headers.
__pos int64
__state struct {
__count int32
__value struct{ __wch uint32 }
}
} /* _G_config.h:30:3 */
type _G_fpos64_t = struct {
__pos int64
__state struct {
__count int32
__value struct{ __wch uint32 }
}
} /* _G_config.h:35:3 */
// A streammarker remembers a position in a buffer. // Many more flag bits are defined internally.
type _IO_marker = struct { type off_t = int64 /* stdio.h:65:19 */
_next uintptr
_sbuf uintptr
_pos int32
_ [4]byte
} /* __FILE.h:4:1 */
type _IO_FILE = _IO_FILE1 /* libio.h:314:25 */ type ssize_t = int64 /* stdio.h:77:19 */
type off_t = int64 /* stdio.h:59:19 */
type ssize_t = int64 /* stdio.h:71:19 */
// The type of the second argument to `fgetpos' and `fsetpos'. // The type of the second argument to `fgetpos' and `fsetpos'.
type fpos_t = _G_fpos64_t /* stdio.h:80:21 */ type fpos_t = _G_fpos64_t /* stdio.h:86:20 */
// If we are compiling with optimizing read this file. It contains // If we are compiling with optimizing read this file. It contains
// several optimizing inline functions and macros. // several optimizing inline functions and macros.
@@ -3698,8 +3651,6 @@ type fpos_t = _G_fpos64_t /* stdio.h:80:21 */
// The X/Open Unix extensions are available. // The X/Open Unix extensions are available.
// Encryption is present.
// The enhanced internationalization capabilities according to XPG4.2 // The enhanced internationalization capabilities according to XPG4.2
// are present. // are present.
@@ -3991,7 +3942,7 @@ type fpos_t = _G_fpos64_t /* stdio.h:80:21 */
// Never include this file directly; use <sys/types.h> instead. // Never include this file directly; use <sys/types.h> instead.
// Copyright (C) 1989-2017 Free Software Foundation, Inc. // Copyright (C) 1989-2018 Free Software Foundation, Inc.
// //
// This file is part of GCC. // This file is part of GCC.
// //
@@ -4075,17 +4026,17 @@ type fpos_t = _G_fpos64_t /* stdio.h:80:21 */
// The Single Unix specification says that some more types are // The Single Unix specification says that some more types are
// available here. // available here.
type gid_t = uint32 /* unistd.h:235:17 */ type gid_t = uint32 /* unistd.h:232:17 */
type uid_t = uint32 /* unistd.h:240:17 */ type uid_t = uint32 /* unistd.h:237:17 */
type useconds_t = uint32 /* unistd.h:258:22 */ type useconds_t = uint32 /* unistd.h:255:22 */
type pid_t = int32 /* unistd.h:263:17 */ type pid_t = int32 /* unistd.h:260:17 */
type intptr_t = int64 /* unistd.h:270:20 */ type intptr_t = int64 /* unistd.h:267:20 */
type socklen_t = uint32 /* unistd.h:277:21 */ type socklen_t = uint32 /* unistd.h:274:21 */
// In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
// are already defined. // are already defined.
@@ -4319,6 +4270,11 @@ type idtype_t = uint32 /* waitflags.h:57:3 */
// configurations support _Float128x or, as of GCC 7, have compiler // configurations support _Float128x or, as of GCC 7, have compiler
// support for a type meeting the requirements for _Float128x. // support for a type meeting the requirements for _Float128x.
// Defined to 1 if the corresponding _FloatN type is not binary compatible
// with the corresponding ISO C type in the current compilation unit as
// opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built
// in glibc.
// Defined to 1 if any _FloatN or _FloatNx types that are not // Defined to 1 if any _FloatN or _FloatNx types that are not
// ABI-distinct are however distinct types at the C language level (so // ABI-distinct are however distinct types at the C language level (so
// for the purposes of __builtin_types_compatible_p and _Generic). // for the purposes of __builtin_types_compatible_p and _Generic).
@@ -4419,23 +4375,22 @@ type u_long = uint64 /* types.h:36:18 */
type quad_t = int64 /* types.h:37:18 */ type quad_t = int64 /* types.h:37:18 */
type u_quad_t = uint64 /* types.h:38:20 */ type u_quad_t = uint64 /* types.h:38:20 */
type fsid_t = struct{ __val [2]int32 } /* types.h:39:18 */ type fsid_t = struct{ __val [2]int32 } /* types.h:39:18 */
type loff_t = int64 /* types.h:42:18 */
type loff_t = int64 /* types.h:44:18 */ type ino_t = uint64 /* types.h:49:19 */
type ino_t = uint64 /* types.h:50:19 */ type dev_t = uint64 /* types.h:59:17 */
type dev_t = uint64 /* types.h:60:17 */ type mode_t = uint32 /* types.h:69:18 */
type mode_t = uint32 /* types.h:70:18 */ type nlink_t = uint64 /* types.h:74:19 */
type nlink_t = uint64 /* types.h:75:19 */ type id_t = uint32 /* types.h:103:16 */
type id_t = uint32 /* types.h:104:16 */ type daddr_t = int32 /* types.h:114:19 */
type caddr_t = uintptr /* types.h:115:19 */
type daddr_t = int32 /* types.h:115:19 */ type key_t = int32 /* types.h:121:17 */
type caddr_t = uintptr /* types.h:116:19 */
type key_t = int32 /* types.h:122:17 */
// bits/types.h -- definitions of __*_t types underlying *_t types. // bits/types.h -- definitions of __*_t types underlying *_t types.
// Copyright (C) 2002-2018 Free Software Foundation, Inc. // Copyright (C) 2002-2018 Free Software Foundation, Inc.
@@ -4529,7 +4484,7 @@ type time_t = int64 /* time_t.h:7:18 */
// Timer ID returned by `timer_create'. // Timer ID returned by `timer_create'.
type timer_t = uintptr /* timer_t.h:7:19 */ type timer_t = uintptr /* timer_t.h:7:19 */
// Copyright (C) 1989-2017 Free Software Foundation, Inc. // Copyright (C) 1989-2018 Free Software Foundation, Inc.
// //
// This file is part of GCC. // This file is part of GCC.
// //
@@ -4612,9 +4567,9 @@ type timer_t = uintptr /* timer_t.h:7:19 */
// A null pointer constant. // A null pointer constant.
// Old compatibility names for C types. // Old compatibility names for C types.
type ulong = uint64 /* types.h:149:27 */ type ulong = uint64 /* types.h:148:27 */
type ushort = uint16 /* types.h:150:28 */ type ushort = uint16 /* types.h:149:28 */
type uint = uint32 /* types.h:151:22 */ type uint = uint32 /* types.h:150:22 */
// These size-specific names are used by some of the inet code. // These size-specific names are used by some of the inet code.
@@ -4663,12 +4618,12 @@ type int64_t = int64 /* stdint-intn.h:27:19 */
// For GCC 2.7 and later, we can use specific type-size attributes. // For GCC 2.7 and later, we can use specific type-size attributes.
type u_int8_t = uint32 /* types.h:178:1 */ type u_int8_t = uint32 /* types.h:177:1 */
type u_int16_t = uint32 /* types.h:179:1 */ type u_int16_t = uint32 /* types.h:178:1 */
type u_int32_t = uint32 /* types.h:180:1 */ type u_int32_t = uint32 /* types.h:179:1 */
type u_int64_t = uint32 /* types.h:181:1 */ type u_int64_t = uint32 /* types.h:180:1 */
type register_t = int32 /* types.h:183:13 */ type register_t = int32 /* types.h:182:13 */
// A set of signals to be blocked, unblocked, or waited for. // A set of signals to be blocked, unblocked, or waited for.
type sigset_t = struct{ __val [16]uint64 } /* sigset_t.h:7:20 */ type sigset_t = struct{ __val [16]uint64 } /* sigset_t.h:7:20 */
@@ -4744,12 +4699,14 @@ type fd_set = struct{ __fds_bits [16]int64 } /* select.h:70:5 */
// Sometimes the fd_set member is assumed to have this type. // Sometimes the fd_set member is assumed to have this type.
type fd_mask = int64 /* select.h:77:19 */ type fd_mask = int64 /* select.h:77:19 */
type blksize_t = int64 /* types.h:212:21 */ // Define some inlines helping to catch common problems.
type blksize_t = int64 /* types.h:202:21 */
// Types from the Large File Support interface. // Types from the Large File Support interface.
type blkcnt_t = int64 /* types.h:232:22 */ // Type to count number of disk blocks. type blkcnt_t = int64 /* types.h:222:22 */ // Type to count number of disk blocks.
type fsblkcnt_t = uint64 /* types.h:236:24 */ // Type to count file system blocks. type fsblkcnt_t = uint64 /* types.h:226:24 */ // Type to count file system blocks.
type fsfilcnt_t = uint64 /* types.h:240:24 */ // Type to count file system inodes. type fsfilcnt_t = uint64 /* types.h:230:24 */ // Type to count file system inodes.
// Now add the thread types. // Now add the thread types.
// Declaration of common pthread types for all architectures. // Declaration of common pthread types for all architectures.

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
// Code generated by 'ccgo -DSQLITE_PRIVATE= -export-defines -export-enums -export-externs X -export-fields F -export-typedefs -pkgname sqlite3 -o lib/sqlite_linux_amd64.go -trace-translation-units testdata/sqlite-amalgamation-3350000/sqlite3.c -DNDEBUG -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 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT. // Code generated by 'ccgo -DSQLITE_PRIVATE= -export-defines -export-enums -export-externs X -export-fields F -export-typedefs -pkgname sqlite3 -o lib/sqlite_linux_amd64.go -trace-translation-units testdata/sqlite-amalgamation-3350000/sqlite3.c -DNDEBUG -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 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT.
package sqlite3 package sqlite3
@@ -405,6 +405,7 @@ var CAPI = map[string]struct{}{
"sqlite3MemCompare": {}, "sqlite3MemCompare": {},
"sqlite3MemJournalOpen": {}, "sqlite3MemJournalOpen": {},
"sqlite3MemSetDefault": {}, "sqlite3MemSetDefault": {},
"sqlite3MemoryBarrier": {},
"sqlite3MisuseError": {}, "sqlite3MisuseError": {},
"sqlite3MulInt64": {}, "sqlite3MulInt64": {},
"sqlite3MultiWrite": {}, "sqlite3MultiWrite": {},

File diff suppressed because one or more lines are too long

View File

@@ -148870,7 +148870,6 @@ func Xsqlite3GenerateConstraintChecks(tls *libc.TLS, pParse uintptr, pTab uintpt
goto __4 goto __4
goto __6 goto __6
__6: __6:
} }
} }
@@ -204101,7 +204100,6 @@ __15:
goto __14 goto __14
goto __16 goto __16
__16: __16:
} }
// This is a helper function for rbuObjIterCacheTableInfo(). It populates // This is a helper function for rbuObjIterCacheTableInfo(). It populates

View File

@@ -1,4 +1,4 @@
// Code generated by 'ccgo -DSQLITE_PRIVATE= -export-defines -export-enums -export-externs X -export-fields F -export-typedefs -pkgname sqlite3 -o libtest/sqlite_linux_amd64.go -trace-translation-units -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 testdata/sqlite-amalgamation-3350000/sqlite3.c -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DSQLITE_CKSUMVFS_STATIC -DSQLITE_CORE -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_PAGE_SIZE=1024 -DSQLITE_ENABLE_BYTECODE_VTAB -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_DESERIALIZE -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 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_HAVE_ZLIB=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_TEMP_STORE=1 -DSQLITE_TEST -DSQLITE_THREADSAFE=1', DO NOT EDIT. // Code generated by 'ccgo -DSQLITE_PRIVATE= -export-defines -export-enums -export-externs X -export-fields F -export-typedefs -pkgname sqlite3 -o libtest/sqlite_linux_amd64.go -trace-translation-units -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 testdata/sqlite-amalgamation-3350000/sqlite3.c -DNDEBUG -DHAVE_USLEEP -DLONGDOUBLE_TYPE=double -DSQLITE_CKSUMVFS_STATIC -DSQLITE_CORE -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_PAGE_SIZE=1024 -DSQLITE_ENABLE_BYTECODE_VTAB -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_DESERIALIZE -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 -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_HAVE_ZLIB=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_SOUNDEX -DSQLITE_TEMP_STORE=1 -DSQLITE_TEST -DSQLITE_THREADSAFE=1', DO NOT EDIT.
package sqlite3 package sqlite3
@@ -412,6 +412,7 @@ var CAPI = map[string]struct{}{
"sqlite3MemJournalOpen": {}, "sqlite3MemJournalOpen": {},
"sqlite3MemSetDefault": {}, "sqlite3MemSetDefault": {},
"sqlite3MemdbInit": {}, "sqlite3MemdbInit": {},
"sqlite3MemoryBarrier": {},
"sqlite3MisuseError": {}, "sqlite3MisuseError": {},
"sqlite3MulInt64": {}, "sqlite3MulInt64": {},
"sqlite3MultiWrite": {}, "sqlite3MultiWrite": {},

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
// Code generated by 'ccgo -export-defines "" -o speedtest1/main_linux_amd64.go -trace-translation-units testdata/sqlite-src-3350000/test/speedtest1.c -Itestdata/sqlite-amalgamation-3350000 -l modernc.org/sqlite/lib -DNDEBUG -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 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_MUTEX_NOOP -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT. // Code generated by 'ccgo -export-defines "" -o speedtest1/main_linux_amd64.go -trace-translation-units testdata/sqlite-src-3350000/test/speedtest1.c -Itestdata/sqlite-amalgamation-3350000 -l modernc.org/sqlite/lib -DNDEBUG -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 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MUTEX_APPDEF=1 -DSQLITE_SOUNDEX -DSQLITE_THREADSAFE=1 -DSQLITE_OS_UNIX=1', DO NOT EDIT.
package main package main
@@ -359,7 +359,6 @@ const (
SQLITE_MISUSE = 21 SQLITE_MISUSE = 21
SQLITE_MUTEX_APPDEF = 1 SQLITE_MUTEX_APPDEF = 1
SQLITE_MUTEX_FAST = 0 SQLITE_MUTEX_FAST = 0
SQLITE_MUTEX_NOOP = 1
SQLITE_MUTEX_RECURSIVE = 1 SQLITE_MUTEX_RECURSIVE = 1
SQLITE_MUTEX_STATIC_APP1 = 8 SQLITE_MUTEX_STATIC_APP1 = 8
SQLITE_MUTEX_STATIC_APP2 = 9 SQLITE_MUTEX_STATIC_APP2 = 9
@@ -547,14 +546,11 @@ const (
X_BITS_BYTESWAP_H = 1 X_BITS_BYTESWAP_H = 1
X_BITS_FLOATN_COMMON_H = 0 X_BITS_FLOATN_COMMON_H = 0
X_BITS_FLOATN_H = 0 X_BITS_FLOATN_H = 0
X_BITS_G_CONFIG_H = 1
X_BITS_LIBIO_H = 1
X_BITS_POSIX_OPT_H = 1 X_BITS_POSIX_OPT_H = 1
X_BITS_PTHREADTYPES_ARCH_H = 1 X_BITS_PTHREADTYPES_ARCH_H = 1
X_BITS_PTHREADTYPES_COMMON_H = 1 X_BITS_PTHREADTYPES_COMMON_H = 1
X_BITS_STDINT_INTN_H = 1 X_BITS_STDINT_INTN_H = 1
X_BITS_STDIO_LIM_H = 1 X_BITS_STDIO_LIM_H = 1
X_BITS_SYSMACROS_H = 1
X_BITS_TYPESIZES_H = 1 X_BITS_TYPESIZES_H = 1
X_BITS_TYPES_H = 1 X_BITS_TYPES_H = 1
X_BITS_TYPES_LOCALE_T_H = 1 X_BITS_TYPES_LOCALE_T_H = 1
@@ -572,62 +568,11 @@ const (
X_GCC_WCHAR_T = 0 X_GCC_WCHAR_T = 0
X_GETOPT_CORE_H = 1 X_GETOPT_CORE_H = 1
X_GETOPT_POSIX_H = 1 X_GETOPT_POSIX_H = 1
X_G_BUFSIZ = 8192
X_G_HAVE_MMAP = 1
X_G_HAVE_MREMAP = 1
X_G_HAVE_ST_BLKSIZE = 0
X_G_IO_IO_FILE_VERSION = 0x20001
X_IOFBF = 0 X_IOFBF = 0
X_IOLBF = 1 X_IOLBF = 1
X_IONBF = 2 X_IONBF = 2
X_IOS_APPEND = 8 X_IO_EOF_SEEN = 0x0010
X_IOS_ATEND = 4 X_IO_ERR_SEEN = 0x0020
X_IOS_BIN = 128
X_IOS_INPUT = 1
X_IOS_NOCREATE = 32
X_IOS_NOREPLACE = 64
X_IOS_OUTPUT = 2
X_IOS_TRUNC = 16
X_IO_BAD_SEEN = 0x4000
X_IO_BOOLALPHA = 0200000
X_IO_BUFSIZ = 8192
X_IO_CURRENTLY_PUTTING = 0x800
X_IO_DEC = 020
X_IO_DELETE_DONT_CLOSE = 0x40
X_IO_DONT_CLOSE = 0100000
X_IO_EOF_SEEN = 0x10
X_IO_ERR_SEEN = 0x20
X_IO_FIXED = 010000
X_IO_FLAGS2_MMAP = 1
X_IO_FLAGS2_NOTCANCEL = 2
X_IO_FLAGS2_USER_WBUF = 8
X_IO_HAVE_ST_BLKSIZE = 0
X_IO_HEX = 0100
X_IO_INTERNAL = 010
X_IO_IN_BACKUP = 0x100
X_IO_IS_APPENDING = 0x1000
X_IO_IS_FILEBUF = 0x2000
X_IO_LEFT = 02
X_IO_LINE_BUF = 0x200
X_IO_LINKED = 0x80
X_IO_MAGIC = 0xFBAD0000
X_IO_MAGIC_MASK = 0xFFFF0000
X_IO_NO_READS = 4
X_IO_NO_WRITES = 8
X_IO_OCT = 040
X_IO_RIGHT = 04
X_IO_SCIENTIFIC = 04000
X_IO_SHOWBASE = 0200
X_IO_SHOWPOINT = 0400
X_IO_SHOWPOS = 02000
X_IO_SKIPWS = 01
X_IO_STDIO = 040000
X_IO_TIED_PUT_GET = 0x400
X_IO_UNBUFFERED = 2
X_IO_UNIFIED_JUMPTABLES = 1
X_IO_UNITBUF = 020000
X_IO_UPPERCASE = 01000
X_IO_USER_BUF = 1
X_IO_USER_LOCK = 0x8000 X_IO_USER_LOCK = 0x8000
X_LFS64_ASYNCHRONOUS_IO = 1 X_LFS64_ASYNCHRONOUS_IO = 1
X_LFS64_LARGEFILE = 1 X_LFS64_LARGEFILE = 1
@@ -635,7 +580,6 @@ const (
X_LFS_ASYNCHRONOUS_IO = 1 X_LFS_ASYNCHRONOUS_IO = 1
X_LFS_LARGEFILE = 1 X_LFS_LARGEFILE = 1
X_LP64 = 1 X_LP64 = 1
X_OLD_STDIO_MAGIC = 0xFABC0000
X_POSIX2_CHAR_TERM = 200809 X_POSIX2_CHAR_TERM = 200809
X_POSIX2_C_BIND = 200809 X_POSIX2_C_BIND = 200809
X_POSIX2_C_DEV = 200809 X_POSIX2_C_DEV = 200809
@@ -712,7 +656,6 @@ const (
X_STDARG_H = 0 X_STDARG_H = 0
X_STDC_PREDEF_H = 1 X_STDC_PREDEF_H = 1
X_STDIO_H = 1 X_STDIO_H = 1
X_STDIO_USES_IOSTREAM = 0
X_STDLIB_H = 1 X_STDLIB_H = 1
X_STRINGS_H = 1 X_STRINGS_H = 1
X_STRING_H = 1 X_STRING_H = 1
@@ -720,7 +663,6 @@ const (
X_SYS_CDEFS_H = 1 X_SYS_CDEFS_H = 1
X_SYS_SELECT_H = 1 X_SYS_SELECT_H = 1
X_SYS_SIZE_T_H = 0 X_SYS_SIZE_T_H = 0
X_SYS_SYSMACROS_H = 1
X_SYS_TYPES_H = 1 X_SYS_TYPES_H = 1
X_THREAD_SHARED_TYPES_H = 1 X_THREAD_SHARED_TYPES_H = 1
X_T_SIZE = 0 X_T_SIZE = 0
@@ -740,7 +682,6 @@ const (
X_WCHAR_T_H = 0 X_WCHAR_T_H = 0
X_XBS5_LP64_OFF64 = 1 X_XBS5_LP64_OFF64 = 1
X_XBS5_LPBIG_OFFBIG = -1 X_XBS5_LPBIG_OFFBIG = -1
X_XOPEN_CRYPT = 1
X_XOPEN_ENH_I18N = 1 X_XOPEN_ENH_I18N = 1
X_XOPEN_LEGACY = 1 X_XOPEN_LEGACY = 1
X_XOPEN_REALTIME = 1 X_XOPEN_REALTIME = 1
@@ -1220,14 +1161,6 @@ const ( /* confname.h:71:1: */
_SC_THREAD_ROBUST_PRIO_PROTECT = 248 _SC_THREAD_ROBUST_PRIO_PROTECT = 248
) )
// This is the structure from the libstdc++ codecvt class.
const ( /* libio.h:180:1: */
__codecvt_ok = 0
__codecvt_partial = 1
__codecvt_error = 2
__codecvt_noconv = 3
)
// In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
// are already defined. // are already defined.
// BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here. // BSD/OS 3.1 and FreeBSD [23].x require the MACHINE_ANSI_H check here.
@@ -3374,7 +3307,49 @@ type fts5_api1 = struct {
// FTS5 EXTENSION REGISTRATION API // FTS5 EXTENSION REGISTRATION API
type fts5_api = fts5_api1 /* sqlite3.h:12223:25 */ type fts5_api = fts5_api1 /* sqlite3.h:12223:25 */
type _IO_FILE1 = struct { // The tag name of this struct is _G_fpos_t to preserve historic
// C++ mangled names for functions taking fpos_t arguments.
// That name should not be used in new code.
type _G_fpos_t = struct {
__pos int64
__state struct {
__count int32
__value struct{ __wch uint32 }
}
} /* __fpos_t.h:10:9 */
// bits/types.h -- definitions of __*_t types underlying *_t types.
// Copyright (C) 2002-2018 Free Software Foundation, Inc.
// This file is part of the GNU C Library.
//
// The GNU C Library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// The GNU C Library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with the GNU C Library; if not, see
// <http://www.gnu.org/licenses/>.
// Never include this file directly; use <sys/types.h> instead.
// The tag name of this struct is _G_fpos64_t to preserve historic
// C++ mangled names for functions taking fpos_t and/or fpos64_t
// arguments. That name should not be used in new code.
type _G_fpos64_t = struct {
__pos int64
__state struct {
__count int32
__value struct{ __wch uint32 }
}
} /* __fpos64_t.h:10:9 */
type _IO_FILE = struct {
_flags int32 _flags int32
_ [4]byte _ [4]byte
_IO_read_ptr uintptr _IO_read_ptr uintptr
@@ -3399,50 +3374,28 @@ type _IO_FILE1 = struct {
_ [4]byte _ [4]byte
_lock uintptr _lock uintptr
_offset int64 _offset int64
__pad1 uintptr _codecvt uintptr
__pad2 uintptr _wide_data uintptr
__pad3 uintptr _freeres_list uintptr
__pad4 uintptr _freeres_buf uintptr
__pad5 size_t __pad5 size_t
_mode int32 _mode int32
_unused2 [20]int8 _unused2 [20]int8
} /* __FILE.h:4:1 */ } /* __FILE.h:4:1 */
// The opaque type of streams. This is the definition used elsewhere. // The opaque type of streams. This is the definition used elsewhere.
type FILE = _IO_FILE1 /* FILE.h:7:25 */ type FILE = _IO_FILE /* FILE.h:7:25 */
type _G_fpos_t = struct { // These macros are used by bits/stdio.h and internal headers.
__pos int64
__state struct {
__count int32
__value struct{ __wch uint32 }
}
} /* _G_config.h:30:3 */
type _G_fpos64_t = struct {
__pos int64
__state struct {
__count int32
__value struct{ __wch uint32 }
}
} /* _G_config.h:35:3 */
// A streammarker remembers a position in a buffer. // Many more flag bits are defined internally.
type _IO_marker = struct { type off_t = int64 /* stdio.h:65:19 */
_next uintptr
_sbuf uintptr
_pos int32
_ [4]byte
} /* __FILE.h:4:1 */
type _IO_FILE = _IO_FILE1 /* libio.h:314:25 */ type ssize_t = int64 /* stdio.h:77:19 */
type off_t = int64 /* stdio.h:59:19 */
type ssize_t = int64 /* stdio.h:71:19 */
// The type of the second argument to `fgetpos' and `fsetpos'. // The type of the second argument to `fgetpos' and `fsetpos'.
type fpos_t = _G_fpos64_t /* stdio.h:80:21 */ type fpos_t = _G_fpos64_t /* stdio.h:86:20 */
// In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. // In 4.3bsd-net2, leave these undefined to indicate that size_t, etc.
// are already defined. // are already defined.
@@ -3676,6 +3629,11 @@ type idtype_t = uint32 /* waitflags.h:57:3 */
// configurations support _Float128x or, as of GCC 7, have compiler // configurations support _Float128x or, as of GCC 7, have compiler
// support for a type meeting the requirements for _Float128x. // support for a type meeting the requirements for _Float128x.
// Defined to 1 if the corresponding _FloatN type is not binary compatible
// with the corresponding ISO C type in the current compilation unit as
// opposed to __HAVE_DISTINCT_FLOATN, which indicates the default types built
// in glibc.
// Defined to 1 if any _FloatN or _FloatNx types that are not // Defined to 1 if any _FloatN or _FloatNx types that are not
// ABI-distinct are however distinct types at the C language level (so // ABI-distinct are however distinct types at the C language level (so
// for the purposes of __builtin_types_compatible_p and _Generic). // for the purposes of __builtin_types_compatible_p and _Generic).
@@ -3776,29 +3734,28 @@ type u_long = uint64 /* types.h:36:18 */
type quad_t = int64 /* types.h:37:18 */ type quad_t = int64 /* types.h:37:18 */
type u_quad_t = uint64 /* types.h:38:20 */ type u_quad_t = uint64 /* types.h:38:20 */
type fsid_t = struct{ __val [2]int32 } /* types.h:39:18 */ type fsid_t = struct{ __val [2]int32 } /* types.h:39:18 */
type loff_t = int64 /* types.h:42:18 */
type loff_t = int64 /* types.h:44:18 */ type ino_t = uint64 /* types.h:49:19 */
type ino_t = uint64 /* types.h:50:19 */ type dev_t = uint64 /* types.h:59:17 */
type dev_t = uint64 /* types.h:60:17 */ type gid_t = uint32 /* types.h:64:17 */
type gid_t = uint32 /* types.h:65:17 */ type mode_t = uint32 /* types.h:69:18 */
type mode_t = uint32 /* types.h:70:18 */ type nlink_t = uint64 /* types.h:74:19 */
type nlink_t = uint64 /* types.h:75:19 */ type uid_t = uint32 /* types.h:79:17 */
type uid_t = uint32 /* types.h:80:17 */ type pid_t = int32 /* types.h:97:17 */
type pid_t = int32 /* types.h:98:17 */ type id_t = uint32 /* types.h:103:16 */
type id_t = uint32 /* types.h:104:16 */ type daddr_t = int32 /* types.h:114:19 */
type caddr_t = uintptr /* types.h:115:19 */
type daddr_t = int32 /* types.h:115:19 */ type key_t = int32 /* types.h:121:17 */
type caddr_t = uintptr /* types.h:116:19 */
type key_t = int32 /* types.h:122:17 */
// bits/types.h -- definitions of __*_t types underlying *_t types. // bits/types.h -- definitions of __*_t types underlying *_t types.
// Copyright (C) 2002-2018 Free Software Foundation, Inc. // Copyright (C) 2002-2018 Free Software Foundation, Inc.
@@ -3892,7 +3849,7 @@ type time_t = int64 /* time_t.h:7:18 */
// Timer ID returned by `timer_create'. // Timer ID returned by `timer_create'.
type timer_t = uintptr /* timer_t.h:7:19 */ type timer_t = uintptr /* timer_t.h:7:19 */
// Copyright (C) 1989-2017 Free Software Foundation, Inc. // Copyright (C) 1989-2018 Free Software Foundation, Inc.
// //
// This file is part of GCC. // This file is part of GCC.
// //
@@ -3975,9 +3932,9 @@ type timer_t = uintptr /* timer_t.h:7:19 */
// A null pointer constant. // A null pointer constant.
// Old compatibility names for C types. // Old compatibility names for C types.
type ulong = uint64 /* types.h:149:27 */ type ulong = uint64 /* types.h:148:27 */
type ushort = uint16 /* types.h:150:28 */ type ushort = uint16 /* types.h:149:28 */
type uint = uint32 /* types.h:151:22 */ type uint = uint32 /* types.h:150:22 */
// These size-specific names are used by some of the inet code. // These size-specific names are used by some of the inet code.
@@ -4026,12 +3983,12 @@ type int64_t = int64 /* stdint-intn.h:27:19 */
// For GCC 2.7 and later, we can use specific type-size attributes. // For GCC 2.7 and later, we can use specific type-size attributes.
type u_int8_t = uint32 /* types.h:178:1 */ type u_int8_t = uint32 /* types.h:177:1 */
type u_int16_t = uint32 /* types.h:179:1 */ type u_int16_t = uint32 /* types.h:178:1 */
type u_int32_t = uint32 /* types.h:180:1 */ type u_int32_t = uint32 /* types.h:179:1 */
type u_int64_t = uint32 /* types.h:181:1 */ type u_int64_t = uint32 /* types.h:180:1 */
type register_t = int32 /* types.h:183:13 */ type register_t = int32 /* types.h:182:13 */
// A set of signals to be blocked, unblocked, or waited for. // A set of signals to be blocked, unblocked, or waited for.
type sigset_t = struct{ __val [16]uint64 } /* sigset_t.h:7:20 */ type sigset_t = struct{ __val [16]uint64 } /* sigset_t.h:7:20 */
@@ -4107,12 +4064,14 @@ type fd_set = struct{ __fds_bits [16]int64 } /* select.h:70:5 */
// Sometimes the fd_set member is assumed to have this type. // Sometimes the fd_set member is assumed to have this type.
type fd_mask = int64 /* select.h:77:19 */ type fd_mask = int64 /* select.h:77:19 */
type blksize_t = int64 /* types.h:212:21 */ // Define some inlines helping to catch common problems.
type blksize_t = int64 /* types.h:202:21 */
// Types from the Large File Support interface. // Types from the Large File Support interface.
type blkcnt_t = int64 /* types.h:232:22 */ // Type to count number of disk blocks. type blkcnt_t = int64 /* types.h:222:22 */ // Type to count number of disk blocks.
type fsblkcnt_t = uint64 /* types.h:236:24 */ // Type to count file system blocks. type fsblkcnt_t = uint64 /* types.h:226:24 */ // Type to count file system blocks.
type fsfilcnt_t = uint64 /* types.h:240:24 */ // Type to count file system inodes. type fsfilcnt_t = uint64 /* types.h:230:24 */ // Type to count file system inodes.
// Now add the thread types. // Now add the thread types.
// Declaration of common pthread types for all architectures. // Declaration of common pthread types for all architectures.
@@ -4489,8 +4448,6 @@ type locale_t = uintptr /* locale_t.h:24:20 */
// The X/Open Unix extensions are available. // The X/Open Unix extensions are available.
// Encryption is present.
// The enhanced internationalization capabilities according to XPG4.2 // The enhanced internationalization capabilities according to XPG4.2
// are present. // are present.
@@ -4782,7 +4739,7 @@ type locale_t = uintptr /* locale_t.h:24:20 */
// Never include this file directly; use <sys/types.h> instead. // Never include this file directly; use <sys/types.h> instead.
// Copyright (C) 1989-2017 Free Software Foundation, Inc. // Copyright (C) 1989-2018 Free Software Foundation, Inc.
// //
// This file is part of GCC. // This file is part of GCC.
// //
@@ -4867,11 +4824,11 @@ type locale_t = uintptr /* locale_t.h:24:20 */
// The Single Unix specification says that some more types are // The Single Unix specification says that some more types are
// available here. // available here.
type useconds_t = uint32 /* unistd.h:258:22 */ type useconds_t = uint32 /* unistd.h:255:22 */
type intptr_t = int64 /* unistd.h:270:20 */ type intptr_t = int64 /* unistd.h:267:20 */
type socklen_t = uint32 /* unistd.h:277:21 */ type socklen_t = uint32 /* unistd.h:274:21 */
// Define some macros helping to catch buffer overflows. // Define some macros helping to catch buffer overflows.

View File

@@ -15,6 +15,7 @@ import (
"io" "io"
"math" "math"
"reflect" "reflect"
"runtime"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@@ -127,11 +128,14 @@ func init() {
panic(fmt.Errorf("cannot allocate memory")) panic(fmt.Errorf("cannot allocate memory"))
} }
// int sqlite3_config(int, ...); // experimental pthreads support currently only on linux/amd64
if rc := sqlite3.Xsqlite3_config(tls, sqlite3.SQLITE_CONFIG_MUTEX, libc.VaList(varArgs, uintptr(unsafe.Pointer(&mutexMethods)))); rc != sqlite3.SQLITE_OK { if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
p := sqlite3.Xsqlite3_errstr(tls, rc) // int sqlite3_config(int, ...);
str := libc.GoString(p) if rc := sqlite3.Xsqlite3_config(tls, sqlite3.SQLITE_CONFIG_MUTEX, libc.VaList(varArgs, uintptr(unsafe.Pointer(&mutexMethods)))); rc != sqlite3.SQLITE_OK {
panic(fmt.Errorf("sqlite: failed to configure mutex methods: %v", str)) p := sqlite3.Xsqlite3_errstr(tls, rc)
str := libc.GoString(p)
panic(fmt.Errorf("sqlite: failed to configure mutex methods: %v", str))
}
} }
libc.Xfree(tls, varArgs) libc.Xfree(tls, varArgs)

127
testdata/overlay/crash5.test vendored Normal file
View File

@@ -0,0 +1,127 @@
# 2007 Aug 13
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
#
# This file tests aspects of recovery from a malloc() failure
# in a CREATE INDEX statement.
#
# $Id: crash5.test,v 1.3 2008/07/12 14:52:20 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
# Only run these tests if memory debugging is turned on.
#
ifcapable !crashtest||!memorymanage {
puts "Skipping crash5 tests: not compiled with -DSQLITE_ENABLE_MEMORY_MANAGEMENT..."
finish_test
return
}
db close
for {set ii 0} {$ii < 10} {incr ii} {
for {set jj 1} {$jj < 100} {incr jj} {
# Set up the database so that it is an auto-vacuum database
# containing a single table (root page 3) with a single row.
# The row has an overflow page (page 4).
forcedelete test.db test.db-journal
sqlite3 db test.db
set c [string repeat 3 1500]
db eval {
pragma auto_vacuum = 1;
CREATE TABLE t1(a, b, c);
INSERT INTO t1 VALUES('1111111111', '2222222222', $c);
}
db close
do_test crash5-$ii.$jj.1 {
crashsql -delay 1 -file test.db-journal -seed $ii -tclbody [join [list \
[list set iFail $jj] {
proc get_pwd {} {
if {$::tcl_platform(platform) eq "windows"} {
if {[info exists ::env(ComSpec)]} {
set comSpec $::env(ComSpec)
} else {
# NOTE: Hard-code the typical default value.
set comSpec {C:\Windows\system32\cmd.exe}
}
return [string map [list \\ /] \
[string trim [exec -- $comSpec /c echo cd ]]]
} else {
return [pwd]
}
}
sqlite3_crashparams 0 [file join [get_pwd] test.db-journal]
# Begin a transaction and evaluate a "CREATE INDEX" statement
# with the iFail'th malloc() set to fail. This operation will
# have to move the current contents of page 4 (the overflow
# page) to make room for the new root page. The bug is that
# if malloc() fails at a particular point in sqlite3PagerMovepage(),
# sqlite mistakenly thinks that the page being moved (page 4) has
# been safely synced into the journal. If the page is written
# to later in the transaction, it may be written out to the database
# before the relevant part of the journal has been synced.
#
db eval BEGIN
sqlite3_memdebug_fail $iFail -repeat 0
set rc [catch {db eval { CREATE UNIQUE INDEX i1 ON t1(a); }} msg]
# puts "$msg ac=[sqlite3_get_autocommit db] iFail=$iFail"
# puts "fail=[sqlite3_memdebug_fail -1]"
if {$rc} {
# If the transaction is still active (it may not be if the malloc()
# failure occurred in the OS layer), write to the database. Make sure
# page 4 is among those written.
#
if {![sqlite3_get_autocommit db]} {
db eval {
DELETE FROM t1; -- This will put page 4 on the free list.
INSERT INTO t1 VALUES('111111111', '2222222222', '33333333');
INSERT INTO t1 SELECT * FROM t1; -- 2
INSERT INTO t1 SELECT * FROM t1; -- 4
INSERT INTO t1 SELECT * FROM t1; -- 8
INSERT INTO t1 SELECT * FROM t1; -- 16
INSERT INTO t1 SELECT * FROM t1; -- 32
INSERT INTO t1 SELECT * FROM t1 WHERE rowid%2; -- 48
}
}
# If the right malloc() failed during the 'CREATE INDEX' above and
# the transaction was not rolled back, then the sqlite cache now
# has a dirty page 4 that it incorrectly believes is already safely
# in the synced part of the journal file. When
# sqlite3_release_memory() is called sqlite tries to free memory
# by writing page 4 out to the db file. If it crashes later on,
# before syncing the journal... Corruption!
#
sqlite3_crashparams 1 [file join [get_pwd] test.db-journal]
sqlite3_release_memory 8092
}
}]] {}
expr 1
} {1}
sqlite3 db test.db
do_test crash5-$ii.$jj.2 {
db eval {pragma integrity_check}
} {ok}
do_test crash5-$ii.$jj.3 {
db eval {SELECT * FROM t1}
} [list 1111111111 2222222222 $::c]
db close
}
}
finish_test

2497
testdata/overlay/tester.tcl vendored Normal file

File diff suppressed because it is too large Load Diff

150
testdata/tcl/atrc.c vendored Normal file
View File

@@ -0,0 +1,150 @@
/*
** This program generates a script that stresses the ALTER TABLE statement.
** Compile like this:
**
** gcc -g -c sqlite3.c
** gcc -g -o atrc atrc.c sqlite3.o -ldl -lpthread
**
** Run the program this way:
**
** ./atrc DATABASE | ./sqlite3 DATABASE
**
** This program "atrc" generates a script that can be fed into an ordinary
** command-line shell. The script performs many ALTER TABLE statements,
** runs ".schema --indent" and "PRAGMA integrity_check;", does more
** ALTER TABLE statements to restore the original schema, and then
** runs "PRAGMA integrity_check" again. Every table and column has its
** name changed. The entire script is contained within BEGIN...ROLLBACK
** so that no changes are ever actually made to the database.
*/
#include "sqlite3.h"
#include <stdio.h>
/*
** Generate the text of ALTER TABLE statements that will rename
** every column in table zTable to a generic name composed from
** zColPrefix and a sequential number. The generated text is
** appended pConvert. If pUndo is not NULL, then SQL text that
** will undo the change is appended to pUndo.
**
** The table to be converted must be in the "main" schema.
*/
int rename_all_columns_of_table(
sqlite3 *db, /* Database connection */
const char *zTab, /* Table whose columns should all be renamed */
const char *zColPrefix, /* Prefix for new column names */
sqlite3_str *pConvert, /* Append ALTER TABLE statements here */
sqlite3_str *pUndo /* SQL to undo the change, if not NULL */
){
sqlite3_stmt *pStmt;
int rc;
int cnt = 0;
rc = sqlite3_prepare_v2(db,
"SELECT name FROM pragma_table_info(?1);",
-1, &pStmt, 0);
if( rc ) return rc;
sqlite3_bind_text(pStmt, 1, zTab, -1, SQLITE_STATIC);
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zCol = (const char*)sqlite3_column_text(pStmt, 0);
cnt++;
sqlite3_str_appendf(pConvert,
"ALTER TABLE \"%w\" RENAME COLUMN \"%w\" TO \"%w%d\";\n",
zTab, zCol, zColPrefix, cnt
);
if( pUndo ){
sqlite3_str_appendf(pUndo,
"ALTER TABLE \"%w\" RENAME COLUMN \"%w%d\" TO \"%w\";\n",
zTab, zColPrefix, cnt, zCol
);
}
}
sqlite3_finalize(pStmt);
return SQLITE_OK;
}
/* Rename all tables and their columns in the main database
*/
int rename_all_tables(
sqlite3 *db, /* Database connection */
sqlite3_str *pConvert, /* Append SQL to do the rename here */
sqlite3_str *pUndo /* Append SQL to undo the rename here */
){
sqlite3_stmt *pStmt;
int rc;
int cnt = 0;
rc = sqlite3_prepare_v2(db,
"SELECT name FROM sqlite_schema WHERE type='table'"
" AND name NOT LIKE 'sqlite_%';",
-1, &pStmt, 0);
if( rc ) return rc;
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const char *zTab = (const char*)sqlite3_column_text(pStmt, 0);
char *zNewTab;
char zPrefix[2];
zPrefix[0] = (cnt%26) + 'a';
zPrefix[1] = 0;
zNewTab = sqlite3_mprintf("tx%d", ++cnt);
if( pUndo ){
sqlite3_str_appendf(pUndo,
"ALTER TABLE \"%s\" RENAME TO \"%w\";\n",
zNewTab, zTab
);
}
rename_all_columns_of_table(db, zTab, zPrefix, pConvert, pUndo);
sqlite3_str_appendf(pConvert,
"ALTER TABLE \"%w\" RENAME TO \"%s\";\n",
zTab, zNewTab
);
sqlite3_free(zNewTab);
}
sqlite3_finalize(pStmt);
return SQLITE_OK;
}
/*
** Generate a script that does this:
**
** (1) Start a transaction
** (2) Rename all tables and columns to use generic names.
** (3) Print the schema after this rename
** (4) Run pragma integrity_check
** (5) Do more ALTER TABLE statements to change the names back
** (6) Run pragma integrity_check again
** (7) Rollback the transaction
*/
int main(int argc, char **argv){
sqlite3 *db;
int rc;
sqlite3_str *pConvert;
sqlite3_str *pUndo;
char *zDbName;
char *zSql1, *zSql2;
if( argc!=2 ){
fprintf(stderr, "Usage: %s DATABASE\n", argv[0]);
}
zDbName = argv[1];
rc = sqlite3_open(zDbName, &db);
if( rc ){
fprintf(stderr, "sqlite3_open() returns %d\n", rc);
return 1;
}
pConvert = sqlite3_str_new(db);
pUndo = sqlite3_str_new(db);
rename_all_tables(db, pConvert, pUndo);
zSql1 = sqlite3_str_finish(pConvert);
zSql2 = sqlite3_str_finish(pUndo);
sqlite3_close(db);
printf("BEGIN;\n");
printf("%s", zSql1);
sqlite3_free(zSql1);
printf(".schema --indent\n");
printf("PRAGMA integrity_check;\n");
printf("%s", zSql2);
sqlite3_free(zSql2);
printf("PRAGMA integrity_check;\n");
printf("ROLLBACK;\n");
return 0;
}

96
testdata/tcl/crashtest1.c vendored Normal file
View File

@@ -0,0 +1,96 @@
/*
** This program tests the ability of SQLite database to recover from a crash.
** This program runs under Unix only, but the results are applicable to all
** systems.
**
** The main process first constructs a test database, then starts creating
** subprocesses that write to that database. Each subprocess is killed off,
** without a chance to clean up its database connection, after a random
** delay. This killing of the subprocesses simulates a crash or power
** failure. The next subprocess to open the database should rollback
** whatever operation was in process at the time of the simulated crash.
**
** If any problems are encountered, an error is reported and the test stops.
** If no problems are seen after a large number of tests, we assume that
** the rollback mechanism is working.
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <sched.h>
#include "sqlite.h"
static void do_some_sql(int parent){
char *zErr;
int rc = SQLITE_OK;
sqlite *db;
int cnt = 0;
static char zBig[] =
"-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
"-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
if( access("./test.db-journal",0)==0 ){
/*printf("pid %d: journal exists. rollback will be required\n",getpid());*/ unlink("test.db-saved");
system("cp test.db test.db-saved");
unlink("test.db-journal-saved");
system("cp test.db-journal test.db-journal-saved");
}
db = sqlite_open("./test.db", 0, &zErr);
if( db==0 ){
printf("ERROR: %s\n", zErr);
if( strcmp(zErr,"database disk image is malformed")==0 ){
kill(parent, SIGKILL);
}
exit(1);
}
srand(getpid());
while( rc==SQLITE_OK ){
cnt++;
rc = sqlite_exec_printf(db,
"INSERT INTO t1 VALUES(%d,'%d%s')", 0, 0, &zErr,
rand(), rand(), zBig);
}
if( rc!=SQLITE_OK ){
printf("ERROR #%d: %s\n", rc, zErr);
if( rc==SQLITE_CORRUPT ){
kill(parent, SIGKILL);
}
}
printf("pid %d: cnt=%d\n", getpid(), cnt);
}
int main(int argc, char **argv){
int i;
sqlite *db;
char *zErr;
int status;
int parent = getpid();
unlink("test.db");
unlink("test.db-journal");
db = sqlite_open("test.db", 0, &zErr);
if( db==0 ){
printf("Cannot initialize: %s\n", zErr);
return 1;
}
sqlite_exec(db, "CREATE TABLE t1(a,b)", 0, 0, 0);
sqlite_close(db);
for(i=0; i<10000; i++){
int pid = fork();
if( pid==0 ){
sched_yield();
do_some_sql(parent);
return 0;
}
printf("test %d, pid=%d\n", i, pid);
usleep(rand()%10000 + 1000);
kill(pid, SIGKILL);
waitpid(pid, &status, 0);
}
return 0;
}

754
testdata/tcl/dbfuzz.c vendored Normal file
View File

@@ -0,0 +1,754 @@
/*
** 2016-12-17
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This program is designed for fuzz-testing SQLite database files.
**
** This program reads fuzzed database files from the disk files named
** on the command-line. Each database is loaded into an in-memory
** filesystem so that the original database file is unmolested.
**
** The fuzzed database is then opened, and series of SQL statements
** are run against the database to ensure that SQLite can safely handle
** the fuzzed database.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#define ISSPACE(X) isspace((unsigned char)(X))
#define ISDIGIT(X) isdigit((unsigned char)(X))
#include "sqlite3.h"
#ifdef __unix__
# include <signal.h>
# include <unistd.h>
#endif
/*
** Print sketchy documentation for this utility program
*/
static void showHelp(const char *zArgv0){
printf("Usage: %s [options] DATABASE ...\n", zArgv0);
printf(
"Read databases into an in-memory filesystem. Run test SQL as specified\n"
"by command-line arguments or from\n"
"\n"
" SELECT group_concat(sql) FROM autoexec;\n"
"\n"
"Options:\n"
" --help Show this help text\n"
" -q|--quiet Reduced output\n"
" --limit-mem N Limit memory used by test SQLite instances to N bytes\n"
" --limit-vdbe Panic if any test runs for more than 100,000 cycles\n"
" --no-lookaside Disable the lookaside memory allocator\n"
" --timeout N Timeout after N seconds.\n"
" --trace Show the results of each SQL command\n"
" -v|--verbose Increased output. Repeat for more output.\n"
);
exit(0);
}
/*
** Print an error message and quit.
*/
static void fatalError(const char *zFormat, ...){
va_list ap;
va_start(ap, zFormat);
vfprintf(stderr, zFormat, ap);
va_end(ap);
fprintf(stderr, "\n");
exit(1);
}
/*
** Files in the virtual file system.
*/
typedef struct VFile VFile;
typedef struct VHandle VHandle;
struct VFile {
char *zFilename; /* Filename. NULL for delete-on-close. From malloc() */
int sz; /* Size of the file in bytes */
int nRef; /* Number of references to this file */
unsigned char *a; /* Content of the file. From malloc() */
};
struct VHandle {
sqlite3_file base; /* Base class. Must be first */
VFile *pVFile; /* The underlying file */
};
/*
** Maximum number of files in the in-memory virtual filesystem.
*/
#define MX_FILE 10
/*
** Maximum allowed file size
*/
#define MX_FILE_SZ 1000000
/*
** All global variables are gathered into the "g" singleton.
*/
static struct GlobalVars {
VFile aFile[MX_FILE]; /* The virtual filesystem */
} g;
/*
** Initialize the virtual file system.
*/
static void formatVfs(void){
int i;
for(i=0; i<MX_FILE; i++){
g.aFile[i].sz = -1;
g.aFile[i].zFilename = 0;
g.aFile[i].a = 0;
g.aFile[i].nRef = 0;
}
}
/*
** Erase all information in the virtual file system.
*/
static void reformatVfs(void){
int i;
for(i=0; i<MX_FILE; i++){
if( g.aFile[i].sz<0 ) continue;
if( g.aFile[i].zFilename ){
free(g.aFile[i].zFilename);
g.aFile[i].zFilename = 0;
}
if( g.aFile[i].nRef>0 ){
fatalError("file %d still open. nRef=%d", i, g.aFile[i].nRef);
}
g.aFile[i].sz = -1;
free(g.aFile[i].a);
g.aFile[i].a = 0;
g.aFile[i].nRef = 0;
}
}
/*
** Find a VFile by name
*/
static VFile *findVFile(const char *zName){
int i;
if( zName==0 ) return 0;
for(i=0; i<MX_FILE; i++){
if( g.aFile[i].zFilename==0 ) continue;
if( strcmp(g.aFile[i].zFilename, zName)==0 ) return &g.aFile[i];
}
return 0;
}
/*
** Find a VFile called zName. Initialize it to the content of
** disk file zDiskFile.
**
** Return NULL if the filesystem is full.
*/
static VFile *createVFile(const char *zName, const char *zDiskFile){
VFile *pNew = findVFile(zName);
int i;
FILE *in = 0;
long sz = 0;
if( pNew ) return pNew;
for(i=0; i<MX_FILE && g.aFile[i].sz>=0; i++){}
if( i>=MX_FILE ) return 0;
if( zDiskFile ){
in = fopen(zDiskFile, "rb");
if( in==0 ) fatalError("no such file: \"%s\"", zDiskFile);
fseek(in, 0, SEEK_END);
sz = ftell(in);
rewind(in);
}
pNew = &g.aFile[i];
if( zName ){
int nName = (int)strlen(zName)+1;
pNew->zFilename = malloc(nName);
if( pNew->zFilename==0 ){
if( in ) fclose(in);
return 0;
}
memcpy(pNew->zFilename, zName, nName);
}else{
pNew->zFilename = 0;
}
pNew->nRef = 0;
pNew->sz = sz;
pNew->a = malloc(sz);
if( sz>0 ){
if( pNew->a==0 || fread(pNew->a, sz, 1, in)<1 ){
free(pNew->zFilename);
free(pNew->a);
pNew->a = 0;
pNew->zFilename = 0;
pNew->sz = -1;
pNew = 0;
}
}
if( in ) fclose(in);
return pNew;
}
/* Methods for the VHandle object
*/
static int inmemClose(sqlite3_file *pFile){
VHandle *p = (VHandle*)pFile;
VFile *pVFile = p->pVFile;
pVFile->nRef--;
if( pVFile->nRef==0 && pVFile->zFilename==0 ){
pVFile->sz = -1;
free(pVFile->a);
pVFile->a = 0;
}
return SQLITE_OK;
}
static int inmemRead(
sqlite3_file *pFile, /* Read from this open file */
void *pData, /* Store content in this buffer */
int iAmt, /* Bytes of content */
sqlite3_int64 iOfst /* Start reading here */
){
VHandle *pHandle = (VHandle*)pFile;
VFile *pVFile = pHandle->pVFile;
if( iOfst<0 || iOfst>=pVFile->sz ){
memset(pData, 0, iAmt);
return SQLITE_IOERR_SHORT_READ;
}
if( iOfst+iAmt>pVFile->sz ){
memset(pData, 0, iAmt);
iAmt = (int)(pVFile->sz - iOfst);
memcpy(pData, pVFile->a, iAmt);
return SQLITE_IOERR_SHORT_READ;
}
memcpy(pData, pVFile->a + iOfst, iAmt);
return SQLITE_OK;
}
static int inmemWrite(
sqlite3_file *pFile, /* Write to this file */
const void *pData, /* Content to write */
int iAmt, /* bytes to write */
sqlite3_int64 iOfst /* Start writing here */
){
VHandle *pHandle = (VHandle*)pFile;
VFile *pVFile = pHandle->pVFile;
if( iOfst+iAmt > pVFile->sz ){
unsigned char *aNew;
if( iOfst+iAmt >= MX_FILE_SZ ){
return SQLITE_FULL;
}
aNew = realloc(pVFile->a, (int)(iOfst+iAmt));
if( aNew==0 ){
return SQLITE_FULL;
}
pVFile->a = aNew;
if( iOfst > pVFile->sz ){
memset(pVFile->a + pVFile->sz, 0, (int)(iOfst - pVFile->sz));
}
pVFile->sz = (int)(iOfst + iAmt);
}
memcpy(pVFile->a + iOfst, pData, iAmt);
return SQLITE_OK;
}
static int inmemTruncate(sqlite3_file *pFile, sqlite3_int64 iSize){
VHandle *pHandle = (VHandle*)pFile;
VFile *pVFile = pHandle->pVFile;
if( pVFile->sz>iSize && iSize>=0 ) pVFile->sz = (int)iSize;
return SQLITE_OK;
}
static int inmemSync(sqlite3_file *pFile, int flags){
return SQLITE_OK;
}
static int inmemFileSize(sqlite3_file *pFile, sqlite3_int64 *pSize){
*pSize = ((VHandle*)pFile)->pVFile->sz;
return SQLITE_OK;
}
static int inmemLock(sqlite3_file *pFile, int type){
return SQLITE_OK;
}
static int inmemUnlock(sqlite3_file *pFile, int type){
return SQLITE_OK;
}
static int inmemCheckReservedLock(sqlite3_file *pFile, int *pOut){
*pOut = 0;
return SQLITE_OK;
}
static int inmemFileControl(sqlite3_file *pFile, int op, void *pArg){
return SQLITE_NOTFOUND;
}
static int inmemSectorSize(sqlite3_file *pFile){
return 512;
}
static int inmemDeviceCharacteristics(sqlite3_file *pFile){
return
SQLITE_IOCAP_SAFE_APPEND |
SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN |
SQLITE_IOCAP_POWERSAFE_OVERWRITE;
}
/* Method table for VHandle
*/
static sqlite3_io_methods VHandleMethods = {
/* iVersion */ 1,
/* xClose */ inmemClose,
/* xRead */ inmemRead,
/* xWrite */ inmemWrite,
/* xTruncate */ inmemTruncate,
/* xSync */ inmemSync,
/* xFileSize */ inmemFileSize,
/* xLock */ inmemLock,
/* xUnlock */ inmemUnlock,
/* xCheck... */ inmemCheckReservedLock,
/* xFileCtrl */ inmemFileControl,
/* xSectorSz */ inmemSectorSize,
/* xDevchar */ inmemDeviceCharacteristics,
/* xShmMap */ 0,
/* xShmLock */ 0,
/* xShmBarrier */ 0,
/* xShmUnmap */ 0,
/* xFetch */ 0,
/* xUnfetch */ 0
};
/*
** Open a new file in the inmem VFS. All files are anonymous and are
** delete-on-close.
*/
static int inmemOpen(
sqlite3_vfs *pVfs,
const char *zFilename,
sqlite3_file *pFile,
int openFlags,
int *pOutFlags
){
VFile *pVFile = createVFile(zFilename, 0);
VHandle *pHandle = (VHandle*)pFile;
if( pVFile==0 ){
return SQLITE_FULL;
}
pHandle->pVFile = pVFile;
pVFile->nRef++;
pFile->pMethods = &VHandleMethods;
if( pOutFlags ) *pOutFlags = openFlags;
return SQLITE_OK;
}
/*
** Delete a file by name
*/
static int inmemDelete(
sqlite3_vfs *pVfs,
const char *zFilename,
int syncdir
){
VFile *pVFile = findVFile(zFilename);
if( pVFile==0 ) return SQLITE_OK;
if( pVFile->nRef==0 ){
free(pVFile->zFilename);
pVFile->zFilename = 0;
pVFile->sz = -1;
free(pVFile->a);
pVFile->a = 0;
return SQLITE_OK;
}
return SQLITE_IOERR_DELETE;
}
/* Check for the existance of a file
*/
static int inmemAccess(
sqlite3_vfs *pVfs,
const char *zFilename,
int flags,
int *pResOut
){
VFile *pVFile = findVFile(zFilename);
*pResOut = pVFile!=0;
return SQLITE_OK;
}
/* Get the canonical pathname for a file
*/
static int inmemFullPathname(
sqlite3_vfs *pVfs,
const char *zFilename,
int nOut,
char *zOut
){
sqlite3_snprintf(nOut, zOut, "%s", zFilename);
return SQLITE_OK;
}
/*
** Register the VFS that reads from the g.aFile[] set of files.
*/
static void inmemVfsRegister(void){
static sqlite3_vfs inmemVfs;
sqlite3_vfs *pDefault = sqlite3_vfs_find(0);
inmemVfs.iVersion = 3;
inmemVfs.szOsFile = sizeof(VHandle);
inmemVfs.mxPathname = 200;
inmemVfs.zName = "inmem";
inmemVfs.xOpen = inmemOpen;
inmemVfs.xDelete = inmemDelete;
inmemVfs.xAccess = inmemAccess;
inmemVfs.xFullPathname = inmemFullPathname;
inmemVfs.xRandomness = pDefault->xRandomness;
inmemVfs.xSleep = pDefault->xSleep;
inmemVfs.xCurrentTimeInt64 = pDefault->xCurrentTimeInt64;
sqlite3_vfs_register(&inmemVfs, 0);
};
/*
** Timeout handler
*/
#ifdef __unix__
static void timeoutHandler(int NotUsed){
(void)NotUsed;
fatalError("timeout\n");
}
#endif
/*
** Set the an alarm to go off after N seconds. Disable the alarm
** if N==0
*/
static void setAlarm(int N){
#ifdef __unix__
alarm(N);
#else
(void)N;
#endif
}
/***************************************************************************
** String accumulator object
*/
typedef struct Str Str;
struct Str {
char *z; /* The string. Memory from malloc() */
sqlite3_uint64 n; /* Bytes of input used */
sqlite3_uint64 nAlloc; /* Bytes allocated to z[] */
int oomErr; /* OOM error has been seen */
};
/* Initialize a Str object */
static void StrInit(Str *p){
memset(p, 0, sizeof(*p));
}
/* Append text to the end of a Str object */
static void StrAppend(Str *p, const char *z){
sqlite3_uint64 n = strlen(z);
if( p->n + n >= p->nAlloc ){
char *zNew;
sqlite3_uint64 nNew;
if( p->oomErr ) return;
nNew = p->nAlloc*2 + 100 + n;
zNew = sqlite3_realloc64(p->z, nNew);
if( zNew==0 ){
sqlite3_free(p->z);
memset(p, 0, sizeof(*p));
p->oomErr = 1;
return;
}
p->z = zNew;
p->nAlloc = nNew;
}
memcpy(p->z + p->n, z, (int)n);
p->n += n;
p->z[p->n] = 0;
}
/* Return the current string content */
static char *StrStr(Str *p){
return p->z;
}
/* Free the string */
static void StrFree(Str *p){
sqlite3_free(p->z);
StrInit(p);
}
/*
** Return the value of a hexadecimal digit. Return -1 if the input
** is not a hex digit.
*/
static int hexDigitValue(char c){
if( c>='0' && c<='9' ) return c - '0';
if( c>='a' && c<='f' ) return c - 'a' + 10;
if( c>='A' && c<='F' ) return c - 'A' + 10;
return -1;
}
/*
** Interpret zArg as an integer value, possibly with suffixes.
*/
static int integerValue(const char *zArg){
sqlite3_int64 v = 0;
static const struct { char *zSuffix; int iMult; } aMult[] = {
{ "KiB", 1024 },
{ "MiB", 1024*1024 },
{ "GiB", 1024*1024*1024 },
{ "KB", 1000 },
{ "MB", 1000000 },
{ "GB", 1000000000 },
{ "K", 1000 },
{ "M", 1000000 },
{ "G", 1000000000 },
};
int i;
int isNeg = 0;
if( zArg[0]=='-' ){
isNeg = 1;
zArg++;
}else if( zArg[0]=='+' ){
zArg++;
}
if( zArg[0]=='0' && zArg[1]=='x' ){
int x;
zArg += 2;
while( (x = hexDigitValue(zArg[0]))>=0 ){
v = (v<<4) + x;
zArg++;
}
}else{
while( ISDIGIT(zArg[0]) ){
v = v*10 + zArg[0] - '0';
zArg++;
}
}
for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
v *= aMult[i].iMult;
break;
}
}
if( v>0x7fffffff ) fatalError("parameter too large - max 2147483648");
return (int)(isNeg? -v : v);
}
/*
** This callback is invoked by sqlite3_log().
*/
static void sqlLog(void *pNotUsed, int iErrCode, const char *zMsg){
printf("LOG: (%d) %s\n", iErrCode, zMsg);
fflush(stdout);
}
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
/*
** This an SQL progress handler. After an SQL statement has run for
** many steps, we want to interrupt it. This guards against infinite
** loops from recursive common table expressions.
**
** *pVdbeLimitFlag is true if the --limit-vdbe command-line option is used.
** In that case, hitting the progress handler is a fatal error.
*/
static int progressHandler(void *pVdbeLimitFlag){
if( *(int*)pVdbeLimitFlag ) fatalError("too many VDBE cycles");
return 1;
}
#endif
/*
** Allowed values for the runFlags parameter to runSql()
*/
#define SQL_TRACE 0x0001 /* Print each SQL statement as it is prepared */
#define SQL_OUTPUT 0x0002 /* Show the SQL output */
/*
** Run multiple commands of SQL. Similar to sqlite3_exec(), but does not
** stop if an error is encountered.
*/
static void runSql(sqlite3 *db, const char *zSql, unsigned runFlags){
const char *zMore;
const char *zEnd = &zSql[strlen(zSql)];
sqlite3_stmt *pStmt;
while( zSql && zSql[0] ){
zMore = 0;
pStmt = 0;
sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zMore);
assert( zMore<=zEnd );
if( zMore==zSql ) break;
if( runFlags & SQL_TRACE ){
const char *z = zSql;
int n;
while( z<zMore && ISSPACE(z[0]) ) z++;
n = (int)(zMore - z);
while( n>0 && ISSPACE(z[n-1]) ) n--;
if( n==0 ) break;
if( pStmt==0 ){
printf("TRACE: %.*s (error: %s)\n", n, z, sqlite3_errmsg(db));
}else{
printf("TRACE: %.*s\n", n, z);
}
}
zSql = zMore;
if( pStmt ){
if( (runFlags & SQL_OUTPUT)==0 ){
while( SQLITE_ROW==sqlite3_step(pStmt) ){}
}else{
int nCol = -1;
int nRow;
for(nRow=0; SQLITE_ROW==sqlite3_step(pStmt); nRow++){
int i;
if( nCol<0 ){
nCol = sqlite3_column_count(pStmt);
}
for(i=0; i<nCol; i++){
int eType = sqlite3_column_type(pStmt,i);
printf("ROW[%d].%s = ", nRow, sqlite3_column_name(pStmt,i));
switch( eType ){
case SQLITE_NULL: {
printf("NULL\n");
break;
}
case SQLITE_INTEGER: {
printf("INT %s\n", sqlite3_column_text(pStmt,i));
break;
}
case SQLITE_FLOAT: {
printf("FLOAT %s\n", sqlite3_column_text(pStmt,i));
break;
}
case SQLITE_TEXT: {
printf("TEXT [%s]\n", sqlite3_column_text(pStmt,i));
break;
}
case SQLITE_BLOB: {
printf("BLOB (%d bytes)\n", sqlite3_column_bytes(pStmt,i));
break;
}
}
}
}
}
sqlite3_finalize(pStmt);
}
}
}
int main(int argc, char **argv){
int i; /* Loop counter */
int nDb = 0; /* Number of databases to fuzz */
char **azDb = 0; /* Names of the databases (limit: 20) */
int verboseFlag = 0; /* True for extra output */
int noLookaside = 0; /* Disable lookaside if true */
int vdbeLimitFlag = 0; /* Stop after 100,000 VDBE ops */
int nHeap = 0; /* True for fixed heap size */
int iTimeout = 0; /* Timeout delay in seconds */
int rc; /* Result code from SQLite3 API calls */
sqlite3 *db; /* The database connection */
sqlite3_stmt *pStmt; /* A single SQL statement */
Str sql; /* SQL to run */
unsigned runFlags = 0; /* Flags passed to runSql */
for(i=1; i<argc; i++){
char *z = argv[i];
if( z[0]!='-' ){
azDb = realloc(azDb, sizeof(azDb[0])*(nDb+1));
if( azDb==0 ) fatalError("out of memory");
azDb[nDb++] = z;
continue;
}
z++;
if( z[0]=='-' ) z++;
if( strcmp(z, "help")==0 ){
showHelp(argv[0]);
}else if( strcmp(z, "limit-mem")==0 ){
if( i==argc-1 ) fatalError("missing argument to %s", argv[i]);
nHeap = integerValue(argv[++i]);
}else if( strcmp(z, "no-lookaside")==0 ){
noLookaside = 1;
}else if( strcmp(z, "timeout")==0 ){
if( i==argc-1 ) fatalError("missing argument to %s", argv[i]);
iTimeout = integerValue(argv[++i]);
}else if( strcmp(z, "trace")==0 ){
runFlags |= SQL_OUTPUT|SQL_TRACE;
}else if( strcmp(z, "limit-vdbe")==0 ){
vdbeLimitFlag = 1;
}else if( strcmp(z, "v")==0 || strcmp(z, "verbose")==0 ){
verboseFlag = 1;
runFlags |= SQL_TRACE;
}else{
fatalError("unknown command-line option: \"%s\"\n", argv[i]);
}
}
if( nDb==0 ){
showHelp(argv[0]);
}
if( verboseFlag ){
sqlite3_config(SQLITE_CONFIG_LOG, sqlLog);
}
if( nHeap>0 ){
void *pHeap = malloc( nHeap );
if( pHeap==0 ) fatalError("cannot allocate %d-byte heap\n", nHeap);
rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, 32);
if( rc ) fatalError("heap configuration failed: %d\n", rc);
}
if( noLookaside ){
sqlite3_config(SQLITE_CONFIG_LOOKASIDE, 0, 0);
}
inmemVfsRegister();
formatVfs();
StrInit(&sql);
#ifdef __unix__
signal(SIGALRM, timeoutHandler);
#endif
for(i=0; i<nDb; i++){
if( verboseFlag && nDb>1 ){
printf("DATABASE-FILE: %s\n", azDb[i]);
fflush(stdout);
}
if( iTimeout ) setAlarm(iTimeout);
createVFile("test.db", azDb[i]);
rc = sqlite3_open_v2("test.db", &db, SQLITE_OPEN_READWRITE, "inmem");
if( rc ){
printf("cannot open test.db for \"%s\"\n", azDb[i]);
reformatVfs();
continue;
}
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
if( vdbeLimitFlag ){
sqlite3_progress_handler(db, 100000, progressHandler, &vdbeLimitFlag);
}
#endif
rc = sqlite3_prepare_v2(db, "SELECT sql FROM autoexec", -1, &pStmt, 0);
if( rc==SQLITE_OK ){
while( SQLITE_ROW==sqlite3_step(pStmt) ){
StrAppend(&sql, (const char*)sqlite3_column_text(pStmt, 0));
StrAppend(&sql, "\n");
}
}
sqlite3_finalize(pStmt);
StrAppend(&sql, "PRAGMA integrity_check;\n");
runSql(db, StrStr(&sql), runFlags);
sqlite3_close(db);
reformatVfs();
StrFree(&sql);
if( sqlite3_memory_used()>0 ){
free(azDb);
reformatVfs();
fatalError("memory leak of %lld bytes", sqlite3_memory_used());
}
}
StrFree(&sql);
reformatVfs();
return 0;
}

BIN
testdata/tcl/dbfuzz2-seed1.db vendored Normal file

Binary file not shown.

403
testdata/tcl/dbfuzz2.c vendored Normal file
View File

@@ -0,0 +1,403 @@
/*
** 2018-10-26
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This program is designed for fuzz-testing SQLite database files using
** the -fsanitize=fuzzer option of clang.
**
** The -fsanitize=fuzzer option causes a main() to be inserted automatically.
** That main() invokes LLVMFuzzerTestOneInput(D,S) to be invoked repeatedly.
** Each D is a fuzzed database file. The code in this file runs various
** SQL statements against that database, trying to provoke a failure.
**
** For best results the seed database files should have these tables:
**
** Table "t1" with columns "a" and "b"
** Tables "t2" and "t3 with the same number of compatible columns
** "t3" should have a column names "x"
** Table "t4" with a column "x" that is compatible with t3.x.
**
** Any of these tables can be virtual tables, for example FTS or RTree tables.
**
** To run this test:
**
** mkdir dir
** cp dbfuzz2-seed*.db dir
** clang-6.0 -I. -g -O1 -fsanitize=fuzzer \
** -DTHREADSAFE=0 -DSQLITE_ENABLE_DESERIALIZE \
** -DSQLITE_ENABLE_DBSTAT_VTAB dbfuzz2.c sqlite3.c -ldl
** ./a.out dir
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <stdint.h>
#ifndef _WIN32
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include "sqlite3.h"
/*
** This is the is the SQL that is run against the database.
*/
static const char *azSql[] = {
"PRAGMA integrity_check;",
"SELECT * FROM sqlite_schema;",
"SELECT sum(length(name)) FROM dbstat;",
"UPDATE t1 SET b=a, a=b WHERE a<b;",
"ALTER TABLE t1 RENAME TO alkjalkjdfiiiwuer987lkjwer82mx97sf98788s9789s;",
"INSERT INTO t3 SELECT * FROM t2;",
"DELETE FROM t3 WHERE x IN (SELECT x FROM t4);",
"REINDEX;",
"DROP TABLE t3;",
"VACUUM;",
};
/* Output verbosity level. 0 means complete silence */
int eVerbosity = 0;
/* True to activate PRAGMA vdbe_debug=on */
static int bVdbeDebug = 0;
/* Maximum size of the in-memory database file */
static sqlite3_int64 szMax = 104857600;
/* Progress handler callback data */
static int nCb = 0; /* Number of callbacks seen so far */
static int mxCb = 250000; /* Maximum allowed callbacks */
/***** Copy/paste from ext/misc/memtrace.c ***************************/
/* The original memory allocation routines */
static sqlite3_mem_methods memtraceBase;
static FILE *memtraceOut;
/* Methods that trace memory allocations */
static void *memtraceMalloc(int n){
if( memtraceOut ){
fprintf(memtraceOut, "MEMTRACE: allocate %d bytes\n",
memtraceBase.xRoundup(n));
}
return memtraceBase.xMalloc(n);
}
static void memtraceFree(void *p){
if( p==0 ) return;
if( memtraceOut ){
fprintf(memtraceOut, "MEMTRACE: free %d bytes\n", memtraceBase.xSize(p));
}
memtraceBase.xFree(p);
}
static void *memtraceRealloc(void *p, int n){
if( p==0 ) return memtraceMalloc(n);
if( n==0 ){
memtraceFree(p);
return 0;
}
if( memtraceOut ){
fprintf(memtraceOut, "MEMTRACE: resize %d -> %d bytes\n",
memtraceBase.xSize(p), memtraceBase.xRoundup(n));
}
return memtraceBase.xRealloc(p, n);
}
static int memtraceSize(void *p){
return memtraceBase.xSize(p);
}
static int memtraceRoundup(int n){
return memtraceBase.xRoundup(n);
}
static int memtraceInit(void *p){
return memtraceBase.xInit(p);
}
static void memtraceShutdown(void *p){
memtraceBase.xShutdown(p);
}
/* The substitute memory allocator */
static sqlite3_mem_methods ersaztMethods = {
memtraceMalloc,
memtraceFree,
memtraceRealloc,
memtraceSize,
memtraceRoundup,
memtraceInit,
memtraceShutdown
};
/* Begin tracing memory allocations to out. */
int sqlite3MemTraceActivate(FILE *out){
int rc = SQLITE_OK;
if( memtraceBase.xMalloc==0 ){
rc = sqlite3_config(SQLITE_CONFIG_GETMALLOC, &memtraceBase);
if( rc==SQLITE_OK ){
rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &ersaztMethods);
}
}
memtraceOut = out;
return rc;
}
/* Deactivate memory tracing */
int sqlite3MemTraceDeactivate(void){
int rc = SQLITE_OK;
if( memtraceBase.xMalloc!=0 ){
rc = sqlite3_config(SQLITE_CONFIG_MALLOC, &memtraceBase);
if( rc==SQLITE_OK ){
memset(&memtraceBase, 0, sizeof(memtraceBase));
}
}
memtraceOut = 0;
return rc;
}
/***** End copy/paste from ext/misc/memtrace.c ***************************/
/*
** Progress handler callback
**
** Count the number of callbacks and cause an abort once the limit is
** reached.
*/
static int progress_handler(void *pNotUsed){
nCb++;
if( nCb<mxCb ) return 0;
if( eVerbosity>=1 ){
printf("-- Progress limit of %d reached\n", mxCb);
}
return 1;
}
/* libFuzzer invokes this routine with fuzzed database files (in aData).
** This routine run SQLite against the malformed database to see if it
** can provoke a failure or malfunction.
*/
int LLVMFuzzerTestOneInput(const uint8_t *aData, size_t nByte){
unsigned char *a;
sqlite3 *db;
int rc;
int i;
sqlite3_int64 x;
char *zErr = 0;
if( eVerbosity>=1 ){
printf("************** nByte=%d ***************\n", (int)nByte);
fflush(stdout);
}
if( sqlite3_initialize() ) return 0;
rc = sqlite3_open(0, &db);
if( rc ) return 1;
a = sqlite3_malloc64(nByte+1);
if( a==0 ) return 1;
memcpy(a, aData, nByte);
sqlite3_deserialize(db, "main", a, nByte, nByte,
SQLITE_DESERIALIZE_RESIZEABLE |
SQLITE_DESERIALIZE_FREEONCLOSE);
x = szMax;
#ifdef SQLITE_FCNTL_SIZE_LIMIT
sqlite3_file_control(db, "main", SQLITE_FCNTL_SIZE_LIMIT, &x);
#endif
if( bVdbeDebug ){
sqlite3_exec(db, "PRAGMA vdbe_debug=ON", 0, 0, 0);
}
if( mxCb>0 ){
sqlite3_progress_handler(db, 10, progress_handler, 0);
}
#ifdef SQLITE_TESTCTRL_PRNG_SEED
sqlite3_test_control(SQLITE_TESTCTRL_PRNG_SEED, 1, db);
#endif
for(i=0; i<sizeof(azSql)/sizeof(azSql[0]); i++){
if( eVerbosity>=1 ){
printf("%s\n", azSql[i]);
fflush(stdout);
}
zErr = 0;
nCb = 0;
rc = sqlite3_exec(db, azSql[i], 0, 0, &zErr);
if( rc && eVerbosity>=1 ){
printf("-- rc=%d zErr=%s\n", rc, zErr);
}
sqlite3_free(zErr);
}
rc = sqlite3_close(db);
if( rc!=SQLITE_OK ){
fprintf(stdout, "sqlite3_close() returns %d\n", rc);
}
if( sqlite3_memory_used()!=0 ){
int nAlloc = 0;
int nNotUsed = 0;
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &nAlloc, &nNotUsed, 0);
fprintf(stderr,"Memory leak: %lld bytes in %d allocations\n",
sqlite3_memory_used(), nAlloc);
exit(1);
}
return 0;
}
/*
** Return the number of "v" characters in a string. Return 0 if there
** are any characters in the string other than "v".
*/
static int numberOfVChar(const char *z){
int N = 0;
while( z[0] && z[0]=='v' ){
z++;
N++;
}
return z[0]==0 ? N : 0;
}
/* libFuzzer invokes this routine once when the executable starts, to
** process the command-line arguments.
*/
int LLVMFuzzerInitialize(int *pArgc, char ***pArgv){
int i, j, n;
int argc = *pArgc;
char **argv = *pArgv;
for(i=j=1; i<argc; i++){
char *z = argv[i];
if( z[0]=='-' ){
z++;
if( z[0]=='-' ) z++;
if( z[0]=='v' && (n = numberOfVChar(z))>0 ){
eVerbosity += n;
continue;
}
if( strcmp(z,"vdbe-debug")==0 ){
bVdbeDebug = 1;
continue;
}
if( strcmp(z,"limit")==0 ){
if( i+1==argc ){
fprintf(stderr, "missing argument to %s\n", argv[i]);
exit(1);
}
mxCb = strtol(argv[++i], 0, 0);
continue;
}
if( strcmp(z,"memtrace")==0 ){
sqlite3MemTraceActivate(stdout);
continue;
}
if( strcmp(z,"max-db-size")==0 ){
if( i+1==argc ){
fprintf(stderr, "missing argument to %s\n", argv[i]);
exit(1);
}
szMax = strtol(argv[++i], 0, 0);
continue;
}
if( strcmp(z, "lookaside")==0 ){
int sz, nSlot;
if( i+2>=argc ){
fprintf(stderr,
"--lookaside requires two arguments: slot-size num-slots\n");
exit(1);
}
sz = atoi(argv[++i]);
nSlot = atoi(argv[++i]);
sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, nSlot);
continue;
}
#ifndef _WIN32
if( strcmp(z,"max-stack")==0
|| strcmp(z,"max-data")==0
|| strcmp(z,"max-as")==0
){
struct rlimit x,y;
int resource = RLIMIT_STACK;
char *zType = "RLIMIT_STACK";
if( i+1==argc ){
fprintf(stderr, "missing argument to %s\n", argv[i]);
exit(1);
}
if( z[4]=='d' ){
resource = RLIMIT_DATA;
zType = "RLIMIT_DATA";
}
if( z[4]=='a' ){
resource = RLIMIT_AS;
zType = "RLIMIT_AS";
}
memset(&x,0,sizeof(x));
getrlimit(resource, &x);
y.rlim_cur = atoi(argv[++i]);
y.rlim_max = x.rlim_cur;
setrlimit(resource, &y);
memset(&y,0,sizeof(y));
getrlimit(resource, &y);
printf("%s changed from %d to %d\n",
zType, (int)x.rlim_cur, (int)y.rlim_cur);
continue;
}
#endif /* _WIN32 */
}
argv[j++] = argv[i];
}
argv[j] = 0;
*pArgc = j;
return 0;
}
#ifdef STANDALONE
/*
** Read an entire file into memory. Space to hold the file comes
** from malloc().
*/
static unsigned char *readFile(const char *zName, int *pnByte){
FILE *in = fopen(zName, "rb");
long nIn;
size_t nRead;
unsigned char *pBuf;
if( in==0 ) return 0;
fseek(in, 0, SEEK_END);
nIn = ftell(in);
rewind(in);
pBuf = malloc( nIn+1 );
if( pBuf==0 ){ fclose(in); return 0; }
nRead = fread(pBuf, nIn, 1, in);
fclose(in);
if( nRead!=1 ){
free(pBuf);
return 0;
}
pBuf[nIn] = 0;
if( pnByte ) *pnByte = nIn;
return pBuf;
}
#endif /* STANDALONE */
#ifdef STANDALONE
int main(int argc, char **argv){
int i;
LLVMFuzzerInitialize(&argc, &argv);
for(i=1; i<argc; i++){
unsigned char *pIn;
int nIn;
pIn = readFile(argv[i], &nIn);
if( pIn ){
LLVMFuzzerTestOneInput((const uint8_t*)pIn, (size_t)nIn);
free(pIn);
}
}
#ifdef RUSAGE_SELF
if( eVerbosity>0 ){
struct rusage x;
printf("SQLite %s\n", sqlite3_sourceid());
memset(&x, 0, sizeof(x));
if( getrusage(RUSAGE_SELF, &x)==0 ){
printf("Maximum RSS = %ld KB\n", x.ru_maxrss);
}
}
#endif
return 0;
}
#endif /*STANDALONE*/

2068
testdata/tcl/fuzzcheck.c vendored Normal file

File diff suppressed because it is too large Load Diff

BIN
testdata/tcl/fuzzdata1.db vendored Normal file

Binary file not shown.

BIN
testdata/tcl/fuzzdata2.db vendored Normal file

Binary file not shown.

BIN
testdata/tcl/fuzzdata3.db vendored Normal file

Binary file not shown.

BIN
testdata/tcl/fuzzdata4.db vendored Normal file

Binary file not shown.

BIN
testdata/tcl/fuzzdata5.db vendored Normal file

Binary file not shown.

BIN
testdata/tcl/fuzzdata6.db vendored Normal file

Binary file not shown.

BIN
testdata/tcl/fuzzdata7.db vendored Normal file

Binary file not shown.

BIN
testdata/tcl/fuzzdata8.db vendored Normal file

Binary file not shown.

1137
testdata/tcl/kvtest.c vendored Normal file

File diff suppressed because it is too large Load Diff

75
testdata/tcl/lemon-test01.y vendored Normal file
View File

@@ -0,0 +1,75 @@
// A test case for the LEMON parser generator. Run as follows:
//
// lemon lemon-test01.y && gcc -g lemon-test01.c && ./a.out
//
%token_prefix TK_
%token_type int
%default_type int
%include {
static int nSyntaxError = 0;
static int nAccept = 0;
static int nFailure = 0;
}
all ::= A B.
all ::= error B.
%syntax_error {
nSyntaxError++;
}
%parse_accept {
nAccept++;
}
%parse_failure {
nFailure++;
}
%code {
#include <assert.h>
#include "lemon-test01.h"
static int nTest = 0;
static int nErr = 0;
static int testCase(int testId, int shouldBe, int actual){
nTest++;
if( shouldBe==actual ){
printf("test %d: ok\n", testId);
}else{
printf("test %d: got %d, expected %d\n", testId, actual, shouldBe);
nErr++;
}
}
int main(int argc, char **argv){
yyParser xp;
ParseInit(&xp);
Parse(&xp, TK_A, 0);
Parse(&xp, TK_B, 0);
Parse(&xp, 0, 0);
ParseFinalize(&xp);
testCase(100, 0, nSyntaxError);
testCase(110, 1, nAccept);
testCase(120, 0, nFailure);
nSyntaxError = nAccept = nFailure = 0;
ParseInit(&xp);
Parse(&xp, TK_B, 0);
Parse(&xp, TK_B, 0);
Parse(&xp, 0, 0);
ParseFinalize(&xp);
testCase(200, 1, nSyntaxError);
testCase(210, 1, nAccept);
testCase(220, 0, nFailure);
nSyntaxError = nAccept = nFailure = 0;
ParseInit(&xp);
Parse(&xp, TK_A, 0);
Parse(&xp, TK_A, 0);
Parse(&xp, 0, 0);
ParseFinalize(&xp);
testCase(200, 1, nSyntaxError);
testCase(210, 0, nAccept);
testCase(220, 0, nFailure);
if( nErr==0 ){
printf("%d tests pass\n", nTest);
}else{
printf("%d errors out %d tests\n", nErr, nTest);
}
return nErr;
}
}

947
testdata/tcl/optfuzz-db01.c vendored Normal file
View File

@@ -0,0 +1,947 @@
/* content of file testdb01.db */
unsigned char data001[] = {
83, 81, 76,105,116,101, 32,102,111,114,109, 97,116, 32, 51, 0, 2, 0, 1,
1, 0, 64, 32, 32, 0, 0, 0, 2, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 31, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 0, 46, 32,152, 5, 0, 0, 0, 7, 1,221, 0, 0, 0, 0, 35, 1,251,
1,246, 1,241, 1,236, 1,231, 1,226, 1,221, 84, 4, 7, 23, 17, 17, 1,
129, 19,116, 97, 98,108,101,116, 52,116, 52, 5, 67, 82, 69, 65, 84, 69, 32,
84, 65, 66, 76, 69, 32,116, 52, 40, 97, 32, 73, 78, 84, 32, 85, 78, 73, 81,
85, 69, 32, 78, 79, 84, 32, 78, 85, 76, 76, 44, 32, 98, 32, 73, 78, 84, 32,
85, 78, 73, 81, 85, 69, 32, 78, 79, 84, 32, 78, 85, 76, 76, 44, 99, 44,100,
44,101, 41, 35, 6, 6, 23, 55, 17, 1, 0,105,110,100,101,120,115,113,108,
105,116,101, 95, 97,117,116,111,105,110,100,101,120, 95,116, 52, 95, 50,116,
52, 7, 35, 5, 6, 23, 55, 17, 1, 0,105,110,100,101,120,115,113,108,105,
116,101, 95, 97,117,116,111,105,110,100,101,120, 95,116, 52, 95, 49,116, 52,
6, 42, 3, 6, 23, 17, 17, 1, 65,116, 97, 98,108,101,116, 51,116, 51, 4,
67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 51, 40, 97, 44, 98,
44, 99, 44,100, 44,101, 41, 95, 2, 7, 23, 17, 17, 1,129, 41,116, 97, 98,
108,101,116, 50,116, 50, 3, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69,
32,116, 50, 40, 97, 32, 73, 78, 84, 44, 32, 98, 32, 73, 78, 84, 44, 32, 99,
32, 73, 78, 84, 44,100, 32, 73, 78, 84, 44,101, 32, 73, 78, 84, 44, 80, 82,
73, 77, 65, 82, 89, 32, 75, 69, 89, 40, 98, 44, 97, 41, 41, 87, 73, 84, 72,
79, 85, 84, 32, 82, 79, 87, 73, 68, 83, 1, 7, 23, 17, 17, 1,129, 17,116,
97, 98,108,101,116, 49,116, 49, 2, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66,
76, 69, 32,116, 49, 40, 97, 32, 73, 78, 84, 69, 71, 69, 82, 32, 80, 82, 73,
77, 65, 0, 0, 0, 34, 32, 0, 0, 0, 33, 29, 0, 0, 0, 32, 26, 0, 0,
0, 31, 23, 0, 0, 0, 30, 19, 0, 0, 0, 11, 14, 0, 0, 0, 9, 7, 5,
0, 0, 0, 1, 1,251, 0, 0, 0, 0, 16, 1,251, 1,195, 1,180, 1,166,
1,151, 1,136, 1,121, 1,105, 1, 91, 1, 76, 1, 61, 1, 46, 1, 29, 1,
14, 0,252, 0,238, 0,224, 0,209, 0,194, 0,177, 0,157, 0,143, 0,128,
0,110, 0, 94, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 14, 28, 6, 0, 1, 1, 1, 23, 17, 67, 31,119,111,114,107,115, 14, 27,
6, 0, 1, 1, 1, 23, 22, 71, 3, 97,110,103,101,108, 16, 26, 6, 0, 1,
1, 1, 27, 40, 98, 17,109,111,114,110,105,110,103, 13, 25, 6, 0, 1, 1,
1, 21, 10, 7, 19,103,111,110,101, 12, 24, 6, 0, 1, 1, 9, 21, 43, 46,
119, 97,121,115, 18, 23, 6, 0, 1, 1, 1, 31, 6, 37, 31,115, 97, 99,114,
105,102,105, 99,101, 15, 22, 6, 0, 1, 1, 1, 25, 45, 71, 28,116,104,111,
117,103,104, 13, 21, 6, 0, 1, 1, 1, 21, 22, 92, 18,115,111,109,101, 13,
20, 6, 0, 9, 1, 1, 23, 2, 45, 97, 98,111,118,101, 12, 19, 6, 0, 1,
1, 8, 21, 4, 58,119, 97,121,115, 12, 18, 6, 0, 1, 1, 1, 19, 44, 19,
43,119, 97,114, 16, 17, 6, 0, 1, 1, 1, 27, 29, 74, 36, 98,101,116,119,
101,101,110, 13, 16, 6, 0, 1, 1, 1, 21, 44, 52, 19,112,111,111,114, 15,
15, 6, 0, 1, 1, 1, 25, 6, 3, 11,116,101,109,112,108,101, 13, 14, 6,
0, 1, 1, 1, 21, 35, 48, 27,100,105,101,100, 13, 13, 6, 0, 1, 1, 1,
21, 4, 21, 39,100,111,116,104, 13, 12, 6, 0, 1, 1, 1, 21, 4, 38, 36,
115,101,110,100, 12, 11, 6, 0, 1, 1, 1, 19, 13, 48, 22,115,105,120, 14,
10, 6, 0, 1, 1, 1, 23, 41, 89, 14,115,101,114,118,101, 13, 9, 6, 0,
8, 1, 1, 23, 16, 50, 98,101,103, 97,116, 13, 8, 6, 0, 1, 1, 1, 21,
42, 49, 34,115,101,110,100, 13, 7, 6, 0, 1, 1, 1, 21, 21, 91, 38,110,
101, 97,114, 12, 6, 6, 0, 1, 1, 1, 19, 2, 37, 11, 99, 97,110, 13, 5,
6, 0, 1, 1, 1, 21, 25, 27, 28,103,111,110,101, 13, 4, 6, 0, 1, 1,
1, 21, 41, 32, 35,110,101, 97,114, 14, 3, 6, 0, 1, 1, 1, 23, 32, 24,
26,115,101,114,118,101, 13, 2, 6, 0, 1, 1, 1, 21, 45, 14, 39,115, 97,
118,101, 13, 1, 6, 0, 1, 1, 1, 21, 40, 68, 0, 0, 0, 15, 28, 2, 0,
0, 0, 1, 1,238, 0, 0, 0, 0, 22, 1,238, 1,197, 1,181, 1,166, 1,
151, 1,137, 1,121, 1,104, 1, 84, 1, 73, 1, 59, 1, 41, 1, 26, 1, 11,
0,253, 0,238, 0,223, 0,207, 0,191, 0,175, 0,159, 0,144, 0,129, 0,
113, 0, 97, 0, 82, 0, 68, 0, 0, 13, 6, 1, 1, 1, 1, 19, 26, 34, 15,
20, 97,114,107, 14, 6, 1, 1, 1, 1, 21, 25, 5, 27, 28,103,111,110,101,
15, 6, 1, 1, 1, 1, 23, 22, 47, 16, 40, 97,110,103,101,114, 15, 6, 1,
1, 1, 1, 23, 22, 27, 71, 3, 97,110,103,101,108, 14, 6, 1, 1, 1, 1,
21, 22, 21, 92, 18,115,111,109,101, 14, 6, 1, 1, 1, 1, 21, 21, 7, 91,
38,110,101, 97,114, 15, 6, 1, 1, 1, 1, 23, 20, 42, 18, 5, 98,101,103,
97,116, 15, 6, 1, 1, 1, 1, 23, 17, 37, 66, 18,100,119,101,108,116, 15,
6, 1, 1, 1, 1, 23, 17, 28, 67, 31,119,111,114,107,115, 15, 6, 1, 1,
1, 8, 25, 16, 32, 7,112,108, 97, 99,101,115, 14, 6, 1, 1, 1, 1, 21,
16, 30, 81, 25,119, 97,108,107, 14, 6, 1, 1, 1, 1, 21, 14, 40, 30, 26,
115,101,110,100, 13, 6, 1, 1, 1, 1, 19, 13, 11, 48, 22,115,105,120, 14,
6, 1, 1, 1, 1, 21, 10, 38, 97, 34,115,104,101,119, 14, 6, 1, 1, 1,
1, 21, 10, 25, 7, 19,103,111,110,101, 17, 6, 1, 1, 1, 1, 27, 9, 50,
92, 29,116,104,101,114,101,105,110, 13, 6, 1, 1, 1, 1, 19, 9, 49, 51,
38,111,105,108, 10, 6, 1, 1, 1, 1, 0, 7, 33, 72, 31, 19, 6, 1, 1,
1, 1, 31, 6, 23, 37, 31,115, 97, 99,114,105,102,105, 99,101, 16, 6, 1,
1, 1, 1, 25, 6, 15, 3, 11,116,101,109,112,108,101, 15, 6, 1, 1, 1,
1, 23, 5, 43, 23, 41, 98,101,103, 97,116, 13, 6, 1, 1, 1, 8, 21, 4,
19, 58,119, 97,121,115, 14, 6, 1, 1, 1, 1, 21, 4, 13, 21, 39,100,111,
116,104, 14, 6, 1, 1, 1, 1, 21, 4, 12, 38, 36,115,101,110,100, 15, 6,
1, 1, 1, 1, 23, 3, 39, 21, 45, 98,101,103, 97,116, 13, 6, 1, 1, 1,
1, 19, 2, 6, 37, 11, 99, 97,110, 14, 6, 9, 1, 1, 1, 23, 20, 2, 45,
97, 98,111,118,101, 14, 6, 8, 1, 1, 1, 23, 36, 52, 17, 99,104, 0, 0,
0, 21, 13, 6, 1, 1, 1, 1, 19, 26, 34, 15, 20, 97,114,107, 13, 0, 0,
0, 35, 0, 92, 0, 1,244, 1,232, 1,216, 1,204, 1,186, 1,171, 1,160,
1,149, 1,138, 1,128, 1,117, 1,106, 1, 92, 1, 76, 1, 65, 1, 49, 1,
32, 1, 21, 1, 10, 0,255, 0,241, 0,225, 0,214, 0,203, 0,192, 0,180,
0,168, 0,156, 0,144, 0,132, 0,124, 0,116, 0,108, 0,100, 0, 92, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 35, 6, 0, 0, 0,
0, 0, 6, 34, 6, 0, 0, 0, 0, 0, 6, 33, 6, 0, 0, 0, 0, 0, 6,
32, 6, 0, 0, 0, 0, 0, 6, 31, 6, 0, 0, 0, 0, 0, 10, 30, 6, 1,
1, 1, 1, 0, 48, 37, 93, 7, 10, 29, 6, 1, 1, 1, 1, 0, 28, 17, 67,
31, 10, 28, 6, 1, 1, 1, 1, 0, 22, 45, 71, 28, 10, 27, 6, 1, 1, 1,
1, 0, 12, 4, 38, 36, 10, 26, 6, 1, 1, 1, 1, 0, 49, 9, 51, 38, 9,
25, 6, 1, 1, 1, 0, 0, 17, 29, 74, 9, 24, 6, 1, 1, 1, 0, 0, 47,
22, 16, 9, 23, 6, 1, 1, 1, 0, 0, 32, 16, 7, 14, 22, 6, 1, 1, 1,
0, 23, 42, 20, 18, 98,101,103, 97,116, 12, 21, 6, 1, 1, 1, 0, 19, 34,
26, 15, 97,114,107, 9, 20, 6, 1, 1, 0, 1, 0, 49, 9, 38, 9, 19, 6,
1, 1, 0, 1, 0, 44, 48, 9, 9, 18, 6, 1, 1, 0, 1, 0, 21, 22, 18,
15, 17, 6, 1, 1, 0, 1, 25, 35, 38, 22, 99,117, 98,105,116,115, 14, 16,
6, 1, 1, 0, 1, 23, 37, 17, 18,100,119,101,108,116, 9, 15, 6, 1, 0,
1, 1, 0, 49, 51, 38, 14, 14, 6, 1, 0, 1, 1, 23, 10, 89, 14,115,101,
114,118,101, 12, 13, 6, 9, 0, 1, 1, 21, 68, 32,100,111,116,104, 9, 12,
6, 1, 0, 1, 1, 0, 47, 16, 40, 9, 11, 6, 1, 0, 1, 1, 0, 25, 7,
19, 8, 10, 6, 0, 1, 1, 8, 0, 16, 7, 9, 9, 6, 0, 1, 1, 1, 0,
16, 81, 25, 9, 8, 6, 0, 1, 1, 1, 0, 7, 72, 31, 9, 7, 6, 0, 1,
1, 1, 0, 6, 37, 31, 13, 6, 6, 0, 1, 1, 1, 21, 21, 91, 38,110,101,
97,114, 16, 5, 6, 1, 1, 1, 1, 25, 15, 6, 3, 11,116,101,109,112,108,
101, 10, 4, 6, 1, 1, 1, 1, 0, 21, 22, 92, 18, 14, 3, 6, 1, 1, 1,
1, 21, 4, 41, 32, 35,110,101, 97,114, 10, 2, 6, 1, 1, 1, 1, 0, 46,
28, 88, 22, 10, 1, 6, 1, 1, 1, 1, 0, 17, 29, 74, 36, 13, 0, 0, 0,
15, 1, 71, 0, 1,243, 1,230, 1,217, 1,204, 1,191, 1,179, 1,167, 1,
155, 1,143, 1,131, 1,119, 1,107, 1, 95, 1, 83, 1, 71, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10, 15, 6, 1, 1, 1, 1, 0, 48, 37, 93, 7, 10, 14, 6, 1, 1, 1, 1,
0, 22, 45, 71, 28, 10, 13, 6, 1, 1, 1, 1, 0, 12, 4, 38, 36, 10, 12,
6, 1, 1, 1, 0, 1, 32, 16, 7, 79, 10, 11, 6, 1, 1, 1, 0, 1, 42,
20, 18, 19, 10, 10, 6, 1, 1, 1, 0, 1, 34, 26, 15, 13, 10, 9, 6, 1,
1, 0, 1, 1, 49, 9, 38, 97, 10, 8, 6, 1, 1, 0, 1, 1, 44, 48, 9,
90, 10, 7, 6, 1, 1, 0, 1, 1, 35, 38, 22, 33, 10, 6, 6, 1, 1, 0,
1, 1, 37, 17, 18, 18, 11, 5, 6, 1, 1, 1, 1, 1, 15, 6, 3, 11, 43,
11, 4, 6, 1, 1, 1, 1, 1, 21, 22, 92, 18, 62, 11, 3, 6, 1, 1, 1,
1, 1, 4, 41, 32, 35, 36, 11, 2, 6, 1, 1, 1, 1, 1, 46, 28, 88, 22,
77, 11, 1, 6, 1, 1, 1, 1, 1, 17, 29, 74, 36, 61, 10, 0, 0, 0, 15,
1,167, 0, 1,250, 1,244, 1,238, 1,233, 1,227, 1,221, 1,215, 1,209,
1,203, 1,197, 1,191, 1,185, 1,179, 1,173, 1,167, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
5, 3, 1, 1, 49, 9, 5, 3, 1, 1, 48, 15, 5, 3, 1, 1, 46, 2, 5,
3, 1, 1, 44, 8, 5, 3, 1, 1, 42, 11, 5, 3, 1, 1, 37, 6, 5, 3,
1, 1, 35, 7, 5, 3, 1, 1, 34, 10, 5, 3, 1, 1, 32, 12, 5, 3, 1,
1, 22, 14, 5, 3, 1, 1, 21, 4, 4, 3, 1, 9, 17, 5, 3, 1, 1, 15,
5, 5, 3, 1, 1, 12, 13, 5, 3, 1, 1, 4, 3, 10, 0, 0, 0, 15, 1,
167, 0, 1,250, 1,244, 1,238, 1,232, 1,226, 1,220, 1,214, 1,208, 1,
202, 1,197, 1,191, 1,185, 1,179, 1,173, 1,167, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
3, 1, 1, 48, 8, 5, 3, 1, 1, 45, 14, 5, 3, 1, 1, 41, 3, 5, 3,
1, 1, 38, 7, 5, 3, 1, 1, 37, 15, 4, 3, 1, 9, 29, 5, 3, 1, 1,
28, 2, 5, 3, 1, 1, 26, 10, 5, 3, 1, 1, 22, 4, 5, 3, 1, 1, 20,
11, 5, 3, 1, 1, 17, 6, 5, 3, 1, 1, 16, 12, 5, 3, 1, 1, 9, 9,
5, 3, 1, 1, 6, 5, 5, 3, 1, 1, 4, 13, 5, 0, 0, 0, 2, 1,246,
0, 0, 0, 0, 27, 1,251, 1,246, 1,168, 1,148, 1,130, 1,107, 1, 86,
1, 65, 1, 44, 1, 27, 1, 14, 0,250, 0,224, 0,205, 0,184, 0,165, 0,
145, 0,123, 0,106, 0, 86, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 17, 23, 6, 0, 23, 1, 1, 21,107,110,111,119,110, 52, 19,112,
111,111,114, 18, 22, 6, 0, 23, 1, 1, 23, 97, 98,111,118,101, 24, 26,115,
101,114,118,101, 15, 21, 6, 0, 19, 1, 1, 21,119, 97,114, 52, 19,112,111,
111,114, 20, 20, 6, 0, 27, 1, 8, 25,110,111,116,104,105,110,103, 7,112,
108, 97, 99,101,115, 18, 19, 6, 0, 23, 1, 1, 23, 98,101,103, 97,116, 90,
27,116,114,117,116,104, 17, 18, 6, 0, 23, 1, 1, 21,100,119,101,108,116,
21, 39,100,111,116,104, 19, 17, 6, 0, 27, 1, 1, 21,109,111,114,110,105,
110,103, 52, 19,112,111,111,114, 17, 16, 6, 0, 21, 1, 1, 23,115,104,101,
119, 90, 27,116,114,117,116,104, 24, 15, 6, 0, 27, 1, 1, 31,116,104,101,
114,101,105,110, 37, 31,115, 97, 99,114,105,102,105, 99,101, 18, 14, 6, 0,
23, 1, 8, 25,115,109,111,116,101, 7,112,108, 97, 99,101,115, 11, 13, 6,
0, 19, 1, 1, 0, 97,114,107, 72, 31, 15, 12, 6, 0, 21, 1, 8, 21,119,
105,110,101, 58,119, 97,121,115, 19, 11, 6, 0, 21, 1, 1, 27,115,111,109,
101, 98, 17,109,111,114,110,105,110,103, 19, 10, 6, 0, 27, 1, 1, 21, 98,
101,116,119,101,101,110, 92, 18,115,111,109,101, 19, 9, 6, 0, 21, 1, 1,
27,115, 97,118,101, 74, 36, 98,101,116,119,101,101,110, 21, 8, 6, 0, 25,
1, 1, 27,116,104,111,117,103,104, 98, 17,109,111,114,110,105,110,103, 16,
7, 6, 0, 21, 1, 1, 21,115,101,110,100, 49, 34,115,101,110,100, 18, 6,
6, 0, 25, 1, 1, 21,119,105,115,100,111,109, 38, 36,115,101,110,100, 16,
5, 6, 0, 23, 1, 9, 21, 97,110,103,101,114, 46,119, 97,121,115, 14, 4,
6, 0, 19, 1, 1, 19, 99, 97,110, 19, 43,119, 97,114, 16, 3, 6, 0, 23,
1, 1, 19,111,102,102,101,114, 48, 22,115,105,120, 16, 2, 6, 0, 23, 1,
8, 21,119,111,114,107,115, 58,119, 97,121,115, 16, 1, 6, 0, 23, 1, 1,
19, 0, 0, 0, 26, 45, 0, 0, 0, 25, 23, 13, 0, 0, 0, 7, 0, 48, 0,
1,171, 1, 74, 1, 30, 0,126, 0,249, 0,212, 0, 48, 0, 81, 0, 0, 84,
4, 7, 23, 17, 17, 1,129, 19,116, 97, 98,108,101,116, 52,116, 52, 5, 67,
82, 69, 76, 7, 7, 23, 17, 17, 1,129, 3,116, 97, 98,108,101,116, 53,116,
53, 8, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 53, 40, 97,
32, 73, 78, 84, 69, 71, 69, 82, 32, 80, 82, 73, 77, 65, 82, 89, 32, 75, 69,
89, 44, 32, 98, 32, 84, 69, 88, 84, 32, 85, 78, 73, 81, 85, 69, 44, 99, 44,
100, 44,101, 41, 84, 4, 7, 23, 17, 17, 1,129, 19,116, 97, 98,108,101,116,
52,116, 52, 5, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 52,
40, 97, 32, 73, 78, 84, 32, 85, 78, 73, 81, 85, 69, 32, 78, 79, 84, 32, 78,
85, 76, 76, 44, 32, 98, 32, 73, 78, 84, 32, 85, 78, 73, 81, 85, 69, 32, 78,
79, 84, 32, 78, 85, 76, 76, 44, 99, 44,100, 44,101, 41, 35, 6, 6, 23, 55,
17, 1, 0,105,110,100,101,120,115,113,108,105,116,101, 95, 97,117,116,111,
105,110,100,101,120, 95,116, 52, 95, 50,116, 52, 7, 35, 5, 6, 23, 55, 17,
1, 0,105,110,100,101,120,115,113,108,105,116,101, 95, 97,117,116,111,105,
110,100,101,120, 95,116, 52, 95, 49,116, 52, 6, 42, 3, 6, 23, 17, 17, 1,
65,116, 97, 98,108,101,116, 51,116, 51, 4, 67, 82, 69, 65, 84, 69, 32, 84,
65, 66, 76, 69, 32,116, 51, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 95,
2, 7, 23, 17, 17, 1,129, 41,116, 97, 98,108,101,116, 50,116, 50, 3, 67,
82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 50, 40, 97, 32, 73, 78,
84, 44, 32, 98, 32, 73, 78, 84, 44, 32, 99, 32, 73, 78, 84, 44,100, 32, 73,
78, 84, 44,101, 32, 73, 78, 84, 44, 80, 82, 73, 77, 65, 82, 89, 32, 75, 69,
89, 40, 98, 44, 97, 41, 41, 87, 73, 84, 72, 79, 85, 84, 32, 82, 79, 87, 73,
68, 83, 1, 7, 23, 17, 17, 1,129, 17,116, 97, 98,108,101,116, 49,116, 49,
2, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76, 69, 32,116, 49, 40, 97, 32,
73, 78, 84, 69, 71, 69, 82, 32, 80, 82, 73, 77, 65, 82, 89, 32, 75, 69, 89,
44, 32, 98, 32, 73, 78, 84, 44, 32, 99, 32, 73, 78, 84, 44, 32,100, 32, 73,
78, 84, 44, 32,101, 32, 73, 78, 84, 41, 2, 0, 0, 0, 1, 1,243, 0, 0,
0, 0, 29, 1,243, 1,218, 1,209, 1,199, 1,187, 1,179, 1,169, 1,158,
1,145, 1,136, 1,127, 1,117, 1,107, 1, 98, 1, 82, 1, 72, 1, 63, 1,
51, 1, 42, 1, 30, 1, 20, 1, 12, 1, 3, 0,248, 0,239, 0,225, 0,216,
0,207, 0,197, 0,188, 0,180, 0,170, 0,161, 0,152, 0,141, 0,129, 0,
118, 0,106, 0, 97, 0, 0, 0, 0, 0, 0, 0, 8, 3, 21, 1,116,114,101,
101, 49, 11, 3, 27, 1,116,104,121,115,101,108,102, 27, 10, 3, 25, 1,116,
104,111,117,103,104, 8, 11, 3, 27, 1,116,104,101,114,101,105,110, 15, 10,
3, 25, 1,116,101,109,112,108,101, 43, 8, 3, 21, 1,116,101,108,108, 25,
8, 3, 21, 1,115,111,109,101, 11, 9, 3, 23, 1,115,109,111,116,101, 14,
7, 3, 19, 1,115,105,120, 48, 8, 3, 21, 1,115,104,101,119, 16, 9, 3,
23, 1,115,101,114,118,101, 37, 8, 3, 21, 1,115,101,110,100, 7, 8, 3,
21, 1,115, 97,118,101, 9, 13, 3, 31, 1,115, 97, 99,114,105,102,105, 99,
101, 24, 8, 3, 21, 1,112,111,111,114, 40, 10, 3, 25, 1,112,108, 97, 99,
101,115, 28, 8, 3, 21, 1,112, 97,114,116, 30, 7, 3, 19, 1,111,105,108,
46, 9, 3, 23, 1,111,102,102,101,114, 3, 11, 3, 27, 1,110,111,116,104,
105,110,103, 20, 8, 3, 21, 1,110,101, 97,114, 36, 11, 3, 27, 1,109,111,
114,110,105,110,103, 17, 8, 3, 21, 1,108,111,110,103, 35, 9, 3, 23, 1,
107,110,111,119,110, 23, 15, 3, 35, 1,105,110,104, 97, 98,105,116, 97,110,
116,115, 45, 8, 3, 21, 1,103,111,110,101, 32, 9, 3, 23, 1,102,114,117,
105,116, 38, 9, 3, 23, 1,100,119,101,108,116, 18, 8, 3, 21, 1,100,111,
116,104, 39, 8, 3, 21, 1,100,105,101,100, 47, 12, 3, 29, 1,100,101,112,
97,114,116,101,100, 26, 10, 3, 25, 1, 99,117, 98,105,116,115, 33, 9, 3,
23, 1, 99,104,105,108,100, 42, 7, 3, 19, 1, 99, 97,110, 4, 11, 3, 27,
1, 98,101,116,119,101,101,110, 10, 9, 3, 23, 1, 98,101,103, 97,116, 19,
8, 3, 21, 1, 98,101, 97,114, 29, 7, 3, 19, 1, 97,114,107, 13, 9, 3,
23, 1, 97,110,103,101,114, 5, 9, 3, 23, 1, 97,110,103, 0, 0, 0, 28,
8, 3, 21, 1,116,114,101,101, 49, 13, 1,104, 0, 7, 0, 24, 0, 1, 67,
1, 13, 0,225, 0,177, 0,109, 1,171, 0, 24, 0, 0, 83, 14, 7, 21, 19,
19, 8,129, 17,118,105,101,119,118, 50, 48,118, 50, 48, 67, 82, 69, 65, 84,
69, 32, 86, 73, 69, 87, 32,118, 50, 48, 40, 97, 44, 98, 44, 99, 44,100, 44,
101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,
100, 44,101, 32, 70, 82, 79, 77, 32,116, 50, 32, 87, 72, 69, 82, 69, 32, 97,
60, 62, 50, 53, 66, 12, 6, 21, 19, 19, 8,113,118,105,101,119,118, 48, 48,
118, 48, 48, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 48, 48, 40,
97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67,
84, 32, 49, 44, 49, 44, 49, 44, 49, 44, 39,111,110,101, 39, 46, 11, 6, 23,
21, 17, 1, 69,105,110,100,101,120,116, 50,101,100,116, 50, 14, 67, 82, 69,
65, 84, 69, 32, 73, 78, 68, 69, 88, 32,116, 50,101,100, 32, 79, 78, 32,116,
50, 40,101, 44,100, 41, 42, 10, 6, 23, 19, 17, 1, 63,105,110,100,101,120,
116, 49,101,116, 49, 13, 67, 82, 69, 65, 84, 69, 32, 73, 78, 68, 69, 88, 32,
116, 49,101, 32, 79, 78, 32,116, 49, 40,101, 41, 52, 9, 6, 23, 21, 17, 1,
81,105,110,100,101,120,116, 51,120, 49,116, 51, 12, 67, 82, 69, 65, 84, 69,
32, 73, 78, 68, 69, 88, 32,116, 51,120, 49, 32, 79, 78, 32,116, 51, 40, 97,
44, 98, 44, 99, 44,100, 44,101, 41, 35, 8, 6, 23, 55, 17, 1, 0,105,110,
100,101,120,115,113,108,105,116,101, 95, 97,117,116,111,105,110,100,101,120,
95,116, 53, 95, 49,116, 53, 10, 0, 0, 0, 67, 17, 17, 1,129, 3,116, 97,
98,108,101,116, 53,116, 53, 8, 67, 82, 69, 65, 84, 69, 32, 84, 65, 66, 76,
69, 32,116, 53, 40, 97, 32, 73, 78, 84, 69, 71, 69, 82, 32, 80, 82, 73, 77,
65, 82, 89, 32, 75, 69, 89, 44, 32, 98, 32, 84, 69, 88, 84, 32, 85, 78, 83,
13, 7, 21, 19, 19, 8,129, 17,118,105,101,119,118, 49, 48,118, 49, 48, 67,
82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 49, 48, 40, 97, 44, 98, 44,
99, 44,100, 44,101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44,
98, 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 49, 32, 87, 72, 69,
82, 69, 32, 97, 60, 62, 50, 53, 2, 0, 0, 0, 1, 1,240, 0, 0, 0, 0,
24, 1,240, 1,220, 1,211, 1,199, 1,187, 1,176, 1,164, 1,148, 1,133,
1,116, 1, 99, 1, 86, 1, 67, 1, 55, 1, 43, 1, 31, 1, 18, 1, 5, 0,
249, 0,236, 0,224, 0,209, 0,191, 0,174, 0,157, 0,145, 0,132, 0,120,
0,108, 0, 95, 0, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 7, 1, 0,
1, 1, 0, 1, 49, 51, 38, 15, 12, 7, 1, 1, 1, 1, 0, 1, 48, 37, 93,
7, 30, 11, 7, 1, 1, 1, 0, 0, 1, 47, 22, 16, 24, 11, 7, 1, 0, 1,
1, 0, 1, 47, 16, 40, 12, 12, 7, 1, 1, 1, 1, 0, 1, 46, 28, 88, 22,
2, 11, 7, 1, 1, 0, 1, 0, 1, 44, 48, 9, 19, 16, 7, 1, 1, 1, 0,
23, 1, 42, 20, 18, 98,101,103, 97,116, 22, 16, 7, 1, 1, 0, 1, 23, 1,
37, 17, 18,100,119,101,108,116, 16, 17, 7, 1, 1, 0, 1, 25, 1, 35, 38,
22, 99,117, 98,105,116,115, 17, 14, 7, 1, 1, 1, 0, 19, 1, 34, 26, 15,
97,114,107, 21, 11, 7, 1, 1, 1, 0, 0, 1, 32, 16, 7, 23, 12, 7, 1,
1, 1, 1, 0, 1, 28, 17, 67, 31, 29, 11, 7, 1, 0, 1, 1, 0, 1, 25,
7, 19, 11, 12, 7, 1, 1, 1, 1, 0, 1, 22, 45, 71, 28, 28, 12, 7, 1,
1, 1, 1, 0, 1, 21, 22, 92, 18, 4, 11, 7, 1, 1, 0, 1, 0, 1, 21,
22, 18, 18, 11, 7, 1, 1, 1, 1, 0, 9, 17, 29, 74, 36, 11, 7, 1, 1,
1, 0, 0, 1, 17, 29, 74, 25, 18, 7, 1, 1, 1, 1, 25, 1, 15, 6, 3,
11,116,101,109,112,108,101, 5, 12, 7, 1, 1, 1, 1, 0, 1, 12, 4, 38,
36, 27, 16, 7, 1, 0, 1, 1, 23, 1, 10, 89, 14,115,101,114,118,101, 14,
16, 7, 1, 1, 1, 1, 21, 1, 4, 41, 32, 35,110,101, 97,114, 3, 14, 7,
9, 0, 1, 1, 21, 1, 68, 32,100,111,116,104, 13, 15, 7, 0, 1, 1, 1,
21, 1, 21, 91, 38,110,101, 97,114, 6, 11, 7, 0, 1, 1, 1, 0, 1, 16,
81, 25, 9, 10, 7, 0, 1, 1, 8, 0, 1, 16, 7, 10, 11, 7, 0, 1, 1,
1, 0, 1, 7, 72, 31, 8, 11, 7, 0, 1, 1, 1, 0, 1, 6, 37, 31, 7,
8, 7, 0, 0, 0, 0, 0, 1, 35, 8, 7, 0, 0, 0, 0, 0, 1, 34, 8,
7, 0, 0, 0, 0, 0, 1, 33, 8, 7, 0, 0, 0, 23, 11, 7, 1, 0, 1,
1, 0, 1, 49, 51, 38, 15, 2, 0, 0, 0, 1, 1,241, 0, 0, 0, 0, 18,
1,241, 1,221, 1,211, 1,203, 1,193, 1,183, 1,173, 1,163, 1,151, 1,
143, 1,133, 1,122, 1,109, 1,100, 1, 92, 1, 83, 1, 74, 1, 64, 1, 55,
1, 46, 1, 34, 1, 22, 1, 13, 1, 4, 0,252, 0,241, 0,232, 0,218, 0,
209, 0,200, 0,191, 0,182, 0,173, 0,163, 0,153, 0,144, 0,136, 0,127,
0,116, 0,105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 3,
25, 1,116,101,109,112,108,101, 48, 10, 3, 25, 1,116,101,109,112,108,101,
15, 8, 3, 21, 1,115,111,109,101, 21, 7, 3, 19, 1,115,105,120, 11, 8,
3, 21, 1,115,104,101,119, 38, 9, 3, 23, 1,115,101,114,118,101, 10, 9,
3, 23, 1,115,101,114,118,101, 3, 8, 3, 21, 1,115,101,110,100, 40, 8,
3, 21, 1,115,101,110,100, 29, 8, 3, 21, 1,115,101,110,100, 12, 8, 3,
21, 1,115,101,110,100, 8, 8, 3, 21, 1,115, 97,118,101, 2, 13, 3, 31,
1,115, 97, 99,114,105,102,105, 99,101, 23, 8, 3, 21, 1,112,111,111,114,
16, 10, 3, 25, 1,112,108, 97, 99,101,115, 32, 7, 3, 19, 1,111,105,108,
49, 8, 3, 21, 1,110,101, 97,114, 7, 8, 3, 21, 1,110,101, 97,114, 4,
11, 3, 27, 1,109,111,114,110,105,110,103, 41, 11, 3, 27, 1,109,111,114,
110,105,110,103, 26, 8, 3, 21, 1,103,111,110,101, 25, 8, 3, 21, 1,103,
111,110,101, 5, 9, 3, 23, 1,100,119,101,108,116, 37, 8, 3, 21, 1,100,
111,116,104, 44, 8, 3, 21, 1,100,111,116,104, 13, 7, 3, 21, 9,100,111,
116,104, 8, 3, 21, 1,100,105,101,100, 14, 12, 3, 29, 1,100,101,112, 97,
114,116,101,100, 46, 10, 3, 25, 1, 99,117, 98,105,116,115, 35, 9, 3, 23,
1, 99,104,105,108,100, 36, 7, 3, 19, 1, 99, 97,110, 6, 11, 3, 27, 1,
98,101,116,119,101,101,110, 17, 9, 3, 23, 1, 98,101,103, 97,116, 43, 9,
3, 23, 1, 98,101,103, 97,116, 42, 9, 3, 23, 1, 98,101,103, 97,116, 39,
9, 3, 23, 1, 98,101,103, 97,116, 9, 7, 3, 19, 1, 97,114,107, 34, 9,
3, 23, 1, 97,110,103,101,114, 47, 9, 3, 23, 1, 97,110,103,101,108, 27,
9, 3, 23, 1, 97, 98,111,118,101, 45, 0, 0, 0, 17, 10, 3, 25, 1,116,
101,109,112,108,101, 48, 2, 0, 0, 0, 1, 1,239, 0, 0, 0, 0, 20, 1,
239, 1,206, 1,192, 1,180, 1,166, 1,152, 1,138, 1,125, 1,109, 1, 97,
1, 84, 1, 69, 1, 52, 1, 39, 1, 26, 1, 14, 1, 1, 0,243, 0,230, 0,
217, 0,201, 0,185, 0,172, 0,159, 0,147, 0,133, 0,120, 0,102, 0, 89,
0, 76, 0, 0, 0, 0, 12, 5, 21, 1, 1, 1,115,101,110,100, 26, 14, 40,
12, 5, 21, 1, 1, 1,115, 97,118,101, 39, 45, 2, 17, 5, 31, 1, 1, 1,
115, 97, 99,114,105,102,105, 99,101, 31, 6, 23, 12, 5, 21, 1, 1, 1,112,
111,111,114, 19, 44, 16, 13, 5, 25, 8, 1, 1,112,108, 97, 99,101,115, 16,
32, 11, 5, 19, 1, 1, 1,111,105,108, 38, 9, 49, 12, 5, 21, 1, 1, 1,
110,101, 97,114, 38, 21, 7, 12, 5, 21, 1, 1, 1,110,101, 97,114, 35, 41,
4, 15, 5, 27, 1, 1, 1,109,111,114,110,105,110,103, 17, 40, 26, 15, 5,
27, 1, 1, 1,109,111,114,110,105,110,103, 13, 46, 41, 12, 5, 21, 1, 1,
1,103,111,110,101, 28, 25, 5, 12, 5, 21, 1, 1, 1,103,111,110,101, 19,
10, 25, 13, 5, 23, 1, 1, 1,100,119,101,108,116, 18, 17, 37, 12, 5, 21,
1, 1, 1,100,111,116,104, 39, 4, 13, 11, 5, 21, 1, 1, 9,100,111,116,
104, 32, 40, 12, 5, 21, 1, 1, 1,100,111,116,104, 9, 48, 44, 12, 5, 21,
1, 1, 1,100,105,101,100, 27, 35, 14, 16, 5, 29, 1, 1, 1,100,101,112,
97,114,116,101,100, 22, 28, 46, 14, 5, 25, 1, 1, 1, 99,117, 98,105,116,
115, 22, 38, 35, 12, 5, 23, 1, 8, 1, 99,104,105,108,100, 17, 36, 11, 5,
19, 1, 1, 1, 99, 97,110, 11, 2, 6, 15, 5, 27, 1, 1, 1, 98,101,116,
119,101,101,110, 36, 29, 17, 12, 5, 23, 1, 8, 1, 98,101,103, 97,116, 50,
9, 13, 5, 23, 1, 1, 1, 98,101,103, 97,116, 45, 3, 39, 13, 5, 23, 1,
1, 1, 98,101,103, 97,116, 41, 5, 43, 13, 5, 23, 1, 1, 1, 98,101,103,
97,116, 5, 20, 42, 11, 5, 19, 1, 1, 1, 97,114,107, 20, 26, 34, 13, 5,
23, 1, 1, 1, 97,110,103,101,114, 40, 22, 47, 13, 5, 23, 1, 1, 1, 97,
110,103,101,108, 3, 22, 27, 12, 5, 23, 1, 9, 1, 97, 98,111,118,101, 45,
20, 13, 5, 23, 1, 1, 1, 0, 0, 0, 19, 12, 5, 21, 1, 1, 1,115,101,
110,100, 26, 14, 40, 13, 0, 0, 0, 28, 0, 78, 0, 1,241, 1,226, 1,210,
1,195, 1,180, 1,166, 1,151, 1,136, 1,121, 1,105, 1, 91, 1, 76, 1,
61, 1, 46, 1, 29, 1, 14, 0,252, 0,238, 0,224, 0,209, 0,194, 0,177,
0,157, 0,143, 0,128, 0,110, 0, 94, 0, 78, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 14, 28, 6, 0, 1, 1, 1, 23, 17, 67, 31,119,
111,114,107,115, 14, 27, 6, 0, 1, 1, 1, 23, 22, 71, 3, 97,110,103,101,
108, 16, 26, 6, 0, 1, 1, 1, 27, 40, 98, 17,109,111,114,110,105,110,103,
13, 25, 6, 0, 1, 1, 1, 21, 10, 7, 19,103,111,110,101, 12, 24, 6, 0,
1, 1, 9, 21, 43, 46,119, 97,121,115, 18, 23, 6, 0, 1, 1, 1, 31, 6,
37, 31,115, 97, 99,114,105,102,105, 99,101, 15, 22, 6, 0, 1, 1, 1, 25,
45, 71, 28,116,104,111,117,103,104, 13, 21, 6, 0, 1, 1, 1, 21, 22, 92,
18,115,111,109,101, 13, 20, 6, 0, 9, 1, 1, 23, 2, 45, 97, 98,111,118,
101, 12, 19, 6, 0, 1, 1, 8, 21, 4, 58,119, 97,121,115, 12, 18, 6, 0,
1, 1, 1, 19, 44, 19, 43,119, 97,114, 16, 17, 6, 0, 1, 1, 1, 27, 29,
74, 36, 98,101,116,119,101,101,110, 13, 16, 6, 0, 1, 1, 1, 21, 44, 52,
19,112,111,111,114, 15, 15, 6, 0, 1, 1, 1, 25, 6, 3, 11,116,101,109,
112,108,101, 13, 14, 6, 0, 1, 1, 1, 21, 35, 48, 27,100,105,101,100, 13,
13, 6, 0, 1, 1, 1, 21, 4, 21, 39,100,111,116,104, 13, 12, 6, 0, 1,
1, 1, 21, 4, 38, 36,115,101,110,100, 12, 11, 6, 0, 1, 1, 1, 19, 13,
48, 22,115,105,120, 14, 10, 6, 0, 1, 1, 1, 23, 41, 89, 14,115,101,114,
118,101, 13, 9, 6, 0, 8, 1, 1, 23, 16, 50, 98,101,103, 97,116, 13, 8,
6, 0, 1, 1, 1, 21, 42, 49, 34,115,101,110,100, 13, 7, 6, 0, 1, 1,
1, 21, 21, 91, 38,110,101, 97,114, 12, 6, 6, 0, 1, 1, 1, 19, 2, 37,
11, 99, 97,110, 13, 5, 6, 0, 1, 1, 1, 21, 25, 27, 28,103,111,110,101,
13, 4, 6, 0, 1, 1, 1, 21, 41, 32, 35,110,101, 97,114, 14, 3, 6, 0,
1, 1, 1, 23, 32, 24, 26,115,101,114,118,101, 13, 2, 6, 0, 1, 1, 1,
21, 45, 14, 39,115, 97,118,101, 13, 1, 6, 0, 1, 1, 1, 21, 40, 68, 32,
100,111,116,104, 13, 0, 0, 0, 22, 0,166, 0, 1,241, 1,226, 1,210, 1,
194, 1,183, 1,169, 1,152, 1,137, 1,121, 1,106, 1, 90, 1, 75, 1, 57,
1, 41, 1, 25, 1, 10, 0,250, 0,231, 0,215, 0,198, 0,184, 0,166, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16,
50, 6, 0, 1, 1, 1, 27, 9, 92, 29,116,104,101,114,101,105,110, 12, 49,
6, 0, 1, 1, 1, 19, 9, 51, 38,111,105,108, 15, 48, 6, 0, 1, 1, 1,
25, 37, 93, 7,116,101,109,112,108,101, 14, 47, 6, 0, 1, 1, 1, 23, 22,
16, 40, 97,110,103,101,114, 17, 46, 6, 0, 1, 1, 1, 29, 28, 88, 22,100,
101,112, 97,114,116,101,100, 14, 45, 6, 0, 1, 1, 1, 23, 47, 54, 12, 97,
98,111,118,101, 13, 44, 6, 0, 1, 1, 1, 21, 48, 15, 9,100,111,116,104,
14, 43, 6, 0, 1, 1, 1, 23, 5, 23, 41, 98,101,103, 97,116, 14, 42, 6,
0, 1, 1, 1, 23, 20, 18, 5, 98,101,103, 97,116, 16, 41, 6, 0, 1, 1,
1, 27, 46, 92, 13,109,111,114,110,105,110,103, 13, 40, 6, 0, 1, 1, 1,
21, 14, 30, 26,115,101,110,100, 14, 39, 6, 0, 1, 1, 1, 23, 3, 21, 45,
98,101,103, 97,116, 13, 38, 6, 0, 1, 1, 1, 21, 10, 97, 34,115,104,101,
119, 14, 37, 6, 0, 1, 1, 1, 23, 17, 66, 18,100,119,101,108,116, 13, 36,
6, 0, 8, 1, 1, 23, 52, 17, 99,104,105,108,100, 15, 35, 6, 0, 1, 1,
1, 25, 38, 34, 22, 99,117, 98,105,116,115, 12, 34, 6, 0, 1, 1, 1, 19,
26, 15, 20, 97,114,107, 9, 33, 6, 0, 1, 1, 1, 0, 7, 72, 31, 14, 32,
6, 0, 1, 1, 8, 25, 16, 7,112,108, 97, 99,101,115, 14, 31, 6, 0, 1,
1, 1, 23, 39, 90, 27,116,114,117,116,104, 13, 30, 6, 0, 1, 1, 1, 21,
16, 81, 25,119, 97,108,107, 13, 29, 6, 0, 1, 1, 1, 21, 34, 62, 27,115,
101,110,100, 10, 0, 0, 0, 41, 0,116, 0, 1,251, 1,241, 1,231, 1,221,
1,211, 1,203, 1,193, 1,183, 1,173, 1,163, 1,151, 1,143, 1,133, 1,
122, 1,109, 1,100, 1, 92, 1, 83, 1, 74, 1, 64, 1, 55, 1, 46, 1, 34,
1, 22, 1, 13, 1, 4, 0,252, 0,241, 0,232, 0,218, 0,209, 0,200, 0,
191, 0,182, 0,173, 0,163, 0,153, 0,144, 0,136, 0,127, 0,116, 0,105,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11,116,101,
109,112,108,101, 48, 10, 3, 25, 1,116,101,109,112,108,101, 15, 8, 3, 21,
1,115,111,109,101, 21, 7, 3, 19, 1,115,105,120, 11, 8, 3, 21, 1,115,
104,101,119, 38, 9, 3, 23, 1,115,101,114,118,101, 10, 9, 3, 23, 1,115,
101,114,118,101, 3, 8, 3, 21, 1,115,101,110,100, 40, 8, 3, 21, 1,115,
101,110,100, 29, 8, 3, 21, 1,115,101,110,100, 12, 8, 3, 21, 1,115,101,
110,100, 8, 8, 3, 21, 1,115, 97,118,101, 2, 13, 3, 31, 1,115, 97, 99,
114,105,102,105, 99,101, 23, 8, 3, 21, 1,112,111,111,114, 16, 10, 3, 25,
1,112,108, 97, 99,101,115, 32, 7, 3, 19, 1,111,105,108, 49, 8, 3, 21,
1,110,101, 97,114, 7, 8, 3, 21, 1,110,101, 97,114, 4, 11, 3, 27, 1,
109,111,114,110,105,110,103, 41, 11, 3, 27, 1,109,111,114,110,105,110,103,
26, 8, 3, 21, 1,103,111,110,101, 25, 8, 3, 21, 1,103,111,110,101, 5,
9, 3, 23, 1,100,119,101,108,116, 37, 8, 3, 21, 1,100,111,116,104, 44,
8, 3, 21, 1,100,111,116,104, 13, 7, 3, 21, 9,100,111,116,104, 8, 3,
21, 1,100,105,101,100, 14, 12, 3, 29, 1,100,101,112, 97,114,116,101,100,
46, 10, 3, 25, 1, 99,117, 98,105,116,115, 35, 9, 3, 23, 1, 99,104,105,
108,100, 36, 7, 3, 19, 1, 99, 97,110, 6, 11, 3, 27, 1, 98,101,116,119,
101,101,110, 17, 9, 3, 23, 1, 98,101,103, 97,116, 43, 9, 3, 23, 1, 98,
101,103, 97,116, 42, 9, 3, 23, 1, 98,101,103, 97,116, 39, 9, 3, 23, 1,
98,101,103, 97,116, 9, 7, 3, 19, 1, 97,114,107, 34, 9, 3, 23, 1, 97,
110,103,101,114, 47, 9, 3, 23, 1, 97,110,103,101,108, 27, 9, 3, 23, 1,
97, 98,111,118,101, 45, 9, 3, 23, 1, 97, 98,111,118,101, 20, 4, 3, 0,
1, 33, 10, 0, 0, 0, 8, 1,178, 0, 1,244, 1,233, 1,223, 1,214, 1,
206, 1,197, 1,188, 1,178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,
3, 23, 1,119,111,114,107,115, 28, 8, 3, 21, 1,119, 97,121,115, 24, 8,
3, 21, 1,119, 97,121,115, 19, 7, 3, 19, 1,119, 97,114, 18, 8, 3, 21,
1,119, 97,108,107, 30, 9, 3, 23, 1,116,114,117,116,104, 31, 10, 3, 25,
1,116,104,111,117,103,104, 22, 11, 3, 27, 1,116,104,101,114,101,105,110,
50, 10, 0, 0, 0, 31, 0, 89, 0, 1,247, 1,233, 1,220, 1,206, 1,192,
1,180, 1,166, 1,152, 1,138, 1,125, 1,109, 1, 97, 1, 84, 1, 69, 1,
52, 1, 39, 1, 26, 1, 14, 1, 1, 0,243, 0,230, 0,217, 0,201, 0,185,
0,172, 0,159, 0,147, 0,133, 0,120, 0,102, 0, 89, 0, 76, 0, 0, 0,
0, 0, 0, 0, 13, 1, 1,115,101,110,100, 26, 14, 40, 12, 5, 21, 1, 1,
1,115, 97,118,101, 39, 45, 2, 17, 5, 31, 1, 1, 1,115, 97, 99,114,105,
102,105, 99,101, 31, 6, 23, 12, 5, 21, 1, 1, 1,112,111,111,114, 19, 44,
16, 13, 5, 25, 8, 1, 1,112,108, 97, 99,101,115, 16, 32, 11, 5, 19, 1,
1, 1,111,105,108, 38, 9, 49, 12, 5, 21, 1, 1, 1,110,101, 97,114, 38,
21, 7, 12, 5, 21, 1, 1, 1,110,101, 97,114, 35, 41, 4, 15, 5, 27, 1,
1, 1,109,111,114,110,105,110,103, 17, 40, 26, 15, 5, 27, 1, 1, 1,109,
111,114,110,105,110,103, 13, 46, 41, 12, 5, 21, 1, 1, 1,103,111,110,101,
28, 25, 5, 12, 5, 21, 1, 1, 1,103,111,110,101, 19, 10, 25, 13, 5, 23,
1, 1, 1,100,119,101,108,116, 18, 17, 37, 12, 5, 21, 1, 1, 1,100,111,
116,104, 39, 4, 13, 11, 5, 21, 1, 1, 9,100,111,116,104, 32, 40, 12, 5,
21, 1, 1, 1,100,111,116,104, 9, 48, 44, 12, 5, 21, 1, 1, 1,100,105,
101,100, 27, 35, 14, 16, 5, 29, 1, 1, 1,100,101,112, 97,114,116,101,100,
22, 28, 46, 14, 5, 25, 1, 1, 1, 99,117, 98,105,116,115, 22, 38, 35, 12,
5, 23, 1, 8, 1, 99,104,105,108,100, 17, 36, 11, 5, 19, 1, 1, 1, 99,
97,110, 11, 2, 6, 15, 5, 27, 1, 1, 1, 98,101,116,119,101,101,110, 36,
29, 17, 12, 5, 23, 1, 8, 1, 98,101,103, 97,116, 50, 9, 13, 5, 23, 1,
1, 1, 98,101,103, 97,116, 45, 3, 39, 13, 5, 23, 1, 1, 1, 98,101,103,
97,116, 41, 5, 43, 13, 5, 23, 1, 1, 1, 98,101,103, 97,116, 5, 20, 42,
11, 5, 19, 1, 1, 1, 97,114,107, 20, 26, 34, 13, 5, 23, 1, 1, 1, 97,
110,103,101,114, 40, 22, 47, 13, 5, 23, 1, 1, 1, 97,110,103,101,108, 3,
22, 27, 12, 5, 23, 1, 9, 1, 97, 98,111,118,101, 45, 20, 13, 5, 23, 1,
1, 1, 97, 98,111,118,101, 12, 47, 45, 8, 5, 0, 1, 1, 1, 31, 7, 33,
10, 0, 0, 0, 18, 1, 13, 0, 1,243, 1,230, 1,217, 1,203, 1,189, 1,
176, 1,164, 1,151, 1,136, 1,121, 1,105, 1, 90, 1, 76, 1, 63, 1, 51,
1, 39, 1, 27, 1, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 13, 5, 23, 1, 1, 1,119,111,114,107,115, 31, 17, 28, 11, 5,
21, 9, 1, 1,119, 97,121,115, 43, 24, 11, 5, 21, 8, 1, 1,119, 97,121,
115, 4, 19, 11, 5, 19, 1, 1, 1,119, 97,114, 43, 44, 18, 12, 5, 21, 1,
1, 1,119, 97,108,107, 25, 16, 30, 13, 5, 23, 1, 1, 1,116,114,117,116,
104, 27, 39, 31, 14, 5, 25, 1, 1, 1,116,104,111,117,103,104, 28, 45, 22,
15, 5, 27, 1, 1, 1,116,104,101,114,101,105,110, 29, 9, 50, 14, 5, 25,
1, 1, 1,116,101,109,112,108,101, 11, 6, 15, 14, 5, 25, 1, 1, 1,116,
101,109,112,108,101, 7, 37, 48, 12, 5, 21, 1, 1, 1,115,111,109,101, 18,
22, 21, 11, 5, 19, 1, 1, 1,115,105,120, 22, 13, 11, 12, 5, 21, 1, 1,
1,115,104,101,119, 34, 10, 38, 13, 5, 23, 1, 1, 1,115,101,114,118,101,
26, 32, 3, 13, 5, 23, 1, 1, 1,115,101,114,118,101, 14, 41, 10, 12, 5,
21, 1, 1, 1,115,101,110,100, 36, 4, 12, 12, 5, 21, 1, 1, 1,115,101,
110,100, 34, 42, 8, 12, 5, 21, 1, 1, 1,115,101,110,100, 27, 34, 29, 10,
0, 0, 0, 28, 0, 82, 0, 1,241, 1,226, 1,211, 1,197, 1,181, 1,166,
1,151, 1,137, 1,121, 1,104, 1, 84, 1, 73, 1, 59, 1, 41, 1, 26, 1,
11, 0,253, 0,238, 0,223, 0,207, 0,191, 0,175, 0,159, 0,144, 0,129,
0,113, 0, 97, 0, 82, 0, 68, 0, 0, 0, 0, 0, 14, 1, 1, 19, 26, 34,
15, 20, 97,114,107, 14, 6, 1, 1, 1, 1, 21, 25, 5, 27, 28,103,111,110,
101, 15, 6, 1, 1, 1, 1, 23, 22, 47, 16, 40, 97,110,103,101,114, 15, 6,
1, 1, 1, 1, 23, 22, 27, 71, 3, 97,110,103,101,108, 14, 6, 1, 1, 1,
1, 21, 22, 21, 92, 18,115,111,109,101, 14, 6, 1, 1, 1, 1, 21, 21, 7,
91, 38,110,101, 97,114, 15, 6, 1, 1, 1, 1, 23, 20, 42, 18, 5, 98,101,
103, 97,116, 15, 6, 1, 1, 1, 1, 23, 17, 37, 66, 18,100,119,101,108,116,
15, 6, 1, 1, 1, 1, 23, 17, 28, 67, 31,119,111,114,107,115, 15, 6, 1,
1, 1, 8, 25, 16, 32, 7,112,108, 97, 99,101,115, 14, 6, 1, 1, 1, 1,
21, 16, 30, 81, 25,119, 97,108,107, 14, 6, 1, 1, 1, 1, 21, 14, 40, 30,
26,115,101,110,100, 13, 6, 1, 1, 1, 1, 19, 13, 11, 48, 22,115,105,120,
14, 6, 1, 1, 1, 1, 21, 10, 38, 97, 34,115,104,101,119, 14, 6, 1, 1,
1, 1, 21, 10, 25, 7, 19,103,111,110,101, 17, 6, 1, 1, 1, 1, 27, 9,
50, 92, 29,116,104,101,114,101,105,110, 13, 6, 1, 1, 1, 1, 19, 9, 49,
51, 38,111,105,108, 10, 6, 1, 1, 1, 1, 0, 7, 33, 72, 31, 19, 6, 1,
1, 1, 1, 31, 6, 23, 37, 31,115, 97, 99,114,105,102,105, 99,101, 16, 6,
1, 1, 1, 1, 25, 6, 15, 3, 11,116,101,109,112,108,101, 15, 6, 1, 1,
1, 1, 23, 5, 43, 23, 41, 98,101,103, 97,116, 13, 6, 1, 1, 1, 8, 21,
4, 19, 58,119, 97,121,115, 14, 6, 1, 1, 1, 1, 21, 4, 13, 21, 39,100,
111,116,104, 14, 6, 1, 1, 1, 1, 21, 4, 12, 38, 36,115,101,110,100, 15,
6, 1, 1, 1, 1, 23, 3, 39, 21, 45, 98,101,103, 97,116, 13, 6, 1, 1,
1, 1, 19, 2, 6, 37, 11, 99, 97,110, 14, 6, 9, 1, 1, 1, 23, 20, 2,
45, 97, 98,111,118,101, 14, 6, 8, 1, 1, 1, 23, 36, 52, 17, 99,104,105,
108,100, 14, 6, 8, 1, 1, 1, 23, 9, 16, 50, 98,101,103, 97,116, 10, 0,
0, 0, 21, 0,177, 0, 1,237, 1,219, 1,203, 1,188, 1,173, 1,156, 1,
139, 1,123, 1,109, 1, 91, 1, 76, 1, 60, 1, 45, 1, 31, 1, 16, 1, 2,
0,243, 0,226, 0,208, 0,192, 0,177, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 14, 6, 1, 1, 1, 1, 21, 48, 44, 15, 9,100,111,116,104,
15, 6, 1, 1, 1, 1, 23, 47, 45, 54, 12, 97, 98,111,118,101, 17, 6, 1,
1, 1, 1, 27, 46, 41, 92, 13,109,111,114,110,105,110,103, 16, 6, 1, 1,
1, 1, 25, 45, 22, 71, 28,116,104,111,117,103,104, 14, 6, 1, 1, 1, 1,
21, 45, 2, 14, 39,115, 97,118,101, 13, 6, 1, 1, 1, 1, 19, 44, 18, 19,
43,119, 97,114, 14, 6, 1, 1, 1, 1, 21, 44, 16, 52, 19,112,111,111,114,
13, 6, 1, 1, 1, 9, 21, 43, 24, 46,119, 97,121,115, 14, 6, 1, 1, 1,
1, 21, 42, 8, 49, 34,115,101,110,100, 15, 6, 1, 1, 1, 1, 23, 41, 10,
89, 14,115,101,114,118,101, 14, 6, 1, 1, 1, 1, 21, 41, 4, 32, 35,110,
101, 97,114, 17, 6, 1, 1, 1, 1, 27, 40, 26, 98, 17,109,111,114,110,105,
110,103, 13, 6, 1, 9, 1, 1, 21, 40, 68, 32,100,111,116,104, 15, 6, 1,
1, 1, 1, 23, 39, 31, 90, 27,116,114,117,116,104, 16, 6, 1, 1, 1, 1,
25, 38, 35, 34, 22, 99,117, 98,105,116,115, 16, 6, 1, 1, 1, 1, 25, 37,
48, 93, 7,116,101,109,112,108,101, 14, 6, 1, 1, 1, 1, 21, 35, 14, 48,
27,100,105,101,100, 14, 6, 1, 1, 1, 1, 21, 34, 29, 62, 27,115,101,110,
100, 15, 6, 1, 1, 1, 1, 23, 32, 3, 24, 26,115,101,114,118,101, 17, 6,
1, 1, 1, 1, 27, 29, 17, 74, 36, 98,101,116,119,101,101,110, 18, 6, 1,
1, 1, 1, 29, 28, 46, 88, 22,100,101,112, 97,114,116,101,100, 10, 0, 0,
0, 32, 0, 95, 0, 1,247, 1,238, 1,229, 1,220, 1,211, 1,199, 1,187,
1,176, 1,164, 1,148, 1,133, 1,116, 1, 99, 1, 86, 1, 67, 1, 55, 1,
43, 1, 31, 1, 18, 1, 5, 0,249, 0,236, 0,224, 0,209, 0,191, 0,174,
0,157, 0,145, 0,132, 0,120, 0,108, 0, 95, 0, 83, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 12, 1, 1, 0, 1, 49, 51, 38, 15, 12, 7, 1,
1, 1, 1, 0, 1, 48, 37, 93, 7, 30, 11, 7, 1, 1, 1, 0, 0, 1, 47,
22, 16, 24, 11, 7, 1, 0, 1, 1, 0, 1, 47, 16, 40, 12, 12, 7, 1, 1,
1, 1, 0, 1, 46, 28, 88, 22, 2, 11, 7, 1, 1, 0, 1, 0, 1, 44, 48,
9, 19, 16, 7, 1, 1, 1, 0, 23, 1, 42, 20, 18, 98,101,103, 97,116, 22,
16, 7, 1, 1, 0, 1, 23, 1, 37, 17, 18,100,119,101,108,116, 16, 17, 7,
1, 1, 0, 1, 25, 1, 35, 38, 22, 99,117, 98,105,116,115, 17, 14, 7, 1,
1, 1, 0, 19, 1, 34, 26, 15, 97,114,107, 21, 11, 7, 1, 1, 1, 0, 0,
1, 32, 16, 7, 23, 12, 7, 1, 1, 1, 1, 0, 1, 28, 17, 67, 31, 29, 11,
7, 1, 0, 1, 1, 0, 1, 25, 7, 19, 11, 12, 7, 1, 1, 1, 1, 0, 1,
22, 45, 71, 28, 28, 12, 7, 1, 1, 1, 1, 0, 1, 21, 22, 92, 18, 4, 11,
7, 1, 1, 0, 1, 0, 1, 21, 22, 18, 18, 11, 7, 1, 1, 1, 1, 0, 9,
17, 29, 74, 36, 11, 7, 1, 1, 1, 0, 0, 1, 17, 29, 74, 25, 18, 7, 1,
1, 1, 1, 25, 1, 15, 6, 3, 11,116,101,109,112,108,101, 5, 12, 7, 1,
1, 1, 1, 0, 1, 12, 4, 38, 36, 27, 16, 7, 1, 0, 1, 1, 23, 1, 10,
89, 14,115,101,114,118,101, 14, 16, 7, 1, 1, 1, 1, 21, 1, 4, 41, 32,
35,110,101, 97,114, 3, 14, 7, 9, 0, 1, 1, 21, 1, 68, 32,100,111,116,
104, 13, 15, 7, 0, 1, 1, 1, 21, 1, 21, 91, 38,110,101, 97,114, 6, 11,
7, 0, 1, 1, 1, 0, 1, 16, 81, 25, 9, 10, 7, 0, 1, 1, 8, 0, 1,
16, 7, 10, 11, 7, 0, 1, 1, 1, 0, 1, 7, 72, 31, 8, 11, 7, 0, 1,
1, 1, 0, 1, 6, 37, 31, 7, 8, 7, 0, 0, 0, 0, 0, 1, 35, 8, 7,
0, 0, 0, 0, 0, 1, 34, 8, 7, 0, 0, 0, 0, 0, 1, 33, 8, 7, 0,
0, 0, 0, 0, 1, 32, 8, 7, 0, 0, 0, 0, 0, 1, 31, 10, 0, 0, 0,
2, 1,231, 0, 1,244, 1,231, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 12, 7, 1, 1, 1, 1, 0, 1, 49, 9, 51,
38, 26, 11, 7, 1, 1, 0, 1, 0, 1, 49, 9, 38, 20, 13, 0, 0, 0, 23,
0, 67, 0, 1,238, 1,220, 1,202, 1,186, 1,168, 1,148, 1,130, 1,107,
1, 86, 1, 65, 1, 44, 1, 27, 1, 14, 0,250, 0,224, 0,205, 0,184, 0,
165, 0,145, 0,123, 0,106, 0, 86, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 17, 23, 6, 0, 23, 1, 1, 21,107,110,111,119,110, 52,
19,112,111,111,114, 18, 22, 6, 0, 23, 1, 1, 23, 97, 98,111,118,101, 24,
26,115,101,114,118,101, 15, 21, 6, 0, 19, 1, 1, 21,119, 97,114, 52, 19,
112,111,111,114, 20, 20, 6, 0, 27, 1, 8, 25,110,111,116,104,105,110,103,
7,112,108, 97, 99,101,115, 18, 19, 6, 0, 23, 1, 1, 23, 98,101,103, 97,
116, 90, 27,116,114,117,116,104, 17, 18, 6, 0, 23, 1, 1, 21,100,119,101,
108,116, 21, 39,100,111,116,104, 19, 17, 6, 0, 27, 1, 1, 21,109,111,114,
110,105,110,103, 52, 19,112,111,111,114, 17, 16, 6, 0, 21, 1, 1, 23,115,
104,101,119, 90, 27,116,114,117,116,104, 24, 15, 6, 0, 27, 1, 1, 31,116,
104,101,114,101,105,110, 37, 31,115, 97, 99,114,105,102,105, 99,101, 18, 14,
6, 0, 23, 1, 8, 25,115,109,111,116,101, 7,112,108, 97, 99,101,115, 11,
13, 6, 0, 19, 1, 1, 0, 97,114,107, 72, 31, 15, 12, 6, 0, 21, 1, 8,
21,119,105,110,101, 58,119, 97,121,115, 19, 11, 6, 0, 21, 1, 1, 27,115,
111,109,101, 98, 17,109,111,114,110,105,110,103, 19, 10, 6, 0, 27, 1, 1,
21, 98,101,116,119,101,101,110, 92, 18,115,111,109,101, 19, 9, 6, 0, 21,
1, 1, 27,115, 97,118,101, 74, 36, 98,101,116,119,101,101,110, 21, 8, 6,
0, 25, 1, 1, 27,116,104,111,117,103,104, 98, 17,109,111,114,110,105,110,
103, 16, 7, 6, 0, 21, 1, 1, 21,115,101,110,100, 49, 34,115,101,110,100,
18, 6, 6, 0, 25, 1, 1, 21,119,105,115,100,111,109, 38, 36,115,101,110,
100, 16, 5, 6, 0, 23, 1, 9, 21, 97,110,103,101,114, 46,119, 97,121,115,
14, 4, 6, 0, 19, 1, 1, 19, 99, 97,110, 19, 43,119, 97,114, 16, 3, 6,
0, 23, 1, 1, 19,111,102,102,101,114, 48, 22,115,105,120, 16, 2, 6, 0,
23, 1, 8, 21,119,111,114,107,115, 58,119, 97,121,115, 16, 1, 6, 0, 23,
1, 1, 19,116,114,117,116,104, 37, 11, 99, 97,110, 13, 0, 0, 0, 22, 0,
64, 0, 1,230, 1,213, 1,191, 1,169, 1,148, 1,130, 1,108, 1, 89, 1,
70, 1, 51, 1, 34, 1, 16, 0,253, 0,233, 0,214, 0,194, 0,174, 0,151,
0,132, 0,109, 0, 90, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 24, 45, 6, 0, 35, 1, 1, 23,105,110,104, 97, 98,105,116, 97,110,116,
115, 23, 41, 98,101,103, 97,116, 17, 44, 6, 0, 23, 1, 1, 21, 97,110,103,
101,108, 48, 27,100,105,101,100, 21, 43, 6, 0, 25, 1, 1, 27,116,101,109,
112,108,101, 74, 36, 98,101,116,119,101,101,110, 17, 42, 6, 0, 23, 1, 1,
21, 99,104,105,108,100, 81, 25,119, 97,108,107, 21, 41, 6, 0, 21, 1, 1,
31,119, 97,121,115, 37, 31,115, 97, 99,114,105,102,105, 99,101, 18, 40, 6,
0, 21, 1, 1, 25,112,111,111,114, 93, 7,116,101,109,112,108,101, 18, 39,
6, 0, 21, 1, 1, 25,100,111,116,104, 3, 11,116,101,109,112,108,101, 17,
38, 6, 0, 23, 1, 1, 21,102,114,117,105,116, 62, 27,115,101,110,100, 18,
37, 6, 0, 23, 1, 1, 23,115,101,114,118,101, 90, 27,116,114,117,116,104,
17, 36, 6, 0, 21, 1, 1, 23,110,101, 97,114, 90, 27,116,114,117,116,104,
16, 35, 6, 0, 21, 1, 1, 21,108,111,110,103, 14, 39,115, 97,118,101, 15,
34, 6, 0, 21, 1, 1, 19,119, 97,108,107, 15, 20, 97,114,107, 17, 33, 6,
0, 25, 1, 9, 21, 99,117, 98,105,116,115, 46,119, 97,121,115, 17, 32, 6,
0, 21, 1, 1, 23,103,111,110,101, 23, 41, 98,101,103, 97,116, 17, 31, 6,
0, 23, 1, 1, 21,119,104,105,108,101, 49, 34,115,101,110,100, 20, 30, 6,
0, 21, 1, 1, 29,112, 97,114,116, 88, 22,100,101,112, 97,114,116,101,100,
16, 29, 6, 0, 21, 1, 1, 21, 98,101, 97,114, 92, 18,115,111,109,101, 19,
28, 6, 0, 25, 1, 1, 23,112,108, 97, 99,101,115, 23, 41, 98,101,103, 97,
116, 20, 27, 6, 0, 27, 1, 1, 23,116,104,121,115,101,108,102, 54, 12, 97,
98,111,118,101, 20, 26, 6, 0, 29, 1, 1, 21,100,101,112, 97,114,116,101,
100, 92, 18,115,111,109,101, 15, 25, 6, 0, 21, 1, 1, 19,116,101,108,108,
19, 43,119, 97,114, 24, 24, 6, 0, 31, 1, 1, 27,115, 97, 99,114,105,102,
105, 99,101, 92, 13,109,111,114,110,105,110,103, 13, 0, 0, 0, 5, 1,162,
0, 1,239, 1,221, 1,203, 1,182, 1,162, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 50, 6, 0, 23, 1, 1,
23,119,114, 97,116,104, 21, 45, 98,101,103, 97,116, 19, 49, 6, 0, 21, 1,
1, 27,116,114,101,101, 98, 17,109,111,114,110,105,110,103, 16, 48, 6, 0,
19, 1, 1, 23,115,105,120, 71, 3, 97,110,103,101,108, 16, 47, 6, 0, 21,
1, 1, 21,100,105,101,100, 7, 19,103,111,110,101, 15, 46, 6, 0, 19, 1,
1, 21,111,105,108, 81, 25,119, 97,108,107, 10, 0, 0, 0, 40, 0,106, 0,
1,246, 1,236, 1,226, 1,218, 1,209, 1,199, 1,187, 1,179, 1,169, 1,
158, 1,145, 1,136, 1,127, 1,117, 1,107, 1, 98, 1, 82, 1, 72, 1, 63,
1, 51, 1, 42, 1, 30, 1, 20, 1, 12, 1, 3, 0,248, 0,239, 0,225, 0,
216, 0,207, 0,197, 0,188, 0,180, 0,170, 0,161, 0,152, 0,141, 0,129,
0,118, 0,106, 0, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,116,114,
101,101, 49, 11, 3, 27, 1,116,104,121,115,101,108,102, 27, 10, 3, 25, 1,
116,104,111,117,103,104, 8, 11, 3, 27, 1,116,104,101,114,101,105,110, 15,
10, 3, 25, 1,116,101,109,112,108,101, 43, 8, 3, 21, 1,116,101,108,108,
25, 8, 3, 21, 1,115,111,109,101, 11, 9, 3, 23, 1,115,109,111,116,101,
14, 7, 3, 19, 1,115,105,120, 48, 8, 3, 21, 1,115,104,101,119, 16, 9,
3, 23, 1,115,101,114,118,101, 37, 8, 3, 21, 1,115,101,110,100, 7, 8,
3, 21, 1,115, 97,118,101, 9, 13, 3, 31, 1,115, 97, 99,114,105,102,105,
99,101, 24, 8, 3, 21, 1,112,111,111,114, 40, 10, 3, 25, 1,112,108, 97,
99,101,115, 28, 8, 3, 21, 1,112, 97,114,116, 30, 7, 3, 19, 1,111,105,
108, 46, 9, 3, 23, 1,111,102,102,101,114, 3, 11, 3, 27, 1,110,111,116,
104,105,110,103, 20, 8, 3, 21, 1,110,101, 97,114, 36, 11, 3, 27, 1,109,
111,114,110,105,110,103, 17, 8, 3, 21, 1,108,111,110,103, 35, 9, 3, 23,
1,107,110,111,119,110, 23, 15, 3, 35, 1,105,110,104, 97, 98,105,116, 97,
110,116,115, 45, 8, 3, 21, 1,103,111,110,101, 32, 9, 3, 23, 1,102,114,
117,105,116, 38, 9, 3, 23, 1,100,119,101,108,116, 18, 8, 3, 21, 1,100,
111,116,104, 39, 8, 3, 21, 1,100,105,101,100, 47, 12, 3, 29, 1,100,101,
112, 97,114,116,101,100, 26, 10, 3, 25, 1, 99,117, 98,105,116,115, 33, 9,
3, 23, 1, 99,104,105,108,100, 42, 7, 3, 19, 1, 99, 97,110, 4, 11, 3,
27, 1, 98,101,116,119,101,101,110, 10, 9, 3, 23, 1, 98,101,103, 97,116,
19, 8, 3, 21, 1, 98,101, 97,114, 29, 7, 3, 19, 1, 97,114,107, 13, 9,
3, 23, 1, 97,110,103,101,114, 5, 9, 3, 23, 1, 97,110,103,101,108, 44,
9, 3, 23, 1, 97, 98,111,118,101, 22, 10, 0, 0, 0, 9, 1,171, 0, 1,
247, 1,238, 1,230, 1,221, 1,211, 1,202, 1,191, 1,181, 1,171, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9, 3, 23, 1,119,114, 97,116,104, 50, 9, 3, 23, 1,119,111,114,107,115,
2, 10, 3, 25, 1,119,105,115,100,111,109, 6, 8, 3, 21, 1,119,105,110,
101, 12, 9, 3, 23, 1,119,104,105,108,101, 31, 8, 3, 21, 1,119, 97,121,
115, 41, 7, 3, 19, 1,119, 97,114, 21, 8, 3, 21, 1,119, 97,108,107, 34,
8, 3, 23, 9,116,114,117,116,104, 13, 0, 0, 0, 5, 0, 84, 0, 1, 78,
0,249, 0,177, 1,163, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 19,
7, 21, 19, 19, 8,129, 33,118,105,101,119,118, 50, 49,118, 50, 49, 67, 82,
69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 50, 49, 40, 97, 44, 98, 44, 99,
44,100, 44,101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98,
44, 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 50, 32, 79, 82, 68, 69,
82, 32, 66, 89, 32, 98, 32, 76, 73, 77, 73, 84, 32, 49, 48, 70, 17, 6, 21,
19, 19, 8,121,118,105,101,119,118, 53, 48,118, 53, 48, 67, 82, 69, 65, 84,
69, 32, 86, 73, 69, 87, 32,118, 53, 48, 40, 97, 44, 98, 41, 32, 65, 83, 32,
83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 32, 70, 82, 79, 77, 32,116, 53, 32,
87, 72, 69, 82, 69, 32, 97, 60, 62, 50, 53, 83, 16, 7, 21, 19, 19, 8,129,
17,118,105,101,119,118, 52, 48,118, 52, 48, 67, 82, 69, 65, 84, 69, 32, 86,
73, 69, 87, 32,118, 52, 48, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32,
65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101,
32, 70, 82, 79, 77, 32,116, 52, 32, 87, 72, 69, 82, 69, 32, 97, 60, 62, 50,
53, 83, 15, 7, 21, 19, 19, 8,129, 17,118,105,101,119,118, 51, 48,118, 51,
48, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 51, 48, 40, 97, 44,
98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32,
97, 44, 98, 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 51, 32, 87,
72, 69, 82, 69, 32, 97, 60, 62, 50, 53, 91, 18, 7, 21, 19, 19, 8,129, 33,
118,105,101,119,118, 49, 49,118, 49, 49, 67, 82, 69, 65, 84, 69, 32, 86, 73,
69, 87, 32,118, 49, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65,
83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101, 32,
70, 82, 79, 77, 32,116, 49, 32, 79, 82, 68, 69, 82, 32, 66, 89, 32, 98, 32,
76, 73, 77, 73, 84, 32, 49, 48, 13, 1,163, 0, 4, 0, 40, 0, 1, 70, 0,
233, 0,152, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,110, 23, 7, 21, 19, 19, 8,129, 71,
118,105,101,119,118, 49, 50,118, 49, 50, 67, 82, 69, 65, 84, 69, 32, 86, 73,
69, 87, 32,118, 49, 50, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65,
83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,115,117,109, 40, 97, 41, 44, 32,
97,118,103, 40, 98, 41, 44, 32, 99,111,117,110,116, 40, 42, 41, 44, 32,109,
105,110, 40,100, 41, 44, 32,101, 32, 70, 82, 79, 77, 32,116, 49, 32, 71, 82,
79, 85, 80, 32, 66, 89, 32, 53, 79, 22, 7, 21, 19, 19, 8,129, 9,118,105,
101,119,118, 53, 49,118, 53, 49, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87,
32,118, 53, 49, 40, 97, 44, 98, 41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84,
32, 97, 44, 98, 32, 70, 82, 79, 77, 32,116, 53, 32, 79, 82, 68, 69, 82, 32,
66, 89, 32, 98, 32, 76, 73, 77, 73, 84, 32, 49, 48, 91, 21, 7, 21, 19, 19,
8,129, 33,118,105,101,119,118, 52, 49,118, 52, 49, 67, 82, 69, 65, 84, 69,
32, 86, 73, 69, 87, 32,118, 52, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101,
41, 32, 65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100,
44,101, 32, 70, 82, 79, 77, 32,116, 52, 32, 79, 82, 68, 69, 82, 32, 66, 89,
32, 98, 32, 76, 73, 77, 73, 84, 32, 49, 48, 91, 20, 7, 21, 19, 19, 8,129,
33,118,105,101,119,118, 51, 49,118, 51, 49, 67, 82, 69, 65, 84, 69, 32, 86,
73, 69, 87, 32,118, 51, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32,
65, 83, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101,
32, 70, 82, 79, 77, 32,116, 51, 32, 79, 82, 68, 69, 82, 32, 66, 89, 32, 98,
32, 76, 73, 77, 73, 84, 32, 49, 48, 0, 0, 0, 93, 19, 19, 8,129, 33,118,
105,101,119,118, 50, 49,118, 50, 49, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69,
87, 32,118, 50, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83,
32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101, 32, 70,
82, 79, 77, 32,116, 50, 32, 79, 82, 68, 69, 82, 32, 66, 89, 32, 98, 32, 76,
73, 77, 73, 84, 32, 49, 48, 13, 0, 0, 0, 3, 0, 66, 0, 1,107, 0,214,
0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,129, 17, 26,
7, 21, 19, 19, 8,130, 13,118,105,101,119,118, 52, 50,118, 52, 50, 67, 82,
69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 52, 50, 40, 97, 44, 98, 44, 99,
44,100, 44,101, 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,115,
117,109, 40, 97, 41, 44, 32, 97,118,103, 40, 98, 41, 44, 32, 99,111,117,110,
116, 40, 42, 41, 44, 32,109,105,110, 40,100, 41, 44, 32,101, 32, 70, 82, 79,
77, 32,116, 52, 32, 71, 82, 79, 85, 80, 32, 66, 89, 32, 53, 10, 32, 32, 32,
32, 72, 65, 86, 73, 78, 71, 32,109,105,110, 40,100, 41, 60, 51, 48, 32, 79,
82, 68, 69, 82, 32, 66, 89, 32, 51, 44, 32, 49,129, 18, 25, 7, 21, 19, 19,
8,130, 15,118,105,101,119,118, 51, 50,118, 51, 50, 67, 82, 69, 65, 84, 69,
32, 86, 73, 69, 87, 32,118, 51, 50, 40, 97, 44, 98, 44, 99, 44,100, 44,101,
41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,115,117,109, 40, 97,
41, 44, 32, 97,118,103, 40, 98, 41, 44, 32, 99,111,117,110,116, 40, 42, 41,
44, 32,109,105,110, 40,100, 41, 44, 32,101, 32, 70, 82, 79, 77, 32,116, 51,
32, 71, 82, 79, 85, 80, 32, 66, 89, 32, 53, 10, 32, 32, 32, 32, 72, 65, 86,
73, 78, 71, 32, 99,111,117,110,116, 40, 42, 41, 62, 49, 32, 79, 82, 68, 69,
82, 32, 66, 89, 32, 51, 44, 32, 49,129, 18, 24, 7, 21, 19, 19, 8,130, 15,
118,105,101,119,118, 50, 50,118, 50, 50, 67, 82, 69, 65, 84, 69, 32, 86, 73,
69, 87, 32,118, 50, 50, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65,
83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,115,117,109, 40, 97, 41, 44, 32,
97,118,103, 40, 98, 41, 44, 32, 99,111,117,110,116, 40, 42, 41, 44, 32,109,
105,110, 40,100, 41, 44, 32,101, 32, 70, 82, 79, 77, 32,116, 50, 32, 71, 82,
79, 85, 80, 32, 66, 89, 32, 53, 10, 32, 32, 32, 32, 72, 65, 86, 73, 78, 71,
32, 99,111,117,110,116, 40, 42, 41, 62, 49, 32, 79, 82, 68, 69, 82, 32, 66,
89, 32, 51, 44, 32, 49, 13, 1,108, 0, 3, 0, 83, 0, 0,225, 0, 83, 1,
136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,129, 11, 28, 7, 21, 19,
19, 8,130, 1,118,105,101,119,118, 49, 51,118, 49, 51, 67, 82, 69, 65, 84,
69, 32, 86, 73, 69, 87, 32,118, 49, 51, 40, 97, 44, 98, 44, 99, 44,100, 44,
101, 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44,
99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 49, 10, 32, 32, 85, 78, 73,
79, 78, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101,
32, 70, 82, 79, 77, 32,116, 50, 10, 32, 32, 85, 78, 73, 79, 78, 32, 83, 69,
76, 69, 67, 84, 32, 97, 44, 98, 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77,
32,116, 51,129, 8, 27, 7, 21, 19, 19, 8,129,123,118,105,101,119,118, 53,
50,118, 53, 50, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 53, 50,
40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 10, 32, 32, 83, 69,
76, 69, 67, 84, 32, 99,111,117,110,116, 40, 42, 41, 44, 32,109,105,110, 40,
98, 41, 44, 32,115,117, 98,115,116,114, 40, 98, 44, 49, 44, 49, 41, 44, 32,
109,105,110, 40, 97, 41, 44, 32,109, 97,120, 40, 97, 41, 32, 70, 82, 79, 77,
32,116, 53, 10, 32, 32, 32, 71, 82, 79, 85, 80, 32, 66, 89, 32, 51, 32, 79,
82, 68, 69, 82, 32, 66, 89, 32, 49, 0, 0, 0, 28, 21, 19, 19, 8,130, 13,
118,105,101,119,118, 52, 50,118, 52, 50, 67, 82, 69, 65, 84, 69, 32, 86,118,
29, 7, 21, 19, 19, 8,129, 87,118,105,101,119,118, 50, 51,118, 50, 51, 67,
82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,118, 50, 51, 40, 97, 44, 98, 44,
99, 44,100, 44,101, 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,
97, 44, 98, 44, 99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 49, 10, 32,
32, 69, 88, 67, 69, 80, 84, 32, 83, 69, 76, 69, 67, 84, 32, 97, 44, 98, 44,
99, 44,100, 44,101, 32, 70, 82, 79, 77, 32,116, 49, 32, 87, 72, 69, 82, 69,
32, 98, 60, 50, 53, 13, 0, 0, 0, 3, 0, 40, 0, 1,134, 1, 12, 0, 40,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,129, 97, 32, 7, 21, 19, 19, 8,131, 45,118,105,
101,119,118, 54, 50,118, 54, 50, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87,
32,118, 54, 50, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 10,
32, 32, 83, 69, 76, 69, 67, 84, 32,116, 49, 46, 97, 44,116, 50, 46, 98, 44,
116, 51, 46, 99, 44,116, 52, 46,100, 44,116, 53, 46, 98, 10, 32, 32, 32, 32,
70, 82, 79, 77, 32,116, 49, 32, 74, 79, 73, 78, 32,116, 50, 32, 79, 78, 32,
40,116, 49, 46, 97, 61,116, 50, 46, 98, 41, 10, 32, 32, 32, 32, 32, 32, 32,
32, 32, 32, 32, 32, 74, 79, 73, 78, 32,116, 51, 32, 79, 78, 32, 40,116, 49,
46, 97, 61,116, 51, 46, 97, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
32, 32, 74, 79, 73, 78, 32,116, 52, 32, 79, 78, 32, 40,116, 52, 46, 98, 61,
116, 51, 46, 98, 41, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 76,
69, 70, 84, 32, 74, 79, 73, 78, 32,116, 53, 32, 79, 78, 32, 40,116, 53, 46,
97, 61,116, 49, 46, 99, 41,120, 31, 7, 21, 19, 19, 8,129, 91,118,105,101,
119,118, 54, 49,118, 54, 49, 67, 82, 69, 65, 84, 69, 32, 86, 73, 69, 87, 32,
118, 54, 49, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32, 65, 83, 10, 32,
32, 83, 69, 76, 69, 67, 84, 32,116, 50, 46, 97, 44,116, 51, 46, 98, 44,116,
50, 46, 99, 44,116, 51, 46,100, 44,116, 50, 46,101, 10, 32, 32, 32, 32, 70,
82, 79, 77, 32,116, 50, 32, 76, 69, 70, 84, 32, 74, 79, 73, 78, 32,116, 51,
32, 79, 78, 32, 40,116, 50, 46, 97, 61,116, 51, 46, 97, 41,120, 30, 7, 21,
19, 19, 8,129, 91,118,105,101,119,118, 54, 48,118, 54, 48, 67, 82, 69, 65,
84, 69, 32, 86, 73, 69, 87, 32,118, 54, 48, 40, 97, 44, 98, 44, 99, 44,100,
44,101, 41, 32, 65, 83, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,116, 49, 46,
97, 44,116, 50, 46, 98, 44,116, 49, 46, 99, 44,116, 50, 46,100, 44,116, 49,
46,101, 10, 32, 32, 32, 32, 70, 82, 79, 77, 32,116, 49, 32, 76, 69, 70, 84,
32, 74, 79, 73, 78, 32,116, 50, 32, 79, 78, 32, 40,116, 49, 46, 97, 61,116,
50, 46, 98, 41, 13, 0, 0, 0, 1, 1, 73, 0, 1, 73, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,129, 52, 33, 7, 21, 19, 19, 8,130,
83,118,105,101,119,118, 55, 48,118, 55, 48, 67, 82, 69, 65, 84, 69, 32, 86,
73, 69, 87, 32,118, 55, 48, 40, 97, 44, 98, 44, 99, 44,100, 44,101, 41, 32,
65, 83, 10, 32, 32, 87, 73, 84, 72, 32, 82, 69, 67, 85, 82, 83, 73, 86, 69,
32, 99, 48, 40,120, 41, 32, 65, 83, 32, 40, 86, 65, 76, 85, 69, 83, 40, 49,
41, 32, 85, 78, 73, 79, 78, 32, 65, 76, 76, 32, 83, 69, 76, 69, 67, 84, 32,
120, 43, 49, 32, 70, 82, 79, 77, 32, 99, 48, 32, 87, 72, 69, 82, 69, 32,120,
60, 57, 41, 10, 32, 32, 83, 69, 76, 69, 67, 84, 32,120, 44, 32, 98, 44, 32,
99, 44, 32,100, 44, 32,101, 32, 70, 82, 79, 77, 32, 99, 48, 32, 74, 79, 73,
78, 32,116, 49, 32, 79, 78, 32, 40,116, 49, 46, 97, 61, 53, 48, 45, 99, 48,
46,120, 41,
};

142
testdata/tcl/optfuzz-db01.txt vendored Normal file
View File

@@ -0,0 +1,142 @@
-- Run this script through the sqlite3 command-line shell in order to generate
-- a database file containing lots of data for testing purposes.
--
-- This script assumes that the "bin2c" program is available on ones $PATH.
-- The "bin2c" program reads a binary file and outputs C-code that creates
-- an array of bytes holding the content of that file.
--
-- This script is designed to create many tables and views all having
-- 5 columns, "a" through "e", and with a variety of integers, short strings,
-- and NULL values.
--
.open -new testdb01.db
PRAGMA page_size=512;
BEGIN;
CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT, c INT, d INT, e INT);
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<50)
INSERT INTO t1(a,b,c,d,e) SELECT x,abs(random()%51),
abs(random()%100), abs(random()%51), abs(random()%100) FROM c;
CREATE TABLE t2(a INT, b INT, c INT,d INT,e INT,PRIMARY KEY(b,a))WITHOUT ROWID;
INSERT INTO t2 SELECT * FROM t1;
CREATE TABLE t3(a,b,c,d,e);
INSERT INTO t3 SELECT a,b,c,d,e FROM t1 ORDER BY random() LIMIT 5;
INSERT INTO t3 SELECT null,b,c,d,e FROM t1 ORDER BY random() LIMIT 5;
INSERT INTO t3 SELECT a,null,c,d,e FROM t1 ORDER BY random() LIMIT 5;
INSERT INTO t3 SELECT a,b,null,d,e FROM t1 ORDER BY random() LIMIT 5;
INSERT INTO t3 SELECT a,b,c,null,e FROM t1 ORDER BY random() LIMIT 5;
INSERT INTO t3 SELECT a,b,c,d,null FROM t1 ORDER BY random() LIMIT 5;
INSERT INTO t3 SELECT null,null,null,null,null FROM t1 LIMIT 5;
CREATE INDEX t3x1 ON t3(a,b,c,d,e);
CREATE TABLE t4(a INT UNIQUE NOT NULL, b INT UNIQUE NOT NULL,c,d,e);
INSERT OR IGNORE INTO t4 SELECT a,b,c,d,e FROM t3;
CREATE TABLE t5(a INTEGER PRIMARY KEY, b TEXT UNIQUE,c,d,e);
INSERT INTO t5(b) VALUES
('truth'),
('works'),
('offer'),
('can'),
('anger'),
('wisdom'),
('send'),
('though'),
('save'),
('between'),
('some'),
('wine'),
('ark'),
('smote'),
('therein'),
('shew'),
('morning'),
('dwelt'),
('begat'),
('nothing'),
('war'),
('above'),
('known'),
('sacrifice'),
('tell'),
('departed'),
('thyself'),
('places'),
('bear'),
('part'),
('while'),
('gone'),
('cubits'),
('walk'),
('long'),
('near'),
('serve'),
('fruit'),
('doth'),
('poor'),
('ways'),
('child'),
('temple'),
('angel'),
('inhabitants'),
('oil'),
('died'),
('six'),
('tree'),
('wrath');
UPDATE t1 SET e=(SELECT b FROM t5 WHERE t5.a=(t1.e%51));
UPDATE t5 SET (c,d,e) =
(SELECT c,d,e FROM t1 WHERE t1.a=abs(t5.a+random()/100)%50+1);
UPDATE t2 SET e=(SELECT b FROM t5 WHERE t5.a=(t2.e%51));
UPDATE t3 SET e=(SELECT b FROM t5 WHERE t5.a=t3.e);
CREATE INDEX t1e ON t1(e);
CREATE INDEX t2ed ON t2(e,d);
CREATE VIEW v00(a,b,c,d,e) AS SELECT 1,1,1,1,'one';
CREATE VIEW v10(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t1 WHERE a<>25;
CREATE VIEW v20(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t2 WHERE a<>25;
CREATE VIEW v30(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t3 WHERE a<>25;
CREATE VIEW v40(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t4 WHERE a<>25;
CREATE VIEW v50(a,b) AS SELECT a,b FROM t5 WHERE a<>25;
CREATE VIEW v11(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t1 ORDER BY b LIMIT 10;
CREATE VIEW v21(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t2 ORDER BY b LIMIT 10;
CREATE VIEW v31(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t3 ORDER BY b LIMIT 10;
CREATE VIEW v41(a,b,c,d,e) AS SELECT a,b,c,d,e FROM t4 ORDER BY b LIMIT 10;
CREATE VIEW v51(a,b) AS SELECT a,b FROM t5 ORDER BY b LIMIT 10;
CREATE VIEW v12(a,b,c,d,e) AS
SELECT sum(a), avg(b), count(*), min(d), e FROM t1 GROUP BY 5;
CREATE VIEW v22(a,b,c,d,e) AS
SELECT sum(a), avg(b), count(*), min(d), e FROM t2 GROUP BY 5
HAVING count(*)>1 ORDER BY 3, 1;
CREATE VIEW v32(a,b,c,d,e) AS
SELECT sum(a), avg(b), count(*), min(d), e FROM t3 GROUP BY 5
HAVING count(*)>1 ORDER BY 3, 1;
CREATE VIEW v42(a,b,c,d,e) AS
SELECT sum(a), avg(b), count(*), min(d), e FROM t4 GROUP BY 5
HAVING min(d)<30 ORDER BY 3, 1;
CREATE VIEW v52(a,b,c,d,e) AS
SELECT count(*), min(b), substr(b,1,1), min(a), max(a) FROM t5
GROUP BY 3 ORDER BY 1;
CREATE VIEW v13(a,b,c,d,e) AS
SELECT a,b,c,d,e FROM t1
UNION SELECT a,b,c,d,e FROM t2
UNION SELECT a,b,c,d,e FROM t3;
CREATE VIEW v23(a,b,c,d,e) AS
SELECT a,b,c,d,e FROM t1
EXCEPT SELECT a,b,c,d,e FROM t1 WHERE b<25;
CREATE VIEW v60(a,b,c,d,e) AS
SELECT t1.a,t2.b,t1.c,t2.d,t1.e
FROM t1 LEFT JOIN t2 ON (t1.a=t2.b);
CREATE VIEW v61(a,b,c,d,e) AS
SELECT t2.a,t3.b,t2.c,t3.d,t2.e
FROM t2 LEFT JOIN t3 ON (t2.a=t3.a);
CREATE VIEW v62(a,b,c,d,e) AS
SELECT t1.a,t2.b,t3.c,t4.d,t5.b
FROM t1 JOIN t2 ON (t1.a=t2.b)
JOIN t3 ON (t1.a=t3.a)
JOIN t4 ON (t4.b=t3.b)
LEFT JOIN t5 ON (t5.a=t1.c);
CREATE VIEW v70(a,b,c,d,e) AS
WITH RECURSIVE c0(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c0 WHERE x<9)
SELECT x, b, c, d, e FROM c0 JOIN t1 ON (t1.a=50-c0.x);
COMMIT;
VACUUM;
.shell bin2c testdb01.db

309
testdata/tcl/optfuzz.c vendored Normal file
View File

@@ -0,0 +1,309 @@
/*
** 2018-03-21
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This program attempts to verify the correctness of the SQLite query
** optimizer by fuzzing.
**
** The input is an SQL script, presumably generated by a fuzzer. The
** argument is the name of the input. If no files are named, standard
** input is read.
**
** The SQL script is run twice, once with optimization enabled, and again
** with optimization disabled. If the output is not equivalent, an error
** is printed and the program returns non-zero.
*/
/* Include the SQLite amalgamation, after making appropriate #defines.
*/
#define SQLITE_THREADSAFE 0
#define SQLITE_OMIT_LOAD_EXTENSION 1
#define SQLITE_ENABLE_DESERIALIZE 1
#include "sqlite3.c"
/* Content of the read-only test database */
#include "optfuzz-db01.c"
/*
** Prepare a single SQL statement. Panic if anything goes wrong
*/
static sqlite3_stmt *prepare_sql(sqlite3 *db, const char *zFormat, ...){
char *zSql;
int rc;
sqlite3_stmt *pStmt = 0;
va_list ap;
va_start(ap, zFormat);
zSql = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( rc ){
printf("Error: %s\nSQL: %s\n",
sqlite3_errmsg(db), zSql);
exit(1);
}
sqlite3_free(zSql);
return pStmt;
}
/*
** Run SQL. Panic if anything goes wrong
*/
static void run_sql(sqlite3 *db, const char *zFormat, ...){
char *zSql;
int rc;
char *zErr = 0;
va_list ap;
va_start(ap, zFormat);
zSql = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
if( rc || zErr ){
printf("Error: %s\nsqlite3_errmsg: %s\nSQL: %s\n",
zErr, sqlite3_errmsg(db), zSql);
exit(1);
}
sqlite3_free(zSql);
}
/*
** Run one or more SQL statements contained in zSql against database dbRun.
** Store the input in database dbOut.
*/
static int optfuzz_exec(
sqlite3 *dbRun, /* The database on which the SQL executes */
const char *zSql, /* The SQL to be executed */
sqlite3 *dbOut, /* Store results in this database */
const char *zOutTab, /* Store results in this table of dbOut */
int *pnStmt, /* Write the number of statements here */
int *pnRow, /* Write the number of rows here */
int bTrace /* Print query results if true */
){
int rc = SQLITE_OK; /* Return code */
const char *zLeftover; /* Tail of unprocessed SQL */
sqlite3_stmt *pStmt = 0; /* The current SQL statement */
sqlite3_stmt *pIns = 0; /* Statement to insert into dbOut */
const char *zCol; /* Single column value */
int nCol; /* Number of output columns */
char zLine[4000]; /* Complete row value */
run_sql(dbOut, "BEGIN");
run_sql(dbOut, "CREATE TABLE IF NOT EXISTS staging(x TEXT)");
run_sql(dbOut, "CREATE TABLE IF NOT EXISTS \"%w\"(x TEXT)", zOutTab);
pIns = prepare_sql(dbOut, "INSERT INTO staging(x) VALUES(?1)");
*pnRow = *pnStmt = 0;
while( rc==SQLITE_OK && zSql && zSql[0] ){
zLeftover = 0;
rc = sqlite3_prepare_v2(dbRun, zSql, -1, &pStmt, &zLeftover);
zSql = zLeftover;
assert( rc==SQLITE_OK || pStmt==0 );
if( rc!=SQLITE_OK ){
printf("Error with [%s]\n%s\n", zSql, sqlite3_errmsg(dbRun));
break;
}
if( !pStmt ) continue;
(*pnStmt)++;
nCol = sqlite3_column_count(pStmt);
run_sql(dbOut, "DELETE FROM staging;");
while( sqlite3_step(pStmt)==SQLITE_ROW ){
int i, j;
for(i=j=0; i<nCol && j<sizeof(zLine)-50; i++){
int eType = sqlite3_column_type(pStmt, i);
if( eType==SQLITE_NULL ){
zCol = "NULL";
}else{
zCol = (const char*)sqlite3_column_text(pStmt, i);
}
if( i ) zLine[j++] = ',';
if( eType==SQLITE_TEXT ){
sqlite3_snprintf(sizeof(zLine)-j, zLine+j, "'%q'", zCol);
}else{
sqlite3_snprintf(sizeof(zLine)-j, zLine+j, "%s", zCol);
}
j += (int)strlen(zLine+j);
}
/* Detect if any row is too large and throw an error, because we will
** want to go back and look more closely at that case */
if( j>=sizeof(zLine)-100 ){
printf("Excessively long output line: %d bytes\n" ,j);
exit(1);
}
if( bTrace ){
printf("%s\n", zLine);
}
(*pnRow)++;
sqlite3_bind_text(pIns, 1, zLine, j, SQLITE_TRANSIENT);
rc = sqlite3_step(pIns);
assert( rc==SQLITE_DONE );
rc = sqlite3_reset(pIns);
}
run_sql(dbOut,
"INSERT INTO \"%w\"(x) VALUES('### %q ###')",
zOutTab, sqlite3_sql(pStmt)
);
run_sql(dbOut,
"INSERT INTO \"%w\"(x) SELECT group_concat(x,char(10))"
" FROM (SELECT x FROM staging ORDER BY x)",
zOutTab
);
run_sql(dbOut, "COMMIT");
sqlite3_finalize(pStmt);
pStmt = 0;
}
sqlite3_finalize(pStmt);
sqlite3_finalize(pIns);
return rc;
}
/*
** Read the content of file zName into memory obtained from sqlite3_malloc64()
** and return a pointer to the buffer. The caller is responsible for freeing
** the memory.
**
** If parameter pnByte is not NULL, (*pnByte) is set to the number of bytes
** read.
**
** For convenience, a nul-terminator byte is always appended to the data read
** from the file before the buffer is returned. This byte is not included in
** the final value of (*pnByte), if applicable.
**
** NULL is returned if any error is encountered. The final value of *pnByte
** is undefined in this case.
*/
static char *readFile(const char *zName, int *pnByte){
FILE *in = fopen(zName, "rb");
long nIn;
size_t nRead;
char *pBuf;
if( in==0 ) return 0;
fseek(in, 0, SEEK_END);
nIn = ftell(in);
rewind(in);
pBuf = sqlite3_malloc64( nIn+1 );
if( pBuf==0 ) return 0;
nRead = fread(pBuf, nIn, 1, in);
fclose(in);
if( nRead!=1 ){
sqlite3_free(pBuf);
return 0;
}
pBuf[nIn] = 0;
if( pnByte ) *pnByte = nIn;
return pBuf;
}
int main(int argc, char **argv){
int nIn = 0; /* Number of input files */
char **azIn = 0; /* Names of input files */
sqlite3 *dbOut = 0; /* Database to hold results */
sqlite3 *dbRun = 0; /* Database used for tests */
int bTrace = 0; /* Show query results */
int bShowValid = 0; /* Just list inputs that are valid SQL */
int nRow, nStmt; /* Number of rows and statements */
int i, rc;
for(i=1; i<argc; i++){
const char *z = argv[i];
if( z[0]=='-' && z[1]=='-' ) z++;
if( strcmp(z,"-help")==0 ){
printf("Usage: %s [OPTIONS] FILENAME ...\n", argv[0]);
printf("Options:\n");
printf(" --help Show his message\n");
printf(" --output-trace Show each line of SQL output\n");
printf(" --valid-sql List FILEs that are valid SQL\n");
return 0;
}
else if( strcmp(z,"-output-trace")==0 ){
bTrace = 1;
}
else if( strcmp(z,"-valid-sql")==0 ){
bShowValid = 1;
}
else if( z[0]=='-' ){
printf("unknown option \"%s\". Use --help for details\n", argv[i]);
return 1;
}
else {
nIn++;
azIn = realloc(azIn, sizeof(azIn[0])*nIn);
if( azIn==0 ){
printf("out of memory\n");
exit(1);
}
azIn[nIn-1] = argv[i];
}
}
sqlite3_open(":memory:", &dbOut);
sqlite3_open(":memory:", &dbRun);
sqlite3_deserialize(dbRun, "main", data001, sizeof(data001),
sizeof(data001), SQLITE_DESERIALIZE_READONLY);
for(i=0; i<nIn; i++){
char *zSql = readFile(azIn[i], 0);
sqlite3_stmt *pCk;
sqlite3_exec(dbRun, "ROLLBACK", 0, 0, 0);
if( bShowValid ){
rc = sqlite3_exec(dbRun, zSql, 0, 0, 0);
if( rc==SQLITE_OK ) printf("%s\n", azIn[i]);
sqlite3_free(zSql);
continue;
}
sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, dbRun, 0);
if( bTrace ) printf("%s: Optimized\n", azIn[i]);
rc = optfuzz_exec(dbRun, zSql, dbOut, "opt", &nStmt, &nRow, bTrace);
if( rc ){
printf("%s: optimized run failed: %s\n",
azIn[i], sqlite3_errmsg(dbRun));
}else{
sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, dbRun, 0xffff);
if( bTrace ) printf("%s: Non-optimized\n", azIn[i]);
rc = optfuzz_exec(dbRun, zSql, dbOut, "noopt", &nStmt, &nRow, bTrace);
if( rc ){
printf("%s: non-optimized run failed: %s\n",
azIn[i], sqlite3_errmsg(dbRun));
exit(1);
}
pCk = prepare_sql(dbOut,
"SELECT (SELECT group_concat(x,char(10)) FROM opt)=="
" (SELECT group_concat(x,char(10)) FROM noopt)");
rc = sqlite3_step(pCk);
if( rc!=SQLITE_ROW ){
printf("%s: comparison failed\n", sqlite3_errmsg(dbOut));
exit(1);
}
if( !sqlite3_column_int(pCk, 0) ){
printf("%s: opt/no-opt outputs differ\n", azIn[i]);
pCk = prepare_sql(dbOut,
"SELECT group_concat(x,char(10)) FROM opt "
"UNION ALL "
"SELECT group_concat(x,char(10)) FROM noopt");
sqlite3_step(pCk);
printf("opt:\n%s\n", sqlite3_column_text(pCk,0));
sqlite3_step(pCk);
printf("noopt:\n%s\n", sqlite3_column_text(pCk,0));
exit(1);
}else{
printf("%s: %d stmts %d rows ok\n", azIn[i], nStmt, nRow);
}
sqlite3_finalize(pCk);
}
sqlite3_free(zSql);
}
sqlite3_close(dbRun);
sqlite3_close(dbOut);
free(azIn);
if( sqlite3_memory_used() ){
printf("Memory leak of %lld bytes\n", sqlite3_memory_used());
exit(1);
}
return 0;
}

201
testdata/tcl/ossfuzz.c vendored Normal file
View File

@@ -0,0 +1,201 @@
/*
** This module interfaces SQLite to the Google OSS-Fuzz, fuzzer as a service.
** (https://github.com/google/oss-fuzz)
*/
#include <stddef.h>
#if !defined(_MSC_VER)
# include <stdint.h>
#endif
#include <stdio.h>
#include <string.h>
#include "sqlite3.h"
#if defined(_MSC_VER)
typedef unsigned char uint8_t;
#endif
/* Global debugging settings. OSS-Fuzz will have all debugging turned
** off. But if LLVMFuzzerTestOneInput() is called interactively from
** the ossshell utility program, then these flags might be set.
*/
static unsigned mDebug = 0;
#define FUZZ_SQL_TRACE 0x0001 /* Set an sqlite3_trace() callback */
#define FUZZ_SHOW_MAX_DELAY 0x0002 /* Show maximum progress callback delay */
#define FUZZ_SHOW_ERRORS 0x0004 /* Print error messages from SQLite */
/* The ossshell utility program invokes this interface to see the
** debugging flags. Unused by OSS-Fuzz.
*/
void ossfuzz_set_debug_flags(unsigned x){
mDebug = x;
}
/* Return the current real-world time in milliseconds since the
** Julian epoch (-4714-11-24).
*/
static sqlite3_int64 timeOfDay(void){
static sqlite3_vfs *clockVfs = 0;
sqlite3_int64 t;
if( clockVfs==0 ){
clockVfs = sqlite3_vfs_find(0);
if( clockVfs==0 ) return 0;
}
if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
clockVfs->xCurrentTimeInt64(clockVfs, &t);
}else{
double r;
clockVfs->xCurrentTime(clockVfs, &r);
t = (sqlite3_int64)(r*86400000.0);
}
return t;
}
/* An instance of the following object is passed by pointer as the
** client data to various callbacks.
*/
typedef struct FuzzCtx {
sqlite3 *db; /* The database connection */
sqlite3_int64 iCutoffTime; /* Stop processing at this time. */
sqlite3_int64 iLastCb; /* Time recorded for previous progress callback */
sqlite3_int64 mxInterval; /* Longest interval between two progress calls */
unsigned nCb; /* Number of progress callbacks */
unsigned execCnt; /* Number of calls to the sqlite3_exec callback */
} FuzzCtx;
/*
** Progress handler callback.
**
** The argument is the cutoff-time after which all processing should
** stop. So return non-zero if the cut-off time is exceeded.
*/
static int progress_handler(void *pClientData) {
FuzzCtx *p = (FuzzCtx*)pClientData;
sqlite3_int64 iNow = timeOfDay();
int rc = iNow>=p->iCutoffTime;
sqlite3_int64 iDiff = iNow - p->iLastCb;
if( iDiff > p->mxInterval ) p->mxInterval = iDiff;
p->nCb++;
return rc;
}
/*
** Disallow debugging pragmas such as "PRAGMA vdbe_debug" and
** "PRAGMA parser_trace" since they can dramatically increase the
** amount of output without actually testing anything useful.
*/
static int block_debug_pragmas(
void *Notused,
int eCode,
const char *zArg1,
const char *zArg2,
const char *zArg3,
const char *zArg4
){
if( eCode==SQLITE_PRAGMA
&& (sqlite3_strnicmp("vdbe_", zArg1, 5)==0
|| sqlite3_stricmp("parser_trace", zArg1)==0)
){
return SQLITE_DENY;
}
return SQLITE_OK;
}
/*
** Callback for sqlite3_exec().
*/
static int exec_handler(void *pClientData, int argc, char **argv, char **namev){
FuzzCtx *p = (FuzzCtx*)pClientData;
int i;
if( argv ){
for(i=0; i<argc; i++) sqlite3_free(sqlite3_mprintf("%s", argv[i]));
}
return (p->execCnt--)<=0 || progress_handler(pClientData);
}
/*
** Main entry point. The fuzzer invokes this function with each
** fuzzed input.
*/
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
char *zErrMsg = 0; /* Error message returned by sqlite_exec() */
uint8_t uSelector; /* First byte of input data[] */
int rc; /* Return code from various interfaces */
char *zSql; /* Zero-terminated copy of data[] */
FuzzCtx cx; /* Fuzzing context */
memset(&cx, 0, sizeof(cx));
if( size<3 ) return 0; /* Early out if unsufficient data */
/* Extract the selector byte from the beginning of the input. But only
** do this if the second byte is a \n. If the second byte is not \n,
** then use a default selector */
if( data[1]=='\n' ){
uSelector = data[0]; data += 2; size -= 2;
}else{
uSelector = 0xfd;
}
/* Open the database connection. Only use an in-memory database. */
if( sqlite3_initialize() ) return 0;
rc = sqlite3_open_v2("fuzz.db", &cx.db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_MEMORY, 0);
if( rc ) return 0;
/* Invoke the progress handler frequently to check to see if we
** are taking too long. The progress handler will return true
** (which will block further processing) if more than 10 seconds have
** elapsed since the start of the test.
*/
cx.iLastCb = timeOfDay();
cx.iCutoffTime = cx.iLastCb + 10000; /* Now + 10 seconds */
#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
sqlite3_progress_handler(cx.db, 10, progress_handler, (void*)&cx);
#endif
/* Set a limit on the maximum size of a prepared statement */
sqlite3_limit(cx.db, SQLITE_LIMIT_VDBE_OP, 25000);
/* Limit total memory available to SQLite to 20MB */
sqlite3_hard_heap_limit64(20000000);
/* Set a limit on the maximum length of a string or BLOB. Without this
** limit, fuzzers will invoke randomblob(N) for a large N, and the process
** will timeout trying to generate the huge blob */
sqlite3_limit(cx.db, SQLITE_LIMIT_LENGTH, 50000);
/* Bit 1 of the selector enables foreign key constraints */
sqlite3_db_config(cx.db, SQLITE_DBCONFIG_ENABLE_FKEY, uSelector&1, &rc);
uSelector >>= 1;
/* Do not allow debugging pragma statements that might cause excess output */
sqlite3_set_authorizer(cx.db, block_debug_pragmas, 0);
/* Remaining bits of the selector determine a limit on the number of
** output rows */
cx.execCnt = uSelector + 1;
/* Run the SQL. The sqlite_exec() interface expects a zero-terminated
** string, so make a copy. */
zSql = sqlite3_mprintf("%.*s", (int)size, data);
#ifndef SQLITE_OMIT_COMPLETE
sqlite3_complete(zSql);
#endif
sqlite3_exec(cx.db, zSql, exec_handler, (void*)&cx, &zErrMsg);
/* Show any errors */
if( (mDebug & FUZZ_SHOW_ERRORS)!=0 && zErrMsg ){
printf("Error: %s\n", zErrMsg);
}
/* Cleanup and return */
sqlite3_free(zErrMsg);
sqlite3_free(zSql);
sqlite3_exec(cx.db, "PRAGMA temp_store_directory=''", 0, 0, 0);
sqlite3_close(cx.db);
if( mDebug & FUZZ_SHOW_MAX_DELAY ){
printf("Progress callback count....... %d\n", cx.nCb);
printf("Max time between callbacks.... %d ms\n", (int)cx.mxInterval);
}
return 0;
}

100
testdata/tcl/ossshell.c vendored Normal file
View File

@@ -0,0 +1,100 @@
/*
** This is a test interface for the ossfuzz.c module. The ossfuzz.c module
** is an adaptor for OSS-FUZZ. (https://github.com/google/oss-fuzz)
**
** This program links against ossfuzz.c. It reads files named on the
** command line and passes them one by one into ossfuzz.c.
*/
#include <stddef.h>
#if !defined(_MSC_VER)
# include <stdint.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
#if defined(_MSC_VER)
typedef unsigned char uint8_t;
#endif
/*
** The entry point in ossfuzz.c that this routine will be calling
*/
int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
/* Must match equivalent #defines in ossfuzz.c */
#define FUZZ_SQL_TRACE 0x0001 /* Set an sqlite3_trace() callback */
#define FUZZ_SHOW_MAX_DELAY 0x0002 /* Show maximum progress callback delay */
#define FUZZ_SHOW_ERRORS 0x0004 /* Show SQL errors */
extern void ossfuzz_set_debug_flags(unsigned);
/*
** Read files named on the command-line and invoke the fuzzer for
** each one.
*/
int main(int argc, char **argv){
FILE *in;
int i;
int nErr = 0;
uint8_t *zBuf = 0;
size_t sz;
unsigned mDebug = 0;
for(i=1; i<argc; i++){
const char *zFilename = argv[i];
if( zFilename[0]=='-' ){
if( zFilename[1]=='-' ) zFilename++;
if( strcmp(zFilename, "-show-errors")==0 ){
mDebug |= FUZZ_SHOW_ERRORS;
ossfuzz_set_debug_flags(mDebug);
}else
if( strcmp(zFilename, "-show-max-delay")==0 ){
mDebug |= FUZZ_SHOW_MAX_DELAY;
ossfuzz_set_debug_flags(mDebug);
}else
if( strcmp(zFilename, "-sql-trace")==0 ){
mDebug |= FUZZ_SQL_TRACE;
ossfuzz_set_debug_flags(mDebug);
}else
{
printf("unknown option \"%s\"\n", argv[i]);
printf("should be one of: --show-errors --show-max-delay"
" --sql-trace\n");
exit(1);
}
continue;
}
in = fopen(zFilename, "rb");
if( in==0 ){
fprintf(stderr, "cannot open \"%s\"\n", zFilename);
nErr++;
continue;
}
fseek(in, 0, SEEK_END);
sz = ftell(in);
rewind(in);
zBuf = realloc(zBuf, sz);
if( zBuf==0 ){
fprintf(stderr, "cannot malloc() for %d bytes\n", (int)sz);
exit(1);
}
if( fread(zBuf, sz, 1, in)!=1 ){
fprintf(stderr, "cannot read %d bytes from \"%s\"\n",
(int)sz, zFilename);
nErr++;
}else{
printf("%s... ", zFilename);
if( mDebug ) printf("\n");
fflush(stdout);
(void)LLVMFuzzerTestOneInput(zBuf, sz);
if( mDebug ) printf("%s: ", zFilename);
printf("ok\n");
}
fclose(in);
}
free(zBuf);
return nErr;
}

0
testdata/tcl/releasetest.tcl vendored Normal file → Executable file
View File

78
testdata/tcl/run-wordcount.sh vendored Normal file
View File

@@ -0,0 +1,78 @@
#!/bin/sh
#
# This script runs the wordcount program in different ways, comparing
# the output from each.
#
# Select the source text to be analyzed.
#
if test "x$1" = "x";
then echo "Usage: $0 FILENAME [ARGS...]"; exit 1;
fi
# Do test runs
#
rm -f wcdb1.db
./wordcount --timer --summary wcdb1.db $* --insert >wc-out.txt
mv wc-out.txt wc-baseline.txt
rm -f wcdb2.db
./wordcount --timer --summary wcdb2.db $* --insert --without-rowid >wc-out.txt
if cmp -s wc-out.txt wc-baseline.txt;
then echo hi >/dev/null;
else echo ERROR:;
diff -u wc-baseline.txt wc-out.txt;
fi
rm -f wcdb1.db
./wordcount --timer --summary wcdb1.db $* --replace >wc-out.txt
if cmp -s wc-out.txt wc-baseline.txt;
then echo hi >/dev/null;
else echo ERROR:;
diff -u wc-baseline.txt wc-out.txt;
fi
rm -f wcdb2.db
./wordcount --timer --summary wcdb2.db $* --replace --without-rowid >wc-out.txt
if cmp -s wc-out.txt wc-baseline.txt;
then echo hi >/dev/null;
else echo ERROR:;
diff -u wc-baseline.txt wc-out.txt;
fi
rm -f wcdb1.db
./wordcount --timer --summary wcdb1.db $* --select >wc-out.txt
if cmp -s wc-out.txt wc-baseline.txt;
then echo hi >/dev/null;
else echo ERROR:;
diff -u wc-baseline.txt wc-out.txt;
fi
rm -f wcdb2.db
./wordcount --timer --summary wcdb2.db $* --select --without-rowid >wc-out.txt
if cmp -s wc-out.txt wc-baseline.txt;
then echo hi >/dev/null;
else echo ERROR:;
diff -u wc-baseline.txt wc-out.txt;
fi
./wordcount --timer --summary wcdb1.db $* --query >wc-out.txt
mv wc-out.txt wc-baseline.txt
./wordcount --timer --summary wcdb2.db $* --query --without-rowid >wc-out.txt
if cmp -s wc-out.txt wc-baseline.txt;
then echo hi >/dev/null;
else echo ERROR:;
diff -u wc-baseline.txt wc-out.txt;
fi
./wordcount --timer --summary wcdb1.db $* --delete >wc-out.txt
mv wc-out.txt wc-baseline.txt
./wordcount --timer --summary wcdb2.db $* --delete --without-rowid >wc-out.txt
if cmp -s wc-out.txt wc-baseline.txt;
then echo hi >/dev/null;
else echo ERROR:;
diff -u wc-baseline.txt wc-out.txt;
fi
# Clean up temporary files created.
#
rm -rf wcdb1.db wcdb2.db wc-out.txt wc-baseline.txt

BIN
testdata/tcl/sessionfuzz-data1.db vendored Normal file

Binary file not shown.

1023
testdata/tcl/sessionfuzz.c vendored Normal file

File diff suppressed because it is too large Load Diff

366
testdata/tcl/speed1p.explain vendored Normal file
View File

@@ -0,0 +1,366 @@
# 2008 March 21
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is measuring executing speed.
#
# This is a copy of speed1.test modified to user prepared statements.
#
# $Id: speed1p.explain,v 1.1 2008/04/16 12:57:48 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
speed_trial_init speed1
# Set a uniform random seed
expr srand(0)
set sqlout [open speed1.txt w]
proc tracesql {sql} {
puts $::sqlout $sql\;
}
#db trace tracesql
# The number_name procedure below converts its argment (an integer)
# into a string which is the English-language name for that number.
#
# Example:
#
# puts [number_name 123] -> "one hundred twenty three"
#
set ones {zero one two three four five six seven eight nine
ten eleven twelve thirteen fourteen fifteen sixteen seventeen
eighteen nineteen}
set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
proc number_name {n} {
if {$n>=1000} {
set txt "[number_name [expr {$n/1000}]] thousand"
set n [expr {$n%1000}]
} else {
set txt {}
}
if {$n>=100} {
append txt " [lindex $::ones [expr {$n/100}]] hundred"
set n [expr {$n%100}]
}
if {$n>=20} {
append txt " [lindex $::tens [expr {$n/10}]]"
set n [expr {$n%10}]
}
if {$n>0} {
append txt " [lindex $::ones $n]"
}
set txt [string trim $txt]
if {$txt==""} {set txt zero}
return $txt
}
# Create a database schema.
#
do_test speed1p-1.0 {
execsql {
PRAGMA page_size=1024;
PRAGMA cache_size=8192;
PRAGMA locking_mode=EXCLUSIVE;
CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
CREATE INDEX i2a ON t2(a);
CREATE INDEX i2b ON t2(b);
}
execsql {
SELECT name FROM sqlite_master ORDER BY 1;
}
} {i2a i2b t1 t2}
# 50000 INSERTs on an unindexed table
#
set list {}
for {set i 1} {$i<=50000} {incr i} {
set r [expr {int(rand()*500000)}]
set x [number_name $r]
lappend list $i $r $x
}
set script {
foreach {i r x} $::list {
db eval {INSERT INTO t1 VALUES($i,$r,$x)}
}
}
explain {INSERT INTO t1 VALUES($i,$r,$x)}
db eval BEGIN
speed_trial_tcl speed1p-insert1 50000 row $script
db eval COMMIT
# 50000 INSERTs on an indexed table
#
set list {}
for {set i 1} {$i<=50000} {incr i} {
set r [expr {int(rand()*500000)}]
set x [number_name $r]
lappend list $i $r $x
}
set script {
foreach {i r x} $::list {
db eval {INSERT INTO t2 VALUES($i,$r,$x)}
}
}
explain {INSERT INTO t2 VALUES($i,$r,$x)}
db eval BEGIN
speed_trial_tcl speed1p-insert2 50000 row $script
db eval COMMIT
# 50 SELECTs on an integer comparison. There is no index so
# a full table scan is required.
#
set list {}
for {set i 0} {$i<50} {incr i} {
set lwr [expr {$i*100}]
set upr [expr {($i+10)*100}]
lappend list $lwr $upr
}
set script {
foreach {lwr upr} $::list {
db eval {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
}
}
explain {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
db eval BEGIN
speed_trial_tcl speed1p-select1 [expr {50*50000}] row $script
db eval COMMIT
# 50 SELECTs on an LIKE comparison. There is no index so a full
# table scan is required.
#
set list {}
for {set i 0} {$i<50} {incr i} {
lappend list "%[number_name $i]%"
}
set script {
foreach pattern $::list {
db eval {SELECT count(*), avg(b) FROM t1 WHERE c LIKE $pattern}
}
}
explain {SELECT count(*), avg(b) FROM t1 WHERE c LIKE $pattern}
db eval BEGIN
speed_trial_tcl speed1p-select2 [expr {50*50000}] row $script
db eval COMMIT
# Create indices
#
explain {CREATE INDEX i1a ON t1(a)}
explain {CREATE INDEX i1b ON t1(b)}
db eval BEGIN
speed_trial speed1p-createidx 150000 row {
CREATE INDEX i1a ON t1(a);
CREATE INDEX i1b ON t1(b);
CREATE INDEX i1c ON t1(c);
}
db eval COMMIT
# 5000 SELECTs on an integer comparison where the integer is
# indexed.
#
set list {}
for {set i 0} {$i<5000} {incr i} {
set lwr [expr {$i*100}]
set upr [expr {($i+10)*100}]
lappend list $lwr $upr
}
set script {
foreach {lwr upr} $::list {
db eval {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
}
}
explain {SELECT count(*), avg(b) FROM t1 WHERE b>=$lwr AND b<$upr}
db eval BEGIN
speed_trial_tcl speed1p-select3 5000 stmt $script
db eval COMMIT
# 100000 random SELECTs against rowid.
#
set list {}
for {set i 1} {$i<=100000} {incr i} {
set id [expr {int(rand()*50000)+1}]
lappend list $id
}
set script {
foreach id $::list {
db eval {SELECT c FROM t1 WHERE rowid=$id}
}
}
explain {SELECT c FROM t1 WHERE rowid=$id}
db eval BEGIN
speed_trial_tcl speed1p-select4 100000 row $script
db eval COMMIT
# 100000 random SELECTs against a unique indexed column.
#
set list {}
for {set i 1} {$i<=100000} {incr i} {
set id [expr {int(rand()*50000)+1}]
lappend list $id
}
set script {
foreach id $::list {
db eval {SELECT c FROM t1 WHERE a=$id}
}
}
explain {SELECT c FROM t1 WHERE a=$id}
db eval BEGIN
speed_trial_tcl speed1p-select5 100000 row $script
db eval COMMIT
# 50000 random SELECTs against an indexed column text column
#
set list [db eval {SELECT c FROM t1 ORDER BY random() LIMIT 50000}]
set script {
foreach c $::list {
db eval {SELECT c FROM t1 WHERE c=$c}
}
}
explain {SELECT c FROM t1 WHERE c=$c}
db eval BEGIN
speed_trial_tcl speed1p-select6 50000 row $script
db eval COMMIT
# Vacuum
speed_trial speed1p-vacuum 100000 row VACUUM
# 5000 updates of ranges where the field being compared is indexed.
#
set list {}
for {set i 0} {$i<5000} {incr i} {
set lwr [expr {$i*2}]
set upr [expr {($i+1)*2}]
lappend list $lwr $upr
}
set script {
foreach {lwr upr} $::list {
db eval {UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr}
}
}
explain {UPDATE t1 SET b=b*2 WHERE a>=$lwr AND a<$upr}
db eval BEGIN
speed_trial_tcl speed1p-update1 5000 stmt $script
db eval COMMIT
# 50000 single-row updates. An index is used to find the row quickly.
#
set list {}
for {set i 0} {$i<50000} {incr i} {
set r [expr {int(rand()*500000)}]
lappend list $i $r
}
set script {
foreach {i r} $::list {
db eval {UPDATE t1 SET b=$r WHERE a=$i}
}
}
explain {UPDATE t1 SET b=$r WHERE a=$i}
db eval BEGIN
speed_trial_tcl speed1p-update2 50000 row $script
db eval COMMIT
# 1 big text update that touches every row in the table.
#
explain {UPDATE t1 SET c=a}
speed_trial speed1p-update3 50000 row {
UPDATE t1 SET c=a;
}
# Many individual text updates. Each row in the table is
# touched through an index.
#
set list {}
for {set i 1} {$i<=50000} {incr i} {
set r [expr {int(rand()*500000)}]
lappend list $i [number_name $r]
}
set script {
foreach {i x} $::list {
db eval {UPDATE t1 SET c=$x WHERE a=$i}
}
}
explain {UPDATE t1 SET c=$x WHERE a=$i}
db eval BEGIN
speed_trial_tcl speed1p-update4 50000 row $script
db eval COMMIT
# Delete all content in a table.
#
explain {DELETE FROM t1}
speed_trial speed1p-delete1 50000 row {DELETE FROM t1}
# Copy one table into another
#
explain {INSERT INTO t1 SELECT * FROM t2}
speed_trial speed1p-copy1 50000 row {INSERT INTO t1 SELECT * FROM t2}
# Delete all content in a table, one row at a time.
#
explain {DELETE FROM t1 WHERE 1}
speed_trial speed1p-delete2 50000 row {DELETE FROM t1 WHERE 1}
# Refill the table yet again
#
speed_trial speed1p-copy2 50000 row {INSERT INTO t1 SELECT * FROM t2}
# Drop the table and recreate it without its indices.
#
explain {DROP TABLE t1}
explain {CREATE TABLE tX(a INTEGER, b INTEGER, c TEXT)}
db eval BEGIN
speed_trial speed1p-drop1 50000 row {
DROP TABLE t1;
CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
}
db eval COMMIT
# Refill the table yet again. This copy should be faster because
# there are no indices to deal with.
#
speed_trial speed1p-copy3 50000 row {INSERT INTO t1 SELECT * FROM t2}
# Select 20000 rows from the table at random.
#
explain {SELECT rowid FROM t1 ORDER BY random() LIMIT 20000}
speed_trial speed1p-random1 50000 row {
SELECT rowid FROM t1 ORDER BY random() LIMIT 20000
}
# Delete 20000 random rows from the table.
#
explain {DELETE FROM t1 WHERE rowid IN
(SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)}
speed_trial speed1p-random-del1 20000 row {
DELETE FROM t1 WHERE rowid IN
(SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
}
do_test speed1p-1.1 {
db one {SELECT count(*) FROM t1}
} 30000
# Delete 20000 more rows at random from the table.
#
speed_trial speed1p-random-del2 20000 row {
DELETE FROM t1 WHERE rowid IN
(SELECT rowid FROM t1 ORDER BY random() LIMIT 20000)
}
do_test speed1p-1.2 {
db one {SELECT count(*) FROM t1}
} 10000
speed_trial_summary speed1
finish_test

283
testdata/tcl/speed4p.explain vendored Normal file
View File

@@ -0,0 +1,283 @@
# 2007 October 23
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#*************************************************************************
# This file implements regression tests for SQLite library. The
# focus of this script is measuring executing speed. More specifically,
# the focus is on the speed of:
#
# * joins
# * views
# * sub-selects
# * triggers
#
# $Id: speed4p.explain,v 1.1 2008/04/16 12:57:48 drh Exp $
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
speed_trial_init speed1
# Set a uniform random seed
expr srand(0)
set sqlout [open speed1.txt w]
proc tracesql {sql} {
puts $::sqlout $sql\;
}
#db trace tracesql
# The number_name procedure below converts its argment (an integer)
# into a string which is the English-language name for that number.
#
# Example:
#
# puts [number_name 123] -> "one hundred twenty three"
#
set ones {zero one two three four five six seven eight nine
ten eleven twelve thirteen fourteen fifteen sixteen seventeen
eighteen nineteen}
set tens {{} ten twenty thirty forty fifty sixty seventy eighty ninety}
proc number_name {n} {
if {$n>=1000} {
set txt "[number_name [expr {$n/1000}]] thousand"
set n [expr {$n%1000}]
} else {
set txt {}
}
if {$n>=100} {
append txt " [lindex $::ones [expr {$n/100}]] hundred"
set n [expr {$n%100}]
}
if {$n>=20} {
append txt " [lindex $::tens [expr {$n/10}]]"
set n [expr {$n%10}]
}
if {$n>0} {
append txt " [lindex $::ones $n]"
}
set txt [string trim $txt]
if {$txt==""} {set txt zero}
return $txt
}
# Summary of tests:
#
# speed4p-join1: Join three tables using IPK index.
# speed4p-join2: Join three tables using an index.
# speed4p-join3: Join two tables without an index.
#
# speed4p-view1: Querying a view.
# speed4p-table1: Same queries as in speed4p-view1, but run directly against
# the tables for comparison purposes.
#
# speed4p-subselect1: A SELECT statement that uses many sub-queries..
#
# speed4p-trigger1: An INSERT statement that fires a trigger.
# speed4p-trigger2: An UPDATE statement that fires a trigger.
# speed4p-trigger3: A DELETE statement that fires a trigger.
# speed4p-notrigger1: Same operation as trigger1, but without the trigger.
# speed4p-notrigger2: " trigger2 "
# speed4p-notrigger3: " trigger3 "
#
# Set up the schema. Each of the tables t1, t2 and t3 contain 50,000 rows.
# This creates a database of around 16MB.
execsql {
PRAGMA page_size=1024;
PRAGMA cache_size=8192;
PRAGMA locking_mode=EXCLUSIVE;
BEGIN;
CREATE TABLE t1(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
CREATE TABLE t2(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
CREATE TABLE t3(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
CREATE VIEW v1 AS SELECT rowid, i, t FROM t1;
CREATE VIEW v2 AS SELECT rowid, i, t FROM t2;
CREATE VIEW v3 AS SELECT rowid, i, t FROM t3;
}
for {set jj 1} {$jj <= 3} {incr jj} {
set stmt [string map "%T% t$jj" {INSERT INTO %T% VALUES(NULL, $i, $t)}]
for {set ii 0} {$ii < 50000} {incr ii} {
set i [expr {int(rand()*50000)}]
set t [number_name $i]
execsql $stmt
}
}
execsql {
CREATE INDEX i1 ON t1(t);
CREATE INDEX i2 ON t2(t);
CREATE INDEX i3 ON t3(t);
COMMIT;
}
# Before running these tests, disable the compiled statement cache built into
# the Tcl interface. This is because we want to test the speed of SQL
# compilation as well as execution.
#
db cache size 0
# Join t1, t2, t3 on IPK.
set sql "SELECT * FROM t1, t2, t3 WHERE t1.oid = t2.oid AND t2.oid = t3.oid"
explain $sql
speed_trial speed4p-join1 50000 row $sql
# Join t1, t2, t3 on the non-IPK index.
set sql "SELECT * FROM t1, t2, t3 WHERE t1.t = t2.t AND t2.t = t3.t"
explain $sql
speed_trial speed4p-join2 50000 row $sql
# Run 10000 simple queries against the views.
set script {
for {set ii 1} {$ii < 10000} {incr ii} {
set v [expr {$ii*3}]
set t [expr {$ii%3+1}]
db eval "SELECT * FROM v$t WHERE rowid = \$v"
}
}
explain {SELECT * FROm v1 WHERE rowid=$v}
speed_trial_tcl speed4p-view1 10000 stmt $script
# Run the same 10000 simple queries as in the previous test case against
# the underlying tables. The compiled vdbe programs should be identical, so
# the only difference in running time is the extra time taken to compile
# the view definitions.
#
set script {
for {set ii 1} {$ii < 10000} {incr ii} {
set v [expr {$ii*3}]
set t [expr {$ii%3+1}]
db eval "SELECT t FROM t$t WHERE rowid = \$v"
}
}
explain {SELECT * FROM t1 WHERE rowid=$v}
speed_trial_tcl speed4p-table1 10000 stmt $script
# Run a SELECT that uses sub-queries 10000 times. A total of 30000 sub-selects.
#
set script {
for {set ii 1} {$ii < 10000} {incr ii} {
set v [expr {$ii*3}]
db eval {
SELECT (SELECT t FROM t1 WHERE rowid = $v),
(SELECT t FROM t2 WHERE rowid = $v),
(SELECT t FROM t3 WHERE rowid = $v)
}
}
}
explain {
SELECT (SELECT t FROM t1 WHERE rowid = $v),
(SELECT t FROM t2 WHERE rowid = $v),
(SELECT t FROM t3 WHERE rowid = $v)
}
speed_trial_tcl speed4p-subselect1 10000 stmt $script
# The following block tests the speed of some DML statements that cause
# triggers to fire.
#
execsql {
CREATE TABLE log(op TEXT, r INTEGER, i INTEGER, t TEXT);
CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
CREATE TRIGGER t4_trigger1 AFTER INSERT ON t4 BEGIN
INSERT INTO log VALUES('INSERT INTO t4', new.rowid, new.i, new.t);
END;
CREATE TRIGGER t4_trigger2 AFTER UPDATE ON t4 BEGIN
INSERT INTO log VALUES('UPDATE OF t4', new.rowid, new.i, new.t);
END;
CREATE TRIGGER t4_trigger3 AFTER DELETE ON t4 BEGIN
INSERT INTO log VALUES('DELETE OF t4', old.rowid, old.i, old.t);
END;
BEGIN;
}
set list {}
for {set ii 1} {$ii < 10000} {incr ii} {
lappend list $ii [number_name $ii]
}
set script {
foreach {ii name} $::list {
db eval {INSERT INTO t4 VALUES(NULL, $ii, $name)}
}
}
explain {INSERT INTO t4 VALUES(NULL, $ii, $name)}
speed_trial_tcl speed4p-trigger1 10000 stmt $script
set list {}
for {set ii 1} {$ii < 20000} {incr ii 2} {
set ii2 [expr {$ii*2}]
lappend list $ii $ii2 [number_name $ii2]
}
set script {
foreach {ii ii2 name} $::list {
db eval {
UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;
}
}
}
explain {UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii}
speed_trial_tcl speed4p-trigger2 10000 stmt $script
set script {
for {set ii 1} {$ii < 20000} {incr ii 2} {
db eval {DELETE FROM t4 WHERE rowid = $ii}
}
}
explain {DELETE FROM t4 WHERE rowid = $ii}
speed_trial_tcl speed4p-trigger3 10000 stmt $script
execsql {COMMIT}
# The following block contains the same tests as the above block that
# tests triggers, with one crucial difference: no triggers are defined.
# So the difference in speed between these tests and the preceding ones
# is the amount of time taken to compile and execute the trigger programs.
#
execsql {
DROP TABLE t4;
DROP TABLE log;
VACUUM;
CREATE TABLE t4(rowid INTEGER PRIMARY KEY, i INTEGER, t TEXT);
BEGIN;
}
set list {}
for {set ii 1} {$ii < 10000} {incr ii} {
lappend list $ii [number_name $ii]
}
set script {
foreach {ii name} $::list {
db eval {INSERT INTO t4 VALUES(NULL, $ii, $name);}
}
}
explain {INSERT INTO t4 VALUES(NULL, $ii, $name)}
speed_trial_tcl speed4p-notrigger1 10000 stmt $script
set list {}
for {set ii 1} {$ii < 20000} {incr ii 2} {
set ii2 [expr {$ii*2}]
lappend list $ii $ii2 [number_name $ii2]
}
set script {
foreach {ii ii2 name} $::list {
db eval {
UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii;
}
}
}
explain {UPDATE t4 SET i = $ii2, t = $name WHERE rowid = $ii}
speed_trial_tcl speed4p-notrigger2 10000 stmt $script
set script {
for {set ii 1} {$ii < 20000} {incr ii 2} {
db eval {DELETE FROM t4 WHERE rowid = $ii}
}
}
explain {DELETE FROM t4 WHERE rowid = $ii}
speed_trial_tcl speed4p-notrigger3 10000 stmt $script
execsql {COMMIT}
speed_trial_summary speed4
finish_test

2541
testdata/tcl/speedtest1.c vendored Normal file

File diff suppressed because it is too large Load Diff

628
testdata/tcl/startup.c vendored Normal file
View File

@@ -0,0 +1,628 @@
/*
** 2021-01-01
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file implements a program used to measure the start-up performance
** of SQLite.
**
** To use:
**
** ./startup init
** valgrind --tool=cachegrind ./startup run
**
**
** The "./startup init" command creates the test database file named
** "startup.db". The performance test is run by the "./startup run"
** command. That command does nothing but open the database file and
** parse the entire schema.
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "sqlite3.h"
static const char zHelp[] =
"Usage: %s COMMAND\n"
"Commands:\n"
" init Initialized the startup.db database file\n"
" run Run the startup performance test\n"
"Options:\n"
" --dbname NAME Set the name of the test database file\n"
" --heap SZ MIN Memory allocator uses SZ bytes & min allocation MIN\n"
" --stats Show statistics at the end\n"
/* TBD
" --journal M Set the journal_mode to M\n"
" --lookaside N SZ Configure lookaside for N slots of SZ bytes each\n"
" --mmap SZ MMAP the first SZ bytes of the database file\n"
" --multithread Set multithreaded mode\n"
" --nomemstat Disable memory statistics\n"
" --pagesize N Set the page size to N\n"
" --pcache N SZ Configure N pages of pagecache each of size SZ bytes\n"
" --serialized Set serialized threading mode\n"
" --singlethread Set single-threaded mode - disables all mutexing\n"
" --utf16be Set text encoding to UTF-16BE\n"
" --utf16le Set text encoding to UTF-16LE\n"
" --utf8 Set text encoding to UTF-8\n"
*/
;
static void usage(const char *argv0){
printf(zHelp, argv0);
exit(1);
}
/*
** The test schema is derived from the Fossil repository for SQLite itself.
** The schema covers the repository, the local checkout database, and
** the global configuration database.
*/
static const char zTestSchema[] =
"CREATE TABLE repo_blob(\n"
" rid INTEGER PRIMARY KEY,\n"
" rcvid INTEGER,\n"
" size INTEGER,\n"
" uuid TEXT UNIQUE NOT NULL,\n"
" content BLOB,\n"
" CHECK( length(uuid)>=40 AND rid>0 )\n"
");\n"
"CREATE TABLE repo_delta(\n"
" rid INTEGER PRIMARY KEY,\n"
" srcid INTEGER NOT NULL REFERENCES blob\n"
");\n"
"CREATE TABLE repo_rcvfrom(\n"
" rcvid INTEGER PRIMARY KEY,\n"
" uid INTEGER REFERENCES user,\n"
" mtime DATETIME,\n"
" nonce TEXT UNIQUE,\n"
" ipaddr TEXT\n"
");\n"
"CREATE TABLE repo_private(rid INTEGER PRIMARY KEY);\n"
"CREATE TABLE repo_accesslog(\n"
" uname TEXT,\n"
" ipaddr TEXT,\n"
" success BOOLEAN,\n"
" mtime TIMESTAMP);\n"
"CREATE TABLE repo_user(\n"
" uid INTEGER PRIMARY KEY,\n"
" login TEXT UNIQUE,\n"
" pw TEXT,\n"
" cap TEXT,\n"
" cookie TEXT,\n"
" ipaddr TEXT,\n"
" cexpire DATETIME,\n"
" info TEXT,\n"
" mtime DATE,\n"
" photo BLOB\n"
");\n"
"CREATE TABLE repo_reportfmt(\n"
" rn INTEGER PRIMARY KEY,\n"
" owner TEXT,\n"
" title TEXT UNIQUE,\n"
" mtime INTEGER,\n"
" cols TEXT,\n"
" sqlcode TEXT\n"
");\n"
"CREATE TABLE repo_sqlite_stat2(tbl,idx,sampleno,sample);\n"
"CREATE TABLE repo_sqlite_stat1(tbl,idx,stat);\n"
"CREATE TABLE repo_sqlite_stat3(tbl,idx,neq,nlt,ndlt,sample);\n"
"CREATE TABLE repo_config(\n"
" name TEXT PRIMARY KEY NOT NULL,\n"
" value CLOB, mtime INTEGER,\n"
" CHECK( typeof(name)='text' AND length(name)>=1 )\n"
") WITHOUT ROWID;\n"
"CREATE TABLE repo_shun(uuid PRIMARY KEY,\n"
" mtime INTEGER,\n"
" scom TEXT) WITHOUT ROWID;\n"
"CREATE TABLE repo_concealed(\n"
" hash TEXT PRIMARY KEY,\n"
" content TEXT\n"
", mtime INTEGER) WITHOUT ROWID;\n"
"CREATE TABLE repo_admin_log(\n"
" id INTEGER PRIMARY KEY,\n"
" time INTEGER, -- Seconds since 1970\n"
" page TEXT, -- path of page\n"
" who TEXT, -- User who made the change\n"
" what TEXT -- What changed\n"
");\n"
"CREATE TABLE repo_unversioned(\n"
" name TEXT PRIMARY KEY,\n"
" rcvid INTEGER,\n"
" mtime DATETIME,\n"
" hash TEXT,\n"
" sz INTEGER,\n"
" encoding INT,\n"
" content BLOB\n"
") WITHOUT ROWID;\n"
"CREATE TABLE repo_subscriber(\n"
" subscriberId INTEGER PRIMARY KEY,\n"
" subscriberCode BLOB DEFAULT (randomblob(32)) UNIQUE,\n"
" semail TEXT UNIQUE COLLATE nocase,\n"
" suname TEXT,\n"
" sverified BOOLEAN DEFAULT true,\n"
" sdonotcall BOOLEAN,\n"
" sdigest BOOLEAN,\n"
" ssub TEXT,\n"
" sctime INTDATE,\n"
" mtime INTDATE,\n"
" smip TEXT\n"
");\n"
"CREATE TABLE repo_pending_alert(\n"
" eventid TEXT PRIMARY KEY,\n"
" sentSep BOOLEAN DEFAULT false,\n"
" sentDigest BOOLEAN DEFAULT false\n"
", sentMod BOOLEAN DEFAULT false) WITHOUT ROWID;\n"
"CREATE INDEX repo_delta_i1 ON repo_delta(srcid);\n"
"CREATE INDEX repo_blob_rcvid ON repo_blob(rcvid);\n"
"CREATE INDEX repo_subscriberUname\n"
" ON repo_subscriber(suname) WHERE suname IS NOT NULL;\n"
"CREATE VIEW repo_artifact(rid,rcvid,size,atype,srcid,hash,content) AS\n"
" SELECT blob.rid,rcvid,size,1,srcid,uuid,content\n"
" FROM repo_blob LEFT JOIN repo_delta ON (blob.rid=delta.rid);\n"
"CREATE TABLE repo_filename(\n"
" fnid INTEGER PRIMARY KEY,\n"
" name TEXT UNIQUE\n"
");\n"
"CREATE TABLE repo_mlink(\n"
" mid INTEGER,\n"
" fid INTEGER,\n"
" pmid INTEGER,\n"
" pid INTEGER,\n"
" fnid INTEGER REFERENCES filename,\n"
" pfnid INTEGER,\n"
" mperm INTEGER,\n"
" isaux BOOLEAN DEFAULT 0\n"
");\n"
"CREATE INDEX repo_mlink_i1 ON repo_mlink(mid);\n"
"CREATE INDEX repo_mlink_i2 ON repo_mlink(fnid);\n"
"CREATE INDEX repo_mlink_i3 ON repo_mlink(fid);\n"
"CREATE INDEX repo_mlink_i4 ON repo_mlink(pid);\n"
"CREATE TABLE repo_plink(\n"
" pid INTEGER REFERENCES blob,\n"
" cid INTEGER REFERENCES blob,\n"
" isprim BOOLEAN,\n"
" mtime DATETIME,\n"
" baseid INTEGER REFERENCES blob,\n"
" UNIQUE(pid, cid)\n"
");\n"
"CREATE INDEX repo_plink_i2 ON repo_plink(cid,pid);\n"
"CREATE TABLE repo_leaf(rid INTEGER PRIMARY KEY);\n"
"CREATE TABLE repo_event(\n"
" type TEXT,\n"
" mtime DATETIME,\n"
" objid INTEGER PRIMARY KEY,\n"
" tagid INTEGER,\n"
" uid INTEGER REFERENCES user,\n"
" bgcolor TEXT,\n"
" euser TEXT,\n"
" user TEXT,\n"
" ecomment TEXT,\n"
" comment TEXT,\n"
" brief TEXT,\n"
" omtime DATETIME\n"
");\n"
"CREATE INDEX repo_event_i1 ON repo_event(mtime);\n"
"CREATE TABLE repo_phantom(\n"
" rid INTEGER PRIMARY KEY\n"
");\n"
"CREATE TABLE repo_orphan(\n"
" rid INTEGER PRIMARY KEY,\n"
" baseline INTEGER\n"
");\n"
"CREATE INDEX repo_orphan_baseline ON repo_orphan(baseline);\n"
"CREATE TABLE repo_unclustered(\n"
" rid INTEGER PRIMARY KEY\n"
");\n"
"CREATE TABLE repo_unsent(\n"
" rid INTEGER PRIMARY KEY\n"
");\n"
"CREATE TABLE repo_tag(\n"
" tagid INTEGER PRIMARY KEY,\n"
" tagname TEXT UNIQUE\n"
");\n"
"CREATE TABLE repo_tagxref(\n"
" tagid INTEGER REFERENCES tag,\n"
" tagtype INTEGER,\n"
" srcid INTEGER REFERENCES blob,\n"
" origid INTEGER REFERENCES blob,\n"
" value TEXT,\n"
" mtime TIMESTAMP,\n"
" rid INTEGER REFERENCE blob,\n"
" UNIQUE(rid, tagid)\n"
");\n"
"CREATE INDEX repo_tagxref_i1 ON repo_tagxref(tagid, mtime);\n"
"CREATE TABLE repo_backlink(\n"
" target TEXT,\n"
" srctype INT,\n"
" srcid INT,\n"
" mtime TIMESTAMP,\n"
" UNIQUE(target, srctype, srcid)\n"
");\n"
"CREATE INDEX repo_backlink_src ON repo_backlink(srcid, srctype);\n"
"CREATE TABLE repo_attachment(\n"
" attachid INTEGER PRIMARY KEY,\n"
" isLatest BOOLEAN DEFAULT 0,\n"
" mtime TIMESTAMP,\n"
" src TEXT,\n"
" target TEXT,\n"
" filename TEXT,\n"
" comment TEXT,\n"
" user TEXT\n"
");\n"
"CREATE INDEX repo_attachment_idx1\n"
" ON repo_attachment(target, filename, mtime);\n"
"CREATE INDEX repo_attachment_idx2 ON repo_attachment(src);\n"
"CREATE TABLE repo_cherrypick(\n"
" parentid INT,\n"
" childid INT,\n"
" isExclude BOOLEAN DEFAULT false,\n"
" PRIMARY KEY(parentid, childid)\n"
") WITHOUT ROWID;\n"
"CREATE INDEX repo_cherrypick_cid ON repo_cherrypick(childid);\n"
"CREATE TABLE repo_ticket(\n"
" -- Do not change any column that begins with tkt_\n"
" tkt_id INTEGER PRIMARY KEY,\n"
" tkt_uuid TEXT UNIQUE,\n"
" tkt_mtime DATE,\n"
" tkt_ctime DATE,\n"
" -- Add as many fields as required below this line\n"
" type TEXT,\n"
" status TEXT,\n"
" subsystem TEXT,\n"
" priority TEXT,\n"
" severity TEXT,\n"
" foundin TEXT,\n"
" private_contact TEXT,\n"
" resolution TEXT,\n"
" title TEXT,\n"
" comment TEXT\n"
");\n"
"CREATE TABLE repo_ticketchng(\n"
" -- Do not change any column that begins with tkt_\n"
" tkt_id INTEGER REFERENCES ticket,\n"
" tkt_rid INTEGER REFERENCES blob,\n"
" tkt_mtime DATE,\n"
" -- Add as many fields as required below this line\n"
" login TEXT,\n"
" username TEXT,\n"
" mimetype TEXT,\n"
" icomment TEXT\n"
");\n"
"CREATE INDEX repo_ticketchng_idx1 ON repo_ticketchng(tkt_id, tkt_mtime);\n"
"CREATE TRIGGER repo_alert_trigger1\n"
"AFTER INSERT ON repo_event BEGIN\n"
" INSERT INTO repo_pending_alert(eventid)\n"
" SELECT printf('%.1c%d',new.type,new.objid) WHERE true\n"
" ON CONFLICT(eventId) DO NOTHING;\n"
"END;\n"
"CREATE TABLE repo_vcache(\n"
" vid INTEGER, -- check-in ID\n"
" fname TEXT, -- filename\n"
" rid INTEGER, -- artifact ID\n"
" PRIMARY KEY(vid,fname)\n"
") WITHOUT ROWID;\n"
"CREATE TABLE localdb_vvar(\n"
" name TEXT PRIMARY KEY NOT NULL,\n"
" value CLOB,\n"
" CHECK( typeof(name)='text' AND length(name)>=1 )\n"
");\n"
"CREATE TABLE localdb_vfile(\n"
" id INTEGER PRIMARY KEY,\n"
" vid INTEGER REFERENCES blob,\n"
" chnged INT DEFAULT 0,\n"
" deleted BOOLEAN DEFAULT 0,\n"
" isexe BOOLEAN,\n"
" islink BOOLEAN,\n"
" rid INTEGER,\n"
" mrid INTEGER,\n"
" mtime INTEGER,\n"
" pathname TEXT,\n"
" origname TEXT, mhash,\n"
" UNIQUE(pathname,vid)\n"
");\n"
"CREATE TABLE localdb_sqlite_stat1(tbl,idx,stat);\n"
"CREATE TABLE localdb_vcache(\n"
" vid INTEGER, -- check-in ID\n"
" fname TEXT, -- filename\n"
" rid INTEGER, -- artifact ID\n"
" PRIMARY KEY(vid,fname)\n"
") WITHOUT ROWID;\n"
"CREATE TABLE localdb_stash(\n"
" stashid INTEGER PRIMARY KEY,\n"
" vid INTEGER,\n"
" hash TEXT,\n"
" comment TEXT,\n"
" ctime TIMESTAMP\n"
");\n"
"CREATE TABLE localdb_stashfile(\n"
" stashid INTEGER REFERENCES stash,\n"
" isAdded BOOLEAN,\n"
" isRemoved BOOLEAN,\n"
" isExec BOOLEAN,\n"
" isLink BOOLEAN,\n"
" rid INTEGER,\n"
" hash TEXT,\n"
" origname TEXT,\n"
" newname TEXT,\n"
" delta BLOB,\n"
" PRIMARY KEY(newname, stashid)\n"
");\n"
"CREATE TABLE localdb_vmerge(\n"
" id INTEGER REFERENCES vfile,\n"
" merge INTEGER,\n"
" mhash TEXT\n"
");\n"
"CREATE UNIQUE INDEX localdb_vmergex1 ON localdb_vmerge(id,mhash);\n"
"CREATE TRIGGER localdb_vmerge_ck1 AFTER INSERT ON localdb_vmerge\n"
"WHEN new.mhash IS NULL BEGIN\n"
" SELECT raise(FAIL,\n"
" 'trying to update a newer checkout with an older version of Fossil');\n"
"END;\n"
"CREATE TABLE configdb_global_config(\n"
" name TEXT PRIMARY KEY,\n"
" value TEXT\n"
");\n"
"CREATE TABLE configdb_sqlite_stat1(tbl,idx,stat);\n"
;
#ifdef __linux__
#include <sys/types.h>
#include <unistd.h>
/*
** Attempt to display I/O stats on Linux using /proc/PID/io
*/
static void displayLinuxIoStats(FILE *out){
FILE *in;
char z[200];
sqlite3_snprintf(sizeof(z), z, "/proc/%d/io", getpid());
in = fopen(z, "rb");
if( in==0 ) return;
while( fgets(z, sizeof(z), in)!=0 ){
static const struct {
const char *zPattern;
const char *zDesc;
} aTrans[] = {
{ "rchar: ", "Bytes received by read():" },
{ "wchar: ", "Bytes sent to write():" },
{ "syscr: ", "Read() system calls:" },
{ "syscw: ", "Write() system calls:" },
{ "read_bytes: ", "Bytes rcvd from storage:" },
{ "write_bytes: ", "Bytes sent to storage:" },
{ "cancelled_write_bytes: ", "Cancelled write bytes:" },
};
int i;
for(i=0; i<sizeof(aTrans)/sizeof(aTrans[0]); i++){
int n = (int)strlen(aTrans[i].zPattern);
if( strncmp(aTrans[i].zPattern, z, n)==0 ){
fprintf(out, "-- %-28s %s", aTrans[i].zDesc, &z[n]);
break;
}
}
}
fclose(in);
}
#endif
/*
** Return the value of a hexadecimal digit. Return -1 if the input
** is not a hex digit.
*/
static int hexDigitValue(char c){
if( c>='0' && c<='9' ) return c - '0';
if( c>='a' && c<='f' ) return c - 'a' + 10;
if( c>='A' && c<='F' ) return c - 'A' + 10;
return -1;
}
/*
** Interpret zArg as an integer value, possibly with suffixes.
*/
static int integerValue(const char *zArg){
sqlite3_int64 v = 0;
static const struct { char *zSuffix; int iMult; } aMult[] = {
{ "KiB", 1024 },
{ "MiB", 1024*1024 },
{ "GiB", 1024*1024*1024 },
{ "KB", 1000 },
{ "MB", 1000000 },
{ "GB", 1000000000 },
{ "K", 1000 },
{ "M", 1000000 },
{ "G", 1000000000 },
};
int i;
int isNeg = 0;
if( zArg[0]=='-' ){
isNeg = 1;
zArg++;
}else if( zArg[0]=='+' ){
zArg++;
}
if( zArg[0]=='0' && zArg[1]=='x' ){
int x;
zArg += 2;
while( (x = hexDigitValue(zArg[0]))>=0 ){
v = (v<<4) + x;
zArg++;
}
}else{
while( isdigit(zArg[0]) ){
v = v*10 + zArg[0] - '0';
zArg++;
}
}
for(i=0; i<sizeof(aMult)/sizeof(aMult[0]); i++){
if( sqlite3_stricmp(aMult[i].zSuffix, zArg)==0 ){
v *= aMult[i].iMult;
break;
}
}
if( v>0x7fffffff ){
printf("ERROR: parameter too large - max 2147483648\n");
exit(1);
}
return (int)(isNeg? -v : v);
}
int main(int argc, char **argv){
const char *zCmd = 0;
int i;
int bAutovac = 0;
int showStats = 0;
const char *zDbName = "./startup.db";
int nHeap = 0;
int mnHeap = 0;
for(i=1; i<argc; i++){
const char *z = argv[i];
if( z[0]!='-' ){
if( zCmd ){
usage(argv[0]);
}
zCmd = z;
continue;
}
if( z[1]=='-' ) z++;
if( strcmp(z, "-autovacuum")==0 ){
bAutovac = 1;
}else
if( strcmp(z, "-dbname")==0 ){
if( i==argc-1 ){
printf("ERROR: missing argument on \"%s\"\n", argv[0]);
exit(1);
}
zDbName = argv[++i];
}else
if( strcmp(z,"-heap")==0 ){
if( i>=argc-2 ){
printf("ERROR: missing arguments on %s\n", argv[i]);
exit(1);
}
nHeap = integerValue(argv[i+1]);
mnHeap = integerValue(argv[i+2]);
i += 2;
}else
if( strcmp(z,"-stats")==0 ){
showStats = 1;
}else
{
printf("ERROR: unknown option \"%s\"\n", argv[i]);
usage(argv[0]);
}
}
if( zCmd==0 ){
printf("ERROR: no COMMAND specified\n");
usage(argv[0]);
}
if( strcmp(zCmd, "run")==0 ){
sqlite3 *db;
int rc;
char *zErr = 0;
void *pHeap = 0;
if( nHeap>0 ){
pHeap = malloc( nHeap );
if( pHeap==0 ){
printf("ERROR: cannot allocate %d-byte heap\n", nHeap);
exit(1);
}
rc = sqlite3_config(SQLITE_CONFIG_HEAP, pHeap, nHeap, mnHeap);
if( rc ){
printf("ERROR: heap configuration failed: %d\n", rc);
exit(1);
}
}
rc = sqlite3_open(zDbName, &db);
if( rc ){
printf("SQLite error: %s\n", sqlite3_errmsg(db));
}else{
sqlite3_exec(db, "PRAGMA synchronous", 0, 0, &zErr);
}
if( zErr ){
printf("ERROR: %s\n", zErr);
sqlite3_free(zErr);
}
if( showStats ){
int iCur, iHi;
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHi, 0);
printf("-- Lookaside Slots Used: %d (max %d)\n", iCur,iHi);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHi, 0);
printf("-- Successful lookasides: %d\n", iHi);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur,&iHi,0);
printf("-- Lookaside size faults: %d\n", iHi);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur,&iHi,0);
printf("-- Lookaside OOM faults: %d\n", iHi);
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHi, 0);
printf("-- Pager Heap Usage: %d bytes\n", iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHi, 1);
printf("-- Page cache hits: %d\n", iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHi, 1);
printf("-- Page cache misses: %d\n", iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHi, 1);
printf("-- Page cache writes: %d\n", iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHi, 0);
printf("-- Schema Heap Usage: %d bytes\n", iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHi, 0);
printf("-- Statement Heap Usage: %d bytes\n", iCur);
}
sqlite3_close(db);
free(pHeap);
/* Global memory usage statistics printed after the database connection
** has closed. Memory usage should be zero at this point. */
if( showStats ){
int iCur, iHi;
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHi, 0);
printf("-- Memory Used (bytes): %d (max %d)\n", iCur,iHi);
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHi, 0);
printf("-- Outstanding Allocations: %d (max %d)\n", iCur,iHi);
sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHi, 0);
printf("-- Pcache Overflow Bytes: %d (max %d)\n", iCur,iHi);
sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHi, 0);
printf("-- Largest Allocation: %d bytes\n",iHi);
sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHi, 0);
printf("-- Largest Pcache Allocation: %d bytes\n",iHi);
#ifdef __linux__
displayLinuxIoStats(stdout);
#endif
}
return 0;
}
if( strcmp(zCmd, "init")==0 ){
sqlite3 *db;
char *zAux;
char *zErr = 0;
int rc;
unlink(zDbName);
zAux = sqlite3_mprintf("%s-journal", zDbName);
unlink(zAux);
sqlite3_free(zAux);
zAux = sqlite3_mprintf("%s-wal", zDbName);
unlink(zAux);
sqlite3_free(zAux);
rc = sqlite3_open(zDbName, &db);
if( rc ){
printf("SQLite error: %s\n", sqlite3_errmsg(db));
}else{
sqlite3_exec(db, "BEGIN", 0, 0, 0);
sqlite3_exec(db, zTestSchema, 0, 0, &zErr);
sqlite3_exec(db, "COMMIT", 0, 0, 0);
}
if( zErr ){
printf("ERROR: %s\n", zErr);
sqlite3_free(zErr);
}
sqlite3_close(db);
return 0;
}
}

289
testdata/tcl/threadtest1.c vendored Normal file
View File

@@ -0,0 +1,289 @@
/*
** 2002 January 15
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file implements a simple standalone program used to test whether
** or not the SQLite library is threadsafe.
**
** Testing the thread safety of SQLite is difficult because there are very
** few places in the code that are even potentially unsafe, and those
** places execute for very short periods of time. So even if the library
** is compiled with its mutexes disabled, it is likely to work correctly
** in a multi-threaded program most of the time.
**
** This file is NOT part of the standard SQLite library. It is used for
** testing only.
*/
#include "sqlite.h"
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/*
** Enable for tracing
*/
static int verbose = 0;
/*
** Come here to die.
*/
static void Exit(int rc){
exit(rc);
}
extern char *sqlite3_mprintf(const char *zFormat, ...);
extern char *sqlite3_vmprintf(const char *zFormat, va_list);
/*
** When a lock occurs, yield.
*/
static int db_is_locked(void *NotUsed, int iCount){
/* sched_yield(); */
if( verbose ) printf("BUSY %s #%d\n", (char*)NotUsed, iCount);
usleep(100);
return iCount<25;
}
/*
** Used to accumulate query results by db_query()
*/
struct QueryResult {
const char *zFile; /* Filename - used for error reporting */
int nElem; /* Number of used entries in azElem[] */
int nAlloc; /* Number of slots allocated for azElem[] */
char **azElem; /* The result of the query */
};
/*
** The callback function for db_query
*/
static int db_query_callback(
void *pUser, /* Pointer to the QueryResult structure */
int nArg, /* Number of columns in this result row */
char **azArg, /* Text of data in all columns */
char **NotUsed /* Names of the columns */
){
struct QueryResult *pResult = (struct QueryResult*)pUser;
int i;
if( pResult->nElem + nArg >= pResult->nAlloc ){
if( pResult->nAlloc==0 ){
pResult->nAlloc = nArg+1;
}else{
pResult->nAlloc = pResult->nAlloc*2 + nArg + 1;
}
pResult->azElem = realloc( pResult->azElem, pResult->nAlloc*sizeof(char*));
if( pResult->azElem==0 ){
fprintf(stdout,"%s: malloc failed\n", pResult->zFile);
return 1;
}
}
if( azArg==0 ) return 0;
for(i=0; i<nArg; i++){
pResult->azElem[pResult->nElem++] =
sqlite3_mprintf("%s",azArg[i] ? azArg[i] : "");
}
return 0;
}
/*
** Execute a query against the database. NULL values are returned
** as an empty string. The list is terminated by a single NULL pointer.
*/
char **db_query(sqlite *db, const char *zFile, const char *zFormat, ...){
char *zSql;
int rc;
char *zErrMsg = 0;
va_list ap;
struct QueryResult sResult;
va_start(ap, zFormat);
zSql = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
memset(&sResult, 0, sizeof(sResult));
sResult.zFile = zFile;
if( verbose ) printf("QUERY %s: %s\n", zFile, zSql);
rc = sqlite3_exec(db, zSql, db_query_callback, &sResult, &zErrMsg);
if( rc==SQLITE_SCHEMA ){
if( zErrMsg ) free(zErrMsg);
rc = sqlite3_exec(db, zSql, db_query_callback, &sResult, &zErrMsg);
}
if( verbose ) printf("DONE %s %s\n", zFile, zSql);
if( zErrMsg ){
fprintf(stdout,"%s: query failed: %s - %s\n", zFile, zSql, zErrMsg);
free(zErrMsg);
free(zSql);
Exit(1);
}
sqlite3_free(zSql);
if( sResult.azElem==0 ){
db_query_callback(&sResult, 0, 0, 0);
}
sResult.azElem[sResult.nElem] = 0;
return sResult.azElem;
}
/*
** Execute an SQL statement.
*/
void db_execute(sqlite *db, const char *zFile, const char *zFormat, ...){
char *zSql;
int rc;
char *zErrMsg = 0;
va_list ap;
va_start(ap, zFormat);
zSql = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
if( verbose ) printf("EXEC %s: %s\n", zFile, zSql);
do{
rc = sqlite3_exec(db, zSql, 0, 0, &zErrMsg);
}while( rc==SQLITE_BUSY );
if( verbose ) printf("DONE %s: %s\n", zFile, zSql);
if( zErrMsg ){
fprintf(stdout,"%s: command failed: %s - %s\n", zFile, zSql, zErrMsg);
free(zErrMsg);
sqlite3_free(zSql);
Exit(1);
}
sqlite3_free(zSql);
}
/*
** Free the results of a db_query() call.
*/
void db_query_free(char **az){
int i;
for(i=0; az[i]; i++){
sqlite3_free(az[i]);
}
free(az);
}
/*
** Check results
*/
void db_check(const char *zFile, const char *zMsg, char **az, ...){
va_list ap;
int i;
char *z;
va_start(ap, az);
for(i=0; (z = va_arg(ap, char*))!=0; i++){
if( az[i]==0 || strcmp(az[i],z)!=0 ){
fprintf(stdout,"%s: %s: bad result in column %d: %s\n",
zFile, zMsg, i+1, az[i]);
db_query_free(az);
Exit(1);
}
}
va_end(ap);
db_query_free(az);
}
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t sig = PTHREAD_COND_INITIALIZER;
int thread_cnt = 0;
static void *worker_bee(void *pArg){
const char *zFilename = (char*)pArg;
char *azErr;
int i, cnt;
int t = atoi(zFilename);
char **az;
sqlite *db;
pthread_mutex_lock(&lock);
thread_cnt++;
pthread_mutex_unlock(&lock);
printf("%s: START\n", zFilename);
fflush(stdout);
for(cnt=0; cnt<10; cnt++){
sqlite3_open(&zFilename[2], &db);
if( db==0 ){
fprintf(stdout,"%s: can't open\n", zFilename);
Exit(1);
}
sqlite3_busy_handler(db, db_is_locked, zFilename);
db_execute(db, zFilename, "CREATE TABLE t%d(a,b,c);", t);
for(i=1; i<=100; i++){
db_execute(db, zFilename, "INSERT INTO t%d VALUES(%d,%d,%d);",
t, i, i*2, i*i);
}
az = db_query(db, zFilename, "SELECT count(*) FROM t%d", t);
db_check(zFilename, "tX size", az, "100", 0);
az = db_query(db, zFilename, "SELECT avg(b) FROM t%d", t);
db_check(zFilename, "tX avg", az, "101", 0);
db_execute(db, zFilename, "DELETE FROM t%d WHERE a>50", t);
az = db_query(db, zFilename, "SELECT avg(b) FROM t%d", t);
db_check(zFilename, "tX avg2", az, "51", 0);
for(i=1; i<=50; i++){
char z1[30], z2[30];
az = db_query(db, zFilename, "SELECT b, c FROM t%d WHERE a=%d", t, i);
sprintf(z1, "%d", i*2);
sprintf(z2, "%d", i*i);
db_check(zFilename, "readback", az, z1, z2, 0);
}
db_execute(db, zFilename, "DROP TABLE t%d;", t);
sqlite3_close(db);
}
printf("%s: END\n", zFilename);
/* unlink(zFilename); */
fflush(stdout);
pthread_mutex_lock(&lock);
thread_cnt--;
if( thread_cnt<=0 ){
pthread_cond_signal(&sig);
}
pthread_mutex_unlock(&lock);
return 0;
}
int main(int argc, char **argv){
char *zFile;
int i, n;
pthread_t id;
if( argc>2 && strcmp(argv[1], "-v")==0 ){
verbose = 1;
argc--;
argv++;
}
if( argc<2 || (n=atoi(argv[1]))<1 ) n = 10;
for(i=0; i<n; i++){
char zBuf[200];
sprintf(zBuf, "testdb-%d", (i+1)/2);
unlink(zBuf);
}
for(i=0; i<n; i++){
zFile = sqlite3_mprintf("%d.testdb-%d", i%2+1, (i+2)/2);
if( (i%2)==0 ){
/* Remove both the database file and any old journal for the file
** being used by this thread and the next one. */
char *zDb = &zFile[2];
char *zJournal = sqlite3_mprintf("%s-journal", zDb);
unlink(zDb);
unlink(zJournal);
free(zJournal);
}
pthread_create(&id, 0, worker_bee, (void*)zFile);
pthread_detach(id);
}
pthread_mutex_lock(&lock);
while( thread_cnt>0 ){
pthread_cond_wait(&sig, &lock);
}
pthread_mutex_unlock(&lock);
for(i=0; i<n; i++){
char zBuf[200];
sprintf(zBuf, "testdb-%d", (i+1)/2);
unlink(zBuf);
}
return 0;
}

133
testdata/tcl/threadtest2.c vendored Normal file
View File

@@ -0,0 +1,133 @@
/*
** 2004 January 13
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file implements a simple standalone program used to test whether
** or not the SQLite library is threadsafe.
**
** This file is NOT part of the standard SQLite library. It is used for
** testing only.
*/
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
#include <string.h>
#include <stdlib.h>
#include "sqlite.h"
/*
** Name of the database
*/
#define DB_FILE "test.db"
/*
** When this variable becomes non-zero, all threads stop
** what they are doing.
*/
volatile int all_stop = 0;
/*
** Callback from the integrity check. If the result is anything other
** than "ok" it means the integrity check has failed. Set the "all_stop"
** global variable to stop all other activity. Print the error message
** or print OK if the string "ok" is seen.
*/
int check_callback(void *pid, int argc, char **argv, char **notUsed2){
int id = (int)pid;
if( strcmp(argv[0],"ok") ){
all_stop = 1;
fprintf(stderr,"%d: %s\n", id, argv[0]);
}else{
/* fprintf(stderr,"%d: OK\n", id); */
}
return 0;
}
/*
** Do an integrity check on the database. If the first integrity check
** fails, try it a second time.
*/
int integrity_check(sqlite *db, int id){
int rc;
if( all_stop ) return 0;
/* fprintf(stderr,"%d: CHECK\n", id); */
rc = sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0);
if( rc!=SQLITE_OK && rc!=SQLITE_BUSY ){
fprintf(stderr,"%d, Integrity check returns %d\n", id, rc);
}
if( all_stop ){
sqlite3_exec(db, "pragma integrity_check", check_callback, 0, 0);
}
return 0;
}
/*
** This is the worker thread
*/
void *worker(void *workerArg){
sqlite *db;
int id = (int)workerArg;
int rc;
int cnt = 0;
fprintf(stderr, "Starting worker %d\n", id);
while( !all_stop && cnt++<10000 ){
if( cnt%100==0 ) printf("%d: %d\n", id, cnt);
while( (sqlite3_open(DB_FILE, &db))!=SQLITE_OK ) sched_yield();
sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
/* integrity_check(db, id); */
if( all_stop ){ sqlite3_close(db); break; }
/* fprintf(stderr, "%d: BEGIN\n", id); */
rc = sqlite3_exec(db, "INSERT INTO t1 VALUES('bogus data')", 0, 0, 0);
/* fprintf(stderr, "%d: END rc=%d\n", id, rc); */
sqlite3_close(db);
}
fprintf(stderr, "Worker %d finished\n", id);
return 0;
}
/*
** Initialize the database and start the threads
*/
int main(int argc, char **argv){
sqlite *db;
int i, rc;
pthread_t aThread[5];
if( strcmp(DB_FILE,":memory:") ){
char *zJournal = sqlite3_mprintf("%s-journal", DB_FILE);
unlink(DB_FILE);
unlink(zJournal);
sqlite3_free(zJournal);
}
sqlite3_open(DB_FILE, &db);
if( db==0 ){
fprintf(stderr,"unable to initialize database\n");
exit(1);
}
rc = sqlite3_exec(db, "CREATE TABLE t1(x);", 0,0,0);
if( rc ){
fprintf(stderr,"cannot create table t1: %d\n", rc);
exit(1);
}
sqlite3_close(db);
for(i=0; i<sizeof(aThread)/sizeof(aThread[0]); i++){
pthread_create(&aThread[i], 0, worker, (void*)i);
}
for(i=0; i<sizeof(aThread)/sizeof(aThread[i]); i++){
pthread_join(aThread[i], 0);
}
if( !all_stop ){
printf("Everything seems ok.\n");
return 0;
}else{
printf("We hit an error.\n");
return 1;
}
}

1525
testdata/tcl/threadtest3.c vendored Normal file

File diff suppressed because it is too large Load Diff

484
testdata/tcl/threadtest4.c vendored Normal file
View File

@@ -0,0 +1,484 @@
/*
** 2014-12-11
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file implements a simple standalone program used to stress the
** SQLite library when accessing the same set of databases simultaneously
** from multiple threads in shared-cache mode.
**
** This test program runs on unix-like systems only. It uses pthreads.
** To compile:
**
** gcc -g -Wall -I. threadtest4.c sqlite3.c -ldl -lpthread
**
** To run:
**
** ./a.out 10
**
** The argument is the number of threads. There are also options, such
** as -wal and -multithread and -serialized.
**
** Consider also compiling with clang instead of gcc and adding the
** -fsanitize=thread option.
*/
#include "sqlite3.h"
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
/*
** An instance of the following structure is passed into each worker
** thread.
*/
typedef struct WorkerInfo WorkerInfo;
struct WorkerInfo {
int tid; /* Thread ID */
int nWorker; /* Total number of workers */
unsigned wkrFlags; /* Flags */
sqlite3 *mainDb; /* Database connection of the main thread */
sqlite3 *db; /* Database connection of this thread */
int nErr; /* Number of errors seen by this thread */
int nTest; /* Number of tests run by this thread */
char *zMsg; /* Message returned by this thread */
pthread_t id; /* Thread id */
pthread_mutex_t *pWrMutex; /* Hold this mutex while writing */
};
/*
** Allowed values for WorkerInfo.wkrFlags
*/
#define TT4_SERIALIZED 0x0000001 /* The --serialized option is used */
#define TT4_WAL 0x0000002 /* WAL mode in use */
#define TT4_TRACE 0x0000004 /* Trace activity */
/*
** Report an OOM error and die if the argument is NULL
*/
static void check_oom(void *x){
if( x==0 ){
fprintf(stderr, "out of memory\n");
exit(1);
}
}
/*
** Allocate memory. If the allocation fails, print an error message and
** kill the process.
*/
static void *safe_malloc(int sz){
void *x = sqlite3_malloc(sz>0?sz:1);
check_oom(x);
return x;
}
/*
** Print a trace message for a worker
*/
static void worker_trace(WorkerInfo *p, const char *zFormat, ...){
va_list ap;
char *zMsg;
if( (p->wkrFlags & TT4_TRACE)==0 ) return;
va_start(ap, zFormat);
zMsg = sqlite3_vmprintf(zFormat, ap);
check_oom(zMsg);
va_end(ap);
fprintf(stderr, "TRACE(%02d): %s\n", p->tid, zMsg);
sqlite3_free(zMsg);
}
/*
** Prepare a single SQL query
*/
static sqlite3_stmt *prep_sql(sqlite3 *db, const char *zFormat, ...){
va_list ap;
char *zSql;
int rc;
sqlite3_stmt *pStmt = 0;
va_start(ap, zFormat);
zSql = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
check_oom(zSql);
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( rc!=SQLITE_OK ){
fprintf(stderr, "SQL error (%d,%d): %s\nWhile preparing: [%s]\n",
rc, sqlite3_extended_errcode(db), sqlite3_errmsg(db), zSql);
exit(1);
}
sqlite3_free(zSql);
return pStmt;
}
/*
** Run a SQL statements. Panic if unable.
*/
static void run_sql(WorkerInfo *p, const char *zFormat, ...){
va_list ap;
char *zSql;
int rc;
sqlite3_stmt *pStmt = 0;
int nRetry = 0;
va_start(ap, zFormat);
zSql = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
check_oom(zSql);
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
if( rc!=SQLITE_OK ){
fprintf(stderr, "SQL error (%d,%d): %s\nWhile preparing: [%s]\n",
rc, sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zSql);
exit(1);
}
worker_trace(p, "running [%s]", zSql);
while( (rc = sqlite3_step(pStmt))!=SQLITE_DONE ){
if( (rc&0xff)==SQLITE_BUSY || (rc&0xff)==SQLITE_LOCKED ){
sqlite3_reset(pStmt);
nRetry++;
if( nRetry<10 ){
worker_trace(p, "retry %d for [%s]", nRetry, zSql);
sched_yield();
continue;
}else{
fprintf(stderr, "Deadlock in thread %d while running [%s]\n",
p->tid, zSql);
exit(1);
}
}
if( rc!=SQLITE_ROW ){
fprintf(stderr, "SQL error (%d,%d): %s\nWhile running [%s]\n",
rc, sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db), zSql);
exit(1);
}
}
sqlite3_free(zSql);
sqlite3_finalize(pStmt);
}
/*
** Open the database connection for WorkerInfo. The order in which
** the files are opened is a function of the tid value.
*/
static void worker_open_connection(WorkerInfo *p, int iCnt){
char *zFile;
int x;
int rc;
static const unsigned char aOrder[6][3] = {
{ 1, 2, 3},
{ 1, 3, 2},
{ 2, 1, 3},
{ 2, 3, 1},
{ 3, 1, 2},
{ 3, 2, 1}
};
x = (p->tid + iCnt) % 6;
zFile = sqlite3_mprintf("tt4-test%d.db", aOrder[x][0]);
check_oom(zFile);
worker_trace(p, "open %s", zFile);
rc = sqlite3_open_v2(zFile, &p->db,
SQLITE_OPEN_READWRITE|SQLITE_OPEN_SHAREDCACHE, 0);
if( rc!=SQLITE_OK ){
fprintf(stderr, "sqlite_open_v2(%s) failed on thread %d\n",
zFile, p->tid);
exit(1);
}
sqlite3_free(zFile);
run_sql(p, "PRAGMA read_uncommitted=ON;");
sqlite3_busy_timeout(p->db, 10000);
run_sql(p, "PRAGMA synchronous=OFF;");
run_sql(p, "ATTACH 'tt4-test%d.db' AS aux1", aOrder[x][1]);
run_sql(p, "ATTACH 'tt4-test%d.db' AS aux2", aOrder[x][2]);
}
/*
** Close the worker database connection
*/
static void worker_close_connection(WorkerInfo *p){
if( p->db ){
worker_trace(p, "close");
sqlite3_close(p->db);
p->db = 0;
}
}
/*
** Delete all content in the three databases associated with a
** single thread. Make this happen all in a single transaction if
** inTrans is true, or separately for each database if inTrans is
** false.
*/
static void worker_delete_all_content(WorkerInfo *p, int inTrans){
if( inTrans ){
pthread_mutex_lock(p->pWrMutex);
run_sql(p, "BEGIN");
run_sql(p, "DELETE FROM t1 WHERE tid=%d", p->tid);
run_sql(p, "DELETE FROM t2 WHERE tid=%d", p->tid);
run_sql(p, "DELETE FROM t3 WHERE tid=%d", p->tid);
run_sql(p, "COMMIT");
pthread_mutex_unlock(p->pWrMutex);
p->nTest++;
}else{
pthread_mutex_lock(p->pWrMutex);
run_sql(p, "DELETE FROM t1 WHERE tid=%d", p->tid);
pthread_mutex_unlock(p->pWrMutex);
p->nTest++;
pthread_mutex_lock(p->pWrMutex);
run_sql(p, "DELETE FROM t2 WHERE tid=%d", p->tid);
pthread_mutex_unlock(p->pWrMutex);
p->nTest++;
pthread_mutex_lock(p->pWrMutex);
run_sql(p, "DELETE FROM t3 WHERE tid=%d", p->tid);
pthread_mutex_unlock(p->pWrMutex);
p->nTest++;
}
}
/*
** Create rows mn through mx in table iTab for the given worker
*/
static void worker_add_content(WorkerInfo *p, int mn, int mx, int iTab){
char *zTabDef;
switch( iTab ){
case 1: zTabDef = "t1(tid,sp,a,b,c)"; break;
case 2: zTabDef = "t2(tid,sp,d,e,f)"; break;
case 3: zTabDef = "t3(tid,sp,x,y,z)"; break;
}
pthread_mutex_lock(p->pWrMutex);
run_sql(p,
"WITH RECURSIVE\n"
" c(i) AS (VALUES(%d) UNION ALL SELECT i+1 FROM c WHERE i<%d)\n"
"INSERT INTO %s SELECT %d, zeroblob(3000), i, printf('%%d',i), i FROM c;",
mn, mx, zTabDef, p->tid
);
pthread_mutex_unlock(p->pWrMutex);
p->nTest++;
}
/*
** Set an error message on a worker
*/
static void worker_error(WorkerInfo *p, const char *zFormat, ...){
va_list ap;
p->nErr++;
sqlite3_free(p->zMsg);
va_start(ap, zFormat);
p->zMsg = sqlite3_vmprintf(zFormat, ap);
va_end(ap);
}
/*
** Each thread runs the following function.
*/
static void *worker_thread(void *pArg){
WorkerInfo *p = (WorkerInfo*)pArg;
int iOuter;
int i;
int rc;
sqlite3_stmt *pStmt;
printf("worker %d startup\n", p->tid); fflush(stdout);
for(iOuter=1; iOuter<=p->nWorker; iOuter++){
worker_open_connection(p, iOuter);
for(i=0; i<4; i++){
worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter)%3 + 1);
worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter+1)%3 + 1);
worker_add_content(p, i*100+1, (i+1)*100, (p->tid+iOuter+2)%3 + 1);
}
pStmt = prep_sql(p->db, "SELECT count(a) FROM t1 WHERE tid=%d", p->tid);
worker_trace(p, "query [%s]", sqlite3_sql(pStmt));
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ){
worker_error(p, "Failed to step: %s", sqlite3_sql(pStmt));
}else if( sqlite3_column_int(pStmt, 0)!=400 ){
worker_error(p, "Wrong result: %d", sqlite3_column_int(pStmt,0));
}
sqlite3_finalize(pStmt);
if( p->nErr ) break;
if( ((iOuter+p->tid)%3)==0 ){
sqlite3_db_release_memory(p->db);
p->nTest++;
}
pthread_mutex_lock(p->pWrMutex);
run_sql(p, "BEGIN;");
run_sql(p, "UPDATE t1 SET c=NULL WHERE a=55");
run_sql(p, "UPDATE t2 SET f=NULL WHERE d=42");
run_sql(p, "UPDATE t3 SET z=NULL WHERE x=31");
run_sql(p, "ROLLBACK;");
p->nTest++;
pthread_mutex_unlock(p->pWrMutex);
if( iOuter==p->tid ){
pthread_mutex_lock(p->pWrMutex);
run_sql(p, "VACUUM");
pthread_mutex_unlock(p->pWrMutex);
}
pStmt = prep_sql(p->db,
"SELECT t1.rowid, t2.rowid, t3.rowid"
" FROM t1, t2, t3"
" WHERE t1.tid=%d AND t2.tid=%d AND t3.tid=%d"
" AND t1.a<>t2.d AND t2.d<>t3.x"
" ORDER BY 1, 2, 3"
,p->tid, p->tid, p->tid);
worker_trace(p, "query [%s]", sqlite3_sql(pStmt));
for(i=0; i<p->nWorker; i++){
rc = sqlite3_step(pStmt);
if( rc!=SQLITE_ROW ){
worker_error(p, "Failed to step: %s", sqlite3_sql(pStmt));
break;
}
sched_yield();
}
sqlite3_finalize(pStmt);
if( p->nErr ) break;
worker_delete_all_content(p, (p->tid+iOuter)%2);
worker_close_connection(p);
p->db = 0;
}
worker_close_connection(p);
printf("worker %d finished\n", p->tid); fflush(stdout);
return 0;
}
int main(int argc, char **argv){
int nWorker = 0; /* Number of worker threads */
int i; /* Loop counter */
WorkerInfo *aInfo; /* Information for each worker */
unsigned wkrFlags = 0; /* Default worker flags */
int nErr = 0; /* Number of errors */
int nTest = 0; /* Number of tests */
int rc; /* Return code */
sqlite3 *db = 0; /* Main database connection */
pthread_mutex_t wrMutex; /* The write serialization mutex */
WorkerInfo infoTop; /* WorkerInfo for the main thread */
WorkerInfo *p; /* Pointer to infoTop */
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
for(i=1; i<argc; i++){
const char *z = argv[i];
if( z[0]=='-' ){
if( z[1]=='-' && z[2]!=0 ) z++;
if( strcmp(z,"-multithread")==0 ){
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
wkrFlags &= ~TT4_SERIALIZED;
}else if( strcmp(z,"-serialized")==0 ){
sqlite3_config(SQLITE_CONFIG_SERIALIZED);
wkrFlags |= TT4_SERIALIZED;
}else if( strcmp(z,"-wal")==0 ){
wkrFlags |= TT4_WAL;
}else if( strcmp(z,"-trace")==0 ){
wkrFlags |= TT4_TRACE;
}else{
fprintf(stderr, "unknown command-line option: %s\n", argv[i]);
exit(1);
}
}else if( z[0]>='1' && z[0]<='9' && nWorker==0 ){
nWorker = atoi(z);
if( nWorker<2 ){
fprintf(stderr, "minimum of 2 threads\n");
exit(1);
}
}else{
fprintf(stderr, "extra command-line argument: \"%s\"\n", argv[i]);
exit(1);
}
}
if( nWorker==0 ){
fprintf(stderr,
"usage: %s ?OPTIONS? N\n"
"N is the number of threads and must be at least 2.\n"
"Options:\n"
" --serialized\n"
" --multithread\n"
" --wal\n"
" --trace\n"
,argv[0]
);
exit(1);
}
if( !sqlite3_threadsafe() ){
fprintf(stderr, "requires a threadsafe build of SQLite\n");
exit(1);
}
sqlite3_initialize();
sqlite3_enable_shared_cache(1);
pthread_mutex_init(&wrMutex, 0);
/* Initialize the test database files */
(void)unlink("tt4-test1.db");
(void)unlink("tt4-test2.db");
(void)unlink("tt4-test3.db");
rc = sqlite3_open("tt4-test1.db", &db);
if( rc!=SQLITE_OK ){
fprintf(stderr, "Unable to open test database: tt4-test2.db\n");
exit(1);
}
memset(&infoTop, 0, sizeof(infoTop));
infoTop.db = db;
infoTop.wkrFlags = wkrFlags;
p = &infoTop;
if( wkrFlags & TT4_WAL ){
run_sql(p, "PRAGMA journal_mode=WAL");
}
run_sql(p, "PRAGMA synchronous=OFF");
run_sql(p, "CREATE TABLE IF NOT EXISTS t1(tid INTEGER, sp, a, b, c)");
run_sql(p, "CREATE INDEX t1tid ON t1(tid)");
run_sql(p, "CREATE INDEX t1ab ON t1(a,b)");
run_sql(p, "ATTACH 'tt4-test2.db' AS 'test2'");
run_sql(p, "CREATE TABLE IF NOT EXISTS test2.t2(tid INTEGER, sp, d, e, f)");
run_sql(p, "CREATE INDEX test2.t2tid ON t2(tid)");
run_sql(p, "CREATE INDEX test2.t2de ON t2(d,e)");
run_sql(p, "ATTACH 'tt4-test3.db' AS 'test3'");
run_sql(p, "CREATE TABLE IF NOT EXISTS test3.t3(tid INTEGER, sp, x, y, z)");
run_sql(p, "CREATE INDEX test3.t3tid ON t3(tid)");
run_sql(p, "CREATE INDEX test3.t3xy ON t3(x,y)");
aInfo = safe_malloc( sizeof(*aInfo)*nWorker );
memset(aInfo, 0, sizeof(*aInfo)*nWorker);
for(i=0; i<nWorker; i++){
aInfo[i].tid = i+1;
aInfo[i].nWorker = nWorker;
aInfo[i].wkrFlags = wkrFlags;
aInfo[i].mainDb = db;
aInfo[i].pWrMutex = &wrMutex;
rc = pthread_create(&aInfo[i].id, 0, worker_thread, &aInfo[i]);
if( rc!=0 ){
fprintf(stderr, "thread creation failed for thread %d\n", i+1);
exit(1);
}
sched_yield();
}
for(i=0; i<nWorker; i++){
pthread_join(aInfo[i].id, 0);
printf("Joined thread %d: %d errors in %d tests",
aInfo[i].tid, aInfo[i].nErr, aInfo[i].nTest);
if( aInfo[i].zMsg ){
printf(": %s\n", aInfo[i].zMsg);
}else{
printf("\n");
}
nErr += aInfo[i].nErr;
nTest += aInfo[i].nTest;
fflush(stdout);
}
sqlite3_close(db);
sqlite3_free(aInfo);
printf("Total %d errors in %d tests\n", nErr, nTest);
return nErr;
}

34
testdata/tcl/time-wordcount.sh vendored Normal file
View File

@@ -0,0 +1,34 @@
#!/bin/sh
#
# This script runs the wordcount program in different ways and generates
# an output useful for performance comparisons.
#
# Select the source text to be analyzed.
#
if test "x$1" = "x";
then echo "Usage: $0 FILENAME [ARGS...]"; exit 1;
fi
# Do test runs
#
rm -f wcdb1.db
./wordcount --tag A: --timer --summary wcdb1.db $* --insert
rm -f wcdb2.db
./wordcount --tag B: --timer --summary wcdb2.db $* --insert --without-rowid
rm -f wcdb1.db
./wordcount --tag C: --timer --summary wcdb1.db $* --replace
rm -f wcdb2.db
./wordcount --tag D: --timer --summary wcdb2.db $* --replace --without-rowid
rm -f wcdb1.db
./wordcount --tag E: --timer --summary wcdb1.db $* --select
rm -f wcdb2.db
./wordcount --tag F: --timer --summary wcdb2.db $* --select --without-rowid
./wordcount --tag G: --timer --summary wcdb1.db $* --query
./wordcount --tag H: --timer --summary wcdb1.db $* --query --without-rowid
./wordcount --tag I: --timer --summary wcdb1.db $* --delete
./wordcount --tag J: --timer --summary wcdb2.db $* --delete --without-rowid
# Clean up temporary files created.
#
rm -f wcdb1.db wcdb2.db

148
testdata/tcl/tt3_checkpoint.c vendored Normal file
View File

@@ -0,0 +1,148 @@
/*
** 2011-02-02
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file is part of the test program "threadtest3". Despite being a C
** file it is not compiled separately, but included by threadtest3.c using
** the #include directive normally used with header files.
**
** This file contains the implementation of test cases:
**
** checkpoint_starvation_1
** checkpoint_starvation_2
*/
/*
** Both test cases involve 1 writer/checkpointer thread and N reader threads.
**
** Each reader thread performs a series of read transactions, one after
** another. Each read transaction lasts for 100 ms.
**
** The writer writes transactions as fast as possible. It uses a callback
** registered with sqlite3_wal_hook() to try to keep the WAL-size limited to
** around 50 pages.
**
** In test case checkpoint_starvation_1, the auto-checkpoint uses
** SQLITE_CHECKPOINT_PASSIVE. In checkpoint_starvation_2, it uses RESTART.
** The expectation is that in the first case the WAL file will grow very
** large, and in the second will be limited to the 50 pages or thereabouts.
** However, the overall transaction throughput will be lower for
** checkpoint_starvation_2, as every checkpoint will block for up to 200 ms
** waiting for readers to clear.
*/
/* Frame limit used by the WAL hook for these tests. */
#define CHECKPOINT_STARVATION_FRAMELIMIT 50
/* Duration in ms of each read transaction */
#define CHECKPOINT_STARVATION_READMS 100
struct CheckpointStarvationCtx {
int eMode;
int nMaxFrame;
};
typedef struct CheckpointStarvationCtx CheckpointStarvationCtx;
static int checkpoint_starvation_walhook(
void *pCtx,
sqlite3 *db,
const char *zDb,
int nFrame
){
CheckpointStarvationCtx *p = (CheckpointStarvationCtx *)pCtx;
if( nFrame>p->nMaxFrame ){
p->nMaxFrame = nFrame;
}
if( nFrame>=CHECKPOINT_STARVATION_FRAMELIMIT ){
sqlite3_wal_checkpoint_v2(db, zDb, p->eMode, 0, 0);
}
return SQLITE_OK;
}
static char *checkpoint_starvation_reader(int iTid, void *pArg){
Error err = {0};
Sqlite db = {0};
opendb(&err, &db, "test.db", 0);
while( !timetostop(&err) ){
i64 iCount1, iCount2;
sql_script(&err, &db, "BEGIN");
iCount1 = execsql_i64(&err, &db, "SELECT count(x) FROM t1");
usleep(CHECKPOINT_STARVATION_READMS*1000);
iCount2 = execsql_i64(&err, &db, "SELECT count(x) FROM t1");
sql_script(&err, &db, "COMMIT");
if( iCount1!=iCount2 ){
test_error(&err, "Isolation failure - %lld %lld", iCount1, iCount2);
}
}
closedb(&err, &db);
print_and_free_err(&err);
return 0;
}
static void checkpoint_starvation_main(int nMs, CheckpointStarvationCtx *p){
Error err = {0};
Sqlite db = {0};
Threadset threads = {0};
int nInsert = 0;
int i;
opendb(&err, &db, "test.db", 1);
sql_script(&err, &db,
"PRAGMA page_size = 1024;"
"PRAGMA journal_mode = WAL;"
"CREATE TABLE t1(x);"
);
setstoptime(&err, nMs);
for(i=0; i<4; i++){
launch_thread(&err, &threads, checkpoint_starvation_reader, 0);
usleep(CHECKPOINT_STARVATION_READMS*1000/4);
}
sqlite3_wal_hook(db.db, checkpoint_starvation_walhook, (void *)p);
while( !timetostop(&err) ){
sql_script(&err, &db, "INSERT INTO t1 VALUES(randomblob(1200))");
nInsert++;
}
printf(" Checkpoint mode : %s\n",
p->eMode==SQLITE_CHECKPOINT_PASSIVE ? "PASSIVE" : "RESTART"
);
printf(" Peak WAL : %d frames\n", p->nMaxFrame);
printf(" Transaction count: %d transactions\n", nInsert);
join_all_threads(&err, &threads);
closedb(&err, &db);
print_and_free_err(&err);
}
static void checkpoint_starvation_1(int nMs){
Error err = {0};
CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_PASSIVE, 0 };
checkpoint_starvation_main(nMs, &ctx);
if( ctx.nMaxFrame<(CHECKPOINT_STARVATION_FRAMELIMIT*10) ){
test_error(&err, "WAL failed to grow - %d frames", ctx.nMaxFrame);
}
print_and_free_err(&err);
}
static void checkpoint_starvation_2(int nMs){
Error err = {0};
CheckpointStarvationCtx ctx = { SQLITE_CHECKPOINT_RESTART, 0 };
checkpoint_starvation_main(nMs, &ctx);
if( ctx.nMaxFrame>CHECKPOINT_STARVATION_FRAMELIMIT+10 ){
test_error(&err, "WAL grew too large - %d frames", ctx.nMaxFrame);
}
print_and_free_err(&err);
}

74
testdata/tcl/tt3_index.c vendored Normal file
View File

@@ -0,0 +1,74 @@
/*
** 2014 December 9
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** create_drop_index_1
*/
static char *create_drop_index_thread(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
while( !timetostop(&err) ){
opendb(&err, &db, "test.db", 0);
sql_script(&err, &db,
"DROP INDEX IF EXISTS i1;"
"DROP INDEX IF EXISTS i2;"
"DROP INDEX IF EXISTS i3;"
"DROP INDEX IF EXISTS i4;"
"CREATE INDEX IF NOT EXISTS i1 ON t11(a);"
"CREATE INDEX IF NOT EXISTS i2 ON t11(b);"
"CREATE INDEX IF NOT EXISTS i3 ON t11(c);"
"CREATE INDEX IF NOT EXISTS i4 ON t11(d);"
"SELECT * FROM t11 ORDER BY a;"
"SELECT * FROM t11 ORDER BY b;"
"SELECT * FROM t11 ORDER BY c;"
"SELECT * FROM t11 ORDER BY d;"
);
clear_error(&err, SQLITE_LOCKED);
closedb(&err, &db);
}
print_and_free_err(&err);
return sqlite3_mprintf("ok");
}
static void create_drop_index_1(int nMs){
Error err = {0};
Sqlite db = {0};
Threadset threads = {0};
opendb(&err, &db, "test.db", 1);
sql_script(&err, &db,
"CREATE TABLE t11(a, b, c, d);"
"WITH data(x) AS (SELECT 1 UNION ALL SELECT x+1 FROM data WHERE x<100) "
"INSERT INTO t11 SELECT x,x,x,x FROM data;"
);
closedb(&err, &db);
setstoptime(&err, nMs);
sqlite3_enable_shared_cache(1);
launch_thread(&err, &threads, create_drop_index_thread, 0);
launch_thread(&err, &threads, create_drop_index_thread, 0);
launch_thread(&err, &threads, create_drop_index_thread, 0);
launch_thread(&err, &threads, create_drop_index_thread, 0);
launch_thread(&err, &threads, create_drop_index_thread, 0);
join_all_threads(&err, &threads);
sqlite3_enable_shared_cache(0);
print_and_free_err(&err);
}

99
testdata/tcl/tt3_lookaside1.c vendored Normal file
View File

@@ -0,0 +1,99 @@
/*
** 2014 December 9
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** lookaside1
*/
/*
** The test in this file attempts to expose a specific race condition
** that is suspected to exist at time of writing.
*/
static char *lookaside1_thread_reader(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
opendb(&err, &db, "test.db", 0);
while( !timetostop(&err) ){
sqlite3_stmt *pStmt = 0;
int rc;
sqlite3_prepare_v2(db.db, "SELECT 1 FROM t1", -1, &pStmt, 0);
while( sqlite3_step(pStmt)==SQLITE_ROW ){
execsql(&err, &db, "SELECT length(x||y||z) FROM t2");
}
rc = sqlite3_finalize(pStmt);
if( err.rc==SQLITE_OK && rc!=SQLITE_OK ){
sqlite_error(&err, &db, "finalize");
}
}
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf("ok");
}
static char *lookaside1_thread_writer(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
opendb(&err, &db, "test.db", 0);
do{
sql_script(&err, &db,
"BEGIN;"
"UPDATE t3 SET i=i+1 WHERE x=1;"
"ROLLBACK;"
);
}while( !timetostop(&err) );
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf("ok");
}
static void lookaside1(int nMs){
Error err = {0};
Sqlite db = {0};
Threadset threads = {0};
opendb(&err, &db, "test.db", 1);
sql_script(&err, &db,
"CREATE TABLE t1(x PRIMARY KEY) WITHOUT ROWID;"
"WITH data(x,y) AS ("
" SELECT 1, quote(randomblob(750)) UNION ALL "
" SELECT x*2, y||y FROM data WHERE x<5) "
"INSERT INTO t1 SELECT y FROM data;"
"CREATE TABLE t3(x PRIMARY KEY,i) WITHOUT ROWID;"
"INSERT INTO t3 VALUES(1, 1);"
"CREATE TABLE t2(x,y,z);"
"INSERT INTO t2 VALUES(randomblob(50), randomblob(50), randomblob(50));"
);
closedb(&err, &db);
setstoptime(&err, nMs);
sqlite3_enable_shared_cache(1);
launch_thread(&err, &threads, lookaside1_thread_reader, 0);
launch_thread(&err, &threads, lookaside1_thread_reader, 0);
launch_thread(&err, &threads, lookaside1_thread_reader, 0);
launch_thread(&err, &threads, lookaside1_thread_reader, 0);
launch_thread(&err, &threads, lookaside1_thread_reader, 0);
launch_thread(&err, &threads, lookaside1_thread_writer, 0);
join_all_threads(&err, &threads);
sqlite3_enable_shared_cache(0);
print_and_free_err(&err);
}

55
testdata/tcl/tt3_shared.c vendored Normal file
View File

@@ -0,0 +1,55 @@
/*
** 2020 September 5
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
**
*/
/*
*/
static char *shared_thread1(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
while( !timetostop(&err) ){
Sqlite db = {0}; /* SQLite database connection */
opendb(&err, &db, "test.db", 0);
sql_script(&err, &db, "SELECT * FROM t1");
closedb(&err, &db);
}
print_and_free_err(&err);
return sqlite3_mprintf("done!");
}
static void shared1(int nMs){
Error err = {0};
Sqlite db = {0}; /* SQLite database connection */
Threadset threads = {0};
int ii;
opendb(&err, &db, "test.db", 1);
sql_script(&err, &db, "CREATE TABLE t1(x)");
closedb(&err, &db);
setstoptime(&err, nMs);
sqlite3_enable_shared_cache(1);
for(ii=0; ii<5; ii++){
launch_thread(&err, &threads, shared_thread1, 0);
}
join_all_threads(&err, &threads);
sqlite3_enable_shared_cache(0);
print_and_free_err(&err);
}

364
testdata/tcl/tt3_stress.c vendored Normal file
View File

@@ -0,0 +1,364 @@
/*
** 2014 December 9
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
**
*/
/*
** Thread 1. CREATE and DROP a table.
*/
static char *stress_thread_1(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
opendb(&err, &db, "test.db", 0);
while( !timetostop(&err) ){
sql_script(&err, &db, "CREATE TABLE IF NOT EXISTS t1(a PRIMARY KEY, b)");
clear_error(&err, SQLITE_LOCKED);
sql_script(&err, &db, "DROP TABLE IF EXISTS t1");
clear_error(&err, SQLITE_LOCKED);
}
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf("ok");
}
/*
** Thread 2. Open and close database connections.
*/
static char *stress_thread_2(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
while( !timetostop(&err) ){
opendb(&err, &db, "test.db", 0);
sql_script(&err, &db, "SELECT * FROM sqlite_schema;");
clear_error(&err, SQLITE_LOCKED);
closedb(&err, &db);
}
print_and_free_err(&err);
return sqlite3_mprintf("ok");
}
/*
** Thread 3. Attempt many small SELECT statements.
*/
static char *stress_thread_3(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
int i1 = 0;
int i2 = 0;
opendb(&err, &db, "test.db", 0);
while( !timetostop(&err) ){
sql_script(&err, &db, "SELECT * FROM t1 ORDER BY a;");
i1++;
if( err.rc ) i2++;
clear_error(&err, SQLITE_LOCKED);
clear_error(&err, SQLITE_ERROR);
}
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf("read t1 %d/%d attempts", i2, i1);
}
/*
** Thread 5. Attempt INSERT statements.
*/
static char *stress_thread_4(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
int i1 = 0;
int i2 = 0;
int iArg = PTR2INT(pArg);
opendb(&err, &db, "test.db", 0);
while( !timetostop(&err) ){
if( iArg ){
closedb(&err, &db);
opendb(&err, &db, "test.db", 0);
}
sql_script(&err, &db,
"WITH loop(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM loop LIMIT 200) "
"INSERT INTO t1 VALUES(randomblob(60), randomblob(60));"
);
i1++;
if( err.rc ) i2++;
clear_error(&err, SQLITE_LOCKED);
clear_error(&err, SQLITE_ERROR);
}
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf("wrote t1 %d/%d attempts", i2, i1);
}
/*
** Thread 6. Attempt DELETE operations.
*/
static char *stress_thread_5(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
int iArg = PTR2INT(pArg);
int i1 = 0;
int i2 = 0;
opendb(&err, &db, "test.db", 0);
while( !timetostop(&err) ){
i64 i = (i1 % 4);
if( iArg ){
closedb(&err, &db);
opendb(&err, &db, "test.db", 0);
}
execsql(&err, &db, "DELETE FROM t1 WHERE (rowid % 4)==:i", &i);
i1++;
if( err.rc ) i2++;
clear_error(&err, SQLITE_LOCKED);
}
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf("deleted from t1 %d/%d attempts", i2, i1);
}
static void stress1(int nMs){
Error err = {0};
Threadset threads = {0};
setstoptime(&err, nMs);
sqlite3_enable_shared_cache(1);
launch_thread(&err, &threads, stress_thread_1, 0);
launch_thread(&err, &threads, stress_thread_1, 0);
launch_thread(&err, &threads, stress_thread_2, 0);
launch_thread(&err, &threads, stress_thread_2, 0);
launch_thread(&err, &threads, stress_thread_3, 0);
launch_thread(&err, &threads, stress_thread_3, 0);
launch_thread(&err, &threads, stress_thread_4, 0);
launch_thread(&err, &threads, stress_thread_4, 0);
launch_thread(&err, &threads, stress_thread_5, 0);
launch_thread(&err, &threads, stress_thread_5, (void*)1);
join_all_threads(&err, &threads);
sqlite3_enable_shared_cache(0);
print_and_free_err(&err);
}
/**************************************************************************
***************************************************************************
** Start of test case "stress2"
*/
/*
** 1. CREATE TABLE statements.
** 2. DROP TABLE statements.
** 3. Small SELECT statements.
** 4. Big SELECT statements.
** 5. Small INSERT statements.
** 6. Big INSERT statements.
** 7. Small UPDATE statements.
** 8. Big UPDATE statements.
** 9. Small DELETE statements.
** 10. Big DELETE statements.
** 11. VACUUM.
** 14. Integrity-check.
** 17. Switch the journal mode from delete to wal and back again.
** 19. Open and close database connections rapidly.
*/
#define STRESS2_TABCNT 5 /* count1 in SDS test */
#define STRESS2_COUNT2 200 /* count2 in SDS test */
#define STRESS2_COUNT3 57 /* count2 in SDS test */
static void stress2_workload1(Error *pErr, Sqlite *pDb, int i){
int iTab = (i % (STRESS2_TABCNT-1)) + 1;
sql_script_printf(pErr, pDb,
"CREATE TABLE IF NOT EXISTS t%d(x PRIMARY KEY, y, z);", iTab
);
}
static void stress2_workload2(Error *pErr, Sqlite *pDb, int i){
int iTab = (i % (STRESS2_TABCNT-1)) + 1;
sql_script_printf(pErr, pDb, "DROP TABLE IF EXISTS t%d;", iTab);
}
static void stress2_workload3(Error *pErr, Sqlite *pDb, int i){
sql_script(pErr, pDb, "SELECT * FROM t0 WHERE z = 'small'");
}
static void stress2_workload4(Error *pErr, Sqlite *pDb, int i){
sql_script(pErr, pDb, "SELECT * FROM t0 WHERE z = 'big'");
}
static void stress2_workload5(Error *pErr, Sqlite *pDb, int i){
sql_script(pErr, pDb,
"INSERT INTO t0 VALUES(hex(random()), hex(randomblob(200)), 'small');"
);
}
static void stress2_workload6(Error *pErr, Sqlite *pDb, int i){
sql_script(pErr, pDb,
"INSERT INTO t0 VALUES(hex(random()), hex(randomblob(57)), 'big');"
);
}
static void stress2_workload7(Error *pErr, Sqlite *pDb, int i){
sql_script_printf(pErr, pDb,
"UPDATE t0 SET y = hex(randomblob(200)) "
"WHERE x LIKE hex((%d %% 5)) AND z='small';"
,i
);
}
static void stress2_workload8(Error *pErr, Sqlite *pDb, int i){
sql_script_printf(pErr, pDb,
"UPDATE t0 SET y = hex(randomblob(57)) "
"WHERE x LIKE hex(%d %% 5) AND z='big';"
,i
);
}
static void stress2_workload9(Error *pErr, Sqlite *pDb, int i){
sql_script_printf(pErr, pDb,
"DELETE FROM t0 WHERE x LIKE hex(%d %% 5) AND z='small';", i
);
}
static void stress2_workload10(Error *pErr, Sqlite *pDb, int i){
sql_script_printf(pErr, pDb,
"DELETE FROM t0 WHERE x LIKE hex(%d %% 5) AND z='big';", i
);
}
static void stress2_workload11(Error *pErr, Sqlite *pDb, int i){
sql_script(pErr, pDb, "VACUUM");
}
static void stress2_workload14(Error *pErr, Sqlite *pDb, int i){
sql_script(pErr, pDb, "PRAGMA integrity_check");
}
static void stress2_workload17(Error *pErr, Sqlite *pDb, int i){
sql_script_printf(pErr, pDb,
"PRAGMA journal_mode = %q", (i%2) ? "delete" : "wal"
);
}
static char *stress2_workload19(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
const char *zDb = (const char*)pArg;
while( !timetostop(&err) ){
opendb(&err, &db, zDb, 0);
sql_script(&err, &db, "SELECT * FROM sqlite_schema;");
clear_error(&err, SQLITE_LOCKED);
closedb(&err, &db);
}
print_and_free_err(&err);
return sqlite3_mprintf("ok");
}
typedef struct Stress2Ctx Stress2Ctx;
struct Stress2Ctx {
const char *zDb;
void (*xProc)(Error*, Sqlite*, int);
};
static char *stress2_thread_wrapper(int iTid, void *pArg){
Stress2Ctx *pCtx = (Stress2Ctx*)pArg;
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
int i1 = 0;
int i2 = 0;
while( !timetostop(&err) ){
int cnt;
opendb(&err, &db, pCtx->zDb, 0);
for(cnt=0; err.rc==SQLITE_OK && cnt<STRESS2_TABCNT; cnt++){
pCtx->xProc(&err, &db, i1);
i2 += (err.rc==SQLITE_OK);
clear_error(&err, SQLITE_LOCKED);
i1++;
}
closedb(&err, &db);
}
print_and_free_err(&err);
return sqlite3_mprintf("ok %d/%d", i2, i1);
}
static void stress2_launch_thread_loop(
Error *pErr, /* IN/OUT: Error code */
Threadset *pThreads, /* Thread set */
const char *zDb, /* Database name */
void (*x)(Error*,Sqlite*,int) /* Run this until error or timeout */
){
Stress2Ctx *pCtx = sqlite3_malloc(sizeof(Stress2Ctx));
pCtx->zDb = zDb;
pCtx->xProc = x;
launch_thread(pErr, pThreads, stress2_thread_wrapper, (void*)pCtx);
}
static void stress2(int nMs){
struct Stress2Task {
void (*x)(Error*,Sqlite*,int);
} aTask[] = {
{ stress2_workload1 },
{ stress2_workload2 },
{ stress2_workload3 },
{ stress2_workload4 },
{ stress2_workload5 },
{ stress2_workload6 },
{ stress2_workload7 },
{ stress2_workload8 },
{ stress2_workload9 },
{ stress2_workload10 },
{ stress2_workload11 },
{ stress2_workload14 },
{ stress2_workload17 },
};
const char *zDb = "test.db";
int i;
Error err = {0};
Sqlite db = {0};
Threadset threads = {0};
/* To make sure the db file is empty before commencing */
opendb(&err, &db, zDb, 1);
sql_script(&err, &db,
"CREATE TABLE IF NOT EXISTS t0(x PRIMARY KEY, y, z);"
"CREATE INDEX IF NOT EXISTS i0 ON t0(y);"
);
closedb(&err, &db);
setstoptime(&err, nMs);
sqlite3_enable_shared_cache(1);
for(i=0; i<sizeof(aTask)/sizeof(aTask[0]); i++){
stress2_launch_thread_loop(&err, &threads, zDb, aTask[i].x);
}
launch_thread(&err, &threads, stress2_workload19, (void*)zDb);
launch_thread(&err, &threads, stress2_workload19, (void*)zDb);
join_all_threads(&err, &threads);
sqlite3_enable_shared_cache(0);
print_and_free_err(&err);
}

90
testdata/tcl/tt3_vacuum.c vendored Normal file
View File

@@ -0,0 +1,90 @@
/*
** 2014 December 9
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
**
** This file contains multi-threaded tests that use shared-cache and
** the VACUUM command.
**
** Tests:
**
** vacuum1
**
*/
static char *vacuum1_thread_writer(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
opendb(&err, &db, "test.db", 0);
i64 i = 0;
while( !timetostop(&err) ){
i++;
/* Insert lots of rows. Then delete some. */
execsql(&err, &db,
"WITH loop(i) AS (SELECT 1 UNION ALL SELECT i+1 FROM loop WHERE i<100) "
"INSERT INTO t1 SELECT randomblob(50), randomblob(2500) FROM loop"
);
/* Delete lots of rows */
execsql(&err, &db, "DELETE FROM t1 WHERE rowid = :i", &i);
clear_error(&err, SQLITE_LOCKED);
/* Select the rows */
execsql(&err, &db, "SELECT * FROM t1 ORDER BY x");
clear_error(&err, SQLITE_LOCKED);
}
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf("ok");
}
static char *vacuum1_thread_vacuumer(int iTid, void *pArg){
Error err = {0}; /* Error code and message */
Sqlite db = {0}; /* SQLite database connection */
opendb(&err, &db, "test.db", 0);
do{
sql_script(&err, &db, "VACUUM");
clear_error(&err, SQLITE_LOCKED);
}while( !timetostop(&err) );
closedb(&err, &db);
print_and_free_err(&err);
return sqlite3_mprintf("ok");
}
static void vacuum1(int nMs){
Error err = {0};
Sqlite db = {0};
Threadset threads = {0};
opendb(&err, &db, "test.db", 1);
sql_script(&err, &db,
"CREATE TABLE t1(x PRIMARY KEY, y BLOB);"
"CREATE INDEX i1 ON t1(y);"
);
closedb(&err, &db);
setstoptime(&err, nMs);
sqlite3_enable_shared_cache(1);
launch_thread(&err, &threads, vacuum1_thread_writer, 0);
launch_thread(&err, &threads, vacuum1_thread_writer, 0);
launch_thread(&err, &threads, vacuum1_thread_writer, 0);
launch_thread(&err, &threads, vacuum1_thread_vacuumer, 0);
join_all_threads(&err, &threads);
sqlite3_enable_shared_cache(0);
print_and_free_err(&err);
}

0
testdata/tcl/wapptest.tcl vendored Normal file → Executable file
View File

659
testdata/tcl/wordcount.c vendored Normal file
View File

@@ -0,0 +1,659 @@
/*
** This C program extracts all "words" from an input document and adds them
** to an SQLite database. A "word" is any contiguous sequence of alphabetic
** characters. All digits, punctuation, and whitespace characters are
** word separators. The database stores a single entry for each distinct
** word together with a count of the number of occurrences of that word.
** A fresh database is created automatically on each run.
**
** wordcount DATABASE INPUTFILE
**
** The INPUTFILE name can be omitted, in which case input it taken from
** standard input.
**
** Option:
**
**
** Modes:
**
** Insert mode means:
** (1) INSERT OR IGNORE INTO wordcount VALUES($new,1)
** (2) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new -- if (1) is a noop
**
** Update mode means:
** (1) INSERT OR IGNORE INTO wordcount VALUES($new,0)
** (2) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new
**
** Replace mode means:
** (1) REPLACE INTO wordcount
** VALUES($new,ifnull((SELECT cnt FROM wordcount WHERE word=$new),0)+1);
**
** Upsert mode means:
** (1) INSERT INTO wordcount VALUES($new,1)
** ON CONFLICT(word) DO UPDATE SET cnt=cnt+1
**
** Select mode means:
** (1) SELECT 1 FROM wordcount WHERE word=$new
** (2) INSERT INTO wordcount VALUES($new,1) -- if (1) returns nothing
** (3) UPDATE wordcount SET cnt=cnt+1 WHERE word=$new --if (1) return TRUE
**
** Delete mode means:
** (1) DELETE FROM wordcount WHERE word=$new
**
** Query mode means:
** (1) SELECT cnt FROM wordcount WHERE word=$new
**
** Note that delete mode and query mode are only useful for preexisting
** databases. The wordcount table is created using IF NOT EXISTS so this
** utility can be run multiple times on the same database file. The
** --without-rowid, --nocase, and --pagesize parameters are only effective
** when creating a new database and are harmless no-ops on preexisting
** databases.
**
******************************************************************************
**
** Compile as follows:
**
** gcc -I. wordcount.c sqlite3.c -ldl -lpthreads
**
** Or:
**
** gcc -I. -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION \
** wordcount.c sqlite3.c
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdarg.h>
#include "sqlite3.h"
#ifndef _WIN32
# include <unistd.h>
#else
# include <io.h>
#endif
#define ISALPHA(X) isalpha((unsigned char)(X))
const char zHelp[] =
"Usage: wordcount [OPTIONS] DATABASE [INPUT]\n"
" --all Repeat the test for all test modes\n"
" --cachesize NNN Use a cache size of NNN\n"
" --commit NNN Commit after every NNN operations\n"
" --delete Use DELETE mode\n"
" --insert Use INSERT mode (the default)\n"
" --journal MMMM Use PRAGMA journal_mode=MMMM\n"
" --nocase Add the NOCASE collating sequence to the words.\n"
" --nosync Use PRAGMA synchronous=OFF\n"
" --pagesize NNN Use a page size of NNN\n"
" --query Use QUERY mode\n"
" --replace Use REPLACE mode\n"
" --select Use SELECT mode\n"
" --stats Show sqlite3_status() results at the end.\n"
" --summary Show summary information on the collected data.\n"
" --tag NAME Tag all output using NAME. Use only stdout.\n"
" --timer Time the operation of this program\n"
" --trace Enable sqlite3_trace() output.\n"
" --update Use UPDATE mode\n"
" --upsert Use UPSERT mode\n"
" --without-rowid Use a WITHOUT ROWID table to store the words.\n"
;
/* Output tag */
char *zTag = "--";
/* Return the current wall-clock time */
static sqlite3_int64 realTime(void){
static sqlite3_vfs *clockVfs = 0;
sqlite3_int64 t;
if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){
clockVfs->xCurrentTimeInt64(clockVfs, &t);
}else{
double r;
clockVfs->xCurrentTime(clockVfs, &r);
t = (sqlite3_int64)(r*86400000.0);
}
return t;
}
/* Print an error message and exit */
static void fatal_error(const char *zMsg, ...){
va_list ap;
va_start(ap, zMsg);
vfprintf(stderr, zMsg, ap);
va_end(ap);
exit(1);
}
/* Print a usage message and quit */
static void usage(void){
printf("%s",zHelp);
exit(0);
}
/* The sqlite3_trace() callback function */
static void traceCallback(void *NotUsed, const char *zSql){
printf("%s;\n", zSql);
}
/* An sqlite3_exec() callback that prints results on standard output,
** each column separated by a single space. */
static int printResult(void *NotUsed, int nArg, char **azArg, char **azNm){
int i;
printf("%s", zTag);
for(i=0; i<nArg; i++){
printf(" %s", azArg[i] ? azArg[i] : "(null)");
}
printf("\n");
return 0;
}
/*
** Add one character to a hash
*/
static void addCharToHash(unsigned int *a, unsigned char x){
if( a[0]<4 ){
a[1] = (a[1]<<8) | x;
a[0]++;
}else{
a[2] = (a[2]<<8) | x;
a[0]++;
if( a[0]==8 ){
a[3] += a[1] + a[4];
a[4] += a[2] + a[3];
a[0] = a[1] = a[2] = 0;
}
}
}
/*
** Compute the final hash value.
*/
static void finalHash(unsigned int *a, char *z){
a[3] += a[1] + a[4] + a[0];
a[4] += a[2] + a[3];
sqlite3_snprintf(17, z, "%08x%08x", a[3], a[4]);
}
/*
** Implementation of a checksum() aggregate SQL function
*/
static void checksumStep(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
const unsigned char *zVal;
int nVal, i, j;
unsigned int *a;
a = (unsigned*)sqlite3_aggregate_context(context, sizeof(unsigned int)*5);
if( a ){
for(i=0; i<argc; i++){
nVal = sqlite3_value_bytes(argv[i]);
zVal = (const unsigned char*)sqlite3_value_text(argv[i]);
if( zVal ) for(j=0; j<nVal; j++) addCharToHash(a, zVal[j]);
addCharToHash(a, '|');
}
addCharToHash(a, '\n');
}
}
static void checksumFinalize(sqlite3_context *context){
unsigned int *a;
char zResult[24];
a = sqlite3_aggregate_context(context, 0);
if( a ){
finalHash(a, zResult);
sqlite3_result_text(context, zResult, -1, SQLITE_TRANSIENT);
}
}
/* Define operating modes */
#define MODE_INSERT 0
#define MODE_REPLACE 1
#define MODE_UPSERT 2
#define MODE_SELECT 3
#define MODE_UPDATE 4
#define MODE_DELETE 5
#define MODE_QUERY 6
#define MODE_COUNT 7
#define MODE_ALL (-1)
/* Mode names */
static const char *azMode[] = {
"--insert",
"--replace",
"--upsert",
"--select",
"--update",
"--delete",
"--query"
};
/*
** Determine if another iteration of the test is required. Return true
** if so. Return zero if all iterations have finished.
*/
static int allLoop(
int iMode, /* The selected test mode */
int *piLoopCnt, /* Iteration loop counter */
int *piMode2, /* The test mode to use on the next iteration */
int *pUseWithoutRowid /* Whether or not to use --without-rowid */
){
int i;
if( iMode!=MODE_ALL ){
if( *piLoopCnt ) return 0;
*piMode2 = iMode;
*piLoopCnt = 1;
return 1;
}
if( (*piLoopCnt)>=MODE_COUNT*2 ) return 0;
i = (*piLoopCnt)++;
*pUseWithoutRowid = i&1;
*piMode2 = i>>1;
return 1;
}
int main(int argc, char **argv){
const char *zFileToRead = 0; /* Input file. NULL for stdin */
const char *zDbName = 0; /* Name of the database file to create */
int useWithoutRowid = 0; /* True for --without-rowid */
int iMode = MODE_INSERT; /* One of MODE_xxxxx */
int iMode2; /* Mode to use for current --all iteration */
int iLoopCnt = 0; /* Which iteration when running --all */
int useNocase = 0; /* True for --nocase */
int doTrace = 0; /* True for --trace */
int showStats = 0; /* True for --stats */
int showSummary = 0; /* True for --summary */
int showTimer = 0; /* True for --timer */
int cacheSize = 0; /* Desired cache size. 0 means default */
int pageSize = 0; /* Desired page size. 0 means default */
int commitInterval = 0; /* How often to commit. 0 means never */
int noSync = 0; /* True for --nosync */
const char *zJMode = 0; /* Journal mode */
int nOp = 0; /* Operation counter */
int i, j; /* Loop counters */
sqlite3 *db; /* The SQLite database connection */
char *zSql; /* Constructed SQL statement */
sqlite3_stmt *pInsert = 0; /* The INSERT statement */
sqlite3_stmt *pUpdate = 0; /* The UPDATE statement */
sqlite3_stmt *pSelect = 0; /* The SELECT statement */
sqlite3_stmt *pDelete = 0; /* The DELETE statement */
FILE *in; /* The open input file */
int rc; /* Return code from an SQLite interface */
int iCur, iHiwtr; /* Statistics values, current and "highwater" */
FILE *pTimer = stderr; /* Output channel for the timer */
sqlite3_int64 sumCnt = 0; /* Sum in QUERY mode */
sqlite3_int64 startTime; /* Time of start */
sqlite3_int64 totalTime = 0; /* Total time */
char zInput[2000]; /* A single line of input */
/* Process command-line arguments */
for(i=1; i<argc; i++){
const char *z = argv[i];
if( z[0]=='-' ){
do{ z++; }while( z[0]=='-' );
if( strcmp(z,"without-rowid")==0 ){
useWithoutRowid = 1;
}else if( strcmp(z,"replace")==0 ){
iMode = MODE_REPLACE;
}else if( strcmp(z,"upsert")==0 ){
iMode = MODE_UPSERT;
}else if( strcmp(z,"select")==0 ){
iMode = MODE_SELECT;
}else if( strcmp(z,"insert")==0 ){
iMode = MODE_INSERT;
}else if( strcmp(z,"update")==0 ){
iMode = MODE_UPDATE;
}else if( strcmp(z,"delete")==0 ){
iMode = MODE_DELETE;
}else if( strcmp(z,"query")==0 ){
iMode = MODE_QUERY;
}else if( strcmp(z,"all")==0 ){
iMode = MODE_ALL;
showTimer = -99;
}else if( strcmp(z,"nocase")==0 ){
useNocase = 1;
}else if( strcmp(z,"trace")==0 ){
doTrace = 1;
}else if( strcmp(z,"nosync")==0 ){
noSync = 1;
}else if( strcmp(z,"stats")==0 ){
showStats = 1;
}else if( strcmp(z,"summary")==0 ){
showSummary = 1;
}else if( strcmp(z,"timer")==0 ){
showTimer = i;
}else if( strcmp(z,"cachesize")==0 && i<argc-1 ){
i++;
cacheSize = atoi(argv[i]);
}else if( strcmp(z,"pagesize")==0 && i<argc-1 ){
i++;
pageSize = atoi(argv[i]);
}else if( strcmp(z,"commit")==0 && i<argc-1 ){
i++;
commitInterval = atoi(argv[i]);
}else if( strcmp(z,"journal")==0 && i<argc-1 ){
zJMode = argv[++i];
}else if( strcmp(z,"tag")==0 && i<argc-1 ){
zTag = argv[++i];
pTimer = stdout;
}else if( strcmp(z, "help")==0 || strcmp(z,"?")==0 ){
usage();
}else{
fatal_error("unknown option: \"%s\"\n"
"Use --help for a list of options\n",
argv[i]);
}
}else if( zDbName==0 ){
zDbName = argv[i];
}else if( zFileToRead==0 ){
zFileToRead = argv[i];
}else{
fatal_error("surplus argument: \"%s\"\n", argv[i]);
}
}
if( zDbName==0 ){
usage();
}
startTime = realTime();
/* Open the database and the input file */
if( zDbName[0] && strcmp(zDbName,":memory:")!=0 ){
unlink(zDbName);
}
if( sqlite3_open(zDbName, &db) ){
fatal_error("Cannot open database file: %s\n", zDbName);
}
if( zFileToRead ){
in = fopen(zFileToRead, "rb");
if( in==0 ){
fatal_error("Could not open input file \"%s\"\n", zFileToRead);
}
}else{
if( iMode==MODE_ALL ){
fatal_error("The --all mode cannot be used with stdin\n");
}
in = stdin;
}
/* Set database connection options */
if( doTrace ) sqlite3_trace(db, traceCallback, 0);
if( pageSize ){
zSql = sqlite3_mprintf("PRAGMA page_size=%d", pageSize);
sqlite3_exec(db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
if( cacheSize ){
zSql = sqlite3_mprintf("PRAGMA cache_size=%d", cacheSize);
sqlite3_exec(db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
if( noSync ) sqlite3_exec(db, "PRAGMA synchronous=OFF", 0, 0, 0);
if( zJMode ){
zSql = sqlite3_mprintf("PRAGMA journal_mode=%s", zJMode);
sqlite3_exec(db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
iLoopCnt = 0;
while( allLoop(iMode, &iLoopCnt, &iMode2, &useWithoutRowid) ){
/* Delete prior content in --all mode */
if( iMode==MODE_ALL ){
if( sqlite3_exec(db, "DROP TABLE IF EXISTS wordcount; VACUUM;",0,0,0) ){
fatal_error("Could not clean up prior iteration\n");
}
startTime = realTime();
rewind(in);
}
/* Construct the "wordcount" table into which to put the words */
if( sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, 0) ){
fatal_error("Could not start a transaction\n");
}
zSql = sqlite3_mprintf(
"CREATE TABLE IF NOT EXISTS wordcount(\n"
" word TEXT PRIMARY KEY COLLATE %s,\n"
" cnt INTEGER\n"
")%s",
useNocase ? "nocase" : "binary",
useWithoutRowid ? " WITHOUT ROWID" : ""
);
if( zSql==0 ) fatal_error("out of memory\n");
rc = sqlite3_exec(db, zSql, 0, 0, 0);
if( rc ) fatal_error("Could not create the wordcount table: %s.\n",
sqlite3_errmsg(db));
sqlite3_free(zSql);
/* Prepare SQL statements that will be needed */
if( iMode2==MODE_QUERY ){
rc = sqlite3_prepare_v2(db,
"SELECT cnt FROM wordcount WHERE word=?1",
-1, &pSelect, 0);
if( rc ) fatal_error("Could not prepare the SELECT statement: %s\n",
sqlite3_errmsg(db));
}
if( iMode2==MODE_SELECT ){
rc = sqlite3_prepare_v2(db,
"SELECT 1 FROM wordcount WHERE word=?1",
-1, &pSelect, 0);
if( rc ) fatal_error("Could not prepare the SELECT statement: %s\n",
sqlite3_errmsg(db));
rc = sqlite3_prepare_v2(db,
"INSERT INTO wordcount(word,cnt) VALUES(?1,1)",
-1, &pInsert, 0);
if( rc ) fatal_error("Could not prepare the INSERT statement: %s\n",
sqlite3_errmsg(db));
}
if( iMode2==MODE_SELECT || iMode2==MODE_UPDATE || iMode2==MODE_INSERT ){
rc = sqlite3_prepare_v2(db,
"UPDATE wordcount SET cnt=cnt+1 WHERE word=?1",
-1, &pUpdate, 0);
if( rc ) fatal_error("Could not prepare the UPDATE statement: %s\n",
sqlite3_errmsg(db));
}
if( iMode2==MODE_INSERT ){
rc = sqlite3_prepare_v2(db,
"INSERT OR IGNORE INTO wordcount(word,cnt) VALUES(?1,1)",
-1, &pInsert, 0);
if( rc ) fatal_error("Could not prepare the INSERT statement: %s\n",
sqlite3_errmsg(db));
}
if( iMode2==MODE_UPDATE ){
rc = sqlite3_prepare_v2(db,
"INSERT OR IGNORE INTO wordcount(word,cnt) VALUES(?1,0)",
-1, &pInsert, 0);
if( rc ) fatal_error("Could not prepare the INSERT statement: %s\n",
sqlite3_errmsg(db));
}
if( iMode2==MODE_REPLACE ){
rc = sqlite3_prepare_v2(db,
"REPLACE INTO wordcount(word,cnt)"
"VALUES(?1,coalesce((SELECT cnt FROM wordcount WHERE word=?1),0)+1)",
-1, &pInsert, 0);
if( rc ) fatal_error("Could not prepare the REPLACE statement: %s\n",
sqlite3_errmsg(db));
}
if( iMode2==MODE_UPSERT ){
rc = sqlite3_prepare_v2(db,
"INSERT INTO wordcount(word,cnt) VALUES(?1,1) "
"ON CONFLICT(word) DO UPDATE SET cnt=cnt+1",
-1, &pInsert, 0);
if( rc ) fatal_error("Could not prepare the UPSERT statement: %s\n",
sqlite3_errmsg(db));
}
if( iMode2==MODE_DELETE ){
rc = sqlite3_prepare_v2(db,
"DELETE FROM wordcount WHERE word=?1",
-1, &pDelete, 0);
if( rc ) fatal_error("Could not prepare the DELETE statement: %s\n",
sqlite3_errmsg(db));
}
/* Process the input file */
while( fgets(zInput, sizeof(zInput), in) ){
for(i=0; zInput[i]; i++){
if( !ISALPHA(zInput[i]) ) continue;
for(j=i+1; ISALPHA(zInput[j]); j++){}
/* Found a new word at zInput[i] that is j-i bytes long.
** Process it into the wordcount table. */
if( iMode2==MODE_DELETE ){
sqlite3_bind_text(pDelete, 1, zInput+i, j-i, SQLITE_STATIC);
if( sqlite3_step(pDelete)!=SQLITE_DONE ){
fatal_error("DELETE failed: %s\n", sqlite3_errmsg(db));
}
sqlite3_reset(pDelete);
}else if( iMode2==MODE_SELECT ){
sqlite3_bind_text(pSelect, 1, zInput+i, j-i, SQLITE_STATIC);
rc = sqlite3_step(pSelect);
sqlite3_reset(pSelect);
if( rc==SQLITE_ROW ){
sqlite3_bind_text(pUpdate, 1, zInput+i, j-i, SQLITE_STATIC);
if( sqlite3_step(pUpdate)!=SQLITE_DONE ){
fatal_error("UPDATE failed: %s\n", sqlite3_errmsg(db));
}
sqlite3_reset(pUpdate);
}else if( rc==SQLITE_DONE ){
sqlite3_bind_text(pInsert, 1, zInput+i, j-i, SQLITE_STATIC);
if( sqlite3_step(pInsert)!=SQLITE_DONE ){
fatal_error("Insert failed: %s\n", sqlite3_errmsg(db));
}
sqlite3_reset(pInsert);
}else{
fatal_error("SELECT failed: %s\n", sqlite3_errmsg(db));
}
}else if( iMode2==MODE_QUERY ){
sqlite3_bind_text(pSelect, 1, zInput+i, j-i, SQLITE_STATIC);
if( sqlite3_step(pSelect)==SQLITE_ROW ){
sumCnt += sqlite3_column_int64(pSelect, 0);
}
sqlite3_reset(pSelect);
}else{
sqlite3_bind_text(pInsert, 1, zInput+i, j-i, SQLITE_STATIC);
if( sqlite3_step(pInsert)!=SQLITE_DONE ){
fatal_error("INSERT failed: %s\n", sqlite3_errmsg(db));
}
sqlite3_reset(pInsert);
if( iMode2==MODE_UPDATE
|| (iMode2==MODE_INSERT && sqlite3_changes(db)==0)
){
sqlite3_bind_text(pUpdate, 1, zInput+i, j-i, SQLITE_STATIC);
if( sqlite3_step(pUpdate)!=SQLITE_DONE ){
fatal_error("UPDATE failed: %s\n", sqlite3_errmsg(db));
}
sqlite3_reset(pUpdate);
}
}
i = j-1;
/* Increment the operation counter. Do a COMMIT if it is time. */
nOp++;
if( commitInterval>0 && (nOp%commitInterval)==0 ){
sqlite3_exec(db, "COMMIT; BEGIN IMMEDIATE", 0, 0, 0);
}
}
}
sqlite3_exec(db, "COMMIT", 0, 0, 0);
sqlite3_finalize(pInsert); pInsert = 0;
sqlite3_finalize(pUpdate); pUpdate = 0;
sqlite3_finalize(pSelect); pSelect = 0;
sqlite3_finalize(pDelete); pDelete = 0;
if( iMode2==MODE_QUERY && iMode!=MODE_ALL ){
printf("%s sum of cnt: %lld\n", zTag, sumCnt);
rc = sqlite3_prepare_v2(db,"SELECT sum(cnt*cnt) FROM wordcount", -1,
&pSelect, 0);
if( rc==SQLITE_OK && sqlite3_step(pSelect)==SQLITE_ROW ){
printf("%s double-check: %lld\n", zTag,sqlite3_column_int64(pSelect,0));
}
sqlite3_finalize(pSelect);
}
if( showTimer ){
sqlite3_int64 elapseTime = realTime() - startTime;
totalTime += elapseTime;
fprintf(pTimer, "%3d.%03d wordcount", (int)(elapseTime/1000),
(int)(elapseTime%1000));
if( iMode==MODE_ALL ){
fprintf(pTimer, " %s%s\n", azMode[iMode2],
useWithoutRowid? " --without-rowid" : "");
}else{
for(i=1; i<argc; i++) if( i!=showTimer ) fprintf(pTimer," %s",argv[i]);
fprintf(pTimer, "\n");
}
}
if( showSummary ){
sqlite3_create_function(db, "checksum", -1, SQLITE_UTF8, 0,
0, checksumStep, checksumFinalize);
sqlite3_exec(db,
"SELECT 'count(*): ', count(*) FROM wordcount;\n"
"SELECT 'sum(cnt): ', sum(cnt) FROM wordcount;\n"
"SELECT 'max(cnt): ', max(cnt) FROM wordcount;\n"
"SELECT 'avg(cnt): ', avg(cnt) FROM wordcount;\n"
"SELECT 'sum(cnt=1):', sum(cnt=1) FROM wordcount;\n"
"SELECT 'top 10: ', group_concat(word, ', ') FROM "
"(SELECT word FROM wordcount ORDER BY cnt DESC, word LIMIT 10);\n"
"SELECT 'checksum: ', checksum(word, cnt) FROM "
"(SELECT word, cnt FROM wordcount ORDER BY word);\n"
"PRAGMA integrity_check;\n",
printResult, 0, 0);
}
} /* End the --all loop */
/* Close the input file after the last read */
if( zFileToRead ) fclose(in);
/* In --all mode, so the total time */
if( iMode==MODE_ALL && showTimer ){
fprintf(pTimer, "%3d.%03d wordcount --all\n", (int)(totalTime/1000),
(int)(totalTime%1000));
}
/* Database connection statistics printed after both prepared statements
** have been finalized */
if( showStats ){
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, 0);
printf("%s Lookaside Slots Used: %d (max %d)\n", zTag, iCur,iHiwtr);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, 0);
printf("%s Successful lookasides: %d\n", zTag, iHiwtr);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur,&iHiwtr,0);
printf("%s Lookaside size faults: %d\n", zTag, iHiwtr);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur,&iHiwtr,0);
printf("%s Lookaside OOM faults: %d\n", zTag, iHiwtr);
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, 0);
printf("%s Pager Heap Usage: %d bytes\n", zTag, iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
printf("%s Page cache hits: %d\n", zTag, iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
printf("%s Page cache misses: %d\n", zTag, iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
printf("%s Page cache writes: %d\n", zTag, iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, 0);
printf("%s Schema Heap Usage: %d bytes\n", zTag, iCur);
sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, 0);
printf("%s Statement Heap Usage: %d bytes\n", zTag, iCur);
}
sqlite3_close(db);
/* Global memory usage statistics printed after the database connection
** has closed. Memory usage should be zero at this point. */
if( showStats ){
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, 0);
printf("%s Memory Used (bytes): %d (max %d)\n", zTag,iCur,iHiwtr);
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, 0);
printf("%s Outstanding Allocations: %d (max %d)\n",zTag,iCur,iHiwtr);
sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, 0);
printf("%s Pcache Overflow Bytes: %d (max %d)\n",zTag,iCur,iHiwtr);
sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, 0);
printf("%s Largest Allocation: %d bytes\n",zTag,iHiwtr);
sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, 0);
printf("%s Largest Pcache Allocation: %d bytes\n",zTag,iHiwtr);
}
return 0;
}

File diff suppressed because it is too large Load Diff